Skip to content

Return recoverable receipts for settled refreshes - #8090

Merged
huangruiteng merged 2 commits into
mainfrom
codex/settled-refresh-receipt-1105
Nov 5, 2026
Merged

huangruiteng merged 2 commits into
mainfrom
codex/settled-refresh-receipt-1105

Conversation

@loopx-agent

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

Copy link
Copy Markdown
Collaborator

Extracts the settled refresh and receipt readback from #7430 for review directly against main. It can ship with the existing quota packet, host and Turn journal.

An explicit refresh-state --settle-turn --settlement-receipt returns the Turn identity, progress, receipts and outstanding controls. A bounded reader retrieves deferred details from the immutable full result. The shared readback owner can omit duplicate committed record bodies after verifying settlement. Pending work still carries recovery material. Replaying the original refresh verifies the receipts without issuing another debit.

The regression exercises the installed CLI entry against isolated File and SQLite state, including a committed spend followed by failed capture and a successful exact retry. Large unknown controls are read to EOF. TypeScript tests cover the existing readback owner with complete and receipt-only results.

Local validation: 19 Python tests and 137 TypeScript tests passed. The matched model-task experiment is tracked separately. This extraction does not depend on its score.

The previous validation against 03d6ab2864 stopped on the baseline's quota navigation before candidate measurement. This head incorporates main’s pinned-reader fix (#8077). Standard premerge on 2ea918775f against be17d4ff30 passed, including the base/head CLI output-budget differential and public-boundary checks. The inherited maintainability advisory is still recorded. Independent review and merge readiness remain open.

A trial merge of this exact head with #7430 applies cleanly. Five whole changed files drop out of the integration comparison. The historical experiment ledger stays with #7430.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
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; reasoning_effort=max; declaration_source=runtime_reported

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

动机 / Motivation

通过 CLI 结束本轮工作的 Agent,需要确认本轮是否已经记账,并在响应丢失后安全恢复。过去,Agent 在结算后仍要从完整状态快照中找回执;现在显式选择紧凑回执即可直接核对本轮身份和三步提交结果,完整材料仍可按需恢复。本次可验收的是较短的结算显示、完整恢复和不重复扣额;安装态 Host、模型任务增益及 C1 替换仍待各自验证。本次不改变准入、权限、Todo 完成、调度、默认输出或 C1 消费链。

改动思路 / Approach

复用既有 TypeScript 结算判定与完整结果读取器;Python 只组合原命令和显示,未创建第二套准入、记账或持久状态。流程是原 refresh 写回→原 owed 命令→真实回执核对→可选显示。已结算的重放仍核对回执,但不启动另一次扣额子进程。include_record_bodies=false 只有在 canonical progress 已经 settled 后才省去重复记录;未结算恢复保持完整。

最强反对理由是输出适配器的支持字段名单可能随上游 schema 漂移。这里采用保守边界:未知字段、额外控制项、未完成或失败 owner 保留,过大的控制项转为必须读完的原捕获分页,全部材料仍在同一个完整结果。没有必要另建 Turn journal,也没有必要把 C1 的整条迁移作为本次前置条件。本次交付显式 CLI 回执显示和恢复,C1、安装态 Host 与模型实验继续由既有工作负责。

具体改动 / Changes

审查完整 9 文件 diff(301+/73-;生产218+/73-、测试73+、双语文档10+)。以下关键符号均位于 2ea9187:

关键代码讲解

  • settle_refreshed_turn:先验证原身份和 owed argv,再执行现有 CLI;是否成功由真实回执决定。已 settled 的重放只回读。错误工作区、伪造 Turn 和响应丢失分别走原恢复边界。
  • present_settled_refresh:仅作用于显式请求的成功、非 dry-run、无欠账 settled 输出。已完成的已知支持快照可延后;控制项保留或提供强制完整读取。
  • readQuotaSettlementFromRequest:先用完整权威记录判定 phase 和 receipts,再进行显示投影。默认和显式 true 完全一致,pending 下 false 也保留完整恢复材料。
  • write_decision_capture:对实际发布的 UTF-8 字节返回 digest,保留私有目录、原子发布及独立读取校验;它没有证明模型已经读到上下文。

