Skip to content

fix(quota): include hard-lease execution preparation in settlement recipes - #7793

Merged
loopx-agent merged 1 commit into
mainfrom
codex/trajectory-claim-guidance-20261101
Nov 1, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/trajectory-claim-guidance-20261101

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Following a generated settlement recipe for a hard_lease Todo could attempt completion without an execution reference, then require a failed completion, claim and retry. The shared quota/TurnEnvelope plan now supplies the ordinary claim command before task execution and carries its original reference into completion and terminal-closeout templates. Supplied explicit proof is preserved.

The policy comes from the same canonical Todo snapshot, including reads that omit lease records, and travels through goal_boundary.handoff_mode. The existing TypeScript settlement owner selects the guidance; Python renders and transports the existing CLI routes. Soft-claim and policy-unknown recipes retain their previous behavior. Canonical ownership, expiry, generation, validation and settlement checks still decide effects.

Validation:

  • Eight real CLI journeys cover File/SQLite, Codex App/generic CLI and soft/hard modes. All reach accepted Todo completion and idempotent replay. Each hard-mode journey needs three commands including its guard, versus four with the previous recipe and recovery; each soft-mode journey remains at two. This deterministic consumer replay does not measure model behavior or long-horizon benefit.
  • Focused Python runs: 133 passed for guidance/settlement/claim conformance; 119 passed for declaration, completion, writeback and accounting journeys; the final guidance/settlement run passed 89 checks, including supplied-proof preservation. These runs overlap.
  • TypeScript: 154 focused checks passed; canonical snapshot regression checks retain policy when leases are omitted. Type checking and Ruff passed.
  • An isolated real PostgreSQL server passed all 382 authority-store integration checks, with no skips. The final policy-metadata regression was also exercised on PostgreSQL.
  • Standard premerge passed its direct checks and 19 selected checks. The existing unrelated maintainability failure remains an inherited advisory. The first interface-budget run exposed a consumed top-level-key margin; moving the policy into the existing Goal boundary restored the gate without changing ceilings. The unchanged fixture measures 20,021/20,500 quota characters, 565/575 nested keys and 54/55 top-level keys.

This delivers the execution-preparation recipe and its real caller checks. Runtime adoption, model tokens/fees and task-score improvements remain unmeasured. No merge or installation is included.

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 | model=gpt-6.1-sol | provider=OpenAI | runtime_reported | effort=max

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

受影响的是从 quota 或 TurnEnvelope 返回的计划执行任务的 Agent,尤其是采用独占执行租约的任务。旧计划直接提供完成命令,却没有告诉执行者先取得并保留执行引用;按计划操作会先失败,再进入认领和重试。新计划在执行前提供普通认领命令,并把返回的原引用带入完成及终态模板。同一合成任务经过真实 File、SQLite 与两种 Host 入口后,新计划可直接完成并读回 done;重复完成不再写入,伪造引用仍被拒绝。本 PR 不更改任务所有权策略、不自动认领或续租、不放宽验收和结算,也不交付 App 手工代完成、安装升级或模型净收益。

改动思路 / Approach

策略仍由 canonical snapshot 提供,选择逻辑集中在既有 TypeScript 结算 owner,Python 仅传递事实和拼接 CLI;因此没有第二套租约决策或新增持久化证明。本次边界是让既有 hard_lease 任务的返回指引可执行,并保留原执行、验收、回执和结算边界;不改 Host 监督或策略默认值。 原先“已经分配给某 Agent”与“该调用持有当前执行证明”之间存在缺口;这次把普通认领放在工作前,并保留它返回的引用。调用方已有显式 Host proof 或原 claim 引用时,模板继续携带该证明,不叠加另一份引用。

真实调用路径 实际基线 当前精确头
File/SQLite × Codex App/generic,hard_lease 4 条返回的完成命令均先拒绝,handoff_mode_requires_lease 4 条按返回计划认领后均完成;伪造引用拒绝、任务仍 open;正确引用读回 done,重放 changed=false
同样四条 soft_claim 路径 完成、重放成功 归一化后的整份计划与基线逐字相同;完成、重放成功

具体改动 / Changes

审查目标为 #7793ba487a6,实际 merge base 为 6820800。已读取全部 14 个文件的补丁及相关调用者,GitHub patch 与本地内容一致;差异比对只忽略 blob 缩写长度和可选 hunk 标题。合计 +153/-6,其中生产代码 +50/-6、测试 +87、文档 +16,没有生成文件或持久化格式迁移。

关键代码讲解

  1. readCanonicalSnapshotFromStore 在同一 provider head 中保留策略,即使 include_leases=false 也返回该 metadata;它仍然只读,分页继续绑定同一 revision。
  2. active_state_todo_fields 将 canonical policy 经 quota item 传到 goal_boundary.handoff_mode,不从展示 Markdown 推断。我在真实 CLI 中把展示改为相反策略并清空 Todo 展示,两个 provider 仍选择正确任务和指引。
  3. turnScopedCliSettlementPlan 仅对 hard Todo 加认领前置提示;缺少证明时给完成、终态模板追加原引用占位符。soft、legacy、缺失/null 策略保留原计划,不自动升级策略。
  4. build_turn_scoped_cli_settlement_plan 负责原路由、actor、Turn 和 shell 参数,使用 shlex 识别已传 proof 的真实 option token;不是通过任务文字判断权限。
  5. _todo_settlement_plan 将已接受的 claim_operation_id 保留到后续结算命令,避免完成后又丢掉原证明。

