Skip to content

fix(quota): bound unchanged prior-turn recovery admissions - #8577

Merged
huangruiteng merged 6 commits into
loopx-project:mainfrom
xiaobaifly7:codex/bounded-unsettled-recovery
Nov 16, 2026
Merged

huangruiteng merged 6 commits into
loopx-project:mainfrom
xiaobaifly7:codex/bounded-unsettled-recovery

Conversation

@xiaobaifly7

@xiaobaifly7 xiaobaifly7 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

Author Declaration

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

Implemented against

No accepted maintainer policy specification; the conservative admission-bound proposal in this PR is the basis. Existing closeout order and original receipt identity remain authoritative.

Criterion Disposition Symbol / path Test
Persist owed Turn/effect and missing-items checkpoint when recovery admission is issued implemented RecoveryAdmissionCheckpoint; quota_rollout_details File/SQLite fresh-process CLI sequence
Bound unchanged admissions for the same original debt implemented recoveryAdmissions; reduceUnsettledHostTurnRecovery distinct admissions, replay deduplication, other-debt isolation
Reset on actual receipt progress or owner action implemented existing settlement snapshot and canonical activation timestamp real writeback; owner stop/resume
Keep original identity, accepted no-debit closeouts and no fabricated spend implemented existing preflight/reducer closeout precedence original guard reentry, blocked lifecycle closeout, zero debit
No model wake after attention implemented existing interaction and scheduler owners should_run, attempt, delivery, spend and scheduler assertions
DSH/GoalBar dedicated attention presentation deferred existing fault presentation has no recovery-state transport follow-up remains in #8563

POLICY CHOICES — maintainers may change these

  1. RECOVERY_ADMISSION_LIMIT = 3; this bounds admissions, not completed host attempts. A caller issuing fresh committed guards can consume this allowance without a model call. No host-attempt ACK is claimed.
  2. Count distinct recovery Turn identities against the original owed Turn + binding + effect, scoped to the existing Goal/Agent and exact quota owner. Replays do not spend another admission; unrelated debt identities do not erase this debt's streak.
  3. A reduction in missing receipts renews the allowance. Existing validated settlement, monitor-poll and typed lifecycle/no-debit closeouts are evaluated before escalation.
  4. Explicit owner stop/resume renews it through the existing canonical owner activation timestamp. A later controller activation retains the most recent recorded owner epoch; losing the owner projection cannot renew the allowance. No new reset command, setting or parallel state store is added.
  5. Legacy recovery receipts without this new checkpoint start at zero; historical host attempts are not inferred.
  6. Attention retains the original debt, refuses automatic work/delivery/spend and uses existing blocked_wait plus scheduler backoff; it does not stop or complete the Goal.
  • Self-check: read the closeout owner, receipt adapter and consumers; tested persisted File/SQLite CLI paths and pure typed decisions; public-boundary scan used an empty synthetic registry.

Scope And Continuation

Validation

  • Tested revision: 7498e2ae7e2feca54faa51288197fac6fc2fa38a (checks over the same source tree).
  • Run state: finished.
  • Input classes: synthetic, public_fixture.
