Skip to content

fix(settlement): preserve producing workspace in combined refresh - #7533

Merged
huangruiteng merged 2 commits into
mainfrom
codex/refresh-settlement-workspace-20261028
Oct 28, 2026
Merged

huangruiteng merged 2 commits into
mainfrom
codex/refresh-settlement-workspace-20261028

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

refresh-state --settle-turn --delivery-workspace-path <worktree> could commit valid progress and then fail accounting because its child inherited the registry checkout. The caller had to recover the original owed command manually. This change carries the producing cwd into the existing complete CLI while pinning imports to the originating CLI package. A different LoopX package in the delivered project cannot replace the accounting implementation.

The TypeScript settlement and workspace owners retain exact identity, repository/revision refusal, validation, one-debit replay and original-command recovery. The Python adapter changes process context only; no configuration, second owner or budget rule is added. The bounded refactor separates import provenance from accounting cwd inside the existing adapter. Rollback is this commit.

Author: model_agent, OpenAI Codex. Specification: the combined writeback/settlement paragraph in docs/reference/protocols/turn-envelope-v0.md at main 9558f75ae52e8a0c9f74ad7df0f47a69e0d413ad.

Criterion Disposition Evidence
Preserve the original owed command and one debit implemented File/SQLite CLI, exact replay and lost-response tests
Use the named producing worktree implemented Relative path with spaces; linked-worktree fixture
Retain originating implementation and guards implemented Conflicting-package fixture; wrong/missing workspace and invalid-path recovery
Preserve no-option, failed-validation and no-spend paths implemented Ordinary combined CLI negative/parity cases

Validation at rebased head c6e9ed623be8f3d1ebb0a0628b141dfe841522b1:

  • All four proposed file blobs are unchanged by the rebase onto 9558f75ae52e8a0c9f74ad7df0f47a69e0d413ad; DCO sign-off retained.
  • 214 Python cases passed, zero skipped: 16 combined CLI cases, 34 workspace/causality cases and the full 164-case quota-settlement CLI suite. These cover File/SQLite, exact identity, replay, failed/dry/no-spend paths, source refusal, conflicting packages and original-command recovery.
  • Standard diff-selected premerge: 6 direct and 14 selected checks passed, zero failures, warnings or manual holds. Actual four source files and this exact description passed public-boundary checks; no paired RFC changed.
  • Current packaged Chat build and real SQLite delegation search/original-reader refresh smokes passed locally. The previous-head Linux job passed all 27 packaged workspace scenarios, including the map, then failed at the delegation-search fixture entry. The rebase includes the existing mainline repair; the local checks do not certify new-head Linux CI or explain older intermittent map timeouts.
  • Earlier isolated-wheel qualification at c56990477cc05e27a1b22a933eaae44bf18dad9f remains historical: the exact changed modules passed File/SQLite linked-worktree/conflicting-package cases with source PYTHONPATH removed. It was not rerun or relabeled as current-head installed qualification. Its initial stale-bundle build refusal remains recorded.

Synthetic/public fixtures only; no paid model or real benchmark scoring. Windows and real PostgreSQL were not run locally; storage semantics/providers are unchanged. Model behavior, benchmark outcomes, full fees and active-host installation remain unqualified by this repair.

UI impact: none in this four-file proposal. It repairs the existing agent operation and receipt readback; no settings or screens change. Required new-head review, remote CI, exact-head merge readiness and maintainer merge authority remain separate.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/refresh-settlement-workspace-20261028 branch from c569904 to c6e9ed6 Compare October 27, 2026 23:52

@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; model=gpt-6.1-sol; provider=OpenAI; declaration_source=runtime_reported; reasoning_effort=max
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

APPROVE,精确 head c6e9ed623be8f3d1ebb0a0628b141dfe841522b1,未发现阻塞项。实际 base 9558f75ae52e8a0c9f74ad7df0f47a69e0d413ad。

动机 / Motivation

从登记仓库为另一交付worktree提交成果的CLI调用方。 成果在独立worktree生成,refresh已验证写回,但组合结算子进程留在登记仓库,因工作区不符拒绝扣额;修复后它在已指定交付目录执行原待结算命令。 File与SQLite的真实CLI对照均完成原身份结算,重放只保留一次扣额,交付目录中的另一LoopX包没有替换原实现。 不新增准入、配置或扣额规则,也不自动完成Todo、安装运行时或改变调度。 正式宿主采用、平台全矩阵和长期完整成本仍由原交付工作验收,本切片不关闭这些父级要求。

