Skip to content

fix(quota): preserve execution-loss closeout during writer recovery - #9246

Open
loopx-agent wants to merge 7 commits into
mainfrom
codex/heartbeat-turn-envelope-continuation-20261122
Open

loopx-agent wants to merge 7 commits into
mainfrom
codex/heartbeat-turn-envelope-continuation-20261122

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Goal and reproduced failure

When a prior Turn lost its prepared execution lease and the replacement lease later becomes inactive, the guard identifies the outstanding administrative closeout. An ordinary claim projection can nevertheless replace the recovery commands in the final interaction contract. The same Agent can claim its Todo, then has no closeout preview in that response. This reproduces through the public CLI on both File and SQLite.

Delivered outcome

The prior-Turn recovery projection removes ordinary current-work preparation. When canonical state shows an inactive lease for the retained, eligible assignee, the recovery action list offers an ordinary managed claim, current-proof readback and the original Turn's administrative preview. If ownership changed, the response gives inspection and continues to require verified original-Agent authority. The claim and administrative commit still perform their own checks. Selecting the recovery advice grants neither ordinary delivery nor quota spend.

Verification

  • Tested head: 495e3a2f46f22eef2ddc103c84757f06c9ecf2ba. Base: 0814f04e9456899600f3a3c4efccfd7775382cd8. The focused File/SQLite CLI, preparation and recovery suite passed 129 tests. Standard premerge passed 13 checks. TypeScript typecheck and Ruff passed.
  • Baseline on File and SQLite retains the stale ordinary preparation. The regression exercises commands from the real guard through inspection, claim, preview, closeout and replay. A peer's lease yields no self-claim command.
  • A closeout has the original identity, appends no debit, leaves the Todo open and returns the same receipt on replay.
  • The CLI recovery contract has no visual layout changes. Validation uses public-safe, isolated fixtures.

Prior head and Package Smoke

  • Tested head: 94fde408863d33d65fd93ea430938fc5351161c2. The branch incorporates main at 02fd18df7fa119f21611646853b5d14d6448f15e. The comparison still contains the four recovery files and their original behavioral diff. Exact comparison
  • The previous Package Smoke failure tried to parse the literal catalog entry workbench start|status|stop. Fresh standalone Core wheels from the pre-fix main commit and the recovery composition both reproduced the catalog test failure. The already-merged catalog correction lists the three real commands. Failed job, Catalog fix #9240
  • On that tree, 58 tests passed in the two Package Smoke qualification suites. The tests ran serially against a fresh installed Core wheel in Python 3.11 on macOS arm64. The independent review remains pending.
  • On that exact head, 49 tests passed in the focused execution-loss, admission and heartbeat tests. Quick premerge passed six direct and three selected checks.

Recovery across installed packages

The isolated upgrade probe started with the installed build of main at 856cd6ad8fb93bcb8e3a4a1a2f98701da2b07cdc. It created an original Turn, replaced its lease, and released the replacement lease. With the original assignee retained, the older guard omitted the administrative preview on both File and SQLite.

The same registry, runtime and receipt bytes were then opened by a Core wheel built from the merge tree of 94fde408863d33d65fd93ea430938fc5351161c2 and #9180 at 4433e1aed61c380d9118f230cc285243cd2a1a7e. That composed tree is 1b648192739b953bef8483e5597857a93e891ef9.

  • On both providers the new guard offered the retained assignee the claim and preview for the original Turn. The preview made no changes. The closeout preserved the original admission, settled with zero debits and kept the Todo open. Replay made no further write.
  • A peer-owned replacement offered no self-claim on either provider. A closeout with the stale peer proof was refused without effects.
  • In the same wheel, explicit settlement recovered one definitive quota-index conflict with one original debit. Persistent conflict retained the original settlement command without a debit. The composed source tests passed 16 cases and the installed Core suites passed 58 tests on macOS.

Hosted Package Smoke and the real PostgreSQL authority check passed on 94fde408863d33d65fd93ea430938fc5351161c2. The combined-wheel verification is a local installation and persisted-state compatibility check. Independent review, full hosted qualification and production activation remain separate acceptance steps.

Hosted Core package check · Hosted PostgreSQL authority check

