Skip to content

fix(box): gate vllm_omni WebSocket scopes and created-module targets - #1006

Draft
haoruilee wants to merge 2 commits into
InferMatrixLab:mainfrom
haoruilee:fix/vllm-omni-admission-and-target-policy
Draft

haoruilee wants to merge 2 commits into
InferMatrixLab:mainfrom
haoruilee:fix/vllm-omni-admission-and-target-policy

Conversation

@haoruilee

@haoruilee haoruilee commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Governing Issue and delivery slice

Refs #1005

  • Accepted scope / delegation: Proposed in bug(box): enforce WebSocket admission gating and Endpoint allowed_target policy in vllm_omni #1005; this PR remains Draft until Box / Harness maintainers confirm scope, assign an accountable owner, and delegate implementation to @haoruilee.
  • Anchors touched: none
  • What this PR delivers:
    • src/inferrsi/box/repos/vllm_omni/admission.py: narrows the unchecked pass-through guard in OmniBoxAdmissionMiddleware.__call__() to scope_type not in {"http", "websocket"} or scope_type == "http" GET/HEAD requests on ALWAYS_OPEN (matching vllm_common/admission.py:139-143), and closes all ASGI "websocket" scopes immediately with {"type": "websocket.close", "code": 1008} without invoking self.app or reading scope["method"].
    • src/inferrsi/box/repos/vllm_omni/worker.py: passes allowed_target=config.is_target_allowed into Endpoint(...) inside DiffusionWorkerService.__init__() (matching vllm_common/worker_base.py:110), so action="create" patches and subsequent structural edits (targets=()) to created modules enforce VllmOmniConfig.allowed_targets.
    • tests/box/vllm_omni/test_omni_unit.py:
      • Adds test_omni_admission_middleware_closes_websockets_and_passes_lifespan verifying "websocket" scopes on /v1/realtime and /health (without "method") receive {"type": "websocket.close", "code": 1008} and never invoke app across open, drained (b"closed"), and isolated gate states, while "lifespan" and HTTP GET /health pass through.
      • Adds test_omni_startup_wiring_attaches_admission_middleware_to_empty_asgi_app verifying NativeOmniServeLab rejects --middleware overrides via serve_args / engine_args and exercising NativeOmniServeLab._argv() + python -m inferrsi.box.repos.vllm_omni.bootstrap + dynamic --middleware import on a zero-model, zero-device empty ASGI app (confirming "websocket" 1008 closure across open, drained, armed-window, and isolated states, "lifespan" and GET /health pass-through, and normal HTTP POST /v1/videos/sync and 404 non-pilot behavior).
      • Adds test_diffusion_worker_enforces_allowed_targets_on_created_modules verifying DiffusionWorkerService.prepare() rejects action="create" defining a disallowed function (code == "restart_required", phase == "rejected"), accepts and commits action="create" defining an allowed target, and rejects a follow-up structural action="edit" adding a disallowed function to that created module.
  • What it does not deliver: WebSocket admission support for any qualified vLLM-Omni route, changes to vllm_common, Ascend NPU runtime evidence, or Issue closure.

Knowledge authorship declaration

No path protected by docs/knowledge-model-policy.md is changed. The declaration is filled for completeness against the current head.

{
  "schema_version": 1,
  "head_sha": "d8a7fe73bdfc1f57acc9b3b749667530119df8a7",
  "human_only": false,
  "material_ai_authors": [
    {
      "tool": "antigravity-cli",
      "model_id": "gemini-4-neon",
      "effort": "xhigh",
      "role": "author"
    }
  ]
}

Changed artifacts and evidence

