Skip to content

fix(quota): retain composed settlement failure diagnostics - #8267

Merged
loopx-agent merged 1 commit into
mainfrom
codex/retain-composed-spend-diagnostics-main-20261107
Nov 7, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/retain-composed-spend-diagnostics-main-20261107

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

A combined refresh-state --settle-turn retry from the canonical checkout refuses a debit owed by an independent producing worktree. The previous response dropped the child’s workspace requirement and recovery action even though the canonical quota spend-slot returned them. The combined JSON now carries the evaluated failure under quota_spend, including any existing child reader. It keeps the original owed command and the parent’s independently verified receipts.

With --settlement-receipt, a wide failure uses the existing digest-checked result reader. The parent’s selected controls include the child’s reader and its instructions. If the private capture fails, the response returns the original controls and result_delivery_error.

Author Declaration

  • Written by: model_agent, Codex, OpenAI GPT-6 family

Implemented against

TurnEnvelope recovery contract at the tested base and bounded settlement diagnostics.

Criterion Disposition Owner and verification
Carry the existing workspace refusal and recovery action across composition implemented settle_refreshed_turn and the public refresh-state rejection fixture
Preserve the original owed command, effect identity and exact receipts implemented Existing receipt and accounting owners, verified through File and SQLite denial, recovery and replay
Retain complete controls if either view needs pagination implemented Existing quota result capture and context-read, including nested reader and capture privacy tests

Scope And Continuation

The change applies to the existing combined JSON settlement surface on main. The successful response retains the compact spend confirmation and the linked accounting artifact. The adapter reuses the shared bounded result presenter, whose instruction now describes deferred snapshots only when present. The existing CLI command, authority checks and receipt owner determine settlement.

Validation

Tested head 56f352af16c96cfad2adc55bacab1697cee64a1b against 2659e5f70c8a8ba6c23f7588151ea5c06576ef69. Inputs were synthetic public fixtures.

Check kind Result Evidence
real_entrypoint passed Same File and SQLite quota should-run, original writeback, standalone denial, combined denial, missing workspace, correct workspace and exact replay. No debit was recorded on refusal. Recovery preserved the original effect and reached one writeback and one debit.
regression_parity passed The independent workspace oracle failed at the base and passed at the head. The child guard matches the standalone response. Fresh successful receipt stdout was 5,247 B on both revisions and replay was 4,278 B on both, with one command each. The File refusal was 7,922 → 34,276 B and SQLite was 7,958 → 34,312 B, reflecting the returned failure controls and diagnostic snapshot.
integration passed 30 cases in test_refresh_settle_turn.py and test_quota_result_budget.py. The wide transport fixture reads the parent’s complete selected controls and then the child’s synthetic recovery field through both original captures.
real_backend passed The built wheel’s console repeated the same successful and failed settlement/recovery journeys on isolated File and SQLite stores.
static passed Ruff for changed Python, diff and bilingual checks, and standard premerge with six direct and 19 selected checks.

An initial test run used a restrictive umask that made the existing public-directory fixture private. The focused suite passed with the fixture’s expected directory mode. This evidence covers source and disposable wheel CLI behavior. Live model cost, installed host adoption and PostgreSQL were outside this validation.

Frontend / Visual Evidence

The existing machine-facing JSON command and its reader carry the change. Dashboard, App and Lark have no rendering changes in this patch.

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 · OpenAI · gpt-6.1-sol · runtime_reported · max

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

动机 / Motivation

从工作区尝试继续已经写回的组合结算时,操作者可能需要回到实际产出该结果的 worktree。 旧组合 JSON 只有精简子扣额结果,当前工作区不匹配时会丢失具体动作。新结果保留原拒绝详情,并能沿已存在的命令返回正确工作区。 实际 File 与 SQLite 都能读到 return_to_delivery_worktree、原待结算命令和原身份。修正后继续该 Turn,只有一次扣额。 此次只验证组合 JSON 结算和同一原始结果的 reader。实际模型、生产部署和 PostgreSQL 在此次证据范围外。

改动思路 / Approach

组合层只转交现有子命令的拒绝视图。工作区选择、扣额与回执归原 owner。 本 PR 增加失败读回的完整性和预算内传输。现有结果 reader 同时承载原失败与多页说明。 在 base/head 查 settle_refreshed_turn、workspace_guard、budgeted_settlement_result 及独立 quota spend 路径。#7913 的私有 JSON 预算 reader 已提供完整内容、哈希、分页和错误处理。 只提升 error 文本会丢失机器可读工作区、附加控制或嵌套 reader。把完整子失败重用已有输出适配器,兼容现有消费者。

具体改动 / Changes

按 docs/reference/protocols/turn-envelope-v0.md 在 2659e5f 的边界逐项核对。 docs/reference/protocols/turn-envelope-v0.md

  • workspace-recovery · implemented。缺失或错误工作区需保留原欠结算命令及同一次 worktree 恢复。
  • same-receipts · implemented。组合写回核对原回执,重放无第二次扣额。
  • immutable-reader · implemented。紧凑回执的大输出从原结果完整读取,读失败保留原恢复依据。

关键代码讲解

协议文档补充现有权限和错误恢复顺序。测试核对真实错误/缺失工作区、保留 child workspace_guard、正确工作区继续,以及大结果完整的父子 reader。

对主干的风险 / Risks

PASS。head 全部 30 个真实/预算用例。base 的 6 个正例与兼容用例通过,两种 provider 的独立缺字段 oracle 都在旧代码失败。 File/SQLite 真实错误工作区返回 child workspace_guard,缺失工作区保留原 owed,均无扣额。宽控制用例顺序执行父、子两次 digest reader,读到完整嵌套错误。捕获不可用时原拒绝与 result_delivery_error 同返。 省略 --settle-turn 的普通写回仍保留原输出与 owed 行为。相同 fixture 的普通/组合成功和重放在 base/head 通过。 未验证生产输出截断、外部模型采纳或 PostgreSQL 运行时。宽失败的分页证据使用合成拒绝,实际工作区拒绝验证 File/SQLite。

语义与 CI 对齐

有意恢复既有子诊断的可读性,必须处理的控制、权限和继续顺序保持原义。 按子返回码、解码后的 ok 与已读回的结构化结算状态选择输出路径。错误正文不参与授权分类。 CI 未查询。复核命令为 uv run --extra test python -m pytest -q tests/control_plane/test_refresh_settle_turn.py tests/control_plane/test_quota_result_budget.py。

我的整体评价 / Verdict

未发现阻塞问题。 真实组合结算从拒绝回到原 producing worktree 后继续同一 Turn,无二次写回或扣额。 错误定位和恢复路径随原拒绝一起保留,宽结果可通过已存在的 reader 分页读取。 检查范围为机器可读 CLI、捕获读取及其消费命令,未改渲染页面。 失败时多返回实际子诊断,可能增加一次按需读取。该成本受原预算约束,能让操作者定位并恢复原命令。

English verdict: APPROVE. Head 56f352a. Exact-head File and SQLite recovery, base sensitivity, ordinary writeback parity, and nested digest-reader behavior verified. No blocking findings.

@loopx-agent
loopx-agent merged commit 10f66ec into main Nov 7, 2026
24 of 39 checks passed
@loopx-agent
loopx-agent deleted the codex/retain-composed-spend-diagnostics-main-20261107 branch November 7, 2026 09:55
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