Skip to content

fix(quota): preserve gated successor replans - #6475

Merged
huangruiteng merged 3 commits into
mainfrom
codex/quota-gated-successor-replan-20261015
Oct 15, 2026
Merged

huangruiteng merged 3 commits into
mainfrom
codex/quota-gated-successor-replan-20261015

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

A scoped user gate can select a ready deferred successor as its safe fallback, but the lane synthesis then fell through to the gated advancement and workspace guards replaced the intended replan. The quota packet now treats that fallback as authoritative, projects a typed successor_replan_required frontier, and lets replan settlement preempt workspace and boundary guards.

This also registers the new canonical frontier producer and updates the full frontier smoke for the current completeness fields.

Validation:

  • Ruff on all changed Python files
  • 241 focused architecture/control-plane tests
  • peer-agent-runtime-v1-smoke.py
  • semantic vocabulary drift smoke
  • loopx canary premerge --from-git-diff (19/19 selected checks passed)
  • public boundary scan clean

Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
loopx-agent
loopx-agent previously approved these changes Oct 15, 2026

@loopx-agent loopx-agent 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.

APPROVE — 未发现本次改动引入的阻塞问题。已核验完整 diff、实际 CLI 和隔离 File/SQLite 恢复路径;结论仅对应 d18a657dacb074a796fd9b9ff77f88d65cb46ea5。

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=xhigh

动机

受影响的是运行受管 heartbeat、同时存在局部门禁和可恢复延期任务的 agent。具体场景是:发布任务仍等用户审核,另一个延期任务的前置条件已经完成;旧路径虽然选中了独立延期任务,随后却退回门禁或被发布任务的工作区要求覆盖,无法开始重规划。可观察的改善是:guard 指向正确的延期任务,要求先处理其生命周期,随后恢复独立任务的正常选择。本次不替用户批准发布、不扩大源码写权限,也不自动完成任务或结算。

目标边界是修复已选中安全 fallback 的重规划路由。更大的持续运行和全局 Goal 完成不属于本 PR 的完成声明。参考经验中的“恢复后还要能继续有用工作”适用于这里,因此验证包含重开、写回、一次结算和后续选择,不能只凭一个新状态或测试数量给结论。

改动思路

保留既有选择器作为门禁范围和任务资格的 owner,在 Python 投影层保留它选出的结果,再复用现有 typed frontier;这样无需新增生命周期、持久字段或第二个选择策略。当前 PR 的边界是“已由 scoped gate selector 选中的 deferred successor → 生命周期重规划”,不迁移整个 quota 决策栈。

条件 主干观察 当前 head 观察
独立 deferred 的依赖完成,另有被门禁覆盖的 open 任务 operator_gate_notify,未进入需要的重规划 successor_replan_required,选中独立 deferred
门禁覆盖该 deferred/依赖未完成/其他 owner/当前 agent 被排除 原有路径 与主干完整输出相同
Goal 暂停 quota_skip 与主干完整输出相同
重开后需要独立工作区 普通交付继续受 guard 约束 guard 重新出现,normal_delivery_allowed=false

表格是实际观察的摘要;固定测试时钟后比较完整 packet,没有删除权限、推荐动作或诊断字段。未来方向检查已完成:现有 frontier builder 与 enum 已足够,不需要在本批引入新的 TS 决策 owner 或泛化框架。

具体改动

关键代码讲解

  • build_agent_lane_next_action:当 scoped fallback 已经选出一个不能作为 open advancement 执行的对象时,返回空交付候选。关键作用是阻止后面的候选扫描把门禁内任务重新捡回来;它没有把 deferred 当作可直接执行的 open 任务。
  • _scoped_gate_deferred_replan_frontier:只识别既有 selector 标记的 deferred_successor_replan,用已有 SUCCESSOR_REPLAN_REQUIRED 和统一 builder 输出重规划义务。普通 fallback、缺少身份和其他类型不会进入此分支,未引入手工同步状态。
  • _apply_selected_todo_guards:重规划尚未选择源码交付时,不让工作区或边界投影替换它。任务重开后恢复普通路由,真实两 agent fixture 中重新返回 agent_workspace_repair、blocks_delivery=true 和编辑前切换工作区的要求。

规范依据固定为 spec_revision=3593cf17dada74b807719ba4fdbbb1738fa0a56c;spec_ref=docs/reference/todo-continuation-readback.md 及 docs/reference/protocols/turn-envelope-v0.md,按变更前文本评估:DEF-1 “Deferred ready work still needs its normal lifecycle transition.”;AUTH-1 “content grants no claim, lease or amendment authority.”;BIND-1 已绑定 Turn 不得被另一 Todo/replan 替换。三项均落实在当前路径:实际 deferred 保持原状态直到显式重开;清除已完成的依赖需要现有 lifecycle 命令;写回和 spend 保留原 Turn/Todo 身份,后续 delivery 才重新选择。