Requirement (#1005) Actual change Check / evidence and result Remaining gap
Prevent ASGI "websocket" bypass of route allowlist, drain, and isolation, including real startup middleware wiring src/inferrsi/box/repos/vllm_omni/admission.py:49-56 narrows pass-through to non-HTTP/non-WebSocket scopes and HTTP GET/HEAD on ALWAYS_OPEN, and closes "websocket" scopes with code: 1008; tests/box/vllm_omni/test_omni_unit.py adds direct middleware and NativeOmniServeLab._argv() + bootstrap startup-wiring tests Before (da5a01e7): app_reached: [('websocket', '/v1/realtime')] while drained and isolated (and startup-wiring test fails on reverted admission.py); after (d8a7fe73): ws_messages: [{'type': 'websocket.close', 'code': 1008}], app_reached: []; both tests + 6 admission edge probes pass on Py3.10 & Py3.11 Upstream Ready CI on d8a7fe73 and live vLLM-Omni server verification pending
Enforce VllmOmniConfig.allowed_targets on action="create" and follow-up edits to created modules src/inferrsi/box/repos/vllm_omni/worker.py:111 passes allowed_target=config.is_target_allowed to Endpoint(...) Before (da5a01e7): disallowed action="create" authorized and committed (installed_fn_result: 42); after (d8a7fe73): rejected in prepare() with restart_required / rejected (target is outside the enrolled target policy); covered by test_diffusion_worker_enforces_allowed_targets_on_created_modules + 5 worker edge probes on Py3.10 & Py3.11 Upstream Ready CI on d8a7fe73 and live Ascend NPU verification pending

Checks and dependencies

  • Checks actually run (result and tested scope): Linux x86_64 on d8a7fe73bdfc1f57acc9b3b749667530119df8a7 (under env -u PYTHONPATH):
    • ruff check src tests tools (Python 3.10.20 & 3.11.14): passed (All checks passed!).
    • git diff origin/main..HEAD --check: passed.
    • pytest -n 4 tests/box/vllm_omni/ tests/box/ (Python 3.10.20 & 3.11.14): 210 passed on both interpreters.
    • tests/repository/test_architecture_anchors.py: 4 passed.
    • Standalone reproducers before (da5a01e7) vs after (d8a7fe73), mutant check reverting only admission.py to da5a01e7 (caught by test_omni_startup_wiring_attaches_admission_middleware_to_empty_asgi_app), plus 11/11 targeted edge probes passed on both Python 3.10.20 and Python 3.11.14.
    • Local tools/check_pr_references.py and tools/check_knowledge_model_policy.py validation on this PR body and d8a7fe73bdfc1f57acc9b3b749667530119df8a7: passed.
  • Failed, skipped, timed-out or not-run checks (if applicable):
    • Not run locally: full Ready test suite (local host has git 2.43.0 < 2.45), Windows/macOS advisory host-compatibility, installed-package, dashboard-browser, Ascend NPU hardware, live vLLM-Omni serving, and upstream GitHub Actions CI on d8a7fe73 (pending; prior head d3b116f1 passed full-check on Py3.10 & Py3.11 in run 47071324270).
  • Dependencies / shared interfaces / integration assumptions (if applicable):

Remaining work and Issue closure

Align OmniBoxAdmissionMiddleware with vllm_common/admission.py so only
non-HTTP/non-WebSocket scopes (such as lifespan) and HTTP GET/HEAD
requests on ALWAYS_OPEN pass through unchecked, while all ASGI websocket
scopes are closed immediately with code 1008 without reaching self.app.

Pass allowed_target=config.is_target_allowed into Endpoint(...) in
DiffusionWorkerService.__init__, matching vllm_common/worker_base.py, so
action="create" patches and subsequent structural edits to created
modules enforce VllmOmniConfig.allowed_targets.

Add unit tests covering WebSocket rejection across open, drained, and
isolated gate states (alongside lifespan and GET /health pass-through)
and allowed_targets enforcement for created modules and follow-up edits.

Agent-assisted-by: antigravity-cli / gemini-4-neon [effort=xhigh] (author)
Signed-off-by: 李浩瑞 <haoruileee@gmail.com>

@jiangkuaixue123 jiangkuaixue123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

静态复核 d3b116f1。这次改动在 Omni 适配层,没有改通用 Box 协议。当前 CI 两个 Python 全量检查通过,浏览器任务跳过。建议 Ready 前补一个装配层回归,确认实际启动的 ASGI 应用确实挂上这层 middleware;现在新增的测试直接调用 middleware,不覆盖启动接线。可用无模型、无设备的空应用验证修复版本拒绝未支持的协议升级,同时健康检查和正常 HTTP 请求不回退。未独立运行设备,不代 #1005 做范围或验收决定。

@Dong1017 Dong1017 added the area:harness Harness module: profile, A/B loop, quality gates, evidence reports label Dec 3, 2026
Add test_omni_startup_wiring_attaches_admission_middleware_to_empty_asgi_app
to exercise NativeOmniServeLab._argv() and
python -m inferrsi.box.repos.vllm_omni.bootstrap end-to-end against a
zero-model, zero-device empty ASGI stub that dynamically imports the
--middleware dotted path.

Verify that NativeOmniServeLab rejects --middleware overrides, websocket
upgrades close with code 1008 across open, drained, armed-window, and
isolated gate states without reaching the inner ASGI app, and lifespan,
GET /health, and normal POST /v1/videos/sync HTTP requests keep working.

Agent-assisted-by: antigravity-cli / gemini-4-neon [effort=xhigh] (author)
Signed-off-by: 李浩瑞 <haoruileee@gmail.com>
@haoruilee

Copy link
Copy Markdown
Contributor Author

Antigravity (Gemini 4 Neon, xhigh), acting for @haoruilee.

@jiangkuaixue123 Thanks for the review. In d8a7fe73, we added test_omni_startup_wiring_attaches_admission_middleware_to_empty_asgi_app in tests/box/vllm_omni/test_omni_unit.py exercising NativeOmniServeLab._argv() and python -m inferrsi.box.repos.vllm_omni.bootstrap end-to-end against a zero-model, zero-device empty ASGI stub that dynamically imports the --middleware dotted path. It verifies --middleware override refusal via serve_args/engine_args, websocket closure (code: 1008) without reaching the inner app across open, drained, armed-window, and isolated states, and no regression on "lifespan", GET /health, and normal HTTP POST /v1/videos/sync / non-pilot 404 handling. Verified locally on Linux x86_64 under env -u PYTHONPATH (210 passed across tests/box/vllm_omni/ tests/box/ on Python 3.10.20 and 3.11.14). Keeping this PR Draft pending scope confirmation and delegation on #1005.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:harness Harness module: profile, A/B loop, quality gates, evidence reports

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants