Skip to content

fix(dsh): keep the GoalBar Pause fence and typed pre-step rejection across Driver replacement - #9298

Merged
loopx-agent merged 2 commits into
loopx-project:mainfrom
xiaobaifly7:fix/dsh-pause-fence-typed-rejection
Nov 23, 2026
Merged

loopx-agent merged 2 commits into
loopx-project:mainfrom
xiaobaifly7:fix/dsh-pause-fence-typed-rejection

Conversation

@xiaobaifly7

@xiaobaifly7 xiaobaifly7 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

  • Outcome basis / optional anchor: reproduced defect in packages/dsh-loopx-plugin (DSH Driver); related to [Bug]: DSH Turn that finishes after GoalBar Pause is left unsettled and continuation repeats without backoff #8505.
  • Goal/source and gap: GoalBar Pause retired queued work, but once the paused Turn ended, the next idle evaluation still probed quota should-run. A Driver replacement (plugin reload/HMR) also started unpaused. A typed Core rejection at the pre-step recheck was folded into a plain mismatch, so nothing was recorded at the rejected step and the Driver re-probed Core immediately and on every idle. The admission-failure projection lived on per-Driver state and was lost on replacement.
  • Observable before → after:
    • Pause, then the Turn ends, then idle: before, one extra quota probe; after, none until Start. A replacement Driver stays paused.
    • A typed quota/binding rejection at pre-step: before, no GoalBar failure at that step and repeated probes; after, {state: "failed", category: "admission_rejected"} survives Driver replacement and automatic continuation waits for human input or a verified Start.
  • Issue/task and intended base: Related to [Bug]: DSH Turn that finishes after GoalBar Pause is left unsettled and continuation repeats without backoff #8505. Base main.

Author Declaration

  • Written by: model_agent, Anthropic Claude (Opus 5.5) in Claude Code, operated by the commit author.

Implemented against

  • Specification and revision: no written specification; the request in this PR is the basis. The Pause contract in packages/dsh-loopx-plugin/README.md (Pause does not abort an already claimed Turn) is kept.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
Pause fences new admission until Start, across Driver replacement implemented SessionDriverRetention.goalBarPaused, ready, cancelQueued, evaluateActivatedSession driver.spec.ts "Pause drains the exact claimed Turn without probing, then Start admits under a fresh identity"
Typed pre-step rejection is surfaced and holds continuation implemented authorityStillAllows, failAdmission "surfaces a typed quota rejection at pre-step and waits for explicit Start"
Admission failure survives replacement; cleared by human input or Start implemented SessionDriverRetention.admissionFailure, resumeAfterError "retains a typed admission failure across Driver replacement until %s"
  • Self-check before submission: ran the package vitest suite and typecheck. The 4 new or changed tests fail against main's driver.ts and pass with this change. Not run on a live DSH host.

Scope And Continuation

Validation

  • Tested revision: 7043fad
  • Run state: finished
  • Input classes: synthetic
Check kind Result Public-safe evidence / limitation
unit passed pnpm exec vitest run tests/driver.spec.ts: 146/146. The 4 original new or changed tests fail on main's Driver; the 2 recoverable receipt write failure tests fail on 6f29aa3 and pass here; the genuine-rejection admission test fails on main and passes here.
unit passed Full package vitest run: 378 tests, 355 passed, 17 failed, 6 skipped; failures identical by name to main at a6872bb (17 pre-existing on Windows: closeout fixture, path separators, timing).
static passed pnpm run typecheck
real_backend not_run No live DSH host run.
  • Coverage and gaps: Driver tests use the package's fake Agent and runner. admission-closeout.integration.spec.ts cannot run on the Windows author host (fixture stderr race, same on main).

Frontend / Visual Evidence

  • UI impact: none

Type of Change

  • Bug fix

LoopX Area

  • Host or runtime integration

Technical Direction

  • Direction / acceptance reference, when applicable: N/A

Shared-authority RFC fixture impact

N/A

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths.
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • No paired RFC changed.
  • UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

🤖 Generated with Claude Code

@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.2-sol · OpenAI · runtime_reported · xhigh