Check kind Result Public-safe evidence / limitation
integration / real_entrypoint / real_backend passed test_unsettled_recovery_admission_bound.py: 6 initial cases plus 2 focused controller-activation regressions, real CLI processes and File/SQLite authority; unchanged limit, replay, original identity, receipt progress, owner resume, controller non-reset and legal blocked closeout
unit passed 79 distinct TypeScript cases across recovery, interaction execution and scheduler arbitration; all 33 recovery cases rerun after the epoch correction
unit / integration passed 48 passed, 18 skipped across live quota decision, preflight budget, owed-signal, due-successor identity and Turn interruption; skips require POSIX process/FIFO support
unit passed 14 preflight/query-failure cases; overlaps the preceding preflight selection and is not an additional distinct-case total
static passed control-plane TypeScript compile; focused Ruff; semantic advisory; full semantic vocabulary smoke; six-file public-boundary scan; diff/staged RFC checks
integration passed initial admission-bound source: quick diff-selected premerge, 6 direct checks and 3 selected canaries; final epoch correction separately passes typecheck, full recovery tests, Ruff, public-boundary and RFC checks
regression_parity passed Owner-to-controller activation regression fails before the epoch correction (count 0) and passes after it (count 3); both real File/SQLite controller stop/resume cases retain attention.
regression_parity failed then fixed first CLI iteration exposed stale run_now after a negative recovery decision; final projection rebuilds interaction/scheduler arbitration. Initial semantic scan could not recognize a conditional enum producer; explicit registered producer projection now passes.
real_entrypoint not_run Installed DSH, model execution, desktop presentation and live Goal qualification

Focused selections:

python -m pytest -q tests/control_plane/test_unsettled_recovery_admission_bound.py
python -m pytest -q tests/control_plane/test_effect_turn_live_quota_decision.py tests/control_plane/test_prior_closeout_preflight_budget.py tests/control_plane/test_turn_settlement_owed_signal.py tests/control_plane/test_recovery_due_successor_identity.py tests/control_plane/test_turn_interruption_recovery.py
python -m pytest -q tests/control_plane/test_prior_closeout_preflight_budget.py tests/cli_commands/test_quota_closeout_query_failure.py
node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/unsettled_host_turn_recovery.test.ts tests/control_plane_ts/interaction_execution_decision.test.ts tests/control_plane_ts/scheduler_arbitration.test.ts
python -m loopx.entrypoint canary premerge --tier quick --from-git-diff --git-diff-base origin/main

Native Windows validation uses Python 3.12 and Node 24; set process-local PYTHONUTF8=1. Full suites, PostgreSQL and installed-host qualification are not claimed. No paired RFC changed.

Frontend / Visual Evidence

  • UI impact: none; no visual surface changed. Typed recovery attention presentation remains explicitly deferred above.
  • Before / After / First viewport and preview / States and viewports shown: N/A.
  • Source data: synthetic.
  • Attention review / Craft review: N/A.

Type of Change

  • Bug fix
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)

Technical Direction

Bound repeated no-progress recovery through its existing typed owner while preserving settlement and owner authority.

Shared-authority RFC fixture impact

N/A: no provider promotion, authority schema migration or PostgreSQL routing change.

Boundary Checklist

  • Diff and PR contain no private state, credentials, raw traces, internal links or local machine paths.
  • No maintainer-owned benchmark work duplicated.
  • Scoped to the stated issue and admission-bound proposal.
  • No paired RFC changed; RFC diff gate passed.
  • UI impact none; presentation limitation disclosed.
  • Every commit has a DCO sign-off.

Maintainer follow-up

The Goal activation transaction now retains the last committed Owner resume in the source registry and checks it in the shared registry readback. Controller Stop and Resume preserve that record even when no recovery guard runs between the two actors. An Owner Resume on an already active Goal keeps the existing record. The live quota path reuses its registered Goal read, and the TypeScript recovery owner still compares receipts for the original Turn.

The regression fails in both File and SQLite at 7498e2ae7e2feca54faa51288197fac6fc2fa38a when the two actor transitions have no intervening guard. With this update, both orderings recover under the original Turn identity. An intervening committed admission is counted once. Preview preserves registry bytes, the same guard replays its existing receipt, and genuine writeback progress renews the allowance. The integration also retains the hard-pause guard from #8533.

  • Final tested revision 9a30e684d92f562425638806cb4b1c9da1fa659f against 08cc6ef5b9a15a5a74d3e56ba4114cb09b2033ee
  • 158 Python tests including File and SQLite, the lifecycle and source-to-shared registry path, and settlement recovery
  • 80 TypeScript tests across prior-Turn recovery, execution decisions, and scheduler arbitration
  • TypeScript typecheck, Ruff, mypy, semantic-vocabulary advisory and full-tree smoke, and RFC bilingual diff passed
  • Standard premerge reported zero failures across 17 selected checks

