Skip to content

feat(hosts): OAR deep fusion Phase 2 — harden OAR host and migrate DSH, Claude/ACP, and bounded Codex - #9861

Merged
songoow merged 69 commits into
codex/oar-deep-fusion-phase0-1from
codex/oar-deep-fusion-phase2
Dec 5, 2026
Merged

songoow merged 69 commits into
codex/oar-deep-fusion-phase0-1from
codex/oar-deep-fusion-phase2

Conversation

@songoow

@songoow songoow commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #9854 (codex/oar-deep-fusion-phase0-1), this PR delivers Phase 2 of the @botiverse/oar@0.142.0 deep fusion:

  1. Complete, hardened OAR Session Host integration (0e519e18):

    • Anti-YOLO security gateway (loopx/control_plane/oar/session_policy.ts): enforces LoopX sandbox/permission fences across all OAR runtimes — pins DSH_PERMISSION_MODE (read-only / workspace-write, blocking OAR's danger-full-access default) and sessionLogUpload: "off", injects Claude --permission-mode plan|acceptEdits + read-only disallowedTools/--tools (blocking OAR's --dangerously-skip-permissions default), and hardens Codex nativePermissions: "inherit" + sandbox_mode/approval_policy + per-invocation writeDirectory fences.
    • Typed OAR error & failure taxonomy (loopx/control_plane/oar/error_mapping.ts): maps OAR FailureClass, failureAdvice, and typed session errors (SessionNotFoundError, SessionUnavailableError, ResumeCwdError, UnsupportedOptionError, RuntimeFailureError, ModelConfirmationError) directly onto LoopX's HOST_FAILURE_KINDS and recovery semantics.
    • Live NDJSON streaming & full session control plane (session_hub.ts, session_host_server.ts, loopx/hosts/oar_client.py): adds oar.prompt_stream (coalesced text_delta frames over dedicated streaming sockets so concurrent abort never blocks), redactRecord on stored raw records, reduceTaskState, runtime catalog/probing (list_runtimes, probe_all_runtimes, resolveOarRuntimeFromCommand), session controls (deliver, withdraw, abort, compact, stop_task, answer_question, sync_goal, session_telemetry, list_sessions), and dynamic authenticated loopback serveMcpTools callbacks (control_plane_mcp.ts).
    • Doctor readiness: surfaces oar_runtime (collect_oar_runtime_readiness()) in loopx doctor JSON and Markdown output (loopx/doctor.py).
    • Default engine selection: defaults oar_execution_engine_selected() to True with clean rollback via LOOPX_EXECUTION_ENGINE=legacy.
  2. Phase 2 host migrations & legacy SDK/driver deletions (4268baa8):

    • DSH Turn + Steward Chat + Operation Host:
      • Replaced deepseek-harness-sdk Python import and build_sdk_config in loopx/hosts/dsh/turn_host_adapter.py with OAR dshRuntime while preserving --dsh-runner, DshHostConfig, run_dsh_host, and DSH_HOST_CAPABILITIES.
      • Migrated loopx/chat/dsh.py (DshChatAdapter) to persistent OAR dsh sessions with live answer.delta streaming and native interrupt_turn() -> oar.abort() (keeping runner= test seam).
      • Unified managed operation hosts in loopx/control_plane/turn_driver/oar_operation_host.py (loopback callback server + OAR serveMcpTools), shrunk dsh_operation_host.py from 416 LOC to a 66 LOC facade, and deleted loopx/control_plane/turn_driver/dsh_operation_connection.py + 3 obsolete DSH SDK/AF_UNIX test suites (test_dsh_operation_connection.py, test_dsh_operation_entry.py, test_dsh_operation_sdk.py, -1,439 LOC deleted outright; -964 LOC net across the host migration commit).
      • Compacted loopx/hosts/dsh/host_failure_map.py (281 -> 171 LOC) with an OarHostError.failure_kind fast path.
    • Claude Code Chat & ACP Promotion:
      • Migrated ClaudeCodeAdapter (loopx/chat/providers.py) from raw claude --print --output-format stream-json subprocess parsing to persistent OarSessionHost (runtimeId="claude", permissionMode="read_only", live streaming, native abort).
      • Added OAR-native ACP promotion in loopx/chat/acp.py (resolve_oar_acp_runtime) promoting 8 OAR built-in ACP runtimes (kimi, opencode, agy/antigravity, qwen, devin, codebuddy, qoder, factory/droid) onto OarSessionHost, while keeping the compact ACP v1 stdio fallback for kiro-cli acp and custom/test ACP scripts.
    • Bounded Codex CLI Turn & Operation Host:
      • Added OAR execution path (_run_codex_via_oar, build_oar_codex_session_params) in loopx/control_plane/turn_driver/codex_cli.py with admission watchdog -> oar.abort, native outputSchema, writeDirectory, mcpServers, resume, and side-effect-free shim detection (_looks_like_python_shim, covering POSIX shebangs and Windows distlib launchers) so legacy/fake codex exec test fixtures cleanly take _run_codex_via_legacy_exec.
      • Promoted real OAR-capable Codex binaries in loopx/control_plane/turn_driver/codex_operation_host.py to run_oar_operation_host(..., host="codex-cli", runtime_id="codex").