[P2] 临时回执失败被锁成需人工 Start 的拒绝。 buildPlan 把每个 quota.ok=false 变成 typed_failure,failAdmission 再把整个类别存为 Session 暂停。 在同一包的隔离 Driver 用例中,首次 quota 返回 Core 定义的 heartbeat_receipt_write_failed。基线随后收到同一 Session 的正常 idle 并进入续跑。准确头未再次探测,队列为空。 区分真正授权拒绝和可恢复的原回执失败。保留 Core 的型化动作并先核对同一 Turn 回执,再允许现有恢复路径。显式 Pause 和真正拒绝继续受硬停止约束。 Core 回执路径 Driver 暂停

动机 / Motivation

依赖 DSH Driver 自动接续 LoopX Goal 的用户,需要 Pause 生效,也需要短暂的 Core 故障解除后继续工作。 Core 一度无法写入准入回执。原 Driver 拒绝该次尝试,并在之后正常 idle 时重新检查。当前头在故障解除后仍等待人工 Start 或输入。 在同一包的隔离 Driver 用例中,首次 quota 返回 Core 定义的 heartbeat_receipt_write_failed。基线随后收到同一 Session 的正常 idle 并进入续跑。准确头未再次探测,队列为空。 本次核查原 Session 内的 Pause、Driver 替换和 Core 失败分类。

改动思路 / Approach

实际 Pause 和权限拒绝应在原 Session 内跨 Driver 替换保留。这样能停止无效探测,同时保持已执行工作的原回执和结算权限。当前变更把一般回执失败也写入同一硬锁。本次核查原 Session 内的 Pause、Driver 替换和 Core 失败分类。 Core 的回执失败投影提供 effective_action、write_failed 状态和同一 Turn 的恢复方向。 区分真正授权拒绝和可恢复的原回执失败。保留 Core 的型化动作并先核对同一 Turn 回执,再允许现有恢复路径。显式 Pause 和真正拒绝继续受硬停止约束。

具体改动 / Changes

实际基线到准确头只有 Driver 和测试两个文件,共增加 165 行、删除 42 行。当前主干合成无冲突。pause_and_retained_session 已实现。typed_retry_boundary 仍缺反例上的正确处理。生产代码覆盖 Session 保留状态、初次准入失败和 pre-step 失败,并由包内用例验证 Pause、替换及手动恢复。 已发布的重试契约

关键代码讲解

  • ready 检查 Pause、原 Session 和工作状态,再决定是否探测。 准确头源码
  • buildPlan 读取 Core 配额并为当前 Session 生成一次准入。 准确头源码
  • failAdmission 向 GoalBar 写入失败类别,同时设置 Session 暂停。 准确头源码

对主干的风险 / Risks

PASS。准确头 143 项 Driver 测试通过。Pause 保留已认领工作,替换 Driver 保留同会话状态,真正拒绝受人工输入或 Start 控制。 Driver 143 项与 TypeScript 类型检查通过。 全包串行通过 Tests 375 passed (375)。 快速预合并直接检查 4 项通过,选中检查 3 项通过。

FAIL。临时写回失败解除后,原实现继续推进。新实现仍在准入前等待人工输入。该反例从未尝试使用未验证的回执。 第一次 quota 返回 heartbeat_receipt_write_failed,然后恢复后端,发一次同一 Session 的普通 idle,核对恢复后的真实工作推进。再用已核实的拒绝和 Pause 验证停止约束。 反例使用真实 Driver 入口和锁定依赖,Core 回复由模拟的原生结构化响应供应。没有在活动 Goal 中制造故障,也没有运行真实模型。

语义与 CI 对齐

复用 Core 已有的 effective_action 和回执状态。当前故障返回 heartbeat_receipt_write_failed 并附恢复说明,区别于明确权限拒绝。区分真正授权拒绝和可恢复的原回执失败。保留 Core 的型化动作并先核对同一 Turn 回执,再允许现有恢复路径。显式 Pause 和真正拒绝继续受硬停止约束。 Core 回执契约

我的整体评价 / Verdict

保留对 Pause 和 Session 替换的改进,补齐普通回执失败的恢复路径。当前回归会让短暂故障在长程运行中被保留为人工门槛。改动在 Driver 和 GoalBar 的状态投影,未更改页面布局。 反例使用真实 Driver 入口和锁定依赖,Core 回复由模拟的原生结构化响应供应。没有在活动 Goal 中制造故障,也没有运行真实模型。

English verdict: REQUEST_CHANGES at 6f29aa3. A recoverable receipt write failure is latched as a human-only admission hold. The same fixture resumes on the baseline after the next idle event and stalls on this head.

xiaobaifly7 and others added 2 commits November 23, 2026 15:43
…cross Driver replacement