Validation after syncing main

That sync advanced the PR to a8fa33927b876647c15ddb6911e8ca265479e2cd, based on 287616201b81b53824cae570265220ab4142a4b7. The four-file recovery diff is byte-for-byte identical. The focused recovery and release-gate suite passed 18 tests. Standard premerge passed six direct checks and 13 selected checks. Exact comparison

A fresh Core wheel from the merge tree of the new head and #9180 at 4433e1aed61c380d9118f230cc285243cd2a1a7e (d84a6790d674f2c5ce5d96d9faa3e3fd022ef553) repeated the persisted-state handoff on File and SQLite. The retained assignee closed the original Turn without a debit and replay made no further write. Both providers rejected the stale peer proof. A single quota conflict produced one debit, and persistent conflict left the original spend pending with zero debits. These runs used isolated registries with the installed Core wheel. Hosted checks and independent review on the new PR head are pending.

In-place installer rehearsal

The shipped local installer ran against the combined tree d84a6790d674f2c5ce5d96d9faa3e3fd022ef553 using isolated File and SQLite registries that already held pending Turns from an earlier installed 2.4.0 runtime. Installation switched both the loopx and scheduler fallback launchers. Through the new CLI launcher, ordinary recovery kept the original admission and settled without a debit, replay caused no further write, and a stale peer proof was denied on both providers.

The shipped rollback command restored both previous launchers. The previous runtime read back the same admission and recognized the recovered Turn as settled. The Mac had two default state roots. The first rollback plan held without switching either launcher, then succeeded when the exact isolated registry and runtime root were passed explicitly. These are isolated installer and binary rollback results. Hosted review and production activation remain separate acceptance steps.

Runtime-root aliases at the previous head

Head 8b8430d5b7a023ee39d9a9f77d2999110aebe151 includes main at bbd26838366cf03b371f5a2308833e03d1e1229b. An explicit runtime-root alias formerly let Python hand off physical lock paths while the receiving operation compared them with the alias spelling. The closeout adapter now resolves the runtime root before obtaining and handing off the same locks. Original identity, ownership, lock tokens and quota checks continue through the existing owners.

  • On File and SQLite, both public CLI alias cases reproduced the previous writer-lock rejection. The exact updated head passed all 16 execution-loss tests.
  • The installed Core wheel from this head closed the retained assignee's original Turn through a directory alias with zero debits on both providers. A different assignee still received no self-claim path. The fixtures used isolated state and the normal CLI dispatch.
  • Standard diff-selected premerge passed all 13 selected checks and its direct checks.
  • This update remains pending independent exact-head review.

Pinned launcher recovery

The generated execution-loss closeout command preserves the launcher with the global --cli-bin option. The closeout adapter forwarded that rendering option to the administrative effect validator, which rejected the command before either preview or recovery. The adapter now filters this one option at the CLI boundary. The existing checks for permitted effects still apply to the remaining arguments.

  • The previous implementation reproduced the rejection on File and SQLite. All 17 execution-loss CLI cases pass with the fix, including recovery of the same Turn, zero quota debits, idempotent replay and rejection of business effects or invalid writer proof.
  • The installed Core wheel was exercised through its own launcher on both providers. The generated command preserved --cli-bin, preview left state untouched, closeout settled the original Turn once without a debit, and the next guard resumed normal admission.
  • Head b99ac75a3dbcd0b2fbe5aa100293e37b780e3404 includes main at adf4f44148da9768e4ca82feb608683cf2097215 and preserves its canonical write-timeout regression. TypeScript type-checking and the six-file public-boundary scan passed. Standard diff-selected premerge passed all 16 selected smokes and its direct checks. Independent review is pending.

Review scope

This is a follow-up to #9242. The existing recovery admission cap, persisted settlement representation, provider write fences and required eligibility checks remain in force. The implementation uses the existing configuration and stored receipts.

Author declaration

OpenAI Codex model-agent. DCO signed.

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: 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 · Gemini · Google · self_reported

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

