Skip to content

Reuse verified spend receipts in combined settlement - #8405

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/reuse-verified-quota-child-receipts-20261109
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/reuse-verified-quota-child-receipts-20261109

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Combined settlement was looking up the receipt chain again after the quota child had already read it from the authority store. Reuse the child's proof after a fresh append when the original settlement identity, predecessor receipts and spend event all match. Responses that are lost, incomplete or inconsistent, and replays, still use the independent lookup.

The packaged CLI on File and SQLite saved one lookup and about 8.4 KB of internal transfer per successful settlement, with identical CLI output byte counts. The integrated C1 path reproduced the result. Recovery tests cover a lost response after a real debit, missing or mismatched receipts, and idempotent replay.

The standard premerge canary passed. The packaged SQLite CLI also recovered the original receipt chain after an injected response loss following the real debit in each of two Turns.

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, gpt-6.1-sol, OpenAI, runtime_reported, reasoning_effort=max

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

动机 / Motivation

组合 refresh 和 spend 已拿到子进程的权威回执,却再读一次相同结算链。用同一已准入的 Todo 对照普通 writeback、首次组合结算和原 Turn 重试。新提交只在新扣额的完整证明吻合时省一次读回,最终仍给出原来的三份回执。这是隔离的真实 CLI、子进程、TypeScript runtime 和 File/SQLite 权威库。未测线上历史规模与真实模型成本。

改动思路 / Approach

复用固定子 CLI 已完成的权威读回,保留父进程的独立恢复入口。范围限于显式请求组合结算且首次追加成功。身份、两份前序回执、提交状态和扣额事件都需吻合;重放、响应丢失或验证不通过仍走现有 readback。

具体改动 / Changes

评审 37dead1。GitHub 目标基线 71190b6,实际共同祖先 f4c5d6d7;3 个文件,+90/−7。当前主干的 #8403 改动不重叠,合并树干净。原 Turn 契约 对应 exact-fresh-reuse、ambiguous-readback、non-combined-parity 已验证;live-scale-qualification 另验。

关键代码讲解

  • 组合结算入口 仍解析并核对待结算命令,绑定原 Goal、Agent、Todo 和 Turn。
  • 新回执核验 只采用匹配的已提交链。任一条件不满足仍调用原权威 reader,再区分未扣额、回执已提交与响应异常。

对主干的风险 / Risks

File 和 SQLite 的真实 CLI 对照中,完整回执把父进程的结算读取从 3 次减至 2 次,与当前主干的等长夹具对照每次少传 8,676 字节。丢失响应、错配 validation 回执、非零子进程退出与重试都保留原读回;独立读到的三份回执一致,每次实际只扣一格。普通 writeback 仍返回原待结算命令且不扣额。114 项相关测试通过、1 个 Windows 专项跳过,标准预合并 6 项直接和 14 项自动检查通过。

我的整体评价 / Verdict

认可当前提交。复用范围与回执证明匹配,异常和重放仍交给原结算 owner;丢失响应后仍能从独立来源证实扣额已提交,重复执行不增加扣额;真实部署规模的延迟收益另验。

English verdict: APPROVE. The fresh proof saves one parent read while incomplete or inconsistent responses and retries still recover the same authoritative chain with exactly one debit.

This branch has not been deployed

No deployments
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