Repository navigation
fix(dsh): wait for owned host jobs before continuing and keep claimed inputs on rejection - #9301
xiaobaifly7 wants to merge 3 commits into
Conversation
…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]>
… inputs on rejection When a Turn completed while host jobs it started were still running, the Driver immediately admitted the next LoopX Turn. A `tool-jobs` completion notice was then treated as competing input, which fenced or rejected the continuation that the notice was meant to wake. On a pre-step rejection or downstream failure, inputs that the host had already claimed into the rejected batch (for example a job notice) were dropped instead of being put back. - After a completed Turn, wait up to 10 minutes while the Agent owns running or stopping jobs (optional `jobs` host service). The deadline is kept per completed Turn in the process-local Session retention, so a command or Driver replacement does not restart it; a new Turn does. - A plan built while jobs are still running is deferred with its Core Turn identity and revalidated through `quota should-run` before it is queued, instead of minting a new Turn. Human input, Pause, a binding change or a typed Core failure discards the deferred plan. - `tool-jobs` notices wake an idle Driver and are allowed beside the continuation in its step; other automatic input stays fenced. - Restore every claimed input on each pre-step rejection or downstream failure exactly once, without waking the Agent when the step was aborted. Depends on the GoalBar Pause fence change (draft/dsh-pause-fence-typed-rejection). Signed-off-by: xiaobaifly7 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
141bcc0 to
95f2d6f
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
[P2] 可恢复重验失败丢弃已暂存的原 Turn。 evaluate 把同一 Turn 的可恢复错误送进 typed_failure 分支并清除 deferredPlan。下一次 buildPlan 因此生成新 Turn 和第二份任务正文。 Driver 对照记录的三次 guard Turn 依次为 1、1、2,排队消息绑定 Turn 2,heartbeat 读取由一次增为两次。 在 recoverable typed_failure 下保留已暂存计划,按原 Turn 重验;只有真实拒绝、绑定失效或用户停止才清除。 准确提交的调用点
动机 / Motivation
在 DSH 托管 LoopX Goal 的用户经常等后台任务收尾,希望完成后自动接续工作。 基线会在仍有本会话后台任务时即刻请求准入。旧段结束和新段开始之间,任务完成通知也可能被当成竞争输入。 新版本可先等本会话后台任务收尾,再接续已准备的工作。如果这次重验短暂写入失败,恢复后会改用另一轮。 Driver 对照记录的三次 guard Turn 依次为 1、1、2,排队消息绑定 Turn 2,heartbeat 读取由一次增为两次。 这是 DSH Driver 同一个 Session 的任务完成、回执重验和已认领消息恢复。
改动思路 / Approach
这是 DSH Driver 同一个 Session 的任务完成、回执重验和已认领消息恢复。 Core 持有准入和回执,DSH jobs 持有后台任务生命周期,Driver 持有本 Session 的观察、计时和队列。 等待和重验沿用现有 Session 保留状态及 typed notice。在 recoverable typed_failure 下保留已暂存计划,按原 Turn 重验;只有真实拒绝、绑定失效或用户停止才清除。
具体改动 / Changes
实际 merge base 到准确提交共有 2 个文件,增加 810 行,删除 67 行。Driver 与其测试加入 jobs 等待、完成通知的输入分类和认领消息恢复。 上游 Pause 与回执失败分类也进入本 PR,覆盖正常准入和 pre-step 的同一 Session。
规范版本 a6872bba63df5e4a7af5a58fc1cbebc17b8769a7。SAME_SESSION 已实现。TURN_IDENTITY 未满足。 同 Session Driver 和重试契约
关键代码讲解
- checkHostJobWait 只看同一 Session 的运行中或停止中的 jobs,按完成的 Turn 保存等待边界。 准确提交的代码
- buildPlan 取当前绑定和同一 Turn 的准入判断,然后使用已暂存计划。 准确提交的代码
- restoreCompetingMessages 撤销预备步时恢复真正输入,仍按消息 ID 去重。 准确提交的代码
- receiptWriteFailed 根据 Core 类型标签和同一 Turn 回执区分可恢复写入失败。 准确提交的代码
对主干的风险 / Risks
PASS。准确提交的 Driver 测试 171 项及包内 TypeScript 类型检查通过。本地快速预合并的失败项为 python3 examples/canary/dsh-loopx-plugin-validation.py --phase quality、python3 examples/canary/dsh-loopx-plugin-validation.py --phase package、python3 examples/canary/dsh-loopx-plugin-validation.py --phase runtime。 真实 DSH 0.2.2-rc.3 本地 jobs 服务对照确认,运行中零次 quota、一个 10 分钟计时,结算后一次 quota 和一条续跑。 真实 Core 完整 JSON 故障注入后,下一次 idle 的两次 guard 产出一条续跑。
FAIL。让同一测试 Session 的任务在第一次 guard 中途进入 running,完成后让第二次 guard 返回原 Turn 的 write_failed,恢复后断言第三次 guard 与排队消息仍使用原 Turn。 jobs 使用已安装的真实服务,作者用户消息和后台通知都在宿主夹具内驱动。故障交叉由 Driver 测试注入 Core 的真实已知返回结构。
语义与 CI 对齐
复用既有 Core 状态和 Turn 身份,故障回复指向原 Turn 的恢复。上游 #9298 的完整 JSON 普通首次准入已在本头通过。已暂存准入的反例仍会生成第二个 Turn。在 recoverable typed_failure 下保留已暂存计划,按原 Turn 重验;只有真实拒绝、绑定失效或用户停止才清除。 Core 返回契约 上游原评审
我的整体评价 / Verdict
后台等待的主路径已可用。长程续跑还需要在故障解除后交付原计划的结果,操作者才能把后台任务完成与后续进度对齐。修订版本应覆盖后台等待、原身份重验与真实权限拒绝三个相邻分支。 改动位于 Driver 事件消费、队列与本地诊断,页面布局无需验证。
English verdict: REQUEST_CHANGES at 95f2d6f. A recoverable receipt failure discards the deferred plan, so the next idle event mints a second Turn.
| } | ||
| if (!controller.signal.aborted && !cancelled) { | ||
| if (error instanceof LoopXCliError && error.kind === 'typed_failure') { | ||
| this.clearDeferredPlan(state, jobWait.deferredPlan) |
There was a problem hiding this comment.
[P2] 可恢复重验失败丢弃已暂存的原 Turn。Driver 对照记录的三次 guard Turn 依次为 1、1、2,排队消息绑定 Turn 2,heartbeat 读取由一次增为两次。 在 recoverable typed_failure 下保留已暂存计划,按原 Turn 重验;只有真实拒绝、绑定失效或用户停止才清除。
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. 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 HEADFor a same-repository clone whose Keep the DCO |
Goal And Delivered Outcome
tool-jobscompletion notice was then treated as competing input, which fenced or rejected the continuation it was meant to wake. On a pre-step rejection or downstream failure, inputs the host had already claimed into the rejected batch (for example the job notice) were dropped.tool-jobsnotice: before, competing input; after, it wakes an idle Driver and may share the continuation's step.main.Author Declaration
Implemented against
jobshost service is optional; without it behavior is unchanged.checkHostJobWait,JOB_WAIT_MSSessionDriverRetention.jobWait.deferredPlan,buildPlan,queuePlantool-jobsnotices are not competing input; other automatic input still isisToolJobNotice,isAllowedStepContext,inboxHasPendingonPreStep,restoreCompetingMessages(…, wakeup)buildPlanScope And Continuation
Validation
unitpassedtests/driver.spec.ts171/171unitpassedmainat a6872bb (17 pre-existing on Windows: closeout fixture, path separators, timing), except thecli.spec.tsoutput-limit termination timing test, which also fails onmainin 3 of 3 isolated rerunsstaticpassedpnpm run typecheckreal_backendnot_runjobsservice is exercised through a fakelist(agentId); the real DSH jobs service shape (owner,status) is taken from DSH 0.2.2-rc.3 and was not exercised end to end.Frontend / Visual Evidence
Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
N/A
Boundary Checklist
none.Signed-off-bytrailer (git commit -s).🤖 Generated with Claude Code