本次对 loopx-project/loopx#9246 精确提交 a8fa33927b876647c15ddb6911e8ca265479e2cd(相对最新 origin/main 基线 287616201b81b53824cae570265220ab4142a4b7)完成独立代码审阅、File/SQLite 双端 CLI 测试与反例验证(遵循 wait_for_ci: false 本地先行策略);本 PR 为 loopx-agent 自提交,按 author-owned PR 规则发布 COMMENTED 审批结论并保持 PR 开启。

动机 / Motivation

面向在硬租约(hard_lease)下遭遇前置执行租约换代且原 Turn 尚未开始写回或扣额、需要完成无扣额行政结案的 Agent 与运行器调用方。 修改前当替换租约随后失效或释放时,unsettled_host_turn 遗留了普通工作阶段生成的 execution_preparation,导致 interaction_contract.cli_channel.next_cli_actions 被普通 claim 命令覆盖而丢失 --execution-loss-closeout --dry-run 预览;修改后在 File 与 SQLite 上保留完整 closeout 预览链路,并仅当原 Agent 仍保留 Todo 归属且未完成、未被排除时才给出普通 todo claim 取证指引。 恢复契约在控制写入凭据失效时不再被普通当前工作准备动作劫持,原归属 Agent 可依引导重取控制写入租约并完成无扣额 closeout,而异主或受限情况严格保持等待且零扣额、零越权。 本 PR 不放宽执行损失 closeout 的写入栅栏与时序校验证明、不授予旧 Turn 业务交付权,也不修改其他恢复模式或配额扣减账本结构。

改动思路 / Approach

由 TypeScript 侧 observeFencedExecution 统一判断原控制写入者是否仍保有 Todo 归属且具备重取条件(can_reclaim_control_writer),Python 侧仅在 execution_loss_closeout 分支清理遗留的普通 execution_preparation 并按该布尔标记渲染命令提示。

当前 PR 边界严格锁定在硬租约换代后替代租约失效时的恢复动作投影与控制写入凭据重取引导,不放宽任何 closeout 提交校验或跨越非 execution_loss_closeout 恢复路径。 具体路径上,先在 TS 侧 observeFencedExecution 将控制写入匹配拆分为 writerMatches(核验 claimed_by、lease.owner、todo.done !== true、leaseRepositoryRejection === null 及未在 excluded_agents 中)与 active(叠加 leaseIsActive),导出 can_reclaim_control_writer: writerMatches && !active;随后 Python _apply_recovery_projection 在 repair == "execution_loss_closeout" 时弹出此前普通工作准备阶段附带的 execution_preparation,防止 attach_interaction_execution_preparation 把 next_cli_actions 覆写成 [claim_command];最终 recovery_cli_actions 仅在 can_reclaim_control_writer 为真且具备 lifecycle_actor_args 时补充 todo claim --thin + task-lease inspect,再衔接原 --execution-loss-closeout --dry-run 与正式提交指令。

具体改动 / Changes

全部 4 个文件相对基线 287616201b81b53824cae570265220ab4142a4b7 共 +88 / -9 行(3 个生产文件与 1 个双后端 CLI 集成测试文件)。依据契约文档 docs/quota-allocation.md(基线提交 287616201b81b53824cae570265220ab4142a4b7)逐条核对验收标准:

  • ELC-1(换代后指向 execution_loss_closeout 且保留 refresh-state --execution-loss-closeout --dry-run 预览与无扣额提交链路):implemented,由 _apply_recovery_projection 清除 execution_preparation 与 recovery_cli_actions 保障,经 test_closeout_preserves_the_original_turn_and_releases_the_next_guard 验证。
  • ELC-2(保留原 Todo 开放并可由原 Agent 依法续领控制写入凭据后再行 closeout):implemented,由 observeFencedExecution 导出 can_reclaim_control_writer 与 recovery_cli_actions 条件引导 todo claim --thin 实现,经 test_recovery_guides_self_claim_only_for_the_retained_assignee[file/sqlite-OWNER] 验证。
  • ELC-3(控制写入凭据归属他人或不可用时不引导越权自领并保持等待):implemented,writerMatches 校验 owner/done/excluded_agents 并在非原主时阻断 claim 指引,经 PEER 参数化测试与 5 组 TS 反例验证。