The three-admission threshold remains the proposal in this PR. Its count is for distinct committed recovery guards on an already bound debt. Completed DSH host attempts, admission before binding, and GoalBar presentation remain tracked in #8563. Prior review finding

Maintainer follow-up on concurrent recovery

At 9a30e684d92f562425638806cb4b1c9da1fa659f, three independent quota CLI processes competed for the final allowance on SQLite and all three were admitted. A second reproduction on File and SQLite showed that re-reading a previously blocked Turn after Owner Resume returned a positive decision without a positive guard receipt.

The receipt append now revalidates the selected debt, progress checkpoint, and committed grant count under the same rollout lock used to append the receipt. Each losing process recomputes its decision for the same Turn. An unbound wait that becomes eligible records its first positive receipt, and later reads reuse that receipt. The exact-source preflight borrows the caller's locks through the append. The existing three-admission limit and the original settlement identity still govern recovery.

Validation for b958bc4f899c2a78bb5af14136b7c80f3655ad79 against f3bdad2387397e078fbc887e7cb7ed80adaf7510:

  • File and SQLite, real quota CLI processes: one grant and two bounded waits with one allowance left, stable positive receipt on same-Turn replay, and zero quota spend. The existing turn-scoped preview refusal writes no receipt. Owner Resume followed by Controller Stop/Resume still retains the Owner's recovery epoch.
  • 156 relevant Python tests and 216 TypeScript tests passed. The TypeScript suites include exact-source lock lifetime at preflight. TypeScript typecheck, mypy, changed-file Ruff, and the standard premerge gate passed.
  • The separate content-digest ownership check still reports the existing shared-parser finding in Reuse canonical SHA-256 validators for private results #8836. Exact-head independent review and hosted checks are pending. Actual completed DSH attempts, admission before Todo binding, and GoalBar behavior remain in [Bug]: DSH admits completed but unclosed Turns indefinitely without recovery escalation #8563.

Standalone Core integration evidence

Verified the reviewed commit b958bc4f899c2a78bb5af14136b7c80f3655ad79 in a local integration tree with main f38fae05bb9a1c2cc54a2641359224cc253d32ac, which restores Goal Stop and Resume in standalone Core. The tested tree is 72c53fea0d2e37df070567a6b29f92c63d0756e8. Built both versions of the standalone wheel and loaded each in a fresh environment with its own artifact and no Python dependencies on macOS. Model and Host execution were outside this comparison.

  • The ten existing Core lifecycle cases pass on both artifacts. They cover preview, stale fingerprint refusal, preservation of the Todo and lease, and the outer-controller ownership guard.
  • Four packaged quota cases cover File and SQLite and both lifecycle orderings, with and without an intervening guard. Main admits all four unchanged requests. The candidate admits three and waits on the fourth. A Controller Stop/Resume leaves the exhausted allowance in effect. Owner Stop blocks execution, and Owner Resume renews the allowance even when Controller Stop/Resume follows before the next guard.
  • After resume, both backends read the same original receipt identity. Replaying the guard returns the same receipt. Settlement of that original effect results in one debit across two invocations.
  • The hosted TypeScript shard fails on the second digest matcher in native_child_result_inbox.ts. The identical failure is reproducible on main and the integration tree. The aggregate check fails on that TypeScript result. Hosted failure · Digest-owner fix

GitHub records approval of this exact head and still treats the earlier requested-changes review as blocking. DSH completion counts, before-selection exits and GoalBar visibility remain in the original issue. Exact-head review · Earlier review · DSH issue

Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>

@songoow songoow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

动机 / Motivation

