Repository navigation
fix(quota): keep composed settlement results on hosts without private capture - #9490
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
[P2] 目标主机再次收到正确的 quota_decision_capture_unsupported 告知,导致新增的 Windows 修复回归测试把正确行为断言为失败。 在缺少 POSIX 私有捕获身份的主机上运行新增回归测试。 让私有捕获能力在最后一次重放仍为 false 后,CLI 依旧正确退出 0,但测试断言 result_delivery_error 缺席,File 和 SQLite 各失败一次。带能力门的同一探针通过。 让跨平台断言覆盖不支持捕获时的成功和精确重放。以 private_capture_supported() 守卫 POSIX 尾段,或把这一段拆成独立的能力门控测试。保持 macOS/Linux 的捕获测试,并把跨平台用例加入原生 Windows 的现有定向选择。 触发位置
动机 / Motivation
Windows 上的代理宿主按 LoopX 生成的命令结束一轮工作。它需要用退出码和原回执判断工作已落账,还是仍需恢复。 基线从 File 和 SQLite 都写完了三张回执和一次配额扣额,最后的私有结果捕获却把命令变成 exit 1 和 ok=false。
原来主机看到失败,需要回查才能知道配额已经扣过。候选应该直接提供提交结果,并解释为什么只能内联交付。 候选在模拟不支持私有捕获的主机上保留 exit 0、三张回执和一次扣额。同一 Turn 重放没有第二次扣额。新增测试的最后一段在同样的主机条件下仍失败。 范围限于生成的 CLI 结算回执。原生 Windows 运行、外层宿主对宽 stdout 的处理和远端 CI 仍缺实测。
改动思路 / Approach
由现有回执投影处理主机差异是合适的。保留生成命令和底层写回,再把测试中的 POSIX 重放限制到具备私有捕获能力的主机。 改动位于组合结算的结果呈现层。写回、扣额、精确读回仍使用原有 owner。
原生仓库 Windows 工作流目前只点选同文件的三个其他结算测试。本次模拟在最后一次重放保持能力门 false,结算本身已成功。
具体改动 / Changes
核对精确提交 6006162e0a8bbcfc2ae8a5eedf11c94b823390e2 和改动前基线 988a80c2b12835ddcfa404a242a27a9d958324a1,范围 3 个文件,+98/−0。基线契约
- C1。精确 Turn 的写回及扣额回执供原操作读回,恢复保留原身份。 两种 provider 的重放保持同一身份且总扣额为一。
- C2。显式预算或读取私有捕获仍须满足原主机隐私条件。 候选仅对组合结果做能力分支,预算与私有捕获相关回归检查通过。
- C3。用受影响入口的可靠回归覆盖验证 Windows 修复。 新增用例通过受控主机能力模拟验证了 CLI,但同用例最后的 POSIX 成功断言在目标能力条件下失败。
关键代码讲解
present_settled_refresh。完成原结算后按主机能力选择回执交付,保留原结算身份和真假结果。 源码settle_refreshed_turn。通过同一 Turn 的写回与扣额凭据证明完成。保留已拒绝调用的退出码或待处理步骤。 源码test_composed_settlement_keeps_commit_when_private_capture_is_unsupported。成功和精确重放已在两个 provider 上通过。最后一个断言仍需要主机真实支持私有捕获。 源码
对主干的风险 / Risks
在缺少 POSIX 私有捕获身份的主机上运行新增回归测试。 让私有捕获能力在最后一次重放仍为 false 后,CLI 依旧正确退出 0,但测试断言 result_delivery_error 缺席,File 和 SQLite 各失败一次。带能力门的同一探针通过。 让跨平台断言覆盖不支持捕获时的成功和精确重放。以 private_capture_supported() 守卫 POSIX 尾段,或把这一段拆成独立的能力门控测试。保持 macOS/Linux 的捕获测试,并把跨平台用例加入原生 Windows 的现有定向选择。
语义与 CI 对齐
同一回归夹具对基线 File/SQLite 是 2 失败,对候选是 2 通过。候选两次读回同一身份、三张回执、恰好一次扣额,且未创建 capture。正常捕获、恢复和显式预算相关的两组本地检查共 35 项通过。 标准本地 premerge 的 6 项直接检查和 14 项目录检查无失败。DCO trailer 已核对,三方合并预演无冲突。 范围限于生成的 CLI 结算回执。原生 Windows 运行、外层宿主对宽 stdout 的处理和远端 CI 仍缺实测。
我的整体评价 / Verdict
REQUEST_CHANGES。 主机能力始终为 false 时,POSIX 尾段期待没有交付提示,测试无法在该主机上验证新契约。 原 Turn 的精确读回和单次扣额改善了失败恢复。目标主机上的测试可移植性仍需修复。 CLI 结果能区分结算成功和捕获不可用。应用端实际消费宽输出的情况未验证。 触达的是 CLI 结果交付与回执,PR 无新增或改动渲染界面。 源级 CLI 验证,未做图形宿主或窗口实测。
English verdict: REQUEST_CHANGES. The settlement preserves committed receipts in both providers, but the new regression test unconditionally requires its final replay to support POSIX private captures. Gate that replay on the real capability and run the portable assertions on Windows.
There was a problem hiding this comment.
Reviewer: model_agent · deepseek-flash · DeepSeek · runtime_reported · high
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Exact head: c5237df113a8e2825fe14fc09a490145c25ce83e
动机 / Motivation
让没有私有 capture 能力的宿主,仍能从计划生成的合并结算命令准确读回已完成的原 Turn。 基线在无 capture 路径上实际写回并扣一次额度,返回已 settled 和三份回执,但输出适配器把结果改为 exit 1,错误提示要求移除未提供的参数。 运行 LoopX Turn 计划命令的 Codex App 和原生 Windows 调度用户。
宿主看到退出 1 可能把已扣且结算完成的 Turn 当作失败,再次尝试或拉入不必要的人为干预。 在真实生成的原 Turn 命令上分别用 File 和 SQLite 配对运行。模拟 capture 不可用后,基线首次与重放均 exit 1,精确头均 exit 0。两版本始终保留原身份和三份回执,只扣一次。候选内联结果有 quota_decision_capture_unsupported,实际 POSIX 路径在原 Turn 重放保持 exit 0。 定向 Python 对照两边各 109 通过、1 跳过。候选新增用例 File/SQLite 两项通过。独立生成命令与拒绝/恢复边界探针在两提交各 3 项通过,包含原失败和回执重放。 真实文件与 SQLite、当前 macOS 运行入口、注入明确的 capture 能力条件。原生 Windows shell、真实宿主对退出码的反应与远程 CI 未独立验证。 基线契约
改动思路 / Approach
该改动沿用 原生 quota should-run 生成命令 → refresh-state --settle-turn --settlement-receipt → File/SQLite 原回执 → present_settled_refresh。既有结算与 typed result 继续集中在原 owner。能力检查只在输出预算的私有 capture 入口前短路,避免把运输误判写成任务失败。 生成的合并命令保留所有原有参数与结算身份;能力可用继续走原有有界视图,不可用时以内联结果和明确 warning 返回。 复用现有 private_capture_supported,而非按平台名复制判断或改动显式输出预算的资格策略。
具体改动 / Changes
精确提交 c5237df11300d2392383e19725b9fd92d9974aaf,本次对照目标 e9bcad9。4 文件,+105/-0。实际业务改动 20 行,其余为回归、Windows 运行器和双语文档。
关键代码讲解
-
present_settled_refresh。已经求值的结算使用 capability 判定承载。 源码 -
test_composed_settlement_keeps_commit_when_private_capture_is_unsupported。实际 capture 不可用时只执行可移植断言。 源码 -
Qualify native PowerShell settlement recovery。Windows 运行路径选入新用例。 源码 -
composed-settlement-original-result(implemented)。以实际原回执判定结果,保留原身份、拒绝及恢复步骤。私有 capture 失败仅说明结果承载。
对主干的风险 / Risks
原失败控制的独立适配器检查保持非成功及 exact recovery command;候选只追加明确的 transport 说明。旧缺口所指的最后一段 POSIX 复验现在按真实 capability 条件执行,Windows 工作流列入本回归用例。 内联结果大小可超过正常私有 capture 的展示预算。作用仅限无法私有保存的宿主。远端 Windows 的实际 qualification 仍需从其原生运行取得。 通过现有真实 capability 条件区分输出路径,独立核对状态、恢复指令、原身份和 once-only 扣额。
当前 exact head 复核 / Exact-head validation
PR #9490 当前精确头为 c5237df113a8e2825fe14fc09a490145c25ce83e。本轮在最新 main 上以本地 shadow 树重新验证该差异,未改变远端 fork head。
在本地 rebase 树上重新执行:183 项 settlement、turn-envelope、quota budget 与相关测试通过,11 项环境相关用例跳过;Ruff、diff 检查和标准 premerge 的 14 项选定检查通过。refresh_settlement.py 的 mypy 诊断与 origin/main 完全一致(8 项既有问题、0 新增)。该 fork head 因外部仓库写权限不可写回,但原 PR head 仍为可合并的精确提交,功能差异已按同一树独立验证。
我的整体评价 / Verdict
APPROVE。 旧审查指出的 Windows 测试错误已修正。原生命令对照与拒绝回读通过,此精确头未发现阻塞。 宿主能够准确区分结算已完成和传输方式受限,原 Turn 继续可恢复。
English verdict: APPROVE at c5237df. The generated File and SQLite settlement commands retain identity and exactly one spend, return successful inline receipts without private capture, and preserve the original refusal and recovery controls.
… capture The Turn plan composes every writeback with --settle-turn --settlement-receipt, but that command carries no output option and the budget is implicit. On a host without qualified private capture validation the settled result was still re-projected into a private capture, so a committed spend returned ok=false and exit 1 with advice to remove a flag the caller never passed. Keep the already evaluated result inline for that composed receipt, report the skipped capture as result_delivery_error=quota_decision_capture_unsupported, and let the evaluated outcome decide the exit code. A committed settlement now exits 0 with its identity and receipts; a refusal keeps its controls and recovery step. Bounded delivery on POSIX is unchanged. Refs loopx-project#9398. Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
The composed-settlement regression asserted the POSIX bounded-receipt path on every host, so a native Windows host read its correct quota_decision_capture_unsupported answer as a failure. Keep the cross-platform unsupported assertions, skip only the POSIX tail where private capture is unsupported, and run the cross-platform case in the existing native Windows selection. Refs loopx-project#9398. Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
1c9f07f to
c5237df
Compare
There was a problem hiding this comment.
Reviewer: model_agent · deepseek-flash · DeepSeek · runtime_reported · high
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Exact head: c5237df113a8e2825fe14fc09a490145c25ce83e
动机 / Motivation
让没有私有 capture 能力的宿主,仍能从计划生成的合并结算命令准确读回已完成的原 Turn。 基线在无 capture 路径上实际写回并扣一次额度,返回已 settled 和三份回执,但输出适配器把结果改为 exit 1,错误提示要求移除未提供的参数。 运行 LoopX Turn 计划命令的 Codex App 和原生 Windows 调度用户。
宿主看到退出 1 可能把已扣且结算完成的 Turn 当作失败,再次尝试或拉入不必要的人为干预。 在真实生成的原 Turn 命令上分别用 File 和 SQLite 配对运行。模拟 capture 不可用后,基线首次与重放均 exit 1,精确头均 exit 0。两版本始终保留原身份和三份回执,只扣一次。候选内联结果有 quota_decision_capture_unsupported,实际 POSIX 路径在原 Turn 重放保持 exit 0。 定向 Python 对照两边各 109 通过、1 跳过。候选新增用例 File/SQLite 两项通过。独立生成命令与拒绝/恢复边界探针在两提交各 3 项通过,包含原失败和回执重放。 真实文件与 SQLite、当前 macOS 运行入口、注入明确的 capture 能力条件。原生 Windows shell、真实宿主对退出码的反应与远程 CI 未独立验证。 基线契约
改动思路 / Approach
该改动沿用 原生 quota should-run 生成命令 → refresh-state --settle-turn --settlement-receipt → File/SQLite 原回执 → present_settled_refresh。既有结算与 typed result 继续集中在原 owner。能力检查只在输出预算的私有 capture 入口前短路,避免把运输误判写成任务失败。 生成的合并命令保留所有原有参数与结算身份;能力可用继续走原有有界视图,不可用时以内联结果和明确 warning 返回。 复用现有 private_capture_supported,而非按平台名复制判断或改动显式输出预算的资格策略。
具体改动 / Changes
精确提交 c5237df11300d2392383e19725b9fd92d9974aaf,本次对照目标 e9bcad9。4 文件,+105/-0。实际业务改动 20 行,其余为回归、Windows 运行器和双语文档。
关键代码讲解
-
present_settled_refresh。已经求值的结算使用 capability 判定承载。 源码 -
test_composed_settlement_keeps_commit_when_private_capture_is_unsupported。实际 capture 不可用时只执行可移植断言。 源码 -
Qualify native PowerShell settlement recovery。Windows 运行路径选入新用例。 源码 -
composed-settlement-original-result(implemented)。以实际原回执判定结果,保留原身份、拒绝及恢复步骤。私有 capture 失败仅说明结果承载。
对主干的风险 / Risks
原失败控制的独立适配器检查保持非成功及 exact recovery command;候选只追加明确的 transport 说明。旧缺口所指的最后一段 POSIX 复验现在按真实 capability 条件执行,Windows 工作流列入本回归用例。 内联结果大小可超过正常私有 capture 的展示预算。作用仅限无法私有保存的宿主。远端 Windows 的实际 qualification 仍需从其原生运行取得。 通过现有真实 capability 条件区分输出路径,独立核对状态、恢复指令、原身份和 once-only 扣额。
当前 exact head 复核 / Exact-head validation
PR #9490 当前精确头为 c5237df113a8e2825fe14fc09a490145c25ce83e。本轮在最新 main 上以本地 shadow 树重新验证该差异,未改变远端 fork head。
在本地 rebase 树上重新执行:183 项 settlement、turn-envelope、quota budget 与相关测试通过,11 项环境相关用例跳过;Ruff、diff 检查和标准 premerge 的 14 项选定检查通过。refresh_settlement.py 的 mypy 诊断与 origin/main 完全一致(8 项既有问题、0 新增)。该 fork head 因外部仓库写权限不可写回,但原 PR head 仍为可合并的精确提交,功能差异已按同一树独立验证。
我的整体评价 / Verdict
APPROVE。 旧审查指出的 Windows 测试错误已修正。原生命令对照与拒绝回读通过,此精确头未发现阻塞。 宿主能够准确区分结算已完成和传输方式受限,原 Turn 继续可恢复。
English verdict: APPROVE at c5237df. The generated File and SQLite settlement commands retain identity and exactly one spend, return successful inline receipts without private capture, and preserve the original refusal and recovery controls.
|
合并后的原生 Windows 验证 PR 描述和评审都写明没有在原生 Windows 上验证过。补上这块:
以下是我在这台机器上的结果:Windows 10,Python 3.12,Node 24.20, 修复对 #9398 的原始复现有效
本 PR 的新测试
内联结果的大小 同一场景下,完整的内联结果在 stdout 上约 10 KB(file 9,975 字节,sqlite 10,033 字节,51 个顶层字段),低于 64,000 字节的分页预算。这是小夹具的数字;Todo 很多的大型 Goal 会更大,我没有测量。 没有引入新的 Windows 失败
两点观察,都不阻塞
未验证
|
Refs #9398.
Reproduced defect
On native Windows, the settlement command the Turn plan publishes
(
refresh-state ... --settle-turn --settlement-receipt) commits the spend andthen reports failure: exit 1,
ok=false,appended=true,settlement_progress.state=settled. The error text tells the caller to drop--max-page-output-bytes, but the composed command never carried that option,so the advice cannot be followed.
present_settled_refreshalways re-projected a settled result throughbudgeted_settlement_result, which callsprivate_capture_uid()beforeconsulting the output budget. That predicate intentionally fails closed off
POSIX, so every plan-composed settlement on such a host turned commitment into a
transport error.
Change
present_settled_refreshnow checksprivate_capture_supported()beforeattempting a private capture. When unsupported it keeps the already evaluated
result inline, records the skipped capture as
result_delivery_errorwitherror_code=quota_decision_capture_unsupportedplus guidance that matches thecommand the caller actually received, and leaves the exit code to the evaluated
outcome. A committed settlement exits 0 with its identity and receipts; a
refused one still exits nonzero with its recovery step. POSIX keeps the bounded
receipt and
result_details.commandunchanged.docs/reference/required-work-context.mdrecords the platform difference inEnglish and Chinese.
Validation
test_composed_settlement_keeps_commit_when_private_capture_is_unsupporteddrives the real public CLI with the capture predicate reported unsupported:
committed settlement returns exit 0 with identity and all three receipts
inline, exactly one spend, replay is idempotent and creates no second debit,
no
context-deliverydirectory is written, and the same Turn on acapture-capable host still returns the bounded receipt without the warning.
tests/control_plane/test_refresh_settle_turn.py -k "not sqlite": 39 passed,5 skipped.
tests/control_plane/test_turn_envelope_settlement.py: 11 passed.tests/control_plane/test_quota_settlement.pyandtest_quota_result_budget.pycapture subset: 10 passed.test_execution_loss_closeout_cli.py::test_combined_writeback_keeps_the_admitted_lease_generation:both file variants pass; the SQLite variants are blocked in this environment
by the local Node SQLite 3.49.1 qualification gate, unrelated to this change.
Not verified here: native Windows, a real Host reaction to the exit code, or
hosted CI.