关键代码讲解

  1. observeFencedExecution
    在现有 FileAuthorityStore / SqliteAuthorityStore 只读快照校验中,将原先内联在 current_control_writer_active 内的所有者判断提取为 writerMatches,新增 todo.done !== true 与 canonicalLeaseTodoFact(todo)?.excluded_agents.includes(identity.agent_id) === false 两重守护,再区分活跃租约(current_control_writer_active)与可重领的失效租约(can_reclaim_control_writer: writerMatches && !active)。
  2. _apply_recovery_projection
    在清理 selected_todo、todo_id 与 action_portfolio 后,若 recovery.get("repair") == "execution_loss_closeout",显式弹出普通准入遗留的 execution_preparation,避免后续 _build_interaction_contract_projection 调用 attach_interaction_execution_preparation 时覆写恢复动作列表。
  3. recovery_cli_actions
    先输出 task-lease inspect;仅当 proof.get("can_reclaim_control_writer") is True and lifecycle_actor_args 时额外插入标准 todo claim ... --claimed-by <owner> --thin 与二次 inspect,随后始终输出带 --dry-run 的 --execution-loss-closeout 预览与非 dry-run 执行引导。

对主干的风险 / Risks

经独立检验与双端反例复现,未发现阻塞合入的问题(no blocking finding)。

精确提交 a8fa33927b876647c15ddb6911e8ca265479e2cd 本地实测矩阵如下:

  • TypeScript 与静态检查:npm run typecheck:control-plane 通过(0 错误);node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/unsettled_host_turn_recovery.test.ts tests/control_plane_ts/execution_preparation.test.ts tests/control_plane_ts/turn_settlement.test.ts 107/107 passed;ruff check 全部 .py 文件通过;mypy(17 个 strict 核心文件)0 错误且 mypy --follow-imports=silent 在受触 2 个控制面 Python 文件 0 错误;check_rfc_bilingual.py 通过;loopx check 0 错误。
  • Pytest File/SQLite CLI 集成测试:tests/control_plane/test_execution_loss_closeout_cli.py 12 passed in 109.64s(0 failed, 0 skipped),实测覆盖 File 与 SQLite 两大后端上的保留所有者释放租约自领恢复全链路、异主 PEER 拒领、--dry-run 预览与无扣额幂等提交回放。
  • Canary Premerge:status=passed、merge_gate_passed=True、direct_checks 6/6、catalog_canaries 5/5、risk_profile_smokes 8/8(failures=0, manual_hold_count=0)。
  • 反例复验:在 a8fa33927b 上构造并实跑 5 组 observeFencedExecution 状态转移反例及空 lifecycle_actor_args 测试,证实:释放态归属同主返回 active=false, can_reclaim=true;活跃态归属同主返回 active=true, can_reclaim=false;done=true、excluded_agents 包含原 Agent、以及 claimed_by/owner 易主均返回 can_reclaim=false;缺省 lifecycle_actor_args 时不拼装残缺 todo claim 命令。
  • 残余边界:本机未连外部 PostgreSQL 实例(observeFencedExecution 本身明确限域在本地 File/SQLite hard_lease 存储,已按规披露)。

我的整体评价 / Verdict

综合评估精确提交 a8fa33927b876647c15ddb6911e8ca265479e2cd:long_horizon 与 user_experience 均评估为 improved(消除了替换租约释放后恢复动作被普通 execution_preparation 静默覆盖导致的卡死,让原归属 Agent 可直接按引导重新取证并完成无扣额 closeout);本 PR 仅修复控制面租约恢复投影与 CLI 动作生成逻辑,不涉及任何前端渲染或用户界面组件。未验证范围:none。由 TypeScript 侧 observeFencedExecution 统一判断原控制写入者是否仍保有 Todo 归属且具备重取条件(can_reclaim_control_writer),Python 侧仅在 execution_loss_closeout 分支清理遗留的普通 execution_preparation 并按该布尔标记渲染命令提示。 当前 PR 边界严格锁定在硬租约换代后替代租约失效时的恢复动作投影与控制写入凭据重取引导,不放宽任何 closeout 提交校验或跨越非 execution_loss_closeout 恢复路径。 语义词汇策略为 local_only(仅在既有恢复观察载荷上追加内部只读布尔提示 can_reclaim_control_writer,不改动持久化事务日志或公共命令状态枚举)。