使用自动续跑、并需要修复上一个未结算 Turn 的 Goal owner 会遇到这个问题。 以前三个新 Turn 都没有减少缺失回执后,第四个仍会获准恢复;现在第四个进入等待,避免继续唤醒模型做同样的无进展恢复。 真实 CLI 已证明等待时 should_run、must_attempt、delivery 和 spend 都关闭,scheduler 不再给出 run_now。

本 PR 不计数真实 host completed 事件,不实现 GoalBar 警告,也不覆盖尚未选择或绑定工作的 admission。 它是 #8563 的有界 admission 增量;完整的 host-attempt 与 GoalBar 验收仍未交付,而且本轮发现 owner resume 在后续 controller 写入前未产生 guard 时会丢失。

审查基于 7498e2a,基线 beff0f3。需求来源为 https://github.com/loopx-project/loopx/issues/8563,本轮读取的文本固定为 issue-body-sha256-1b1a25a6fd7d2a84be0af5caaa60cbad2e6dc0ccbfa1f5fa918c8a1d0e2b48b5;issue 中的方案尚未成为 maintainer 接受的新策略规范,因此没有把作者选择的 admission 计数冒充 completed-host-attempt 的完整实现。下面分别核对 S1(有界无进展恢复)、S2(真实进展/显式 resume 后重新进入)、S3(保留原身份与真实结算)、S4(DSH/GoalBar 可见性与未绑定 Turn)。另核对基线 docs/heartbeat-automation-prompt.md 的 exact-identity/no-spend closeout 契约。

改动思路 / Approach

计数应留在已有 TypeScript recovery owner,复用持久化回执及 interaction/scheduler 投影;Python 只负责事实读取与传输。 当前 PR 应限定为已有绑定债务的 admission 上限,并在同一边界修复 owner reset 的持久语义;host-attempt ACK 与 GoalBar 展示可继续单独交付。

不修改时,新的 Turn ID 会不断获得正向恢复决定;只改 scheduler 文案不足以停止 DSH,因为 Driver 只在负向 should_run 上应用等待。当前方案把三次正向 admission 的原债务、缺失回执和 owner epoch 写入原有 quota receipt,随后由 TS 返回 attention,再让 Python 同时重建执行和 scheduler 投影。这个边界有实际调用者,也没有新增第二份计数存储。

条件 当前应有结果 独立观察
同一债务三个无进展新 admission 下一新 Turn 等待 File/SQLite CLI 通过
重放相同 Turn、原身份修复、真实回执减少 不重复计数,允许合法修复 CLI 与 TS 通过
controller 独立 stop/resume 不能产生新 owner allowance CLI 通过
owner reset 后先发生 controller 写入 保留已经完成的 owner reset 失败,见 P2

具体改动 / Changes

关键代码讲解

  1. recoveryAdmissions 从同 Goal、Agent、quota owner 的已提交回执中,按 owed Turn、binding、effect 精确筛选并以 run_id 去重。真实缺失回执减少或 owner epoch 改变才截断计数;其他债务与 replay 不能充当进展。
  2. reduceUnsettledHostTurnRecovery 先处理已结算、monitor 与合法 lifecycle closeout,再把 count≥3 的恢复转换为 attention。该转移保留旧债务,不写成功、不扣 quota,也不授权普通 delivery。
  3. quota_rollout_details 只为正向 recovery admission 附加 checkpoint,沿用现有 receipt 提交与 replay 机制。旧 receipt 没有 checkpoint 时从零开始,这是明确披露的兼容规则。
  4. apply_unsettled_host_turn_recovery_if_required 读取 activation 时间作为 owner epoch;此处的当前 actor 过滤造成下面的时序缺陷。随后 _apply_recovery_projection 清理普通 action 投影,并复用 interaction arbitration 重建 scheduler,避免 payload 等待而 scheduler 仍 run_now。