独立规范是变更前的 docs/reference/handoff-mode.md,完整固定版本 6820800(原文)。以下 HL 标签仅用于映射原文未编号条款:HL-1 普通自认领准备执行且 soft 不创建 lease;HL-2 原引用/显式证明不混用、过期及换代证明不能借用;HL-3 guard 不认领或续租;HL-4 保留原 Turn、验收和结算;HL-5 canonical provider 优先于过期展示。五项在此头均为 implemented,由上述真实 CLI、退役引用、终态结算和 snapshot 套件覆盖;没有把这次修改后的说明当作独立规范。

对主干的风险 / Risks

主要风险是把分配状态或旧引用误当成有效执行,以及共享 metadata 传递丢失。独立复演先确认每次 guard 前后的 canonical revision、完整 Todo 和 lease 集合相同,再执行返回命令、单独读回状态。另将实际 CLI 生成阶段的 canonical mode 移除,独立 oracle 如预期以 exit 1 报“缺少执行前准备”;恢复本头后通过。因此证据覆盖真实入口,而不只是 plan helper 或多个 provider 共享同一新规则。

本次独立验证:PASS:178 Python tests、244 TypeScript tests、隔离真实 PostgreSQL 16.15 authority-store 382 tests(0 skips)、TS typecheck、配置内 17 文件 mypy、九个改动 Python/测试路径 Ruff、公共边界扫描、diff hygiene。standard premerge:6 direct + 19 selected,blocking failures、warnings、manual holds 均为 0;exact-scope change-quality receipt valid。另有 1 项已独立对照的既有 maintainability advisory,见下文。。其中终态测试覆盖完成→写回→单次扣账→终态及重试;过期/转移引用、失败验收、分页中途并发仍由原 owner 拒绝。PostgreSQL 使用一次性合成实例,未测试或修改活动 Goal。

本地仍保留一项 FAIL / optional advisory:run_host_process 的既有函数体量债务。对实际 base 和本头分别执行相同 control-plane-maintainability-ratchet-smoke.py,两次均 exit 1,完整输出相同(同一 oversized_decision_function,无 magnitude regression);对应 owner 文件的 Git blob 也相同。此头的同 diff 模块上限检查及上述改动路径验证通过,因此归因为 pre_existing_unrelated,保留诊断,不要求本 PR 修复另一 owner,也没有把失败改称通过。

语义与 CI 对齐

复用现有 HANDOFF_MODES,没有新共享枚举;proof option 集合仅是本地 CLI 语法识别。先执行 diff semantic advisory,再执行完整 semantic smoke,均通过,但不据此宣称覆盖所有动态语义。与基线同负载预算对照:quota 19991→20021 字符、nested keys 564→565、top-level 54→54;dashboard 增加 30 字符/1 key。上限未变,新增字段在共享 soft 路径也有披露;不声称整份 payload 字节不变。保留所有原验收、继续执行、停止和结算条款。

按当前 wait_for_ci=false 策略,没有查询、轮询或等待 CI,也没有把未知 CI 当成本地证据缺口。必要的本地失败仍会阻止批准,不能靠这项策略豁免。此审查不授予合并、dismiss、安装或实验执行权限。

我的整体评价 / Verdict

这项改动已关闭本次“返回的 hard 任务计划缺少执行准备与原引用”的具体缺口;机制和成本与问题相称。长程可靠性判断为 preserved:原身份、回执、接管与扣账边界有真实重试证据;使用体验为 improved:执行者在原计划中直接得到可用准备,不增加用户表单、确认或手工 lease 检查。累计模型效果、费用和人工注意力收益仍未验证,不能从命令成功或测试数量推出。

检查 quota/TurnEnvelope、普通 Todo CLI 与既有 App 完成边界后,确认此头没有修改渲染页面,视觉检查不适用。未验证安装后的界面或真实模型对新增指引的理解;本次证据是源码 checkout 与合成任务的真实 CLI。 更广泛的 Host 监督、App 手工完成和策略默认迁移保持各自验收边界。完整精确头没有发现需作者修复的阻塞问题;后续集成须保持 canonical policy 与 claim/settlement owner 一起进入同一代码路径,不能只摘取说明文字。

English verdict: APPROVE for #7793ba487a6. Local invariants are verified; remote CI was not consulted. This review grants no merge authority.

@loopx-agent
loopx-agent merged commit 02ee861 into main Nov 1, 2026
34 of 40 checks passed
@loopx-agent
loopx-agent deleted the codex/trajectory-claim-guidance-20261101 branch November 1, 2026 11:19
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.

1 participant