English verdict: APPROVE at a8fa339. Verified execution_preparation cleanup on execution_loss_closeout recovery and scoped can_reclaim_control_writer guidance across File and SQLite authorities. Passed tsc, ruff, strict + file mypy, loopx check, 107/107 TS recovery/preparation/settlement tests, 12/12 File/SQLite CLI closeout tests, 13/13 canary premerge smokes, and 6 negative/boundary counterfactuals.

…ecution-loss-runtime-root-alias-20261122

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
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 · Gemini · Google · self_reported

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

本次对 loopx-project/loopx#9246 精确提交 8b8430d5b7a023ee39d9a9f77d2999110aebe151(基线 main 提交 bbd26838366cf03b371f5a2308833e03d1e1229b)执行了完整独立的代码审阅、静态检查、TS/Python 测试与跨版本真实 CLI 反例验证(遵循本地先行、wait_for_ci: false 策略);因本 PR 由 loopx-agent 自提交,按 author-owned PR 规则以 COMMENTED 形式发布审批结论并保持 PR 开启。

动机 / Motivation

在启用硬租约(hard_lease)的 Goal 中,遭遇前置执行租约换代且替代租约随后释放或过期、需要为原 Turn 完成无扣额执行损失结案(execution_loss_closeout)的 Agent 与 CLI/运行器调用方,以及通过符号链接目录别名传入 runtime_root 的本地执行环境。

修改前存在两处断点:第一,当原 Turn 的准备租约被换代且替代租约已释放或过期而原 Agent 仍保有 Todo 认领时,quota should-run 在恢复判定前已将普通工作准备状态 execution_preparation(claim_required)写入载荷并保留至交互契约,使 cli_channel.next_cli_actions 被普通 todo claim 覆盖而丢失 refresh-state --execution-loss-closeout --dry-run 预览入口;第二,当 --runtime-root 或 common_runtime_root 指向目录符号链接别名时,commit_execution_loss_closeout 将未解析的别名路径传给 TypeScript 提交器,而跨运行时锁见证携带解析后的物理路径,导致 writer lock target differs 拒绝预览与提交。修改后,execution_loss_closeout 恢复路径清除普通 execution_preparation,仅在原 Agent 仍保有开放且未排除的 Todo 归属时条件提供 todo claim --thin 取证引导,并在提交前统一解析 runtime_root 物理路径。

在 File 与 SQLite 双后端以及直接路径和符号链接别名路径下,quota should-run 均保留完整 --execution-loss-closeout --dry-run 预览与提交命令链;仅当原 Agent 仍保有未完成且未被排除的 Todo 归属时才输出 todo claim --thin 引导,异主或已禁止认领情况只提供只读探查与等待提示;经由符号链接别名调用 refresh-state --execution-loss-closeout 时可顺利完成预览、零扣额提交与幂等重放,且保持原 Todo 开放并零配额扣减。

本 PR 不放宽 execution-loss closeout 的写入栅栏、注册校验与时间戳顺序检验,不赋予替代租约旧 Turn 业务交付权,不改动普通 resume_prior_turn 恢复分支对 execution_preparation 的保留行为,也不引入新的持久化事务日志字段或公共协议状态值。

改动思路 / Approach

由 TypeScript 侧 observeFencedExecution 统一承担原控制写入者归属与可重领条件判断(can_reclaim_control_writer),Python 侧仅在 execution_loss_closeout 恢复投影阶段剥离普通工作准备遗留的 execution_preparation、渲染受条件约束的 CLI 动作并在锁见证交接前规范化 runtime_root 物理路径,保持策略决策归属单一且未新增状态存储。

当前 PR 边界严格限定在硬租约换代后替代租约失效时的 execution_loss_closeout 动作投影、自领引导开关与 runtime_root 别名锁对齐,不触及独立于 runtime_root 的 legacy source_registry 符号链接解析也不跨入非 execution_loss_closeout 恢复模式。