[P2] owner reset 会在下一次 recovery guard 之前被 controller activation 抹掉。 耗尽三次 allowance 后,依次执行成功的 owner stop/resume、controller stop/resume,新 guard 仍然 count=3、attention、should_run=false。对照组只在两组 lifecycle 操作之间读一次 guard,便得到 count=0,controller 之后继续 count=1。PR 承诺显式 owner stop/resume 续期;该意图已经持久化,不能因为第一轮 guard 尚未把它复制进 checkpoint 就失效。最小修复是让现有 owner lifecycle authority 保留/提供最后一次 owner epoch,再用两种读取顺序验证 controller 既不重置也不撤销该 epoch。

S1 在绑定债务的 admission 范围内已交付,真实 host-attempt 计数仍 deferred;S2 的真实 receipt-progress 分支通过,但 owner reset 分支存在上述 not_met;S3 的 no-spend、exact identity、合法 blocked closeout 与 settled replay 保持;S4 的 UI 与未绑定阶段仍 deferred,不能据此宣称 #8563 已完整关闭。

对主干的风险 / Risks

主要风险是把可变的“最后一次 activation”当成持久 owner reset 意图,导致用户完成推荐的恢复操作后,后续自动生命周期写入又让 Goal 回到原来的等待。这是新增上限的恢复路径缺陷;不是把原有 hard-pause 优先级问题归到本 PR,#8533 仍是独立关联工作。

本轮在精确 head 上独立运行:新增真实 File/SQLite CLI 8/8 通过(107.27 秒);recovery、interaction execution、scheduler arbitration 三组 TS 79/79 通过;完整 control-plane TypeScript typecheck、改变的 Python 文件语法检查、base-to-head git diff --check 均通过。另运行了上述无 mock 的 owner/controller 时序反例及成功对照。新 CLI 回归放到不可变基线运行,在缺少 admissions_without_progress 的断言处失败,确认该测试确实区分原实现,但它本身没有覆盖本轮发现的时序。

远端 packet 没有可用 check rollup;本 review 依赖这里列出的本地证据,不将未知 CI 当成通过。没有运行真实 DSH host 或 GoalBar,因为本 PR 没有交付这些 adapter/展示路径;也没有把 admission 次数当作模型真正完成的恢复次数。并发 guard 的严格全局限额不在本轮验证范围内。

语义与 CI 对齐

这里是默认行为变化:原先可无限正向恢复,现在同一债务达到三次 admission 就等待。变更已在 PR 和 vocabulary 披露。attention_required、blocked_wait、must_attempt_work=false 是机器执行约束,NOTIFY 和修复文案负责告知,不应代替授权或真实 receipt。修复 owner epoch 前,CI 绿色不能证明 S2 的完整恢复语义。

我的整体评价 / Verdict

实现位置、回执复用和防止无进展消耗的方向合理,代码量与这个单一状态转换相称;目前应先修复上述可复现的 owner reset 时序缺陷再批准。修复可留在现有 activation/recovery 边界,不需要加配置、专门 reset 命令或将整个 DSH 工作打包进来。

检查的变更仅涉及 quota CLI、typed recovery、回执与词汇描述,没有修改渲染界面;GoalBar 警告未交付。 未验证范围:真实 host-attempt ACK、GoalBar 可见警告及并发 guard 上限;这些没有被冒充本轮已验证结果。

Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported

English verdict: REQUEST_CHANGES

Comment on lines +365 to +366
owner_action_id=(activation.get("updated_at")
if activation.get("actor_kind") == "owner" else None),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 保留尚未被 recovery guard 消费的 owner reset

