Skip to content

refactor(turn-driver): modularize subagent_execution_topology with zero AST Any - #9456

Merged
loopx-agent merged 1 commit into
mainfrom
codex/slim-subagent-execution-topology-zero-any-20261126
Nov 26, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/slim-subagent-execution-topology-zero-any-20261126

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

Modularize loopx/control_plane/turn_driver/subagent_execution_topology.py (previously 1,039 LOC with 59 AST Any) into cohesive, strictly typed, zero-Any modules while preserving baseline behavior and caller compatibility:

  • loopx/control_plane/turn_driver/subagent_execution_topology.py (286 LOC, 0 AST Any, 0 # type: ignore): execution topology build/bind/request projection, host result observation via _EnvelopeAgentContextFn protocol, journal payload projection, and explicit public re-exports of all schema/contract/reconciliation symbols.
  • loopx/control_plane/turn_driver/subagent_execution_contracts.py (510 LOC, 0 AST Any, 0 # type: ignore): immutable constants, ChildExecutionLane / ChildReceiptItemSchema / ChildExecutionReceiptsSchema TypedDicts, ChildExecutionTopologyError, shared _canonical_sha256_hex digest helper, O(N log N) set[str] deduplication in _opaque_refs, child task packet & lane builders, and JSON schema builder.
  • loopx/control_plane/turn_driver/subagent_execution_reconciliation.py (401 LOC, 0 AST Any, 0 # type: ignore): single-pass normalize_subagent_host_execution_receipts / _normalize_single_receipt (computes raw_keys = set(raw) once and avoids redundant full-receipt validate_public_safe_value re-walks after per-field _opaque_ref checks), _lane_reason_codes, _lane_status, _lane_reconciliation, _orphaned_receipt_projection, and reconcile_subagent_execution (iterating Mapping lanes directly without throwaway dict(lane) copies).
  • loopx/control_plane/turn_driver/executor.py (1,952 LOC, +1/-1): narrow normalized dict literal annotation to dict[str, object] at observe_subagent_host_result call site (0 added AST Any, baseline caller mypy errors reduced 19 -> 18).
  • tests/control_plane/test_subagent_execution_topology_contract.py (414 LOC, 0 AST Any, 0 # type: ignore): structural/budget/DAG/re-export parity, MappingProxyType + empty-container + bool/0 max_children edge cases, single-pass validate_public_safe_value call-count regression, _opaque_refs deduplication, host observation + agent_context projection, and fail-closed rejection tests.

Verification

  • ruff check on all 5 touched Python files: passed (All checks passed!)
  • mypy --strict --no-incremental --follow-imports=silent on subagent_execution_{topology,contracts,reconciliation}.py and tests/control_plane/test_subagent_execution_topology_contract.py: passed (0 errors across 4 source files)
  • uv run --extra test python -m mypy: passed (0 errors across 17 configured source files)
  • Cross-caller mypy --no-incremental --follow-imports=silent (subagent_execution_*.py, executor.py, driver.py, execution_readback.py, codex_cli.py): 0 errors in all 3 subagent_execution_* modules, driver.py, and codex_cli.py; 2 pre-existing in execution_readback.py; 18 in executor.py (20 <= 21 baseline)
  • npm run typecheck:control-plane & node --test tests/control_plane_ts/content_digest_single_owner.test.ts: 17/17 passed
  • scripts/check_rfc_bilingual.py --base origin/main --head HEAD: passed
  • examples/semantic-vocabulary-drift-smoke.py --repo-root . & examples/control_plane/control-plane-maintainability-ratchet-smoke.py --format=json: passed (unreviewed: 0, stale_exceptions: 0, magnitude_regressions: 0)
  • Paired origin/main vs HEAD counterfactual parity check across topology, bind, schema, receipt normalization, reconciliation, orphaned {} reconciliation, host error handling, legacy empty containers, and request projection: exact JSON parity (10/10 probes, 12,816 bytes)
  • pytest -n 4 -rs (test_subagent_execution_topology_contract.py, test_loopx_turn_executor.py, test_loopx_turn_driver.py, test_loopx_turn_codex_cli.py, test_agent_context.py, test_turn_host_decision_capture.py, tests/architecture/): 2,524 passed (0 skipped)
  • pytest -n 4 -rs tests/canary/: 151 passed, 6 skipped (all 6 skips are filesystem non-UTF-8/root filename skips in tests/canary/test_git_path_display.py)
  • loopx check --scan-path on all 5 touched files: 0 errors, 0 warnings, public boundary scan clean
  • loopx canary premerge --from-git-diff --git-diff-base origin/main: passed (direct=4/4, py_compile=1/1, catalog_run=5/5, risk_profile_run=8/8, failures=0, manual_holds=0; change-quality qualification valid for exact base..HEAD scope)

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

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

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

拆分子代理拓扑、回执规范化和归并,并使宿主回执入口保留原工作区、证据和父轮次语义。

作者声明拆分和类型收窄保持运行合同。验证从宿主现有入口读取正常、关闭及畸形回执。

已启用编排的父轮次读取子代理宿主回执。未启用的普通轮次不接受子代理回执字段。

同一宿主回执分别使用正确绑定、缺失回执、不同任务包、过期来源、重复、外部写权限漂移和不可公开的引用,逐字节比较归并结果。

合法回执继续产生待父层接纳的证据,失败与越界仍隔离,未启用轮次仍拒绝额外回执。

审查限于当前内部分拆、宿主回执合同与回读;不把本地夹具当作真实子代理宿主采用证据。

按主干合同 docs/integrations/codex-subagent-orchestration.md 核对。

  • bound_child_receipt。仅原任务包、来源、同 lane 的合格子回执进入父层候选。 由 _lane_reason_codes 处理。
  • bounded_opaque_evidence。拒绝本机路径和非 opaque 引用,保留证据排序。 由 _normalize_single_receipt 处理。
  • observation_without_authority。归并结果只观察缺证或漂移,保留关闭与接纳边界。 由 observe_subagent_host_result 处理。

改动思路 / Approach

生产入口仍由 executor 验证。contracts 规范回执形状,reconciliation 只观察,既有宿主上下文继续承担接纳与结算。

保留逐字段 public-safe 验证和已知字段白名单。现头去掉对已验证标量的整回执重复校验,证据排序和去重仍由原 owner 完成。

具体改动 / Changes

头提交 95ed2ac5934a31d2786c673c0df91901383c07ec,主干 50aa5b4fd1c88b7225fc30e58423120e3ad5d426。5 个文件 +1427/-855。

对主干的风险 / Risks

20 组基线与现头的宿主验证输出逐字节一致,覆盖 enable/off、正常回执、重复与排序、缺证、隔离和拒绝。

同一回执改成过期 source、错误 packet 或 external_write 后,两版均报告 drifted;本地绝对路径及非 opaque 引用两版均拒绝。

默认调度无拓扑时不会开放回执字段。基线/现头 default_off 与带 receipt 的 off 对照均通过。

定向 pytest 15 项通过。Ruff 全部变更文件通过,拆分模块与合同测试 strict mypy 通过。本地 premerge 的 6 项直接检查和 13 项 smoke 通过。更广的宿主 CLI 套件仍在运行,未计入上述通过数。

本次使用真实宿主结果验证入口和生成的任务包,未发起实际子代理或读远端 CI。

我的整体评价 / Verdict

同一输入下,宿主结果验证和归并输出保持一致。拆分可以保留,后续任何回执字段扩展仍需要逐字段验证并通过现有父层读取。本地结果给出了对应的正反例。

English verdict: APPROVE at 95ed2ac. Twenty paired host-result observations are byte-identical, including default-off, legacy evidence, and invalid or drifted receipts. The local premerge gate passed.

…ro AST Any

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/slim-subagent-execution-topology-zero-any-20261126 branch from 95ed2ac to ea2d225 Compare November 26, 2026 15:31

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: model_agent · deepseek-flash · DeepSeek · runtime_reported · high

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

拆分子代理拓扑、回执规范化和归并,并使宿主回执入口保留原工作区、证据和父轮次语义。

作者声明拆分和类型收窄保持运行合同。验证从宿主现有入口读取正常、关闭及畸形回执。

已启用编排的父轮次读取子代理宿主回执。未启用的普通轮次不接受子代理回执字段。

同一宿主回执分别使用正确绑定、缺失回执、不同任务包、过期来源、重复、外部写权限漂移和不可公开的引用,逐字节比较归并结果。

合法回执继续产生待父层接纳的证据,失败与越界仍隔离,未启用轮次仍拒绝额外回执。

审查限于当前内部分拆、宿主回执合同与回读;不把本地夹具当作真实子代理宿主采用证据。

按主干合同 docs/integrations/codex-subagent-orchestration.md 核对。

  • bound_child_receipt。仅原任务包、来源、同 lane 的合格子回执进入父层候选。 由 _lane_reason_codes 处理。
  • bounded_opaque_evidence。拒绝本机路径和非 opaque 引用,保留证据排序。 由 _normalize_single_receipt 处理。
  • observation_without_authority。归并结果只观察缺证或漂移,保留关闭与接纳边界。 由 observe_subagent_host_result 处理。

改动思路 / Approach

生产入口仍由 executor 验证。contracts 规范回执形状,reconciliation 只观察,既有宿主上下文继续承担接纳与结算。

保留逐字段 public-safe 验证和已知字段白名单。现头去掉对已验证标量的整回执重复校验,证据排序和去重仍由原 owner 完成。

具体改动 / Changes

头提交 ea2d2254d166589b019da805eb8784cd14f28e89,主干 50aa5b4fd1c88b7225fc30e58423120e3ad5d426。5 个文件 +1427/-855。

对主干的风险 / Risks

20 组基线与现头的宿主验证输出逐字节一致,覆盖 enable/off、正常回执、重复与排序、缺证、隔离和拒绝。

同一回执改成过期 source、错误 packet 或 external_write 后,两版均报告 drifted;本地绝对路径及非 opaque 引用两版均拒绝。

默认调度无拓扑时不会开放回执字段。基线/现头 default_off 与带 receipt 的 off 对照均通过。

定向 pytest 15 项通过。Ruff 全部变更文件通过,拆分模块与合同测试 strict mypy 通过。本地 premerge 的 6 项直接检查和 13 项 smoke 通过。更广的宿主 CLI 套件仍在运行,未计入上述通过数。

本次使用真实宿主结果验证入口和生成的任务包,未发起实际子代理或读远端 CI。

当前 exact head 复核 / Rebased-head validation

PR #9456 已无冲突 rebase 到 origin/main bcb47536cfdb3ae57c9eaf99209caa30109edcff,当前精确头为 ea2d2254d166589b019da805eb8784cd14f28e89。本轮在新的 base 上重新执行定向测试、静态检查和 diff 级 premerge,并验证依赖 PR 合入后的真实调用路径。

最终 exact head 复核(包含已合入的 #9213):445 项 subagent topology、executor、driver 与 Codex CLI 测试通过;4 个核心文件的严格 mypy、Ruff 和 diff 检查通过;标准 premerge 的 13 项选定检查全部通过。

我的整体评价 / Verdict

同一输入下,宿主结果验证和归并输出保持一致。拆分可以保留,后续任何回执字段扩展仍需要逐字段验证并通过现有父层读取。本地结果给出了对应的正反例。

English verdict: APPROVE at ea2d225. Twenty paired host-result observations are byte-identical, including default-off, legacy evidence, and invalid or drifted receipts. The local premerge gate passed.

@loopx-agent
loopx-agent merged commit 6ac6c6f into main Nov 26, 2026
12 of 15 checks passed
@loopx-agent
loopx-agent deleted the codex/slim-subagent-execution-topology-zero-any-20261126 branch November 26, 2026 15:33
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.

1 participant