环节 修改前行为(基线 / 中间提交) 当前提交 8b8430d5b7 行为 决策归属
恢复动作保留 execution_preparation 保留并覆写 next_cli_actions repair == "execution_loss_closeout" 时弹出 execution_preparation Python 投影清理
取证引导开关 仅输出 current_control_writer_active 与通用提示 observeFencedExecution 导出 can_reclaim_control_writer;仅原主可用时加 todo claim --thin TS 策略判断 + Python 渲染
别名路径交接 未解析 runtime_root 与物理锁见证路径冲突 commit_execution_loss_closeout 对 resolve_runtime_root(...) 调用 .resolve() Python 传输适配层

具体改动 / Changes

全部 5 个文件相对基线 bbd26838366cf03b371f5a2308833e03d1e1229b 共 +102 / -10 行(4 个生产文件与 1 个双后端 CLI 集成测试文件)。依据契约文档 docs/quota-allocation.md(固定基线提交 bbd26838366cf03b371f5a2308833e03d1e1229b,Receipt-backed settlement progress 章节)逐条映射如下:

  • receipt-backed-settlement-progress.execution-loss-closeout-projection(已实现 implemented):当替代租约换代且未开始写回/扣额时,恢复路径保留 refresh-state --execution-loss-closeout --dry-run 预览及无扣额提交流程,不被普通 execution_preparation 覆盖;由 _apply_recovery_projection 与 test_closeout_preserves_the_original_turn_and_releases_the_next_guard 验证。
  • receipt-backed-settlement-progress.control-writer-claim-and-preview(已实现 implemented):原 Agent 仍保留未完成且未排除的 Todo 归属且当前控制租约非活跃时,允许先经普通 todo claim --thin 取得控制写入凭据后再行预览与提交,不授予旧 Turn 业务交付权;由 observeFencedExecution 与 recovery_cli_actions 实现,并经双端 OWNER 释放与过期复现验证。
  • receipt-backed-settlement-progress.foreign-or-missing-writer-hold(已实现 implemented):当前控制写入凭据归属他人、Todo 已标记 done、原 Agent 被排除或仓库漂移时,不引导自领并保持阻塞等待;由 observeFencedExecution 拦截,并经 PEER 参数化测试与 16 组 TS 反例验证。
  • receipt-backed-settlement-progress.alias-safe-lock-handoff(已实现 implemented):通过符号链接别名传入 runtime_root 时,锁目标与物理锁见证一致,预览与提交在 File 与 SQLite 上均可完成;由 commit_execution_loss_closeout 实现,并经 runtime-root-alias 参数化测试与 exact-source 别名探针验证。

关键代码讲解

  1. observeFencedExecution:在现有 File/SQLite 只读权威快照检查中,将所有者校验提取为 writerMatches(核对 todo.claimed_by === identity.agent_id、lease.owner === identity.agent_id、todo.done !== true、leaseRepositoryRejection(todo, lease) === null 及 excluded_agents 未包含原 Agent),将 current_control_writer_active 与 can_reclaim_control_writer: writerMatches && !active 分离导出,使失效但同主可重领状态可被显式区分。
  2. _apply_recovery_projection:在清理 selected_todo、todo_id 与 action_portfolio 后,若 recovery.get("repair") == "execution_loss_closeout" 则弹出先前普通准入附带的 execution_preparation,防止后续 _build_interaction_contract_projection 中的 attach_interaction_execution_preparation 把 next_cli_actions 覆写成 [claim_command] 并篡改 agent_channel.must_attempt。
  3. recovery_cli_actions:在 execution_loss_closeout 分支先输出 task-lease inspect;仅当 proof.get("can_reclaim_control_writer") is True and lifecycle_actor_args 时追加普通 todo claim ... --claimed-by <owner> --thin 与二次 inspect,随后再衔接 --execution-loss-closeout --dry-run 预览与非 dry-run 执行说明,缺省 actor 参数时保持安全不拼装残缺命令。
  4. commit_execution_loss_closeout:在构建跨运行时锁目标与发送 quota.execution_loss_closeout.commit 请求前,对 resolve_runtime_root(registry, runtime_root_override, registry_path=registry_path) 执行 .resolve(),使其与 cross_runtime_lock_witness 写入的物理路径一致,消除符号链接别名下 TS 侧 writer lock target differs 误拒。