这里仅在当前 activation.actor_kind == "owner" 时传入 owner epoch,因此一次后续 controller activation 会覆盖尚未进入 recovery checkpoint 的显式 reset。用真实 File CLI 可复现:耗尽 3 次 recovery admission → owner stop/resume 均成功 → controller stop/resume 均成功 → 新 guard 仍返回 attention_required、admissions_without_progress=3、should_run=false。对照组只在 owner resume 与 controller stop 之间增加一次 guard,就先得到 count=0,controller 后也继续正常 count=1。也就是说,同一次已成功的 owner reset 是否生效取决于调度器是否恰好先读过 guard。这违背 PR 的“Explicit owner stop/resume renews it”承诺;controller 不应撤销 owner 已写入的重置意图。请从不会被 controller activation 覆盖的 canonical owner-action 记录取得 epoch,或在 owner lifecycle transition 时保留该 epoch,并加入这组两种读时序的回归覆盖。无需增加 reset 命令或把 controller 操作也当作 reset。

@mergify

mergify Bot commented Nov 11, 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, @xiaobaifly7.

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 11, 2026
…eserve-owner-resume-8577-20261115

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

# Conflicts:
#	loopx/control_plane/quota/unsettled_host_turn.py
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 15, 2026
loopx-agent
loopx-agent previously approved these changes Nov 15, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

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.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 9a30e684d92f562425638806cb4b1c9da1fa659f。GitHub 记录的目标引用为 beff0f3e55d1f70eceebbd8e78c11f1cff34643b。实际合并基点 08cc6ef5b9a15a5a74d3e56ba4114cb09b2033ee,与主干 b05ac4142be2775eb50371a5f390e373472fbe0c 的合并树模拟通过。

动机 / Motivation

启用自动续跑的 Goal owner 需要阻止模型反复检查同一笔未结算工作,也需要在显式恢复后继续处理这笔工作。 旧实现会持续准入;前一候选拦住了第四次无进展恢复,但在下一 guard 到来前,controller 的生命周期写入会覆盖 owner 的恢复意图。 对已经绑定到原 Turn 的未结算工作,允许三次缺失回执无进展的准入。随后等待真实进展或 owner 显式恢复。

让同一笔应结算工作达到上限。依次让 owner 与 controller 各执行停止和恢复,再分别验证两者之间有无 guard 的结果。 File 和 SQLite 都通过了此前失败的顺序。另用三个独立 CLI 进程争用最后一份恢复准入,各存储只放行一次。 本次批准的是已绑定债务的准入上限和恢复顺序。验证使用本地源码与合成 Goal。安装 DSH、真实模型和远端 CI 未复验。三次上限是本 PR 披露的政策选择。 DSH 实际完成次数、未绑定便退出的 admission 以及 GoalBar 告警仍由 #8563 后续验证。

改动思路 / Approach

source registry 在同一生命周期事务内保留最后一个已提交 owner 恢复 ID。TypeScript 继续依据原 Turn、缺失回执和该 ID 决定是否准入,Python 构造相应交互和调度状态。 两种存储都保留原结算身份。中间没有 guard 时,controller 恢复后的剩余额度从新纪元开始;已有一次准入时,那次仍计入。重读同一 Turn 与已启用时再次请求 owner 恢复均不会续期。 本次批准的是已绑定债务的准入上限和恢复顺序。验证使用本地源码与合成 Goal。安装 DSH、真实模型和远端 CI 未复验。三次上限是本 PR 披露的政策选择。 相关规范或问题

具体改动 / Changes

实际合并基点至候选涉及 11 文件,+447/-19。生产逻辑集中在生命周期、quota 事实传输和 TypeScript 决策,另外有回归、词汇描述和双语配额说明。GitHub 的 776 文件缓存包含既有主干历史。 原有恢复日志保存同一原债务的缺失回执与 owner 恢复 ID。达到上限时返回 typed attention 和调度等待。

关键代码讲解

