Skip to content

fix: isolate agent settlement from peer semantic receipts - #8853

Merged
huangruiteng merged 1 commit into
mainfrom
codex/replan-agent-settlement-isolation-20261116
Nov 16, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/replan-agent-settlement-isolation-20261116

Conversation

@huangruiteng

@huangruiteng huangruiteng commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

An Agent could fail to refresh or settle a valid Turn because another Agent on the same Goal had a malformed semantic-review receipt. Settlement qualified every Agent’s receipts before selecting the requested Agent, and status collection independently repeated that cross-Agent read.

Apply the explicit Agent scope before semantic receipt qualification and carry it through status obligation collection. Shared Goal history, instance ownership and log-integrity checks remain intact. The affected Agent and unscoped readers still reject the malformed receipt; no receipt is repaired or discarded. The existing CLI/status journey is preserved without new configuration. Also remove two duplicate imports from the touched status wrapper.

Validation:

  • 192 TypeScript history/settlement checks passed, including the failing-before/fixed-after case, foreign-work exclusion, invalid-scope rejection and unchanged receipt log.
  • Real CLI File and SQLite regressions pass: refresh succeeds, repeated spend creates exactly one debit, and affected-Agent/global status still fails.
  • 106 status/replan regressions passed; changed-file Ruff, diff/RFC checks and the isolated eight-file public-boundary scan passed.
  • Standard premerge: six direct checks, nine of ten catalog checks and all eight risk-profile checks passed initially. The remaining vocabulary check failed due to missing npm dev dependencies, then passed unchanged after npm ci --ignore-scripts.
  • The optional 232-case sweep was stopped after 17 passing cases (299 s); no full-suite pass is claimed. Both focused same-Turn semantic recovery checks pass for File and SQLite (10.56 s).

The source repair also completed an existing-runtime recovery using its original Turn identity; readback confirmed exactly one writeback and one spend. Installed releases and historical receipts were not modified. Scheduling and Goal policy are unchanged.

Signed-off-by: huangruiteng <huangrt01@163.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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

评审提交 98d640577b2101d0ee8ad872d9d77afb66e4b149,对照实际主干 59e68906d4082f43fae52e4219e374c5e97539a9。

动机 / Motivation

在同一个 Goal 中并行工作、需要结算自己已准入 Turn 的 Agent。
主干会先解释同 Goal 下各 Agent 的语义回执,再挑当前 Agent。另一 Agent 的回执缺少 review stop condition 时,正常 Agent 的状态和结算也会失败。
让 A 在 File 或 SQLite 上按原身份准入,再加入同一个 Goal 中 B 的语义字段不完整回执。分别读取 A、B 和全 Goal 的状态,然后用 A 的原 Turn 结算及重放。
主干的 A 状态和结算均拒绝。候选允许 A 完成一次写回和一次扣额,重放读回同一准入。B 和全 Goal 都仍拒绝原语义错误,共用事件日志的非法 JSON 也仍被拒绝。
验证使用隔离的真实 CLI 与 File/SQLite、合成回执。现场安装和远程运行未验证。

改动思路 / Approach

继续用原 TypeScript 结算和有效 Turn 的计数 owner。当前 Agent 的过滤位置从计数结束前移到解释回执前,状态采集也传同一个 Agent。只改 TypeScript 分支会留下 status 对其他 Agent 的重复解释。
先绑定 Goal 和 Agent 再解释能计数的结算,原 scoped 刷新、扣额和历史诊断继续经现有 owner。

具体改动 / Changes

8 个文件新增 129 行、删除 7 行。按主干 59e68906d4082f43fae52e4219e374c5e97539a9 的 docs/quota-allocation.md 复核 same-agent-settled-count、receipt-replay 和 peer-isolation。 调度和计数协议

关键代码讲解

  • projectSettledReplanHistory。保持 Goal instance 与事件日志读取,在领取结算 snapshot 的候选中只保留当前 Agent 的原回执。无 Agent 的读仍核对全部已匹配的候选。 回执聚合
  • attach_active_state_project_asset_fields。在已有 status 构建链传入 Agent,限制为当前 lane 解释重规划义务。全 Goal 读取仍从原工作历史发现所有 Agent。 状态投影

对主干的风险 / Risks

  • 同一个 fixture 走实际 refresh-state --settle-turn。主干在两个 backend 都拒绝 A,扣额为零。新提交中 A 成功一次,重放为已结算且仅有原准入回执。B 的原行字节保留,B 和无 scope 的 status 仍精确报告原错误。把共用 JSON 写坏仍使 A 的 scoped status 拒绝。
  • 新增 File/SQLite 回归在主干各失败一次,在候选通过。两份 TypeScript history/settlement 测试共 192 项通过,实际 CLI 测试文件 30 项通过。Quick premerge 六个直接与四个选定检查通过。

我的整体评价 / Verdict

批准当前提交。把已有 lane scope 送到回执解释前,能隔离故障,同时保留错误回执和共有日志的检查。调用方沿原 scoped CLI 路径完成结算。

English verdict: APPROVE. Agent-scoped settlement now isolates peer semantic errors and preserves original receipts, exactly-once accounting, and strict shared log validation.

@huangruiteng
huangruiteng merged commit dfa6de7 into main Nov 16, 2026
29 of 52 checks passed
@huangruiteng
huangruiteng deleted the codex/replan-agent-settlement-isolation-20261116 branch November 16, 2026 07:00
huangruiteng added a commit that referenced this pull request Nov 17, 2026
* Prioritize new Lark replies over already attempted cards

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

* Isolate unreadable Lark reply scheduling hints

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

* fix: isolate agent settlement from peer semantic receipts (#8853)

Signed-off-by: huangruiteng <huangrt01@163.com>

* docs: add Japanese README (#8839)

* docs: add Japanese README

Signed-off-by: Ikko Eltociear Ashimine <eltociear@gmail.com>

* docs: sync Japanese README with Goal lifecycle and route it through README checks

Signed-off-by: Ikko Eltociear Ashimine <eltociear@gmail.com>

---------

Signed-off-by: Ikko Eltociear Ashimine <eltociear@gmail.com>

* Retain unreadable Lark recovery hints until the next scan

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

---------

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: Ikko Eltociear Ashimine <eltociear@gmail.com>
Co-authored-by: huangruiteng <huangrt01@163.com>
Co-authored-by: Ikko Eltociear Ashimine <eltociear@gmail.com>
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