对主干的风险 / Risks

经独立复核与跨基线反例测试,未发现阻塞合入的问题(no blocking finding)。

在精确提交 8b8430d5b7a023ee39d9a9f77d2999110aebe151 的本地全量验证矩阵如下(未咨询远端 CI,wait_for_ci: false):

  • TypeScript 与静态类型/规范检查:npm run typecheck:control-plane 通过(0 错误);6 套 TS 单测文件(unsettled_host_turn_recovery、execution_preparation、turn_settlement、quota_settlement_readback、interaction_execution_decision、refresh_recovery)288/288 通过;ruff check loopx tests 通过;mypy(17 个 strict 核心文件)及受触 3 个 Python 文件 mypy --follow-imports=silent 均为 0 错误;check_rfc_bilingual.py 通过;loopx check 对 5 个变更文件扫描 0 错误、0 警告。
  • Pytest File/SQLite 集成测试:test_execution_loss_closeout_cli.py、test_quota_execution_preparation.py、test_unsettled_recovery_admission_bound.py 与 test_codex_execution_preparation.py 共 150 passed(0 failed, 0 skipped),覆盖 File 与 SQLite 双后端、legacy 与 exact-source 配置、直接路径与 runtime-root-alias 符号链接路径的保留自领、异主拒绝、预览、零扣额提交及幂等重放。
  • Premerge 门禁检查:canary premerge --from-git-diff --git-diff-base origin/main --tier standard 执行直接检查 6/6 通过、目录金丝雀 5/5 通过、风险剖面烟测 8/8 通过、manual_hold_count=0(注:Goal 绑定策略下的 change_quality_qualification 尚缺精确范围回执,属合并前发布门禁而非代码缺陷)。
  • 独立基线对比与反例验证:在 bbd26838366cf03b371f5a2308833e03d1e1229b 复现 execution_preparation 覆盖恢复动作缺失 --dry-run 预览的问题,在历史提交 a8fa33927b 复现符号链接 runtime_root 触发 writer lock target differs 的问题,并在 8b8430d5b7a023ee39d9a9f77d2999110aebe151 验证双方修复通过;另外构造并运行了 16 组 File/SQLite observeFencedExecution 反例(覆盖同主已释放、同主活跃、同主已过期未释放、done=true、excluded_agents、claimed_by 易主、lease.owner 易主、仓库漂移)、空 lifecycle_actor_args 测试、exact-source 别名关闭测试、墙钟过期未释放租约完整 CLI 链路测试及同代 resume_prior_turn 回归对比(确认非 execution_loss_closeout 路径未受误删)。
  • 残余风险与边界披露:(1)本地未连接外部 PostgreSQL 服务(observeFencedExecution 与 commitExecutionLossCloseout 本身显式限定于 File/SQLite 本地 hard_lease 存储);(2)在独立探索中观察到一项既有边界:execution_loss_closeout.ts 中 legacy goal.source_registry 上游路径比对使用词法 path.resolve 而非真实路径解析,若 legacy 镜像的 source_registry 本身指向符号链接别名路径会触发 current legacy source route differs from its lifetime admission;该行为在基线 bbd26838366cf03b371f5a2308833e03d1e1229b 已存在且不属本 PR 变更面,记作后续可选改进(follow_up)。

我的整体评价 / Verdict

综合评估精确提交 8b8430d5b7a023ee39d9a9f77d2999110aebe151:long_horizon 与 user_experience 均评估为 improved(在保留既有硬租约换代栅栏与零扣额契约的前提下,消除了 execution_preparation 对恢复动作的静默劫持并打通了符号链接 runtime_root 别名下的锁交接与无扣额结案闭环,且对非 execution_loss_closeout 恢复与异主限制保持原样)。已检查 5 个受触文件(execution_loss_closeout.ts、execution_preparation.py、unsettled_host_turn.py、unsettled_host_turn_contract.py 与 test_execution_loss_closeout_cli.py),本 PR 仅涉及后端控制面恢复逻辑与 CLI 命令投影,无任何前端渲染或 UI 布局变更。 未验证范围(unverified_scope):none。所有可验证行为前后一致性通过实测;code_volume 评估为 necessary(无新增持久化结构,仅条件清理冲突投影并对齐既有锁见证解析),default_off_isolation 与 authority_semantics 均保持既有契约不扩大权限;semantic_alignment 判定为 not_applicable(未新增或变更公共词表)。

