Repository navigation
refactor(quota): reuse heartbeat receipt identity owner - #9208
Conversation
Signed-off-by: lusendong.6789 <[email protected]> Co-authored-by: TRAE CLI <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
操作者恢复一次已提交的心跳时,需要从现有日志取回同一 Turn 的有效回执。 Python 原来独立选择生效记录,可能接受 TypeScript 结算已经判为非法的 Todo 标识。 读回和锁内绑定采用同一套身份判断;非法历史 Todo 绑定在读回时也显式报冲突。 这次收敛 Python 读回与锁内绑定选择,保持当前持久化与执行入口。 重试拿到的是原始已提交记录,后续审计仍可读取原有证据。
改动思路 / Approach
复用既有 TypeScript 心跳回执归约,以原记录的索引和绑定作为返回值。Python 继续读取过滤后的文件并从原列表返回记录。 复用已存在的 TypeScript 归约,省去维持两份冲突判定的成本。 变更落在回执的身份判断,执行准入、租约、日志写入和结算沿用原所有者。 桥接只传用于身份判断的字段。索引保留原始数值、未识别字段和文件读取的顺序。
具体改动 / Changes
准确头 3c4ddce,分叉基线 d28ec76,当前主干整合预演 55bae0a。8 个文件,+227/-66。 核对的仓库契约 对应 receipt-owner 复用身份选择和冲突规则。original-record 保留原始回执。fenced-writeback 保留历史兼容与写回授权。走读了注册桥接、Python 的读取与锁内调用、TypeScript 选择及双语 RFC。对分叉基线、准确头和当前主干整合预演运行同一组 JSONL 输入,比较原始记录和冲突结果,并在两个来源运行回执和可见 Goal 的结算验证。
关键代码讲解
- TypeScript 批量投影 复用有效回执选择和已声明 effect,向读端返回索引。
- Python 事实投影 只把当前作用域内的身份字段交给 TypeScript。
- 读取原回执 按索引返回原记录,保持其他细节。
- 验证历史非法绑定 对照读回与既有结算判断。
对主干的风险 / Risks
未发现阻塞代码问题。对含非规范 Todo 标识的历史记录,回执读取变为显式身份冲突。双语 RFC 已说明这项默认行为变化。 旧读端接受的非规范 Todo 标识现在和结算端一样返回身份冲突,日志字节保持原样。File 和 SQLite 的可见 Goal 手动写回对照保留了原守卫凭证,缺少凭证时拒绝写回且不追加回执。 Goal、Agent、Turn、GoalRef 的筛选保留在原读端;绑定回执仍优先于后写入的无绑定回执。缓存键只有纯身份事实,读取源和授权仍经过现有路径。 准确头和当前主干整合预演各通过 24 项 Python 定向测试;另通过 250 项 TypeScript 相关测试及准确头 quick premerge。 本地验证覆盖读回和结算边界。更宽的 Python 回归批次在 53 项通过时中止,未跑完全。安装态、原生宿主全面接入和长期成本收益仍待实测。
我的整体评价 / Verdict
批准当前准确头。对真实 find_heartbeat_receipt 入口做六组独立对照。合法 Todo、请求、重规划、未绑定和已有的合法身份冲突共五组行为一致。读回的原始回执保留未知字段和 2^61+3 的整数。 恢复工作时,选择结果与结算身份保持一致。已提交证据、同 Turn 重试和现有租约责任链均可继续复用。 保留当前实现边界。变更落在回执的身份判断,执行准入、租约、日志写入和结算沿用原所有者。
English verdict: APPROVE at 3c4ddce. The reader and settlement share the receipt identity rules. Exact-head and current-main integration checks preserve supported records, full numeric precision, and existing writeback guards. Malformed legacy Todo bindings now fail closed.
Python heartbeat receipt readers could accept Todo bindings that the existing TypeScript settlement owner rejected. Reuse that owner for Python binding and effective-receipt selection, returning the original event by index so unknown details and exact integers stay intact. Locked writers reuse the binding returned by the same batch selection.
The intentional behavior change is rejection of noncanonical Todo IDs with the settlement owner's existing diagnostic and no log mutation. File/GoalRef filtering, locks, admission, lease authority and settlement keep their existing boundaries. The visible-Goal control reuses the proof handling already merged in #9203 and adds File/SQLite coverage plus an explicit missing-proof rejection check. The paired mechanism RFC checkpoint keeps broader caller cutover, installed/native adoption and outcome/full-cost qualification open.
Validation so far:
b422ace0eand pass on the candidate; the unknown-detail and exact-integer control passes on both.3c4ddcef: the final Python selection expanded to 73 parameterized nodes, exceeding the agreed 36-node execution scope. It was safely interrupted with 35 passed, no test failures and exit 2; this is partial evidence. Those 35 include receipt 21, File/SQLite proof 2, interrupted/resume 5 and journal 7. The source, original Python interpreter and supervision helpers remained unchanged, and owned test runtimes were shut down. Logs and the interrupted namespace are retained. Static enumeration identifies 38 pending nodes (journal 11 and Codex completion 27); verify their collection in the next authorized serial slot and run only those remaining nodes.Remaining continuation checks also await qualification of the existing original-Turn execution-loss recovery contract in #9153. The 38-node remaining segment has not started collection or execution. This proposal adds no alternate closeout owner; the original 35 passing nodes and all incomplete validation remain recorded above.