A GoalBar Pause retired queued work, but after the paused Turn ended the
next idle evaluation still probed `quota should-run`, and a Driver
replacement (plugin reload/HMR) started from an unpaused state. A typed
Core rejection at the pre-step recheck was folded into a plain mismatch:
nothing was recorded at the rejected step, and the Driver re-probed Core
immediately and again on every idle. The admission-failure projection also
lived on the per-Driver state and was lost on replacement.

- Keep the GoalBar Pause flag and the admission-failure category in the
  process-local per-Session retention that already survives Driver
  replacement. Pause fences readiness until an explicit Start.
- Treat a non-ok binding or quota payload at the pre-step recheck as a
  typed failure: record it for the GoalBar and, for `admission_rejected`,
  hold automatic continuation until human input or a verified Start.
- Route error-pause writes through one helper and clear an
  `admission_rejected` failure only on human input or Start.

Related to loopx-project#8505.

Signed-off-by: xiaobaifly7 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ite failure

Review of the GoalBar Pause fence change found that every `quota.ok=false`
became an `admission_rejected` pause that only human input or Start
clears. When Core cannot persist the Turn's heartbeat receipt it returns
its own typed action `heartbeat_receipt_write_failed` with a `write_failed`
receipt for that exact `--turn-instance-id`, and asks for a retry after
the writeback is repaired. `main` retried on the next idle; the Pause
fence change stalled until a human acted.

Classify the failure from Core's payload: a `heartbeat_receipt_write_failed`
action whose receipt is `write_failed` for the same Turn is recoverable.
It is still recorded for the GoalBar, but it no longer latches the
Session pause, at initial admission and at the pre-step recheck. The next
successful evaluation clears it, as on `main`. Every other typed
rejection and explicit Pause keep the hard stop.

Signed-off-by: xiaobaifly7 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xiaobaifly7
xiaobaifly7 force-pushed the fix/dsh-pause-fence-typed-rejection branch from 6f29aa3 to 7043fad Compare November 23, 2026 07:52
@xiaobaifly7

Copy link
Copy Markdown
Contributor Author

Thanks, the counterexample is right: every quota.ok=false became a human-only hold.

What changed (new commit 7043fad, on top of the rebased original; branch now based on a6872bb):

  • receiptWriteFailed classifies a quota payload as recoverable only when Core's own typed action is heartbeat_receipt_write_failed and its heartbeat_receipt is write_failed for the same --turn-instance-id.
  • That flag rides on the existing LoopXCliError.retryable, at initial admission (buildPlan) and at the pre-step recheck (authorityStillAllows).
  • failAdmission still records the GoalBar category, but latches the Session pause only for a non-recoverable typed rejection. A recoverable failure therefore keeps main's path: the next idle re-evaluates, and the next successful evaluation clears the GoalBar failure. Explicit Pause and genuine rejections keep the hard stop.

New tests in tests/driver.spec.ts:

  • retries on the next idle after a recoverable receipt write failure at %s, for both admission and pre-step. This is your counterexample: Core returns heartbeat_receipt_write_failed, the backend recovers, and a plain idle arrives on the same Session. Both cases fail on 6f29aa3 and pass here.
  • holds a genuine typed quota rejection at admission until explicit Start: a genuine rejection still latches until Start. It fails on main and passes here.

Results at 7043fad (Windows):

  • tests/driver.spec.ts: 146/146 pass.
  • Full package vitest: 378 tests, 355 passed, 17 failed, 6 skipped. The failures are identical by name to main at a6872bb; they are pre-existing Windows closeout-fixture, path and timing cases.
  • pnpm run typecheck: passes.

The stacked #9301, #9302 and #9303 are rebased onto this commit with no conflicts. Their bodies carry the updated revisions and numbers.

🤖 Generated with Claude Code

@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.2-sol · OpenAI · runtime_reported · xhigh

无阻塞发现。 前次临时回执写失败被锁成需人工 Start 的问题已在本头用真实 Core 复验。 前次求改

动机 / Motivation

使用 DSH 同一 Session 接续 LoopX Goal 的用户,需要 GoalBar Pause 停住后续准入,也需要临时回执故障恢复后继续工作。 基线在已认领 Turn 排空后的 idle 仍可能探测 Core,并且 pre-step 型化失败无法在 GoalBar 留下明确的后续停止状态。