English verdict: APPROVE at 8b8430d. Verified execution_preparation cleanup on execution_loss_closeout recovery, guarded can_reclaim_control_writer guidance, and symlinked runtime_root resolution across File and SQLite authorities. Passed tsc, ruff, strict + file mypy, loopx check, 288/288 TS tests, 150/150 pytest tests, 19/19 premerge direct/catalog/profile checks, and baseline/head counterfactual probes.

@mergify

mergify Bot commented Nov 22, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 22, 2026
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 22, 2026

@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)

动机 / Motivation

使用硬租约的 Agent 或宿主需要关闭已失去执行资格的原 Turn。 租约换代后,普通准备命令曾覆盖原 Turn 的管理恢复动作。固定启动器和 runtime-root 目录别名也可能挡住预览。 准确基线的六个针对性用例失败,包含两种存储上的固定启动器拒绝。当前头对应的 17 项执行损失 CLI 用例通过。额外加入一个更高优先级 Todo,在 File 和 SQLite 上验证动作仍指向原 Todo,预览零写入,结算零扣费,重放零新增写入。 相同 Agent 在旧 lease 不活跃时可从原 guard 获得普通领取与预览命令,随后关闭原 Turn。 本轮检查 macOS 上的 File 和 SQLite。未独立运行 PostgreSQL、原生 Windows、Desktop UI 或线上宿主,未查询远端 CI。广泛结算套件未跑完。

改动思路 / Approach

TypeScript 从现有 Todo 与 lease 读取写入资格。Python 只投影当前可用命令、规范路径和分离启动器参数;原行政结算所有者继续校验凭据。 当前边界是修复已有恢复命令和路径拼写。保留原管理结算协议、控制权检查、更新与回滚流程。 修正恢复分支的覆盖关系即可,现有普通 claim 和 preview 检查继续复用。

具体改动 / Changes

完整检查准确头 b99ac75 和 merge base adf4f44 的 6 个文件,+109/−12。按原轮归属、业务与计数隔离、回执重放三项核对现有规范。当前补齐 pinned launcher 的命令参数处理。 在途 Turn 规范

关键代码讲解

  • observeFencedExecution 根据现有 Todo 和租约区分可重新领取的原负责人。恢复投影移除当前工作准备,再列原 Todo 的检查、领取和预览。 资格判断 动作投影
  • CLI 只从效果输入中移除渲染用的 control_cli_bin,再交给原结算 owner。路径规范化与同一个实际锁见证匹配。 CLI 校验边界 物理路径

对主干的风险 / Risks

File 和 SQLite 通过原 guard 生成的命令领取原 Todo 的新凭据、预览、执行和重放。原准入收据和结算标识保留,Todo 仍未完成。 同 generation 仍走普通重入。另一 Agent、旧凭据和业务副作用被拒绝。存在独立待办时,原恢复仍指向旧 Turn。 17 项执行损失 CLI、7 项相邻原轮选择、2 项扩展源码反例、TypeScript typecheck 和 Ruff 通过。新构建并安装的 Core wheel 也在 File 和 SQLite 上用实际 pinned launcher 走过第二待办下的原结算、预览与重放。 标准预合并的 4 个直接检查和 16 个选中检查中的 15 个通过。CLI output-budget 在 120 秒限额超时,单跑相同 smoke 基线 123.31 秒、当前头 145.36 秒均通过。保留该限时门,测量不足以断言性能等价。 与最新主干的本地 merge-tree 无冲突。

我的整体评价 / Verdict

批准当前提交。原 Turn 的管理恢复路径可执行,原归属、回执、未完成 Todo 和额度边界符合预期。标准预合并的限时检查仍有记录,保持独立合并资格判断。

English verdict: APPROVE at b99ac75. Verified original-Turn writer recovery, the pinned launcher, no-spend closeout and exact replay on File and SQLite. The separate CLI output-budget premerge check timed out under its configured deadline, while both exact revisions passed standalone.

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