Skip to content

refactor(goals): modularize acceptance_verification with zero-Any typing and safe deepcopy skip - #9478

Merged
huangruiteng merged 1 commit into
mainfrom
codex/slim-goals-acceptance-zero-any-20261126
Nov 27, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/slim-goals-acceptance-zero-any-20261126

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

  • Modularize Goal acceptance verification, pinned snapshot-oracle readback, and verifier-file hash guards out of loopx/control_plane/goals/acceptance.py (594 -> 458 LOC, 40 -> 0 AST Any, 0 # type: ignore, 0 # noqa) into acyclic loopx/control_plane/goals/acceptance_verification.py (311 LOC, 0 AST Any, 0 ignores).
  • Preserve loopx.control_plane.goals.acceptance as the exact pinned facade listed in tests/architecture/package_kernel_import_pins.json (loopx-jev) with identical re-exported function objects (is identity preserved across observe_goal_acceptance_oracles, observe_canonical_goal_acceptance, _criterion_effects, validation_effect_files_current, run_goal_acceptance_effects, _acceptance_pins_match, _stale_acceptance_receipt, and run_goal_acceptance_validation_effect).
  • Eliminate all caller mypy regressions (129 -> 126 across 23 caller files; 0 errors across changed files) via minimal runtime Mapping / explicit keyword-argument narrowing in acceptance_actions.py, goal_objective_actions.py, start_goal_todo_delta.py, chat_loopx_mode.py, and project_lifecycle_refresh_state.py.
  • Avoid unconditional deepcopy allocations in inspect_goal_acceptance when outcome_context is absent or no oracle criterion / observation hook can mutate goal_acceptance_contract, while keeping deepcopy protection whenever oracle readback or monkeypatched observers can alter the contract.
  • Add tests/control_plane/test_goal_acceptance_contract.py (454 LOC, 0 AST Any) covering LOC/Zero-Any/pin invariants, routing and rejection error boundaries, lifecycle/refine/handoff guards, conditional deepcopy capture, verifier-pin security edges, and snapshot-oracle drift handling.

Verification

  • ruff check across all 8 changed/added files: passed (0 issues)
  • mypy ([tool.mypy] 17/17 clean; --strict --no-incremental --follow-imports=silent on acceptance.py, acceptance_verification.py, test_goal_acceptance_contract.py: 0 errors; 23-file caller --follow-imports=silent: 126 <= 129 baseline)
  • scripts/check_rfc_bilingual.py --base origin/main --head HEAD: passed
  • npm run typecheck:control-plane & 9 TS acceptance suites (goal_acceptance_*, goal_objective, goal_outcome_*, content_digest_single_owner): 195 pass, 0 fail, 27 skipped (PostgreSQL tests skipped where server unavailable)
  • Paired origin/main vs HEAD counterfactual parity check: exact match (PAIRED_COUNTERFACTUAL_PARITY=PASS)
  • Clean-HOME smokes (control-plane-maintainability-ratchet-smoke.py, semantic-vocabulary-drift-smoke.py, loopx-turn-path-delta-acceptance-smoke.py): 3/3 passed (unreviewed: 0, stale_exceptions: 0, magnitude_regressions: 0)
  • Broad pytest -n 6 -rs (test_goal_acceptance_contract.py, test_goal_acceptance_*, test_goal_objective*, test_goal_outcome_*, test_outcome_*, test_goal_*, test_creation_task_queue.py, test_work_acceptance_context.py, test_original_task_entry.py, test_acceptance_restoration.py, test_final_outcome_diagnostics.py, test_project_lifecycle_json_inputs.py, test_chat_loopx_mode.py, test_delivery_review.py, test_independent_delegation_validation.py, test_managed_research_team.py, test_native_steward_turn_host.py, test_progress_review_criterion_binding.py, test_zcode_goal_bridge.py, test_goal_acceptance_contract_rendering.py, test_delegation_acceptance_diagnostics.py, test_canonical_planning_consumers.py, tests/architecture/, tests/canary/): 3,144 passed, 6 skipped, 0 failed (6 APFS non-UTF-8/root-name skips)
  • Public/private boundary check (loopx check) & pre-merge validation gate (loopx canary premerge --from-git-diff --git-diff-base origin/main): gate.status="passed", direct=4/4, py_compile=1/1, catalog=8/8, risk_profile=8/8, failures=0, manual_hold_count=0, cqr_8480d15d2e7ff932fdee (decision="pass", receipt_valid=true)

…ing and safe deepcopy skip

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@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

拆分 Goal 验收门面与真实 verifier/oracle IO,同时保持当前权威验收、历史证据及冻结输入的约束。 基线把权威路由、预览和 revision、验证文件固定及 oracle 当前性放在同一 Python 模块。CLI 预览无执行,只有 owner 能配置。 通过 CLI 或 Personal Workspace 配置、检查或恢复 Goal 验收的 owner,及依赖该验收的 Todo 与 Agent。

如果漂移的验证文件仍能产生当前成功,Goal 或 Todo 会提前关闭;错误划分历史和当前 evidence 会导向同样问题。 用当前目标基线与精确头分别运行 CLI 和真实 File、SQLite authority,预览只返回计划且 revision 未改变,执行验证后独立 inspect 读到已固定的输入与产物 SHA 和 current oracle。 定向 observation/oracle/prepared action 与契约测试在基线 125、精确头 131 项通过。owner 修订、越权拒绝及 Todo 检查实际入口配对各 6 项通过。独立 CLI File/SQLite 探针两侧各 2 项通过。git diff --check 与当前目标静态 merge-tree 通过。 真实 CLI 和本机隔离 File、SQLite,使用合成的无外部网络 checker 与产物。未验证 PostgreSQL、当前安装包或远程 CI。无吞吐提升估算。 基线契约

改动思路 / Approach

该改动沿用 goal-acceptance inspect/configure/verify → existing typed authority → acceptance_verification host IO/pinned snapshot → canonical verification and readback。保持 Python 为宿主 IO,原 typed authority 仍判定接受状态;把所有 verifier asset pin 与 oracle 读回归到同一模块,沿用原 facade 及 TS effect route。 验证前后核对原 pin 和被观测快照。仅无 oracle 且使用原无修改读回时跳过深复制;存在 oracle 或替代 observer 时仍保留原 basis,可撤回过期导航。 保留验收 facade 和现有 TS 合约。只提取 IO 和 receipt emitter,避免新增分叉状态;无 oracle 时的复制优化可独立停用。

具体改动 / Changes

精确提交 8e3e4fa,分叉基线 7f7297a。8 个路径 +1053/-393。门面缩为 458 行,验证模块 311 行,契约测试 454 行。5 个调用方做类型及结构检查,保留原权威入口。

关键代码讲解

  • inspect_goal_acceptance。绑定当前 canonical 读和可选 oracle 观察,观察有变化时撤下旧 outcome_context。 源码

  • verify_goal_acceptance。预览不执行,通过原 revision 提交当前真实检查结果。 源码

  • run_goal_acceptance_validation_effect。在原 workspace 核对验证文件和快照前后身份,短路过期依据。 源码

  • observe_goal_acceptance_oracles。重新读取原已固定的输入与产物后交给原 authority 更新当前观察。 源码

  • owner-pinned-acceptance-preserves-current-verification(implemented)。当前 Goal 验收只认可原 owner、冻结 revision 和实际检查。已固定 verifier 或产物版本漂移时,旧验证证据可保留,当前结论必须撤回。

对主干的风险 / Risks

修改产物后,独立 inspect 显示 stale 而保留原历史 oracle evidence。恢复产物并单独更改 verifier 后,真实 verify 拒绝新验收,两种 backend 同样失败关闭。 优化深复制时必须区分有实际 oracle IO 的场景。无 oracle 原 observer 只返回映射,有观察的路径仍比较原快照。 保持原 authority 配置、核对固定文件和 observation 原 basis,漂移使当前证据变陈旧而保留旧收据。

我的整体评价 / Verdict

APPROVE。 认可当前精确头。真实 File/SQLite 在当前来源固定、历史回执保留和验证依据漂移时的拒绝行为保持。 持续工作的接受和停止可以依同一稳定验证依据重放,避免沿用已失效的通过证据。

English verdict: APPROVE at 8e3e4fa. Exact-base and head File/SQLite CLI checks preserve read-only preview, pinned verification, withdrawal of stale current evidence, and rejection after verifier drift.

@huangruiteng huangruiteng 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-5 · OpenAI · self_reported

动机 / Motivation

复核字段:affected_caller_or_operator=Existing LoopX callers and operators of the changed integration surface. before_after_scenario=The old monolith or broad type surface is replaced by focused modules with explicit validation while public behavior stays stable. observable_outcome=Existing behavior remains reachable through the same entrypoint with stricter typing and focused regression coverage. non_goals=No unrelated product workflow, permission model or external provider protocol is changed.

规范依据:docs/development/testing-and-quality.md(精确头分叉基线 7f7297a790771dab08e2444700f4d76699169950)。

refactor(goals): modularize acceptance_verification with zero-Any typing and safe deepcopy skip。本次审核聚焦于把现有职责拆成更窄的类型化边界,同时保持原有调用方、持久状态、失败路径和恢复身份。该改动面向现有 LoopX 调用方和维护者,目标是在不改变公开行为的前提下降低维护成本与类型歧义。

改动思路 / Approach

复核字段:criterion=goal-acceptance-verification-parity architecture_reason=职责沿现有调用、provider 和持久化边界拆分,公共入口保持。 current_pr_boundary=仅 loopx/chat_loopx_mode.py, loopx/cli_commands/project_lifecycle_refresh_state.py, loopx/control_plane/goals/acceptance.py, loopx/control_plane/goals/acceptance_actions.py, loopx/control_plane/goals/acceptance_verification.py, loopx/control_plane/goals/goal_objective_actions.py, loopx/control_plane/goals/start_goal_todo_delta.py, tests/control_plane/test_goal_acceptance_contract.py。

沿用现有生产入口和权威状态所有者,只把可独立验证的逻辑拆入内聚模块;公共门面继续承担调用兼容和结果收口。

具体改动 / Changes

精确 head 8e3e4fae054dcb265212ae5063fef2be4c3a44ba 相对分叉基线 7f7297a790771dab08e2444700f4d76699169950 包含 8 个路径,新增 1053 行、删除 393 行。

  • loopx/chat_loopx_mode.py
  • loopx/cli_commands/project_lifecycle_refresh_state.py
  • loopx/control_plane/goals/acceptance.py
  • loopx/control_plane/goals/acceptance_actions.py
  • loopx/control_plane/goals/acceptance_verification.py
  • loopx/control_plane/goals/goal_objective_actions.py
  • loopx/control_plane/goals/start_goal_todo_delta.py
  • tests/control_plane/test_goal_acceptance_contract.py

关键代码讲解

改动沿原有调用路径保留输入验证、状态转换、失败关闭和结果读回;新增契约测试覆盖正常路径与拒绝路径。

对主干的风险 / Risks

主要风险是移动代码后改变求值顺序、状态所有权或重复副作用。本次按要求逐项核对生产入口、调用方参数、持久状态读取和失败关闭分支,并用新增契约测试覆盖拒绝与恢复路径;公开入口和既有状态所有者保持可追踪。本次复核以定向测试、静态检查和仓库 premerge 对照限定影响面;未等待远程 CI,也未覆盖安装态及外部服务路径。

我的整体评价 / Verdict

当前精确 head 的改动边界清晰,现有入口和状态所有者保持完整。定向测试和仓库门禁未发现阻塞问题。

本轮独立复核:234 passed; Ruff passed; strict mypy passed;premerge passed 16/16 with 0 manual holds。

English verdict: APPROVE at 8e3e4fa. The exact-head refactor preserves the existing entrypoint and authority boundaries with focused regression coverage.

@huangruiteng
huangruiteng merged commit 9e1f51f into main Nov 27, 2026
40 of 53 checks passed
@huangruiteng
huangruiteng deleted the codex/slim-goals-acceptance-zero-any-20261126 branch November 27, 2026 06:56
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.

2 participants