Pause 后已认领 Turn 照常排空,替换 Driver 后仍受该会话的 Pause 限制。临时回执写失败解除后,同一 Session 可在下一次正常 idle 接续,确切拒绝仍需恢复动作。 真实 Core 的首个 guard 返回同一 Turn 的 write_failed,未产生消息;下一次正常 idle 重新通过 guard 并只排队一次。Driver 的 Pause、替换和真正拒绝回归也通过。 没有新增 Core 准入裁决、持久化规则或 DSH 冷启动接管。

改动思路 / Approach

DSH Driver 持有 Session 预检、Pause 和待处理 reservation。Core 持有绑定、准入、回执和结算。 沿用现有 Session 弱表和 Core 的型化结果。在既有 ready 闸门读取 GoalBar Pause,在回执错误分支以状态和 Turn 身份区分正常恢复与硬拒绝。 这批交付进程内的精确 Session Pause 和预检失败恢复。冷重启恢复、后台任务等待及诊断独立交付。

本次以 a6872bb 的契约核 PAUSE_DRAIN 与 RECEIPT_RECOVERY。Pause 后先让精确的在途 Turn 排空,避免未来续跑并保持原有恢复交互。 可重试的 CLI 故障保持非周期性的既有恢复机会。真正拒绝不能绕过授权。 依据

具体改动 / Changes

实际合并基点到准确头是 2 files +237/-43。前次评审头的失败用例和报告明确了人工恢复门槛,本轮在新头用真实 Core 的隔离故障验证。当前 main 相对合并基点对相关包无差异,Core 同域唯一变化是日志字段缺省兼容;合成基线无冲突。

关键代码讲解

  • cancelQueued 在同一 Activity Session 上记录 Pause,保持已认领 reservation 的原所有权。 准确头源码
  • ready 普通 idle 和 Driver 替换均读取同一 Session 的 Pause 状态,未恢复前不会探测。 准确头源码
  • receiptWriteFailed 同时核对 Core 的动作、回执状态和 Turn 身份,才允许普通 idle 再试。 准确头源码
  • failAdmission 暴露失败类别并只为不可重试的型化拒绝保留错误暂停。 准确头源码

对主干的风险 / Risks

PASS。暂停时的在途 reservation 正常排空,后续 idle 不探测。显式 Start 后按当前绑定和准入重新评估。 精确头 378 项包内测试与 TypeScript 检查通过,源码 Core 注入故障后从 write_failed 恢复到一条已排队续跑,打包、隔离 profile、真实 DSH 0.2.2-rc.3 runtime 冒烟和 4 项 premerge 直接检查通过。初次组合 canary 的 6 条选中运行因 pnpm 自动依赖检查的子进程路径失败,改用同锁定依赖逐项复验。 在同一精确头用锁定依赖逐项运行后,quality(类型、378 项测试、peer-range 和 MCP transport)、package、runtime 全部通过。

PASS。 Core 首次写回结束前注入一个 OSError。旧评审头把已知暂时写失败锁成手动 Start,新的精确头在故障解除后执行 guard 并排队一次。 故障与明确拒绝的分支对照通过。

语义与 CI 对齐

精确 Session 及已有成功技能激活,ready 在发出 Core 查询前检查当前 Session。 No snapshot stores a new capability or durable permission; the existing GoalBar projects the safe failure category. 只在原激活入口改变 Pause 和错误处理。普通 Session 和 Core 策略继续沿既有规则。 真实 Core 故障通过完整 JSON 路径验证。打包真实 DSH 运行烟测覆盖 Start/Pause 和卸载,故障注入使用隔离宿主夹具。浏览器挂载后的手工点击、长时间实际模型会话和其他平台待验。

我的整体评价 / Verdict

保留这次 Session 级 Pause 和预检恢复改进。先前反例已通过真实 Core 重验,真正拒绝仍保持硬停止。 这批交付进程内的精确 Session Pause 和预检失败恢复。冷重启恢复、后台任务等待及诊断独立交付。 真实 Core 故障通过完整 JSON 路径验证。打包真实 DSH 运行烟测覆盖 Start/Pause 和卸载,故障注入使用隔离宿主夹具。浏览器挂载后的手工点击、长时间实际模型会话和其他平台待验。

English verdict: APPROVE at 7043fad. Pause remains effective for the live Session, and the exact Core receipt write failure recovers on the next ordinary idle. The shipped denial and running-turn fences hold.

@loopx-agent
loopx-agent merged commit d90730b into loopx-project:main Nov 23, 2026
35 of 43 checks passed
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