依据 docs/heartbeat-automation-prompt.md 在 b05ac4142be2775eb50371a5f390e373472fbe0c 的约束核对。

  • S1 已绑定债务的有界准入。已绑定的同一债务重复缺同一回执时,应停下无进展的自动执行。 File 和 SQLite 都通过了此前失败的顺序。另用三个独立 CLI 进程争用最后一份恢复准入,各存储只放行一次。
  • S2 恢复原意图。真实回执减少和 owner 显式恢复可以重开该债务的准入。 两种存储都保留原结算身份。中间没有 guard 时,controller 恢复后的剩余额度从新纪元开始;已有一次准入时,那次仍计入。重读同一 Turn 与已启用时再次请求 owner 恢复均不会续期。
  • S3 保留原收据和结算。恢复、No-debit 关闭、写回均按原 Turn 及原授权执行。 仍返回 attention_required,关闭普通交付、执行及扣额。真实写回减少缺失回执时,原身份恢复可用。
  • S4 DSH 用户可见范围。在实际宿主观测完成并展示未结算注意事项。 DSH 实际完成次数、未绑定便退出的 admission 以及 GoalBar 告警仍由 #8563 后续验证。

对主干的风险 / Risks

额度已被三次相同债务的恢复准入用完,随后只发生 controller 恢复或重复读取。 仍返回 attention_required,关闭普通交付、执行及扣额。真实写回减少缺失回执时,原身份恢复可用。 已覆盖此前报告的两种实质顺序。 原评审

128 项 Python、80 项 TypeScript 和两种存储的独立并发对照通过。类型检查、Ruff、RFC 双语校验、git diff --check 及 quick premerge 的 6 项直接与 4 项选定检查均通过。

语义与 CI 对齐

三次上限约束已提交的 guard 准入。类型化等待和回执决定实际执行,通知文案仅说明如何处理。

我的整体评价 / Verdict

APPROVE。 原先的时序异议已在两库复验通过。按此精确提交给出技术批准,GitHub 的旧评审和合并基点走现有保护。 DSH 实际完成次数、未绑定便退出的 admission 以及 GoalBar 告警仍由 #8563 后续验证。 本次批准的是已绑定债务的准入上限和恢复顺序。验证使用本地源码与合成 Goal。安装 DSH、真实模型和远端 CI 未复验。三次上限是本 PR 披露的政策选择。

English verdict: APPROVE at 9a30e68. Owner resume survives later controller transitions and a three-process race admits only the final available recovery on File and SQLite. This is the bound-debt admission slice.

@xiaobaifly7
xiaobaifly7 dismissed loopx-agent’s stale review November 15, 2026 15:55

The merge-base changed after approval.

…settled-recovery-observed-progress-20261116

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

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.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 b958bc4f899c2a78bb5af14136b7c80f3655ad79。原差异基点 f3bdad2387397e078fbc887e7cb7ed80adaf7510。

动机 / Motivation

自动续跑的 Goal owner 需要停止反复恢复同一笔未结算工作,并在真正进展或显式恢复后继续。 File 和 SQLite 上,用真实 CLI 创建原债务、连续请求四次,再让原写回或 owner Stop 发生在另一个恢复 guard 计算完成和写入之间。 主干第四次仍准入,候选开始等待。写回发生后,候选重读并仅保留欠扣额,原回执可幂等结算一次。Stop 发生后,pending guard 不再准入。owner/ controller 有无中间 guard 的原两种顺序均通过。 验证覆盖本地源码 CLI、File/SQLite、受控写入顺序和本地锁。已安装 DSH、真实模型和远端 CI 待验证。

DSH 实机的完成次数、未绑定便退出的场景及 GoalBar 告警继续归 #8563 验收。

改动思路 / Approach

保持同一份原结算回执。TypeScript 按作者披露的三次上限计算准入;提交前从原源读取可能变化的回执和 owner 动作。 现有 TypeScript 负责决定原欠项和预算。Python 只在写入锁内重读同一事实并明确处理发生变化的情况。 当前批准已绑定原 Turn 的源码准入和恢复;#8563 继续跟进宿主可见性和未绑定退出。

具体改动 / Changes

