Repository navigation
refactor(turn-driver): modularize subagent_execution_topology with zero AST Any - #9456
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
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。
- build_subagent_execution_topology。用现有父轮次和待办建立包与 lane。
- _opaque_refs。约束、校验、去重并排序证据引用。
- _normalize_single_receipt。拒绝未知字段后逐项校验标准化回执。
- reconcile_subagent_execution。保持候选和隔离,以及父任务的观察状态。
- observe_subagent_host_result。将归并结果投影到既有宿主读回。
对主干的风险 / 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>
95ed2ac to
ea2d225
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
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。
- build_subagent_execution_topology。用现有父轮次和待办建立包与 lane。
- _opaque_refs。约束、校验、去重并排序证据引用。
- _normalize_single_receipt。拒绝未知字段后逐项校验标准化回执。
- reconcile_subagent_execution。保持候选和隔离,以及父任务的观察状态。
- observe_subagent_host_result。将归并结果投影到既有宿主读回。
对主干的风险 / 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.
Summary
Modularize
loopx/control_plane/turn_driver/subagent_execution_topology.py(previously1,039LOC with59ASTAny) into cohesive, strictly typed, zero-Anymodules while preserving baseline behavior and caller compatibility:loopx/control_plane/turn_driver/subagent_execution_topology.py(286LOC,0ASTAny,0# type: ignore): execution topology build/bind/request projection, host result observation via_EnvelopeAgentContextFnprotocol, journal payload projection, and explicit public re-exports of all schema/contract/reconciliation symbols.loopx/control_plane/turn_driver/subagent_execution_contracts.py(510LOC,0ASTAny,0# type: ignore): immutable constants,ChildExecutionLane/ChildReceiptItemSchema/ChildExecutionReceiptsSchemaTypedDicts,ChildExecutionTopologyError, shared_canonical_sha256_hexdigest 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(401LOC,0ASTAny,0# type: ignore): single-passnormalize_subagent_host_execution_receipts/_normalize_single_receipt(computesraw_keys = set(raw)once and avoids redundant full-receiptvalidate_public_safe_valuere-walks after per-field_opaque_refchecks),_lane_reason_codes,_lane_status,_lane_reconciliation,_orphaned_receipt_projection, andreconcile_subagent_execution(iteratingMappinglanes directly without throwawaydict(lane)copies).loopx/control_plane/turn_driver/executor.py(1,952LOC,+1/-1): narrownormalizeddict literal annotation todict[str, object]atobserve_subagent_host_resultcall site (0added ASTAny, baseline caller mypy errors reduced19 -> 18).tests/control_plane/test_subagent_execution_topology_contract.py(414LOC,0ASTAny,0# type: ignore): structural/budget/DAG/re-export parity,MappingProxyType+ empty-container + bool/0max_childrenedge cases, single-passvalidate_public_safe_valuecall-count regression,_opaque_refsdeduplication, host observation +agent_contextprojection, and fail-closed rejection tests.Verification
ruff checkon all 5 touched Python files: passed (All checks passed!)mypy --strict --no-incremental --follow-imports=silentonsubagent_execution_{topology,contracts,reconciliation}.pyandtests/control_plane/test_subagent_execution_topology_contract.py: passed (0errors across4source files)uv run --extra test python -m mypy: passed (0errors across17configured source files)mypy --no-incremental --follow-imports=silent(subagent_execution_*.py,executor.py,driver.py,execution_readback.py,codex_cli.py):0errors in all3subagent_execution_*modules,driver.py, andcodex_cli.py;2pre-existing inexecution_readback.py;18inexecutor.py(20 <= 21baseline)npm run typecheck:control-plane&node --test tests/control_plane_ts/content_digest_single_owner.test.ts:17/17passedscripts/check_rfc_bilingual.py --base origin/main --head HEAD: passedexamples/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)origin/mainvsHEADcounterfactual parity check across topology, bind, schema, receipt normalization, reconciliation, orphaned{}reconciliation, host error handling, legacy empty containers, and request projection: exact JSON parity (10/10probes,12,816bytes)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(0skipped)pytest -n 4 -rs tests/canary/:151 passed, 6 skipped(all6skips are filesystem non-UTF-8/root filename skips intests/canary/test_git_path_display.py)loopx check --scan-pathon all5touched files:0errors,0warnings, public boundary scan cleanloopx 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 exactbase..HEADscope)