Skip to content

Report a settled Turn when another writer commits its debit - #10294

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/c1-confirm-contended-settlement-20261206
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/c1-confirm-contended-settlement-20261206

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Problem

A composed Turn can receive two definitive quota index conflicts while a concurrent worker settles that same Turn. The authoritative receipt readback reports a settled Turn, but the CLI still exits unsuccessfully because it keeps the failed child result as its disposition. This sends the host an error for work that already settled.

Change

Keep the definitive conflict check with the existing one-retry limit. If the final child attempt was rejected at the index comparison and valid receipts now prove the exact debit, return a settled replay. The result indicates that this invocation appended zero debits and preserves the conflict as a diagnostic. A still-owed debit continues to expose its original recovery command.

Verification

The File and SQLite cases interleave two real conflicting CLI spends, then settle the exact original Turn through a separate CLI call before the parent's receipt readback. The baseline exposes settled receipts with a failed exit code. The candidate returns success, preserves the exact existing receipt chain, and permits an idempotent replay without another spend. The existing single-conflict and still-owed cases keep their assertions.

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.2-sol · OpenAI · runtime_reported · xhigh

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

精确原回执的并发结算已通过 File 和 SQLite 配对复验。

动机 / Motivation

运行 refresh-state --settle-turn 的宿主及处理同一 Turn 竞争写入的代理。 第二次扣额请求明确败于索引比较后,即使其他写入者完成该 Turn,外层 CLI 仍返回失败。 两个子调用因同一目标索引变化而明确未扣额,第三个合成并发调用提交原 Turn debit 后,父命令读回。 已结算的原 Turn 返回成功、零新增 debit 的幂等回读,尚欠 debit 保留原恢复命令。 combined settlement 的 CLI 状态、规范回执核验,以及 File 和 SQLite 并发回归。 本轮验证隔离 File 和 SQLite,使用受控进程交错。其他存储实现未另行运行。 基线 f9d5c99。 基线约定

改动思路 / Approach

combined settlement 的 CLI 状态、规范回执核验,以及 File 和 SQLite 并发回归。 保留现有一次重试和 exact receipt reader,只改变已确认原回执完整时的对外结果。 两个进程同时写入时,以原回执的规范结果定性,区分实际重复扣额和调用重试。

具体改动 / Changes

对主干的风险 / Risks

同一用例在基线两个 provider 均以失败退出。独立读回两份基线 fixture,原 Turn 均已有 validation、durable_writeback 和唯一 quota_spend。 候选两个 provider 都返回成功,回执链一致,quota_spend.appended=false 并标记幂等。仍欠 debit 的持续冲突继续返回失败与原恢复动作。

候选 22 项相关 CLI 用例通过,git diff --check 通过。基线的同一竞争用例在两个 provider 均稳定失败。

我的整体评价 / Verdict

同意精确提交 a7f9183。并发者完成扣额后,本调用返回成功并保留现有回执。两种存储对尚欠扣额仍返回原恢复命令,保留了一次重试上限。精确回执回读验证了每个 Turn 只有一条扣额记录。

English verdict: APPROVE at a7f9183. Both providers report a settled replay after another writer commits the exact debit. The original owed recovery command remains available when the debit is uncommitted.

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