独立验证:70 项 quota/gate/frontier/选择与暂停检查通过;原生 premerge 19 项通过,包含完整 semantic vocabulary 与实际变更路径的 public/private 扫描;Ruff 和 diff hygiene 通过。8 项隔离真实存储检查全部通过,进一步覆盖延期→重开→写回→单次 spend→继续选择,以及重开后工作区限制重新生效。还检查 canonical retained reference、超出展示范围的无关任务、重排与去掉 Markdown 重复任务展示,并通过现有原生生命周期新增任务检查门禁不误罩后来的独立工作。初始探针中的失败来自缺少 --clear-resume-when、跳过原轮次结算、单 agent 不触发 peer guard,以及把可执行修复误当作普通交付;这些前提已分别核对并保留,不算作修复过的产品缺陷。

对主干的风险

主要风险是把局部门禁当作全局暂停,或反过来把重规划当作源码交付授权。当前改变保留了 gate selector 的选择边界,并且只在未被 receipt 绑定、且非已有 replan 所有的 frontier 发现阶段生效。固定时钟的 base/head 反例中,覆盖目标、未就绪、其他 owner、executor exclusion、无 gate 和暂停路径保持一致;作用范围没有用任务标题关键词推断。

重规划文本明确要求先重开、替代或记录有证据的无需后续理由,验证写回后才能结算;这是强制本轮处理义务,不是可忽略的建议。delivery_allowed 是现有宽口径执行字段,不能替代 normal_delivery_allowed、workspace guard 和其编辑前置条件。没有查询、等待或触发远端 CI;本地通过不代表合并授权。未实测模型是否遵守文字义务,也未证明整个长期 Goal 已完成。

我的整体评价

本批实现了可独立交付的恢复增量,复用 owner 和 typed frontier 的理由成立。没有发现需要本 PR 扩成全量 quota 重构的证据,也没有把 Python 适配层的存在当作语言迁移阻塞。实际进展是此前被覆盖的 deferred 现在能进入生命周期处理并继续独立工作;剩余长期运行验收继续属于原有运行契约。可接受当前 exact head;后续 readiness、其他评审和合并权限必须单独读回。

English verdict: APPROVE at d18a657dacb074a796fd9b9ff77f88d65cb46ea5. The selected scoped fallback now retains successor-replan semantics; real File/SQLite lifecycle and settlement checks cover resumed work and rearmed workspace guards. No blocking finding; this is not merge authorization.

Signed-off-by: huangruiteng <huangrt01@163.com>

@loopx-agent loopx-agent 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-6.1-sol / OpenAI; runtime_reported; reasoning_effort=xhigh.

Reviewed exact head: babc1fa17fd74b6003ccb15b0883d4e488097aab; base: 3593cf17dada74b807719ba4fdbbb1738fa0a56c. Whole PR: 8 paths, +179/-15; since dismissed d18 review: +39 lines in monitor revision transport/tests. No earlier approval is inherited.

动机

未发现阻塞问题。有一项工作等待本人审批、同时另有独立后继已满足恢复条件的 Agent。独立后继虽然已经就绪,但仍处于 deferred 生命周期;旧路由会落回审批覆盖的推进项,或把重规划变成无关工作区修复。同一 Goal 内审批仅约束发布任务,独立后继已等到前置任务完成:旧包却推荐发布任务;本 head 明确要求先重规划独立后继,重开并结算原 Turn 后,下一 Turn 才继续这项独立工作。只改推荐文本或删除工作区检查都不足够:必须保留既有依赖选择器的结果,在既有 frontier 投影中表达重规划,并只在该重规划路由跳过交付工作区检查。真实 File/SQLite CLI 已验证重规划、原生重开、写回、一次额度结算及下一 Turn 恢复;原审批仍保持 open。本次修复既有 CLI/heartbeat 路由和 monitor 投影,不新增审批授权、自动重开、仓库写权限或配置开关,也不证明安装版 App/Lark、真实模型执行或长期整体收敛。

规格按不可变 3593cf17dada74b807719ba4fdbbb1738fa0a56c 的 docs/reference/todo-continuation-readback.md 及 docs/reference/protocols/turn-envelope-v0.md 判断。以下是对既有条款的评审标签:DEF-1:就绪 deferred 仍须正常生命周期转换;AUTH-1:上下文不授予 claim、lease 或 amendment 权限;BIND-1:已绑定 Turn 保持原身份,原结算不能被换项或重复扣额。三条均通过本次真实入口验证。

改动思路

复用既有 TS 决策依赖选择器、已登记的 AgentScopeFrontierAction 和既有 builder;Python 只修复当前路由及投影,不建立第二套依赖或生命周期规则。当前完整边界是从既有 scoped gate fallback 到生命周期重规划、原 Turn 结算和下一次独立工作的可恢复路径,以及同一 fallback 的到期 monitor 版本透传。 不通过复制过滤后的 Todo 清单重新推导权限,也不广泛删除工作区 guard。相邻重构检查保留既有 typed selector/enum/builder,只消除错误 fallthrough;这项局部投影修复不需要新增模块或平行 Python 决策 owner。