Scope Notes & Net LOC Ledger

  • OAR integration hardening commit (0e519e18): 10 files, +1,908 / -354 (adds full OAR policy/error/streaming/callback/doctor/test coverage).
  • Host migration & deletion commit (4268baa8): 19 files, +2,125 / -3,089 (-964 LOC net; deletes 4 obsolete DSH SDK/AF_UNIX driver & test files).
  • Retained until Phase 3/4: _run_codex_via_legacy_exec (for _fake_codex shims and LOOPX_EXECUTION_ENGINE=legacy rollback), generic ACP v1 fallback (for kiro-cli acp / custom scripts), reverse in-host plugins (packages/dsh-loopx-plugin/, loopx/claude_goal_mode/), antigravity-app desktop LS, DirectModelAdapter, and --dsh-runner.

Verification

  • npm run typecheck:control-plane + strict tsc on tests/control_plane_ts/oar_session_hub.test.ts: 0 errors
  • npm run test:control-plane: 6,940 passed, 0 failed, 5 skipped
  • pytest tests/control_plane/test_operation_host_source_preflight.py: 36 passed (real OAR + serveMcpTools + loopback operation callbacks over file & sqlite stores)
  • pytest tests/test_loopx_turn_codex_cli.py tests/control_plane/test_oar_phase2_hosts.py tests/control_plane/test_oar_session_client.py: 130 passed
  • pytest tests/test_dsh_goal_mode.py tests/test_chat_dsh_adapter.py tests/test_chat_acp_startup_timeout.py tests/test_chat_agent.py (excluding local .venv optional mcp public-reader cases): 902 passed
  • pytest tests/test_chat_path_redaction.py: 68 passed
  • pytest tests/hosts/test_host_harness_capabilities.py tests/test_codex_operation_host.py tests/test_chat_reasoning_selection.py: passed
  • pytest tests/test_cli_dsh_launch.py tests/test_doctor_*.py tests/test_zcode_doctor_skill_delivery.py tests/capabilities/test_reliability_diagnostics_dsh_provider.py tests/test_dsh_context_page_reclamation.py tests/test_dsh_plugin_publish_workflow.py: 211 passed
  • Kernel static checks (test_stage2c_dependency_lock.py, test_top_level_module_budget.py, test_external_request_lint.py, test_repository_instruction_delivery.py, test_contributing_guide.py): passed
  • ruff check --select F,B,E7,E9 & mypy --follow-imports=silent on all modified/new Phase 2 modules: 0 errors
  • loopx.contract.scan_public_boundary across all 25 changed/new files: 0 hits, 0 blocking hits, 0 warnings
  • loopx canary premerge --tier quick checks: git diff --check, check_rfc_bilingual.py, py_compile, semantic-vocabulary-drift-smoke.py, cli-output-budget-regression-smoke.py all passed; control-plane-maintainability-ratchet-smoke.py reports 0 findings on any file modified in this PR (only pre-existing untouched loopx/status.py)
  • OAR benchmark (examples/control_plane/oar-session-host-benchmark.py): 0.162 ms/RPC, 1.552 ms/warm turn, 2.23 ms abort-to-settled

…and doctor readiness

