Repository navigation
refactor(control-plane): split autonomous_replan_policy with Zero-Any typing and single-pass trigger scans - #9473
Conversation
… typing and single-pass trigger scans Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
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
把自主重规划的触发归纳、身份计算和 CLI 引导移到同一策略模块,保持原 typed trigger 优先级和原轮次写回边界。 基线将多类触发、历史归属、行动建议和 ID 计算放在同一模块。单次输出前为不同类别多次扫同一份记录。 从 status 和 quota 接收有界重规划任务的 Agent,以及依据原 obligation 结算的外层 Turn 执行器。
错误改变触发优先级或重新生成原 obligation ID 会使 Agent 接到错范围任务,或让已准入轮次无法按原证据恢复。 基线与精确头在六种触发的一至三项、共 156 个有序组合上完整 JSON 相同。混合时仍以 blocked successor 优先,外部评估仍保留自己的证据窗口。多 Agent 证据不会采用首个 Todo 的受领者。指定的遗留及现行 obligation ID 与原 CLI 写回动作均一致。 Python 3.12 下基线 116 项、精确头 120 项定向回归通过。两版实际 subprocess CLI 的 autonomous-replan-obligation smoke 通过,且独立配对触发、作用域、遗留身份和 CLI 动作探针输出相同。git diff --check 通过。 使用隔离 fixture、精确源和同一套本机工具链。外部评估 receipt 使用测试数据。生产时延、实际模型采纳、安装和远程 CI 未核验。 基线契约
改动思路 / Approach
该改动沿用 compact run history → TypeScript history owner → autonomous_replan_obligation → status/quota CLI → original semantic writeback。保留高层构建接口与同一 TypeScript 历史、阶段和结算 owner。Python 抽取集中触发归纳,现有 JSON 仍由原路径消费者读取。 typed repeat、已固定的 assist 评估及普通历史触发仍分别保留顺序。组合触发的原行动优先级、三条 Todo 指导上限和 scoped Agent 归属保持。 只改某一个 scan 无法消除触发类别分别出现于动作和标识构造的问题。复用原历史 reducer 和 ACK API,将同一次判定需要的类目信息一次收集。
具体改动 / Changes
精确提交 5ad139a,分叉基线 57c4c43。4 个文件,新增 1,216 行、删除 599 行。将策略提取到 525 行模块,单行调用方类型调整,新增 504 行契约测试。
关键代码讲解
-
autonomous_replan_obligation_from_runs。继续复用 TypeScript 历史判定。typed repeat 先于可选 assist 和普通触发。 源码 -
summarize_trigger_evidence。一次记录触发族、证据基线和 Agent scope,交由原规则生成动作。 源码 -
_extract_trigger_identities。构造现行和历史触发输入,避免替换原义务身份。 源码 -
build_autonomous_replan_cli_actions。保持 staged 原轮次写回和 spend 的可达条件。 源码 -
typed-replan-trigger-priority-and-staged-original-writeback(implemented)。保留 typed repeat、assist 与普通历史触发优先级,保持原 obligation ID、受领范围和原 Turn 写回。拒绝重复观察形成的虚假进展。
对主干的风险 / Risks
隔离真实 CLI smoke 中,等价观测在写入前被拒,新的 typed surface 可关闭原 obligation。普通记录不会触发显式按完成 Todo 周期的阈值,清除该配置后恢复原输出。无 settlement chain 时 verified_replan_writeback 不产生 spend 动作,旧 rearm ID 仍与现行身份并行保留。 改动跨义务身份和准备状态,可能改变权限边界或丢历史。配对混合触发与实际拒绝/接受写回测试覆盖这两处。 单扫保留原每类首个记录,再以原策略排序。只用原字段与稳定键构造 obligation ID。
我的整体评价 / Verdict
APPROVE。 认可当前精确头。独立组合、历史身份和实际 CLI 验证均保持原作用域与写回边界。 保留触发、写回与下一轮证据的原身份,既能回读反例,也允许原先的新 observation 成功关闭 obligation。
English verdict: APPROVE at 5ad139a. Exact-base/head probes match across 156 ordered trigger combinations and preserve original and legacy obligation IDs. The real CLI rejects repeated evidence and accepts a valid new observation under the existing settlement gates.
huangruiteng
left a comment
There was a problem hiding this comment.
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(精确头分叉基线 57c4c43b5243003c6da1988730c49ac2267626f7)。
refactor(control-plane): split autonomous_replan_policy with Zero-Any typing and single-pass trigger scans。本次审核聚焦于把现有职责拆成更窄的类型化边界,同时保持原有调用方、持久状态、失败路径和恢复身份。该改动面向现有 LoopX 调用方和维护者,目标是在不改变公开行为的前提下降低维护成本与类型歧义。
改动思路 / Approach
复核字段:criterion=autonomous-replan-policy-parity architecture_reason=职责沿现有调用、provider 和持久化边界拆分,公共入口保持。 current_pr_boundary=仅 loopx/control_plane/goals/goal_amendment_runtime.py, loopx/control_plane/work_items/autonomous_replan_obligation.py, loopx/control_plane/work_items/autonomous_replan_policy.py, tests/control_plane/test_autonomous_replan_obligation_contract.py。
沿用现有生产入口和权威状态所有者,只把可独立验证的逻辑拆入内聚模块;公共门面继续承担调用兼容和结果收口。
具体改动 / Changes
精确 head 5ad139a55d7d1829a592364707a402206b165446 相对分叉基线 57c4c43b5243003c6da1988730c49ac2267626f7 包含 4 个路径,新增 1216 行、删除 599 行。
loopx/control_plane/goals/goal_amendment_runtime.pyloopx/control_plane/work_items/autonomous_replan_obligation.pyloopx/control_plane/work_items/autonomous_replan_policy.pytests/control_plane/test_autonomous_replan_obligation_contract.py
关键代码讲解
改动沿原有调用路径保留输入验证、状态转换、失败关闭和结果读回;新增契约测试覆盖正常路径与拒绝路径。
对主干的风险 / Risks
主要风险是移动代码后改变求值顺序、状态所有权或重复副作用。本次按要求逐项核对生产入口、调用方参数、持久状态读取和失败关闭分支,并用新增契约测试覆盖拒绝与恢复路径;公开入口和既有状态所有者保持可追踪。本次复核以定向测试、静态检查和仓库 premerge 对照限定影响面;未等待远程 CI,也未覆盖安装态及外部服务路径。
我的整体评价 / Verdict
当前精确 head 的改动边界清晰,现有入口和状态所有者保持完整。定向测试和仓库门禁未发现阻塞问题。
本轮独立复核:36 passed; Ruff passed; strict mypy passed;premerge passed 13/13 with 0 manual holds。
English verdict: APPROVE at 5ad139a. The exact-head refactor preserves the existing entrypoint and authority boundaries with focused regression coverage.
Summary
loopx/control_plane/work_items/autonomous_replan_obligation.py(764 -> 352 <= 550LOC,43 -> 0ASTAny,0 # type: ignore,0 # noqa) into a cohesive policy moduleloopx/control_plane/work_items/autonomous_replan_policy.py(526 < 750LOC,0ASTAny,0 # type: ignore,0 # noqa) while preserving all 22 public/re-exported symbols, signatures, and exactorigin/main(57c4c43b52) semantics.Anyannotations withPayload = dict[str, object],PayloadView = Mapping[str, object],PublicSafeText,AckRecorded = Callable[[dict[str, object]], bool], and@dataclass(slots=True) TriggerEvidenceSummary.Name as Namere-exports inautonomous_replan_obligation.pywith verifiedisobject identity parity for every constant and policy helper; added single-line caller narrowing inloopx/control_plane/goals/goal_amendment_runtime.py(+1/-1, keeping all 42loopx/Python callers at exact88 == 88baseline mypy errors,+0regressions).evidenceinbuild_autonomous_replan_obligationwith single-passsummarize_trigger_evidence(1kindread per item in summarization /2total throughbuild_autonomous_replan_obligation, verified by_CountingMapping).ensure_replan_novelty_policy's separatetrigger_identityandlegacy_revisionsloops into single-pass_extract_trigger_identitieswithout re-reading"kind"; eliminated duplicaterun_history_agent_idcalls during_external_review_agent_runsattribution (5vs6calls on mixed fixture).tests/control_plane/test_autonomous_replan_obligation_contract.py):496LOC,0ASTAny,0 # type: ignore/# noqa; verifies LOC/AST/export identity invariants,MappingProxyType/tupleimmutability, single-pass read counters, malformed/null fail-closed paths, and pairedorigin/mainvsHEADbehavioral parity across novelty policies, CLI actions, lifecycle reentry, run-history attribution,build_autonomous_replan_obligation(all 5 trigger families + agent attribution + empty-evidence fallback), andautonomous_replan_obligation_from_runs.Verification (
HEAD@5ad139a55d7d1829a592364707a402206b165446, clean detached worktree)ruff check(4/4files):All checks passed!mypy --strict --no-incremental --follow-imports=silent(3/3files):Success: no issues found in 3 source filesmypy --config-file pyproject.toml --no-incremental(17/17):Success: no issues found in 17 source files42-fileloopx/callermypy --no-incremental --follow-imports=silent:88 == 88baseline (+0regressions;goal_amendment_runtime.py:0errors)npm run typecheck:control-planeclean +node --testacross7TS suites (content_digest_single_owner,replan_semantics,task_graph,turn_envelope,goal_amendment_proposal,action_selection_admission,steward_reports):241/241passedscripts/check_rfc_bilingual.py --base origin/main --head HEADpassed;TOP_LEVEL_PY=112;module_metric_baseline.jsonuntouched; cleangit merge-tree origin/main HEAD(5e790604a2)autonomous-replan-obligation-smoke,quota-replan-decision-plane-smoke,goal-frontier-replan-rules-smoke,work-lane-contract-smoke,quota-terminal-no-followup-smoke,control-plane-maintainability-ratchet-smoke,semantic-vocabulary-drift-smoke, plusmonitor-poll-writeback-smoke(cleanHOME&canary premerge) andrefresh-state-write-correctness-smoke(canary premerge) passedpytest -n 6 -rs(21suites covering contract/replan/amendment/capability/architecture/canary/cli):2,750 passed, 6 skipped in 200.43s(6 APFS non-UTF8/root filename skips intest_git_path_display.py,0failures)loopx check(5checks,errors=0), Goal CQRcqr_779741b4119645442823(decision="pass",status="valid"), and Goalcanary premerge --from-git-diff --git-diff-base origin/main(gate.status="passed",merge_gate_passed=true,direct=4/4,py_compile=1/1,catalog_run=5/5,risk_profile_run=8/8,failures=0,manual_hold_count=0)