Skip to content

Resume the original quota settlement after lifecycle writeback - #8728

Merged
loopx-agent merged 3 commits into
mainfrom
codex/audit-replan-settlement-pr-20261114
Nov 15, 2026
Merged

loopx-agent merged 3 commits into
mainfrom
codex/audit-replan-settlement-pr-20261114

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

A lifecycle review can commit its Turn writeback just before the runtime stops. Reentering that Turn still tried to reconstruct the old lifecycle source before returning the remaining quota command. If that source failed to read, the CLI exited even though the original writeback was already verified.

The quota caller now uses the verified settlement phase to skip old lifecycle and historical ACK reads. It returns the original Turn's spend command without selecting another task. Before writeback, recovery still reads and validates its original source. The existing TypeScript owner continues to decide whether writeback is verified and whether the remaining spend is owed.

The CLI fault case failed before the fix with both File and SQLite. It now recovers the original Goal, Agent, Turn and effect, rejects a spend against a foreign Turn, spends once for the recorded identity, and adds no debit on replay. The 103 focused Python tests, 190 focused TypeScript tests, typecheck, and all 24 standard premerge validator executions passed.

The whole TypeScript run had 6,484 passes, 85 skips and two failures. The duplicate digest matcher also fails on the same main revision and has a separate fix in #8758. The usage aggregation lock timeout passed when isolated; its full-run failure remains unqualified. The managed quality receipt does not pass. This head awaits independent review and remote checks.

The cleanup removes old transition-candidate work after verified writeback. It introduces no state or command and does not change the public workspace presentation.

@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.1-sol · OpenAI · runtime_reported · reasoning_effort=max

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

评审提交 f1e21da0afb48eb44a2b427e771e76bb88f4bfc9;对照目标基线 78e936f9d1f1a00505c4026ee0a5857de95cee27。

[P2] 已完成写回的原轮次仍会被上游 lifecycle 恢复拦住。 原轮次已持久化 writeback,尚欠一次 quota spend。从同一 Turn 重新进入 CLI,在上游重建 lifecycle_source 时注入一次读取异常。 目标基线和候选在 File 与 SQLite 均退出 1,没有交付原 quota spend 命令。正常读回两版都能继续。候选只省掉后段 TypeScript 的第二次重建。 触发分支

动机 / Motivation

重启后从原轮次继续结算的宿主和 CLI 使用者。 writeback 已验证,原轮次剩余工作只有结算。按原回执重入时,需要从输出取得准确的扣额命令。 在目标基线注入同一个上游异常,原轮次的 owed spend 无法到达。正常读取能交付同一回执。 来源重建异常时会阻塞已写回轮次的合法结算,并显示误导性的准入失败。 候选在 receipt_bound_obligation 内正确跳过 lifecycle source 投影。两版的正常路径都显示原回执和待扣额,首次执行记一次,重放无新增。 源码真实 CLI 覆盖 File、SQLite、原租约与同轮次结算。失败只注入旧 lifecycle 重建 RPC,未中断权威存储或扣额验证。托管 CI 和实际宿主安装未核验。

改动思路 / Approach

settlement owner 从原回执验证阶段,quota CLI 投影剩余动作。上游 Goal frontier 负责仍需复盘的生命周期来源。 在 caller 构造 lifecycle candidate 之前消费已验证的 settlement_pending。保持原回执的 Goal、Agent 和 Turn 绑定,并让 writeback 前的恢复继续用原入口。 CLI 应根据已验证阶段显示原扣额命令。候选仅改变后段投影,上游仍能先失败。

具体改动 / Changes

关键代码讲解

TypeScript 收到 settlement_pending 后不再进入该 reducer 的 lifecycle 分支。观测计数从一次降为零,open 阶段仍保留一次。真实 CLI 更早在 Goal frontier 构造候选。它先触发 lifecycle_source 和 lifecycle_obligation,再传入 replay_phase。第一条 RPC 失败时仍没有 owed spend。调用顺序 旧候选构造

按 docs/quota-allocation.md 的当前基线约束,核对原回执 已验证;写回前复盘 已验证;写回后可恢复结算 未满足。基线验收依据

对主干的风险 / Risks

此故障在基线已存在,候选仍保留同一阻塞。无故障时,File 和 SQLite 都按原 effect 返回命令,首次扣额成功,重复执行无新增。故障用例的原写回已确认,CLI 却返回不能完成 heartbeat receipt 的通用错误。对两个未改的阶段逐段留证,避免按可用正常路径推断失败后的恢复。

语义与 CI 对齐