改动思路 / Approach

结算语义继续归原TypeScript owner,Python只运输既有工作目录并固定原CLI导入来源;没有第二套账户、workspace或授权判断。 当前PR闭合已验证写回到同身份CLI结算这一可独立回退的路径,保留原失败恢复和无选项行为。 保持不变会继续让合法交付在写回后失败;只换cwd会误导入交付项目的另一个LoopX。现在分开导入来源与工作目录,仍走包含原guard、hook及回执的完整CLI。无需新增配置、重输已知信息或向用户增加确认回合。

具体改动 / Changes

规范是 docs/reference/protocols/turn-envelope-v0.md,固定 revision 9558f75ae52e8a0c9f74ad7df0f47a69e0d413ad 的原组合结算段。以下原文准则均 implemented:same Goal, Agent, Todo/obligation and Turn、verifies receipts、cannot debit twice、Ordinary refresh without the option;分别对应精确argv验证、原回执读回、失响应/重放以及无选项路径。新文档仅明确工作目录和实现来源。

关键代码讲解

  • _settle_requested_refresh:把已有delivery_workspace_path传到组合适配器;仍只在明确请求settle-turn时进入。
  • settle_refreshed_turn:先验证原owed argv,再以交付cwd执行固定来源的完整CLI,最终回读原回执。

child使用sys.executable -P -c,把原包根置于模块搜索首项,以cwd指定交付目录;没有从PATH选择另一个loopx,也没有直调底层debit。原命令Goal/Agent/Todo/Turn、registry、runtime、source和slots仍由真实parser逐项检查。

当前head完整受影响Python套件232项通过、0跳过;标准premerge为6 direct +14 selected全通过,零失败、警告或manual hold。独立合成File/SQLite场景先不带settle验证已写回/0debit,再加settle并重放:两例通过、Todo仍open、原身份不变、只有1次扣额,冲突包标记未出现。相同测试在不可变base两例均失败,具体原因为quota spend workspace does not match the latest unspent accountable delivery workspace,历史失败未改写。

对主干的风险 / Risks

最强风险是切cwd时换了CLI实现,或为达成扣额绕开原guard;冲突包、独立worktree、相对含空格路径与原身份对照覆盖这一点。完整组合/结算/workspace套件保留错误Turn、缺失或错误cwd、dry-run、后置条件失败、原Todo完成/未完成及失响应负例。真实回执优先于child传输结果;失败沿原owed命令恢复,不能盲目重复效果。

语义与 CI 对齐

原typed结算/workspace owner仍是唯一决策来源,无新增状态、闭合集合或业务领域特例。双语说明公开了旧cwd失败与新行为;机器校验仍是强约束,不是可忽略建议。依wait_for_ci=false未查询、轮询或等待CI;本地验证不等于merge-readiness或合并授权。未执行native Windows、真实PostgreSQL或当前隔离wheel;未验证正式安装、模型理解及长程净收益。存储语义未改,历史失败和旧wheel结果不倒补当前资格。

我的整体评价 / Verdict

这是 justified_increment。结算语义继续归原TypeScript owner,Python只运输既有工作目录并固定原CLI导入来源;没有第二套账户、workspace或授权判断。 当前PR闭合已验证写回到同身份CLI结算这一可独立回退的路径,保留原失败恢复和无选项行为。 long_horizon preserved,user_experience improved:已授权成果可以沿同一入口直接收尾,恢复和原承诺保留,没有新增人机回合。已检查完整四文件、CLI公开入口及其既有结果读回;本PR不改变渲染页面或设置,visual_review不适用。 未验证范围:未执行native Windows、真实PostgreSQL或当前隔离wheel;未验证正式安装、模型理解及长程净收益。存储语义未改,历史失败和旧wheel结果不倒补当前资格。 正式宿主采用、平台全矩阵和长期完整成本仍由原交付工作验收,本切片不关闭这些父级要求。

English verdict: APPROVE c6e9ed623be8f3d1ebb0a0628b141dfe841522b1. Real File/SQLite CLI counterfactuals establish producing-workspace settlement with the originating implementation and one debit; broader installed and model outcomes remain unverified.

@huangruiteng
huangruiteng merged commit c179d20 into main Oct 28, 2026
4 of 6 checks passed
@huangruiteng
huangruiteng deleted the codex/refresh-settlement-workspace-20261028 branch October 28, 2026 09:59
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