规格依据:docs/reference/protocols/turn-envelope-v0.md,spec_revision=be17d4ff30eb00ef739710961d223ce81fb1b5e9,以改动前的 settle-turn 契约 为准。原文未编号,以下标签只标识原有条款:EXACT-TURN(原 Goal/Agent/绑定/Turn)implemented;NO-EXTRA-DEBIT(不确定响应按原回执恢复,精确重试不重复扣额)implemented;FAILED-NO-DEBIT(失败验证、dry-run、未满足检查点不能扣额)implemented;DEFAULT-PARITY(普通 refresh 保持既有行为)implemented。对应验证是实际 CLI 的 File/SQLite、失败恢复和同输入主干对照;没有用新增文档自行定义通过条件。

对主干的风险 / Risks

没有发现阻塞性正确性问题。最重要的故障是扣额已经提交、随后捕获保存失败:File/SQLite 实测均返回失败状态但保留三步提交回执;修复私有目录权限后按原 Turn 重试成功,扣额计数仍为1。丢响应测试执行真实子进程后才注入传输失败;伪造 owed Turn 在启动子进程前拒绝。未知100k控制项通过返回的真实 reader 读至 EOF,完整值保留。失败、pending、dry-run、错误工作区不会借紧凑显示跳过原门禁。

验证 结果
Python:组合结算、显示、完整分页读取、Turn 捕获 PASS,63项
TypeScript:共享回读及结算计划 PASS,148项
同一 harness/fixture 在主干和候选实际 CLI 执行 PASS;File/SQLite 四组关闭新选项的身份、进度、回执步骤与完整拒绝信息一致
新选项/File、SQLite PASS;完整结果恢复、重放一次扣额、另一 Turn 拒绝;主干不支持新选项时 exit2、无扣额是预期差异
标准 premerge(对上述不可变 base) PASS;语义词表、CLI 输出预算、公共边界等通过

语义与 CI 对齐

复用既有 settlement vocabulary;新增内容是同一读请求的可选 boolean 和 CLI 显示意图,不是第二套结算分类器。未新增领域特定工作义务、按文案猜状态或自动启用能力。--settlement-receipt 缺省关闭;完整默认读和既有请求保持,帮助/双语文档说明显式启用及恢复。

保留一项 inherited advisory:维护性 smoke 在 base/head 都以同一 oversized_decision_function:loopx.control_plane.work_items.interaction_contract:_admitted_interaction_next_cli_actions 失败,magnitude_regressions=0;该文件在两端逐字相同且不在 diff 内。不能把它写成通过;premerge 仅将其归为既有非阻塞项。按当前审查契约未查询或等待远端 CI,其未知状态不作归因。共享捕获 writer 改为一次性构造字节缓冲的生产峰值内存影响未测,当前功能/输出预算检查没有建立模型完整成本结论。

我的整体评价 / Verdict

这是 justified_increment:独立交付可用的 CLI 回执和恢复路径,架构保留既有所有者,机制成本与范围相称。long_horizon=improved,依据是验证过的原 Turn 重放、恢复与一次扣额;user_experience=improved,依据是直接回执及完整详情可达,不代表模型任务分数提升。隔离 fixture 中 combined 输出9609/9667B,receipt为5407/5413B;这只是本次表示大小,不能外推净 token、时延或人工注意力收益。

visual_review=not_applicable:检查的是 CLI JSON 和原读取路径,没有渲染页面改动;渲染范围无待验项。安装态 Host/App/Lark、模型采用和 matched 长程效果仍未验证。保守支持字段投影可保留;等出现第二个实际消费者再判断是否值得共享抽象,当前不增加跟踪任务。当前 head 未变,APPROVE 仅是精确版本审查结论,合并权限与 readiness 独立。

English verdict: APPROVE — 2ea9187; verified recoverable opt-in receipts and exact-once retry, with the inherited advisory and untested adoption/cost boundaries retained.

@huangruiteng
huangruiteng merged commit 0c41df1 into main Nov 5, 2026
35 of 45 checks passed
@huangruiteng
huangruiteng deleted the codex/settled-refresh-receipt-1105 branch November 5, 2026 06:43
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