Signed-off-by: song <xinxinsong66@gmail.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T04:15:21.147619Z 4268baa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4268baa84f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread loopx/hosts/dsh/turn_host_adapter.py Resolved
Comment thread loopx/chat/dsh.py Resolved
Comment thread loopx/chat/acp.py Resolved
Comment thread loopx/chat/acp.py Resolved
…ost.version

Signed-off-by: song <xinxinsong66@gmail.com>
…dex exec

Signed-off-by: song <xinxinsong66@gmail.com>
…ting

Signed-off-by: song <xinxinsong66@gmail.com>
…olated shell

Signed-off-by: song <xinxinsong66@gmail.com>
…l_worker

Signed-off-by: song <xinxinsong66@gmail.com>

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

评审提交 2d96b4c8336e44bdd467fd4a7b421a877fcf74f7,对照基线 1541c290edef4733666bb15da4f80491be1e8bea,并检查与当时主干 d3346487352b96e6e492f5db83f651f0eeb85285 的组合。使用已配置 ACP Agent 的 Chat 用户需要确认原来选定的模型和推理档位,也需要区分失败和完整答案。 Phase 1 的 ACP stdio 入口读取会话选项、应用选择,再由现有 Chat 读回确认后放行。 从正常 ACP 启动入口打开一个用户已选择模型与推理档位的会话。 正常传输已输出部分文本,但 OAR 返回结构化失败终态。 OAR 把执行迁到新的会话宿主。ACP 启动仍传入原来请求的选项,但未把实际配置填回适配器。收到失败状态时也照常发布最终答案。 本次在当前堆叠提交、本地协议进程和 OAR 响应边界验证。保留 Chat 原有模型读回规则与权限边界。

改动思路 / Approach

本次分支在 Phase 1 上迁移 ACP、DSH、Claude 与部分 Codex 入口,并将 OAR 设为默认。 OAR Runtime 提供会话和运行事实。现有 Chat 适配器负责将模型确认和终态交给共享读回与发布代码。 由真实 OAR 会话事实提供已确认配置与可发现选项,再交给现有确认逻辑。无法读回时保留该能力的直接路径或呈现明确不可用。 进入最终答案发布前检查结构化 outcome,按既有 Chat 错误路径保留失败和可恢复性。 现有调用方继续使用原状态与返回路径,故障由实际入口返回,评审以状态与外部可见结果核对具体分支。

具体改动 / Changes

  • MODEL-CONFIRMATION 原模型选择能读回并送达。
  • OUTCOME-READBACK 宿主失败不写成成功。

真实 stdio 选定模型和档位能够通过原有观察校验。相同请求经迁移适配器返回空模型与档位,Chat 拒绝发送。两种传输终态都发出一次 answer.final。OAR 脚本宿主的现有流式和清理用例通过。

验收契约 · 前次评审

对主干的风险 / Risks

48 项 Python 定向测试、控制平面类型检查、外部传输 lint 与快速预合并的阻断项通过。快速预合并保留一条未涉及改动文件的维护性告警。 选定模型复测比较了真实 stdio 协议子进程与 OAR open 响应替身。独立的本地 ACP 进程接 OAR 尝试在启动时超时,未归因。没有实测真实账户、跨宿主迁移或所有默认入口。 当前堆叠与所查 main 存在实际文本冲突。当前结论仅覆盖各自声明的基线与候选。

  • [P1] 已配置的 ACP 会话在发送之前被拒绝。 从正常 ACP 启动入口打开一个用户已选择模型与推理档位的会话。 迁移路径传递了请求值,但构造适配器时未填任何已确认配置,现有 observed_model_settings 收到空模型与空档位,返回 unsupported_configuration。保留的直接 stdio 对照能确认同一选择。 由真实 OAR 会话事实提供已确认配置与可发现选项,再交给现有确认逻辑。无法读回时保留该能力的直接路径或呈现明确不可用。 覆盖受支持模型和档位、回复缺失以及不同于请求的返回。 定位
  • [P2] ACP 把失败的部分输出发布为最终答案。 正常传输已输出部分文本,但 OAR 返回结构化失败终态。 同一文本在 completed 和 failed 对照均发布一次 answer.final,原失败状态未传给 Chat。 进入最终答案发布前检查结构化 outcome,按既有 Chat 错误路径保留失败和可恢复性。 对照同文本成功与失败,只有成功发布 answer.final。 定位