相对目标主干 14 文件、+825/-148。最新提交把工作绑定到更新的源锁、原回执预检和 App CLI 写入。 用原 effect、缺失的回执和最后一个 owner 恢复 ID 确定当前恢复范围。每次准入写入由同一现有锁和原回执读者重验,重复读取保持原记录。 原产品问题 上轮评审 验收约定

关键代码讲解

  • 在 lifecycle 事务中保存真正 owner 恢复。 set_goal_activation_state

  • 按原欠项统计唯一的恢复准入。 recoveryAdmissions

  • 提交前通过已有锁重新验证当前状态。 recovery_admission_append_precondition

  • 候选事实变化时用同一 Turn 重读。 _execute_quota_command

  • bounded-bound-recovery。已绑定欠项反复无进展时进入有界等待。 主干四次均准入,候选前三次准入,第四次 attention_required。

  • owner-lifecycle。owner 显式恢复可重开欠项,controller 不覆盖原意图。 两种操作顺序和中间 guard 参数在两库通过。实际 Stop/Resume 的私有反例也通过。

  • recheck-before-commit。当前已验证回执或暂停变化必须影响本次实际准入。 真实写回改变欠项后只剩 spend,Stop 与重试不提交过时恢复。

  • original-settlement。真实原回执保持身份,重复结算实际只扣一次。 File 与 SQLite 读取原 guard,写回、扣额、重试和欠项消除。

对主干的风险 / Risks

同一欠项在运行中可能变化。将写回和 Stop 插在 guard 计算与提交之间,两个 provider 都重新读取当前状态,回收过时的结论。三次上限刻意作用于有原回执的重复准入。尚待验收的是 DSH 实际运行与未绑定退出的用户可见性。

本地 Python 两组 68 和 27 项,TypeScript 251 项;类型、Ruff、标准 premerge 及合并树通过。真实原回执完成与 owner 暂停都检查了提交前的状态变化。

语义与 CI 对齐

到上限后返回 attention_required 并停止自动执行。补齐缺失回执或 owner 显式 Stop/Resume 可以重新准入。真实回执进展和保护性暂停均已覆盖,控制器普通恢复不重置同一债务。

我的整体评价 / Verdict

APPROVE。 两种后端均验证第四次无进展准入暂停,原写回更新和 owner Stop 都在提交前被重新识别。原回执可以继续完成一次扣额。

English verdict: APPROVE at b958bc4. The bounded recovery grant is now committed against current receipt and lifecycle facts. File and SQLite stop the fourth unchanged attempt, re-evaluate a concurrent writeback, respect an owner stop, and preserve one original debit. Installed DSH and pre-binding exits remain in #8563.

@huangruiteng
huangruiteng merged commit 77eece8 into loopx-project:main Nov 16, 2026
44 of 54 checks passed
loopx-agent added a commit that referenced this pull request Nov 18, 2026
Verify #8577 (77eece8) and #8879 (3d6fd2e) on main against DSH pause/unsettled-recovery regressions across file and sqlite providers:
- Paused Goals (goal_stopped and compute_quota_zero) must keep should_run=False and pause_cause without projecting unsettled_host_turn_recovery, setting closeout_required=True, setting a settlement_effect_id/recovery_effect_id, or consuming the bounded 3-admission recovery budget.
- Resuming restores unsettled_host_turn_recovery with admissions_without_progress == 0.

Closes #8505
Closes #8563

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent added a commit that referenced this pull request Nov 18, 2026
#8955)

Verify #8577 (77eece8) and #8879 (3d6fd2e) on main against DSH pause/unsettled-recovery regressions across file and sqlite providers:
- Paused Goals (goal_stopped and compute_quota_zero) must keep should_run=False and pause_cause without projecting unsettled_host_turn_recovery, setting closeout_required=True, setting a settlement_effect_id/recovery_effect_id, or consuming the bounded 3-admission recovery budget.
- Resuming restores unsettled_host_turn_recovery with admissions_without_progress == 0.

Closes #8505
Closes #8563

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

4 participants