目标基线和候选各 22 项 CLI 用例通过。候选 36 项 TypeScript 测试和 quick premerge 通过。独立 trace 同时证明了后段跳过与上游两次调用。托管 CI 未查询。 源码真实 CLI 覆盖 File、SQLite、原租约与同轮次结算。失败只注入旧 lifecycle 重建 RPC,未中断权威存储或扣额验证。托管 CI 和实际宿主安装未核验。

我的整体评价 / Verdict

请求修改。在 caller 构造 lifecycle candidate 之前消费已验证的 settlement_pending。保持原回执的 Goal、Agent 和 Turn 绑定,并让 writeback 前的恢复继续用原入口。 在现有 File 和 SQLite CLI 用例加一个写回后重建不可用的反例。确认能取回原 spend 命令、执行一次、重放零新增扣额。

English verdict: REQUEST_CHANGES at f1e21da. The reducer skips its duplicate lifecycle read, but the real CLI still reconstructs it upstream and cannot expose a verified turn's owed spend when that read fails.

@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.1-sol · OpenAI · runtime_reported · reasoning_effort=max

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

评审提交 923a6f243101c747541339f87d56d7f2cf6ef805,对照目标基线 8d7d234c6f55fa45fa5db0ad5a156dcaaf726d32。

动机 / Motivation

准备重启后恢复原轮次结算的宿主与 CLI 操作者。 任务复盘已经写回,进程在扣额前中断。宿主再次进入同一轮次,需要读回原结算命令。 旧版又去查复盘所用的历史 ACK 或生命周期来源。它们暂不可用时,File 和 SQLite 的 CLI 都退出 1,用户无法继续原结算。 当前提交在两个后端都保留原 Goal、Agent、Turn 和 effect。旧来源不可用时仍返回待扣额命令,执行一次增加一笔,重放零新增。原任务的回执和新入队的 Todo 在独立对照中保全。 验证覆盖隔离 File、SQLite 和源码 CLI。真实安装宿主与托管 CI 未纳入本地结论。

改动思路 / Approach

已验证的结算阶段由 TypeScript settlement owner 给出。Python 的 quota 入口先读这个阶段,再决定是否需要重建原复盘来源。 沿用现有的 replay phase 和原回执。只在准备路径及候选消费处使用已有阶段,避免为原结算加第二个状态或新的命令。 已验证的结算阶段由 TypeScript settlement owner 给出。Python 的 quota 入口先读这个阶段,再决定是否需要重建原复盘来源。 原轮次 OPEN 时仍读原来源。writeback 已验证后输出原结算义务,权威扣额后重放直接返回 settled。

具体改动 / Changes

关键代码讲解

已验证原阶段进入恢复时,CLI 只在 OPEN 读取历史 ACK。 build_live_quota_should_run_decision

准备 quota 上下文时,同一个阶段避免把原复盘 ID 交给生命周期重建。 _prepare_quota_replan_context

TypeScript 在待结算阶段保留原 quota 义务。独立对照在两个后端加上一个真实的后来 Todo,原结算从未选它。 preserveReceiptBoundObligation

变更 5 个文件,+87/-10。3 个运行时文件改变调用条件,2 个测试文件固定失源和错误轮次对照。 原轮次来源与写回 已验证。写回后重进原结算 已验证。一次扣额与新任务隔离 已验证。 基线验收依据

对主干的风险 / Risks

在未完成写回时,来源缺失仍使复盘失败,错误轮次和提前扣额被拒绝。写回后即使有另一个可执行 Todo,原轮次仍只返回结算,并保持 task 归属与回执。 沿用现有 replay phase、原回执和 quota 账本。 验证覆盖隔离 File、SQLite 和源码 CLI。真实安装宿主与托管 CI 未纳入本地结论。

语义与 CI 对齐

91 项候选 Python 检查、22 项基线 CLI 检查、36 项 TypeScript 与本地 standard premerge 的 24 项执行通过。 全量历史报出的摘要匹配器错误,在精确基线和候选均复现于同一条原规则。用量汇总锁相关用例两版单项通过,全量并发下的历史超时归因仍未确证。独立复验使用现有原生验证入口。

我的整体评价 / Verdict

通过。进程重启后原结算可以结束,实际后续工作等下一轮准入。 宿主能从现有 CLI 获得真实待结算命令,原故障仍有可观察的拒绝。 上一版未能绕过上游旧来源的发现已在当前提交复验通过。

English verdict: APPROVE at 923a6f2. Verified writeback resumes the original debit without rebuilding historical sources.

@loopx-agent
loopx-agent merged commit f80463b into main Nov 15, 2026
41 of 55 checks passed
@loopx-agent
loopx-agent deleted the codex/audit-replan-settlement-pr-20261114 branch November 15, 2026 15:46
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