我的整体评价 / Verdict

请求修改。让已迁移适配器在真实入口上证明模型确认和失败终态,再重新评审。将未迁移或未验收的入口留在原路径可减少这一步的交付范围。 快速预合并与定向测试已核对,验收仍需覆盖完整调用方并读回失败状态。

English verdict: REQUEST_CHANGES at 2d96b4c. The promoted ACP path loses required model confirmation and publishes failed partial responses as final answers. Restore those behaviors before broad default activation.

Comment thread loopx/chat/acp.py Resolved
Comment thread loopx/chat/acp.py Resolved
@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Dec 5, 2026
…under ratchet, and align machine credential tests

Signed-off-by: song <xinxinsong66@gmail.com>
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Dec 5, 2026
Signed-off-by: song <xinxinsong66@gmail.com>
… forwarding

Signed-off-by: song <xinxinsong66@gmail.com>
…runtimes

Signed-off-by: song <xinxinsong66@gmail.com>
…pdate supported host parity test

Signed-off-by: song <xinxinsong66@gmail.com>
…n-phase4-storage-ui

Signed-off-by: song <xinxinsong66@gmail.com>
…0 in Dashboard, and isolate PATH in runtime-readiness-live

Signed-off-by: song <xinxinsong66@gmail.com>
…n-phase4-runtimes

Signed-off-by: song <xinxinsong66@gmail.com>
…n-phase3

Signed-off-by: song <xinxinsong66@gmail.com>
…ion-phase2

Signed-off-by: song <xinxinsong66@gmail.com>
…eep-fusion-phase4-storage-ui

Signed-off-by: song <xinxinsong66@gmail.com>
@songoow

songoow commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator Author

Updated codex/oar-deep-fusion-phase2 at d422e6586 (fix commit 459563682 + merged updated #9854 68617b2b3):

Fixes Included

  • DSH Chat released-session recovery (459563682): Handled terminal OAR session errors (oar_session_not_found, runtime_exited, session_released, transport_lost) in loopx/chat/dsh.py by invalidating the dead session handle and marking healthcheck() unhealthy so Chat recreates the adapter while keeping transient errors healthy. Added real scripted OAR Host recovery & transient rate-limit tests in tests/control_plane/test_oar_transport_regressions.py.
  • Maintainability ratchet (459563682): Extracted _run_codex_cli_exec_session() in loopx/control_plane/turn_driver/codex_cli.py and _execute_watched_oar_operation_prompt() in loopx/control_plane/turn_driver/oar_operation_host.py so decision statements/points stay within ratchet ceilings.
  • Machine credential tests (459563682): Parametrized tests/test_turn_machine_credential.py across oar/legacy and aligned default OAR DSH deferred-probe expectations.

Verification & Gate Status

  • Local verification: 114 mutant/UTF-8/Node24 tests + 73 ratchet/DSH/credential tests passed; CI ruff/lint checks clean on all PR-touched files.
  • All 13 review threads have been replied to and resolved.

cc @loopx-agent @huangruiteng — ready for re-review after #9854.

songwells and others added 7 commits December 5, 2026 07:38
…n-phase4-runtimes

Signed-off-by: song <xinxinsong66@gmail.com>
…n-phase3

Signed-off-by: song <xinxinsong66@gmail.com>
…ion-phase2

Signed-off-by: song <xinxinsong66@gmail.com>
…eep-fusion-phase4-storage-ui

Signed-off-by: song <xinxinsong66@gmail.com>
…ase4-storage-ui

feat(oar): sessions.sqlite WAL storage, in-process MCP write tools, and Dashboard OAR UI
…ase4-runtimes

feat(oar): complete 16 OAR runtimes, CLI/Chat entrypoints, Workbench 0.142.0 alignment, and Windows Job containment
feat(oar): Phase 3 — native child streaming, unified OAR Goal Worker, and Codex Chat OAR decoupling
@songoow
songoow requested a review from maxliux5 as a code owner December 5, 2026 12:43
@songoow
songoow merged commit 96982c0 into codex/oar-deep-fusion-phase0-1 Dec 5, 2026
6 of 8 checks passed
@songoow
songoow deleted the codex/oar-deep-fusion-phase2 branch December 5, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants