Repository navigation
Keep durable quota events out of oversized settlement errors - #8643
Conversation
Signed-off-by: Tartar <xiaoyx67@mail2.sysu.edu.cn>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · max
本次评审对应提交 121e8cc4f1b95b1c489154fcfaa6503d664aff31。
动机 / Motivation
使用有界 JSON 结算回执的自动化维护者。结算已经写入后,若保存有字节上限的响应失败,旧 CLI 仍内嵌持久记录已有的 quota_event;重复数据可能让调用方在保留窗口内读不到原回执。当前提交仅在超限的提交或重放回退里去掉重复事件。8 KiB 配额下,File 响应 9,655 → 6,252 字节,SQLite 响应 9,745 → 6,342 字节;两者仍可从原路径完整回读、只扣费一次。验证覆盖 macOS 的隔离 File/SQLite、真实 CLI 与本地文件权限故障。若剩余控制项本身超限,回退仍保留这些项;本次未验证原生 Windows、部署或 hosted CI。
改动思路 / Approach
将裁剪留在已有输出层,只去掉有持久副本的诊断字段。准入、持久回执和扣费仍由原结算 owner 负责。 只有成功提交或幂等重放、有原持久路径、且回退响应仍超限时,才去掉重复事件;拒绝和未知控制项照常保留。
具体改动 / Changes
关键代码讲解
- CLI 分支 继续把捕获失败作为退出码 1。
ok=true和三步结算回执仍说明原操作已提交。 - 回退投影 继续省略 before/after;符合条件时把 quota_event 记入 omitted_diagnostics,完整事件仍在原 json_path。
- 回归 核对多字节输出、原回执和未知字段;另以真实命令验证错误 Turn 拒绝与权限恢复。
按 docs/reference/protocols/turn-envelope-v0.md 的 d9432f23544e595f9861fcc6d8453ea926721612 版核对 Settlement-identity 和 Failure-controls。
对主干的风险 / Risks
重复调用在 File 和 SQLite 上都只留下一个 spend,原事件逐字节不变。剩余控制项本身很大时仍会超限(例如 14,407 → 9,420 字节);本 PR 解决的是重复事件的体积,不会丢掉必需控制项。
语义与 CI 对齐
12 项定向测试、6 项直接和 18 项选定 premerge 检查通过。当前主干的本地合并候选上,SQLite 权限故障、原回执重放和恢复读回也通过。
我的整体评价 / Verdict
APPROVE。真实故障下压缩有效,结算身份、持久事件和幂等语义保持。本次评审覆盖现有宿主与 CLI 行为。验证覆盖 macOS 的隔离 File/SQLite、真实 CLI 与本地文件权限故障。若剩余控制项本身超限,回退仍保留这些项;本次未验证原生 Windows、部署或 hosted CI。
English verdict: APPROVE. The capture-failure path drops only the recoverable duplicate event, preserving original receipts and one spend on File and SQLite.
A quota spend can commit successfully while permissions prevent writing its bounded response capture. The fallback stripped top-level snapshots but still embedded the same event from the durable spend record. A POSIX File/SQLite run returned 8,327 bytes with an 8,192-byte budget.
When that fallback exceeds the budget, omit the duplicate event for a committed or replayed spend. Keep the settlement identity, receipt, recovery controls and existing path to the complete durable event.
Validated on
121e8cc4f1b95b1c489154fcfaa6503d664aff31frommainatd9432f23544e595f9861fcc6d8453ea926721612, using isolated synthetic File and SQLite fixtures.