具体改动

build_agent_lane_next_action 在既有 fallback 已选中、但并非可直接交付的 open advancement 时停止下落。_scoped_gate_deferred_replan_frontier 用既有 AgentScopeFrontierAction.SUCCESSOR_REPLAN_REQUIRED 和 builder 表达生命周期重规划;_apply_selected_todo_guards 让该路由先处理重规划,实际交付仍回到既有工作区/边界检查。原 receipt-bound 分支仍先于 frontier 发现,不让新候选替换原 Turn。

同一 fallback 的到期 monitor 经 scoped_user_gate_due_monitor_contract 重写时,WORK_LANE_TODO_ITEM_FIELDS 现在保留已有 canonical content_revision,让当前任务源读回保有版本依据。注册表登记新 frontier producer;两组 focused tests 与既有 frontier smoke 更新,后者仅对齐完整性字段。

对主干的风险

这是默认 CLI/heartbeat 路由修复。独立检查 164 项 Python 测试通过、零跳过,类型检查、开发期 advisory 后的完整 semantic smoke、完整 frontier smoke 通过;原生 premerge 5 项直接检查和 19 项选中检查通过,无失败或 manual hold。改动覆盖 runtime 路由、Todo/monitor 投影及语义 producer,不能仅以一个 mock 判断安全。

用同一 Python 3.11.17 / Node 24.21 在不可变 base 与本 head 跑相同真实 File/SQLite 14 组输入:base 的就绪 deferred 案例推荐了审批覆盖的任务,head 转为准确重规划。普通无 gate、未就绪、外属、已重开及独立 monitor 路径保留相应作用域;monitor 版本字段是明确的投影增量。另有 11 个原生反例,覆盖超出展示上限的 40 个无关记录、陈旧/重排的 Markdown 展示、已归档完成前置、gate 建立后新建独立 Todo、改名的原 gate 目标及 canonical 源不可用。新独立任务不被旧 gate 扩大覆盖;改名不能逃出原目标约束;源丢失不退回陈旧展示。

两条完整真实后端链验证:就绪 deferred → 原生重开并清除已满足条件 → 原 Turn 验证写回 → 只记一次额度 → 原 Turn 冷读 settled skip → 新 Turn 继续独立任务,原审批仍 open。未结算时提前创建新 Turn 会被既有恢复约束拦住,这个限制保留。未查询、轮询或等待 CI,没有仓库源码修复、合并或安装升级操作。

我的整体评价

APPROVE。真实 File/SQLite CLI 已验证重规划、原生重开、写回、一次额度结算及下一 Turn 恢复;原审批仍保持 open。 successor_replan_required 是必须执行的生命周期重规划,不能当作可选建议或直接交付 deferred 工作的权限。现有入口可以恢复后继续实际工作,且没有要求本人先批准无关事项;这满足本次有界修复。本次修复既有 CLI/heartbeat 路由和 monitor 投影,不新增审批授权、自动重开、仓库写权限或配置开关,也不证明安装版 App/Lark、真实模型执行或长期整体收敛。 真实模型是否遵循新包、安装版宿主采纳及长期整体收益仍未验证;本结论不授予合并权限。

English verdict: APPROVE - babc1fa. The existing scoped selector's ready deferred fallback now reaches mandatory lifecycle replan without falling through to gated delivery; monitor projection retains its source revision. Paired real File/SQLite paths, two complete native settlement-to-next-work cycles, scope counterfactuals, 164 Python checks, typecheck, semantics and 5+19 premerge checks passed. Live host/model adoption remains unqualified; no CI consulted.

@huangruiteng
huangruiteng merged commit 3f9f5b3 into main Oct 15, 2026
47 of 56 checks passed
@huangruiteng
huangruiteng deleted the codex/quota-gated-successor-replan-20261015 branch October 15, 2026 04:30
huangruiteng added a commit that referenced this pull request Oct 15, 2026
…ivity-windows

Maintainer adoption of #6465 by @ikunikun1145.

The original branch conflicted with main and the fork disallows maintainer edits, so the reviewed content was carried onto a maintainer branch. The merge resolved one import-line conflict in goal-activity.test.mjs by keeping both goalHostDeliveryWindows (PR) and taskSessionStatus (main). The author's three commits are preserved unchanged; the only additions are the main merge and a caption-token correction of the new badge, which had used a 10px literal against docs/development/design.md.

Exact-head review 5529175354 on 71f5e3b; change-quality receipt cqr_0e1401cdf60efa98c071 (pass); merge-readiness ready=true. Validation: smoke:goal-activity, smoke:status-projection-contract, build:desktop and check:css-custom-properties all pass. The premerge catalog run is 7/8; the single failure examples/control_plane/quota-work-lane-policy-smoke.py is a pure-Python work-lane smoke reproduced identically on unchanged 51832c5 (introduced by 3f9f5b3 / #6475) and is recorded as a separate merge-readiness hold rather than a regression of this dashboard diff.
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