refactor(quota): construct unadmitted selection recovery directly - #4788
huangruiteng merged 14 commits into
Conversation
Signed-off-by: song <22676124+songoow@users.noreply.github.com>
…pair-pr4788-ci Signed-off-by: song <22676124+songoow@users.noreply.github.com>
…tion Signed-off-by: song <22676124+songoow@users.noreply.github.com>
songoow
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
PR-08 要消除 deferred/rejected 显式 Todo 选择的“先生成 settlement/replan/primary action,再逐字段删除”流程。旧实现要求维护者持续记住哪些执行字段必须 pop,容易让 TurnEnvelope 或 CLI 暴露未准入动作。exact head f50ec115ac1266c30015da376ee8d3d6696d01d4 将 admission 提前到 interaction 与 CLI 构造边界,直接生成允许的 recovery 响应。
改动思路
current_action_selection_admission 统一读取 selected Todo、typed qualification、execution obligation 与 agent delivery 事实;unadmitted_action_selection 在 settlement、replan packet 和 executable primary action 之前复用同一判定。CLI preflight 只绑定准确 registry/runtime/Goal/Agent/Turn/capability/scheduler argv,receipt 持久化和身份所有权仍在原 reconciliation owner。
具体改动
- qualified delivery、合法 workspace repair 和当前 obligation 的准入规则集中在一个 typed helper。
- deferred/rejected 直接得到 no-spend/no-settlement recovery;旧
apply_action_selection_recoverycleanup 路径实际删除。 - receipt-bound binding 继续由 receipt owner 处理;缺 qualification、未知状态、错误身份和缺 recovery action 均 fail closed。
- recovery command 保留完整调用上下文并排除
--todo-id/--replan-obligation-id。 - execution/quiet flag 投影移到既有 primary-action owner;完整 interaction parity 和结构预算检查通过。
对主干的风险
正向路径中 qualified selection 和明确 delivery-refused 的 workspace repair 仍可执行;缺失或矛盾的 delivery flag 不会伪造准入。负向路径中 deferred/rejected 关闭所有 delivery/repair/actionability 与 spend,并返回 same-Turn guard;首次拒绝不提交 false receipt,既有 identity-less receipt 只 read back。
独立验证覆盖 construction/conflict/reentry、真实 CLI selection/workspace repair/capability reentry/identity、semantic vocabulary、shared Chat/Lark、Ruff、结构预算和 required CI。没有新增词表、capability、持久状态或 authority 名称。残余风险在后续集成:#4764 和 #4794 触及相同构造链,新 head 必须重新验证 receipt owner、packet absence 和 exact argv。
我的整体评价
APPROVE。 本 PR 实际删除旧 cleanup,把准入放回 action-selection/interaction owner;qualified、workspace repair、rejected/deferred、receipt readback、身份拒绝及 argv 均有独立证据。批准仅适用于此 exact head,不授予合并权限。
English verdict: APPROVE — exact head f50ec11 verifies direct unadmitted recovery, workspace-repair admission, receipt-owner identity rejection, exact argv binding and structural parity; any #4764/#4794 rebase requires fresh review.
Signed-off-by: song <22676124+songoow@users.noreply.github.com> # Conflicts: # loopx/cli_commands/quota.py
Signed-off-by: song <22676124+songoow@users.noreply.github.com>
Signed-off-by: song <22676124+songoow@users.noreply.github.com>
huangruiteng
left a comment
There was a problem hiding this comment.
动机
PR-08 要消除 deferred/rejected 显式 Todo 选择的“先构造 settlement/replan/primary action,再逐字段删除”流程。这个目标正确:未准入的选择只能产生一次 no-work/no-spend recovery,不应让执行语义先进入 payload,再依赖 cleanup 恢复安全状态。
当前 exact head 2d85dc6d51f6b533301c2d3643e9fefc04e10818 已把 admission predicate、workspace-repair 条件和 recovery argv 收拢到现有 action-selection/interaction 边界;但真实 CLI 证明它只直接构造了 root 与部分 channel,公共派生投影仍保留拒绝前的动作语义。因此作者声明的“一致 root/agent/CLI/execution obligation”还没有实现完整。
改动思路
TypeScript qualification 继续产出 qualified / deferred / rejected;Python current_action_selection_admission 结合 selected Todo、receipt binding、execution obligation 与 agent delivery facts 判断能否进入执行。未准入时,preflight 返回纯 recovery 字段,CLI 再绑定精确 registry/runtime/Goal/Agent/Turn/capability/scheduler argv。
这个 owner 划分基本合理:candidate qualification 没有被 Python 重写,receipt reconciliation 仍拥有 committed binding,first rejection 也没有伪造 durable receipt。问题在调用顺序:build_live_quota_should_run_decision 已经完成 interaction、protocol、automation 与 scheduler projection,之后 _reconcile_requested_quota_action_selection 才覆盖 root recovery 字段并改两处 channel 命令。
具体改动
关键代码讲解
quota._requested_quota_action_selection_preflight从 in-place mutation 改成返回 recovery dictionary;qualified、receipt-bound、workspace-repair admission 仍 fail closed。action_selection_contract.current_action_selection_admission集中 pending-selection delivery、明确 delivery-refused workspace repair 与当前 obligation 的准入判断。interaction_contract.unadmitted_action_selection在 settlement/replan/primary action construction 前复用同一 admission 事实,避免新建可执行 action。quota._reconcile_requested_quota_action_selection在 live payload 已构造完成后更新 root、obligation 与 recovery command;这里没有重建 interaction mode、protocol packet、automation liveness 或 scheduler hint。
分支上的 construction/conflict/settlement CLI/reentry/portfolio/boundary/live-decision 聚焦组最终为 105 passed in 476.99s;Ruff、semantic-vocabulary drift smoke 与 git diff --check 通过。正向 admission、精确 argv、first-rejection non-durable receipt 和 committed-binding exemption 均有覆盖。
对主干的风险
[P1] recovery 输出仍携带拒绝前的 interaction/protocol/automation 动作
我通过真实 CLI、真实 TS qualifier bridge 和 disposable runtime 复现了两个反例:
- first-call 选择不存在的 Todo:root 为
effective_action=quota_skip、state=quota_action_selection_rejected,但interaction_contract.mode仍是bounded_delivery;protocol_action_packet仍写agent_action_required=true与原 delivery action;automation_liveness.automation_action仍是execute_bounded_work。 - 选择被 autonomous replan 抢占:root 为
quota_skip/quota_action_selection_deferred,但 interaction mode 仍为autonomous_replan。
agent/CLI 的 must_attempt、delivery_allowed 和 spend flags 确实关闭了,但 mode、protocol、automation、scheduler 也是正式消费者。TurnEnvelope、scheduler identity/backoff 或任何不只读取 top-level flags 的 host 都会看到互相矛盾的 authority。当前测试之所以全绿,是因为它们主要断言 settlement/replan 字段不存在和 channel flags 关闭,没有断言这些已经提前构造的派生面。
最小修复不是再 pop 几个字段,而是在 common finalization 之前确定 recovery,或者在 recovery facts 确定后由同一个 owner 重建 interaction/protocol/automation/scheduler。补两条 real CLI + TurnEnvelope 回归:first rejection 与 autonomous-replan deferral 都应保证 root、interaction mode、protocol summary、automation action、scheduler route 一致描述“同 Turn 无选择 reentry、无 delivery、无 spend”。
[P1] exact head 与最新 main 的同一 interaction owner 冲突
GitHub/merge-tree 都显示 DIRTY;冲突包括 interaction_contract.py、semantic smoke/registry 和 action-selection conflict test。修复上面的 stale projection 后还必须 rebase 到最新 main,保留当前主线 interaction 行为并按合并树重算 semantic inventory,再重新做 exact-head 复审。旧 head 的局部验证不能证明冲突解决后的 host contract。
语义与 CI 对齐
本 PR 应复用现有 qualification、EffectiveAction 和 interaction vocabulary,不需要新状态名;但当前同一个 recovery 同时投影成 quota_skip 与 bounded_delivery/autonomous_replan,属于既有 typed contract 的不一致使用。修复目标是让一个既有 recovery authority 驱动所有派生面,而不是提高预算、增加 cleanup 或注册一个掩盖冲突的新值。
我的整体评价
REQUEST_CHANGES。 这次 refactor 已经删掉主要 settlement cleanup,并把 admission 事实收拢到了合理 owner;105 个聚焦测试也说明大量兼容路径没有回退。但真实 CLI 仍暴露拒绝前的 mode/protocol/automation action,这是本 PR 要消除的同类语义泄漏,且 exact head 还未与最新 main 集成。先修完整 projection ordering、补跨表面回归、rebase 后再复审。
English verdict: REQUEST_CHANGES — exact head 2d85dc6 closes settlement/channel flags, but real CLI rejection still exposes the pre-recovery bounded_delivery/autonomous_replan mode, agent_action_required protocol and execute_bounded_work automation; rebuild all derived projections from recovery facts and rebase current main before re-review.
…r4788-20260920 Signed-off-by: song <22676124+songoow@users.noreply.github.com> # Conflicts: # examples/semantic-vocabulary-drift-smoke.py
Signed-off-by: song <22676124+songoow@users.noreply.github.com>
Signed-off-by: song <22676124+songoow@users.noreply.github.com>
Signed-off-by: song <22676124+songoow@users.noreply.github.com>
songoow
left a comment
There was a problem hiding this comment.
Exact-head review status (author-owned PR; required CI rerun needed)
动机
本次复审绑定 exact head 75ac19d294b399334eae058f431c76b04c3b4af1。PR-08 要让 deferred/rejected 显式选择直接产生一个 no-work/no-spend recovery,而不让 settlement/replan/primary action 先进入 payload,再依赖 late cleanup 恢复安全状态。
维护者上一轮的两个 P1 都成立:旧 head 与主干冲突,而且真实 CLI 的 root 虽已 quota_skip,interaction/protocol/automation 仍保留拒绝前的执行语义。当前 head 已修复这两项代码问题。
改动思路
现有 TypeScript qualification 与 receipt identity owner 不变。action-selection owner 构造 closed recovery root facts;quota common finalization 在 automation、interaction、scheduler 和 protocol 之前应用这些 facts。CLI 只绑定精确 registry/runtime/Goal/Agent/Turn/capability/scheduler recovery command。
ReceiptBoundReplayPhase.SETTLED 继续拥有更高优先级:已结算的 receipt-bound replan 不能被新的 selection recovery 覆盖。workspace repair、receipt-bound Todo、autonomous-replan identity-upgrade 正例仍由原 owner 准入。
具体改动
关键代码讲解
build_action_selection_recovery_fields在 action-selection owner 构造quota_skiproot 与 clean no-work obligation。_apply_unadmitted_action_selection_precedence在 quota packet owner 清除旧 selected/replan/lane action projections,再进入共享 finalization。- heartbeat owner 构造
quota_skiprecommendation;interaction、automation、scheduler 和 compatibility packet 从同一 recovery facts 重新投影。 - CLI preflight 复用这份结果,只绑定完整 recovery argv,不恢复旧 cleanup helper,也不新增 packet writer。
- settled receipt guard 阻止 action-selection recovery 覆盖已结算 replan replay。
- 真实 CLI/TurnEnvelope 断言覆盖 first rejection、autonomous-replan deferral、workspace repair、receipt identity 和 settled replay。
对主干的风险
原 P1 反例已闭合:rejected/deferred 输出现在为 interaction_contract.mode=skip,agent/CLI 无 must-attempt、delivery 或 spend;protocol 为 agent_action_required=false;automation 不再 execute_bounded_work;scheduler 使用 quiet backoff;TurnEnvelope 的 primary action 是精确 recovery 命令且 write scope 为空。
本地验证包括 40 个 selection/reentry/workspace/settled-replan 场景、115 个 semantic/maintainability 检查、TypeScript typecheck、Ruff 和 diff check。预算保持原值,packet writer 仍为 5/5。远端 exact head 有 24 项成功,包括 PostgreSQL、Node forward、四个 Python shards、Windows、E2E、mutation、installed、kernel static、pytest 和 Sonar。
当前唯一门禁不是代码断言:node-minimum-compatibility 在 10:05 被 workflow 的 timeout-minutes: 10 取消,merge-gate 仅因此失败。相同 Node 22.18 选择已在本地由前 1050 个连续通过测试,加上取消时所在 nokv_jsonl_transport.test.ts 的完整 189/189 运行覆盖,无失败。当前凭据无权重跑上游 job 或加 ci:full 标签。
语义与 CI 对齐
该 PR 复用 qualification、EffectiveAction.QUOTA_SKIP、receipt phase 和现有 interaction vocabulary;没有新增状态、扩大预算或把字符串启发式变成 authority。producer registry 已指向真实 action-selection constructor。
我的整体评价
代码结论:原 request-changes findings 已修复。合并结论:HOLD。 当前不要求再改 PR 代码;维护者需要重跑 node-minimum-compatibility,让 required merge-gate 在 unchanged head 上取得成功,然后重新提交正式 review。任何 head 变化都需要新的 exact-head 审查。
English verdict: HOLD — exact head 75ac19d294b399334eae058f431c76b04c3b4af1 fixes both code blockers and passes all product checks plus equivalent local Node 22.18 coverage, but the required remote minimum-Node job timed out and its dependent merge gate remains red; maintainer rerun and formal re-review are still required.
huangruiteng
left a comment
There was a problem hiding this comment.
动机
本次复审 exact head 75ac19d294b399334eae058f431c76b04c3b4af1。PR-08 的目标是把 deferred/rejected 显式 Todo 选择变成一个直接构造的、统一的 no-work/no-spend recovery,避免先生成 settlement、replan、primary action 或其他执行权限,再靠不断增长的 cleanup 列表删除。
上一轮在 2d85dc6d... 上阻断的两个问题已经有实质修复:分支已 rebase 到当前 main,而且 recovery 已移到 common finalization 之前;普通 rejection/deferral 下,root、interaction、protocol、automation、scheduler 与 TurnEnvelope 现在都一致描述 quota_skip/skip。但我继续按“所有 authority-bearing consumer 必须一致”的原则检查组合路径,发现 scoped user-gate fallback 仍能把执行权限带过 recovery 边界。
改动思路
当前实现让 TypeScript qualification 继续负责候选 admission,Python current_action_selection_admission 读取 typed qualification、receipt binding 与当前 obligation;_apply_unadmitted_action_selection_precedence 在 shared projections 之前清理 selected Todo、replan、work lane、workspace guard 等字段,再调用 apply_action_selection_recovery_projection 统一 root 与 heartbeat recommendation。
这个 owner 与顺序比旧 head 明显更好,也修复了旧 review 发现的 stale bounded_delivery / autonomous_replan、agent_action_required、execute_bounded_work。问题在于,同一 pipeline 更早会执行 apply_scoped_user_gate_fallback_projection,它设置 safe_bypass_allowed=true、kind、policy 和 executable obligation;新的 recovery 清单没有覆盖这三个字段。之后 common interaction 又把 mode 投影回 scoped_user_gate_fallback。
具体改动
关键代码讲解
should_run_packet._apply_unadmitted_action_selection_precedence现在在 interaction/protocol/automation/scheduler 之前完成 recovery,删除旧 head 的 post-finalization overlay;这是正确的主修复。action_selection_contract.apply_action_selection_recovery_projection统一ok=false、should_run=false、effective_action=quota_skip、delivery/repair/actionable flags 与execution_obligation.kind=quota_skip。test_quota_settlement_cli._assert_action_selection_recovery_projections新增了真实 CLI、TurnEnvelope 和 host authority 的一致性断言,覆盖 ordinary rejection、first rejection 与 autonomous-replan deferral。- 但
todos.user_gate.apply_scoped_user_gate_fallback_projection会更早产生safe_bypass_allowed/kind/policy;recovery 没有清掉它们。heartbeat/task_body.py又明确把should_run=false + safe_bypass_allowed=true解释为“允许完成一个 bounded step、writeback 并 spend once”,所以它不是无害的展示字段。
我在 exact head 上运行了 focused construction/conflict/settlement CLI 三组:79 passed in 643.69s;focused Ruff、semantic-vocabulary drift smoke、git diff --check 和 current-main merge tree 都通过。GitHub 当前绝大多数 required checks 成功;node-minimum-compatibility 为 cancelled,merge-gate 因 changes requested 失败。Goal 配置不要求等待 CI,因此这些只作为旁证。
对主干的风险
[P1] rejected selection 仍可继承 scoped safe-bypass 的执行与记账权限
我用生产 build_quota_should_run、真实 scoped-gate fallback producer 和有效 Codex App scheduler context 构造了组合反例:存在一个与 gate 无关的可运行 fallback,同时请求一个当前不合格的 Todo。结果为:
ok=falseshould_run=falseeffective_action=quota_skipactionable_by_codex=falsesafe_bypass_allowed=truesafe_bypass_kind=scoped_user_gate_fallbackinteraction_contract.mode=scoped_user_gate_fallback
agent/CLI channel 的 must-attempt、delivery 与 spend flags 是关闭的,但 managed heartbeat prompt 明确把残留 safe-bypass 当作更具体的执行许可。因此 host 可以在“选择未准入”的同一 packet 上仍执行一次 fallback、writeback 并记账。这正是本 refactor 旨在消除的细微语义/权限泄漏,只是从旧 head 的 stale common projection 转移到了一个尚未覆盖的组合优先级。
最小修复应放在现有 recovery owner:明确覆盖 safe_bypass_allowed=false,删除或归零 safe_bypass_kind 与 safe_bypass_policy,然后补一个 public quota/real CLI 回归,把 scoped fallback 与 rejected/deferred selection 组合起来,并断言 root、interaction、TurnEnvelope/渲染 task body 都禁止 work/spend。不要新增 mode/schema,也不要再建立第二个 cleanup owner。
语义与 CI 对齐
本 PR 没有 substring/prose 分类,也没有必要引入新 vocabulary。冲突来自两个已有 typed authority 的 precedence:最终 quota_skip 应覆盖先前的 scoped_user_gate_fallback。现有测试把两条路径分别验证为正确,却没有验证组合次序;这也是为什么 79 个 focused tests 与 CI 可以通过而真实 packet 仍矛盾。
我的整体评价
REQUEST_CHANGES。 新 head 已经正确修复上一轮的 construction order、跨表面 stale authority 和 rebase 冲突,79 个聚焦测试也证明普通 recovery 大幅收敛;这部分值得保留。但 no-work/no-spend 的核心不变量仍在 scoped-gate 组合路径上被 safe_bypass_allowed=true 打破,而且 shipped task body 会实际执行这项权限。请在同一 recovery owner 清除它并补组合回归后再复审。
未来向检查:相关的最佳小改动就是让 recovery 统一重置所有 action-authority 字段;除此之外不需要抽象新框架,也不应扩大到 user-gate policy 重构。
English verdict: REQUEST_CHANGES - Exact head 75ac19d fixes the prior stale interaction/protocol/automation projections, but a real scoped-gate plus rejected-selection path still returns quota_skip/actionable=false together with safe_bypass_allowed=true and scoped_user_gate_fallback mode, which the shipped heartbeat task body treats as permission for one bounded action and spend; clear that authority and add the composed-path regression.
A refused selection already produced a closed quota_skip recovery, but a scoped user-gate fallback prepared earlier in the same packet survived it: safe_bypass_allowed stayed true, safe_bypass_kind/policy kept the fallback text, and the fallback projection short-circuited the interaction mode back to scoped_user_gate_fallback with agent_action_required=true. The shipped heartbeat task body reads should_run=false together with safe_bypass_allowed=true as permission to run one bounded safe-bypass step, write back and spend once, so the host could still work and account on a Turn whose selection was refused. Close it in the recovery owner that already constructs the refusal: build_action_selection_recovery_fields() now denies the safe bypass, and the precedence pass drops scoped_user_gate_fallback with the other action projections it already clears. No new mode, schema or second cleanup owner. The fallback itself is untouched: without a refused selection the same fixture still runs it with safe_bypass_allowed=true, and a positive control pins that. The composed regression covers root, execution obligation, interaction, protocol summary, TurnEnvelope, turn authority and the rendered guidance, and both refusal states are pinned at the owner they share. Signed-off-by: song <22676124+songoow@users.noreply.github.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: song <22676124+songoow@users.noreply.github.com>
huangruiteng
left a comment
There was a problem hiding this comment.
动机
本次复审绑定 exact head 7bdac93450686494b673626a7762c94792a14e6f。这个 PR 要解决的是:显式 Todo selection 一旦因 deferred/rejected 而不被接纳,所有后续 authority consumer 都必须看到同一个 no-work/no-spend recovery。上一版 75ac19d 已清理通用投影中的大部分残留,但 scoped_user_gate_fallback 仍可重新导出 safe-bypass,导致拒绝态与可执行态同时出现;当前 head 正面修复了这个组合路径。
改动思路
实现继续复用既有 recovery owner,没有引入第二套状态机:
build_action_selection_recovery_fields明确关闭 rootsafe_bypass_allowed,并清空其 kind/policy;_apply_unadmitted_action_selection_precedence在重建 interaction / automation / scheduler 投影前移除scoped_user_gate_fallback,阻止已拒绝 selection 被 scoped gate 再次“复活”;- 保留一个无 selection rejection 的正向对照,证明合法 scoped fallback 仍然可用,而不是粗暴禁掉整条能力。
具体改动
关键代码讲解
action_selection_contract.py把 safe-bypass 的关闭纳入 unadmitted recovery 的统一字段集合,避免各 consumer 自己猜测或二次修正。should_run_packet.py在恢复优先级处删除scoped_user_gate_fallback,然后才重新构造 automation、interaction、scheduler 和 TurnEnvelope。这一顺序是关键:如果只修 root 字段,后续投影仍会从 fallback 再生成相反结论。test_unadmitted_selection_construction.py新增组合回归,同时检查 root、execution obligation、interaction contract、protocol summary、TurnEnvelope、host authority 与 rendered guidance;并覆盖 deferred/rejected 两类 owner-level 恢复及 scoped fallback 的正向对照。
对主干的风险
最强反例正是上一轮发现的缺陷:同一 packet 里既有 rejected selection,又因 scoped gate 暴露 safe-bypass。当前 head 已用生产构造路径把该反例变成回归测试,且没有扩展协议或默认行为面。
本轮重新验证:
23 passed in 37.83s:完整 unadmitted-selection construction、selection conflict,以及 unprojected Todo、首次拒绝无假 receipt、autonomous replan preemption、auxiliary monitor rejection、settled replay precedence 五条真实 CLI 路径;- 三个改动文件 Ruff 通过;
git diff --check origin/main...HEAD通过;- 基于当前
origin/main的 merge-tree 构造通过; - 上一 head 的 79 项聚焦验证只被当前 3 文件、+112 行增量失效,本轮已针对该增量及其跨 consumer 语义重新覆盖;
- 本轮没有读取、轮询或等待远端 CI。
剩余风险:未在当前 head 重跑全仓测试;不过旧 head 的广覆盖证据仍有效,新增 delta 已由 owner-level、consumer-level 与真实 CLI 回归共同覆盖,足以判断本次修复。
语义与 CI 对齐
实现沿用既有 typed qualification、EffectiveAction 与 safe-bypass 词汇,没有增加 substring/prose 分类规则,也没有把 machine-enforced obligation 描述成 guidance。默认行为只在 explicit selection 已被 deferred/rejected 的恢复路径上收紧;未发生拒绝时的 scoped fallback 正向对照继续通过。
我的整体评价
APPROVE。上一轮 P1 已在 owning boundary 被精确修复:拒绝态现在不能再被 scoped fallback 重新投影为可执行态,同时合法 fallback 保持不变。未来演进检查中,没有发现需要在本 PR 再引入共享抽象;继续复用单一 recovery owner 是更窄、更可逆的边界。
English verdict: APPROVE — Exact head 7bdac93450686494b673626a7762c94792a14e6f closes the scoped safe-bypass leak on rejected/deferred selection recovery, preserves the valid fallback positive control, and passes focused construction, conflict, real-CLI, Ruff, diff, and current-main merge-tree validation.
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
…fresh Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
huangruiteng
left a comment
There was a problem hiding this comment.
动机
本次复审绑定 exact head 2a645ef9479d549c6ea7b83f4d7298d08161fdc8。PR-08 要求 deferred/rejected 的显式 Todo selection 在所有公开投影中形成同一个 no-work/no-spend recovery。当前 main 的同一 scoped user-gate 合成 fixture 仍可复现反例:selection 已拒绝,但结果重新进入 successor_replan_required / scoped_user_gate_fallback,同时暴露 should_run=true、must_attempt=true、safe_bypass_allowed=true 和 spend_after_validation=true。这会允许 heartbeat host 在本应拒绝的 Turn 上再做一步并花费一次 quota。
新 head 把同一输入收敛为 quota_skip、should_run=false、safe bypass 关闭、no-spend 和空 write scope;不带拒绝 selection 的 scoped fallback 正向对照仍保持可执行。这个结果完成了该问题的完整可观察闭环,不是只改变错误文本。
改动思路
实现复用现有 action-selection owner,而不是增加第二套状态或在每个 consumer 里补丁式清理:
current_action_selection_admission统一读取当前 obligation 是否已经接纳 requested Todo;build_action_selection_recovery_fields直接构造 typed deferred/rejected recovery,包括关闭 delivery/repair/actionable/safe-bypass/spend authority;_apply_unadmitted_action_selection_precedence在 active packet 的 interaction、scheduler、protocol、TurnEnvelope 等共享投影完成前收口 action projections;- CLI 层只绑定 registry/runtime/scheduler 相关的精确重入命令,receipt-bound selection 与 settled replay 仍由原 owner 处理。
同步最新 main 时保留了主干已经落地的 direct settled-replay construction 和 _supporting_projections 抽取,没有把旧 cleanup owner 带回来。未来演进检查没有发现需要继续扩展抽象:selection recovery、interaction flags、CLI invocation effect 各有单一变化原因。
具体改动
关键代码讲解
current_action_selection_admission(action_selection_contract.py:162)覆盖普通 obligation、pending delivery、workspace repair 与 receipt recovery 的合法接纳分支,替代 CLI 中的重复判定。build_action_selection_recovery_fields(action_selection_contract.py:275)构造唯一的 closed root result;should_run、所有 delivery/repair flag、actionable_by_codex、safe bypass 与 spend 均在 owner 处关闭。_apply_unadmitted_action_selection_precedence(should_run_packet.py:374)只作用于 active deferred/rejected selection,并在后续 consumer 读取前移除 scoped fallback、selected Todo、replan、work-lane 与 workspace projection。unadmitted_action_selection(interaction_contract.py:1490)复用相同 admission facts,使 CLI channel、agent channel 与 packet precedence 不再各自猜测 refusal。
最终 base-to-head 净差异仍为 10 个文件、+784/-276:6 个生产模块、1 个 vocabulary producer 更新、3 个聚焦测试文件;没有新 schema、CLI option、持久化字段、能力开关或迁移。
对主干的风险
最强回归场景是 projection 顺序再次让 scoped fallback 在 refusal 之后重建 execution authority。为此我用同一公开合成 fixture 经真实 build_quota_should_run 入口做 base/head 对照:
- base
16463b3b:successor_replan_required、scoped fallback、must-attempt、safe bypass 和 spend 均开启,独立 oracle 失败; - head
2a645ef94:quota_skip、rejected、no-bypass、no-attempt、no-spend、empty write scope,独立 oracle 通过。
exact-head 验证结果:
- 39 个 selection/conflict/settled/supporting projection 与 4 条改动过的真实 quota CLI settlement 路径通过;
- 同一净差异在最终无交集主干同步前做过更广的 100-case 运行,
100 passed; - Ruff、
git diff --check、Python compile 与 semantic vocabulary drift smoke 通过;vocabulary smoke 首次因 worktree 未安装声明的 TypeScript parser 依赖失败,执行npm ci --ignore-scripts后重跑通过; loopx canary premerge --from-git-diff --goal-id loopx-meta通过 18/18 风险匹配检查,0 failure、0 warning、0 manual hold;- change-quality receipt
cqr_6f1794db6319f2e1553f与 exact diff 匹配并验证为 valid; - DCO 与公开/私有边界扫描通过;没有读取、轮询或等待远端 CI(goal 配置
wait_for_ci=false)。
语义与 CI 对齐
本 PR 复用既有 action_selection_qualification_v0、EffectiveAction.QUOTA_SKIP、execution obligation、interaction contract 与 TurnEnvelope vocabulary,只更新 producer owner;没有 substring/prose 分类规则,也没有把 machine-enforced obligation 称作 guidance。行为变化明确限制在未被接纳的 deferred/rejected selection;合法 selection、receipt-bound replay、settled replay 和无 refusal 的 scoped fallback 均有正向覆盖。
剩余风险是 exact head 未重跑全仓 pytest。最强缺失验证仍是全套测试;但同 fixture base/head 反例、exact-head 39-case、真实 CLI 路径、semantic registry、有效质量凭证与 18 项风险 canary 已覆盖本次 authority boundary,足以支持当前结论。
我的整体评价
APPROVE。没有发现 blocking finding。新 head 在现有 owner 中直接构造 refusal recovery,保留主干新架构和合法正向路径,并用真实公开入口证明旧反例失败、新行为通过。改动范围与一次可能产生错误执行和 quota spend 的 authority bug 相称。
English verdict: APPROVE — Exact head 2a645ef9479d549c6ea7b83f4d7298d08161fdc8 closes the executable scoped-fallback leak for rejected/deferred selections, preserves valid fallback and replay paths, and passes exact-head focused CLI tests, semantic validation, change-quality qualification, and 18/18 risk-based premerge canaries without consulting remote CI.
A deferred or rejected explicit Todo selection previously built settlement/replan/primary-action projections and then deleted or rewrote them in CLI recovery. PR-08 from discussion #4738 requires one no-work/no-spend recovery result to drive every public projection.
This branch now:
quota_skipexecution obligation and heartbeat recommendation;Current exact head:
75ac19d294b399334eae058f431c76b04c3b4af1onmain@09f10c4e3.Real rejected and autonomous-replan-preempted CLI outputs now agree across all reviewed surfaces:
interaction_contract.mode=skip, no must-attempt/delivery/spend,protocol_action_packethasagent_action_required=false, automation remains active withoutexecute_bounded_work, scheduler uses quiet backoff, and TurnEnvelope exposes the exact recovery command with empty write scope.Validation:
git diff --check: passed;node-minimum-compatibilitywas canceled at the fixed 10-minute timeout without a failed assertion, andmerge-gatefailed only because that required job was not successful. The exact Node 22.18 selection is covered locally by the first 1050 passing tests plus a complete 189/189 run of the remaining NoKV JSON-lines file.No new acceptance domain, capability, persisted schema or frontend setting is introduced. Runtime/control-plane change; maintainer review and merge are required.