Repository navigation
feat(dsh): write Driver diagnostics as JSONL under the resolved DSH home - #9302
xiaobaifly7 wants to merge 4 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]>
When automatic continuation stops, the only trace today is a Cordis warn line, which many DSH installs do not keep, and nothing records why the Driver considered a Session not ready. Diagnosing a stalled Goal required attaching a debugger. - Append one JSON object per event to `<DSH home>/logs/dsh-loopx-driver.jsonl`, where the DSH home follows the `@deepseek-ai/dsh-home-paths` rules (`DSH_HOME`, `~` expansion, default `~/.dsh`). Records: driver start/dispose, observe, skipped requests, the exact readiness blockers, the built plan (binding status and Core `effective_action`/`state`/`reason`), queued Turn identity, host-job waits, and every existing warn line with its Session id. - Identical `not_ready` blocker sets for a Session are written at most once per 60 seconds. The file rotates to `.1` at 5 MiB. The file is created with mode 0600. Write failures are swallowed so logging never changes admission. - Tests isolate `DSH_HOME` so the suite never writes into the real home. Records carry ids, states, categories and the existing warn text; the Turn task body and message contents are not written. Depends on draft/dsh-host-job-wait (logs its wait and tool-job notice filtering). Signed-off-by: xiaobaifly7 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
8858ebc to
4c841b7
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] 诊断同步写盘阻塞未激活的 Session。 observeAgent 和 requestEvaluation 在激活前调用 logDiagnostic,stat、mkdir、轮换和 append 都在宿主事件回调内同步执行。 同一个未激活 Session 的受控慢写对照里,上游头返回前没有写入,当前头同步写两次并在 308 毫秒后返回。每次写入的注入等待为 80 毫秒。 保住未激活时的被动边界。确需记录的事件交给有容量上限的异步诊断写入器,并验证慢写、失败及轮换时关键宿主回调仍能返回。 准确提交的调用点
[P2] 可恢复重验失败丢弃已暂存的原 Turn。 evaluate 把同一 Turn 的可恢复错误送进 typed_failure 分支并清除 deferredPlan。下一次 buildPlan 因此生成新 Turn 和第二份任务正文。 Driver 对照记录的三次 guard Turn 依次为 1、1、2,排队消息绑定 Turn 2,heartbeat 读取由一次增为两次。 在 recoverable typed_failure 下保留已暂存计划,按原 Turn 重验;只有真实拒绝、绑定失效或用户停止才清除。 准确提交的调用点
动机 / Motivation
在 DSH 里排查自动续跑停滞的用户需要持久诊断,也需要开着诊断时 Session 仍能及时接收事件。 上游 Driver 只将警告交给原宿主日志,启动时没有这份 JSONL,未激活的观察不触发持久文件写入。 新版本把停滞原因写入本地 JSONL。当文件变慢时,连尚未启用 LoopX 的 Session 都会在观察回调上等待。 同一个未激活 Session 的受控慢写对照里,上游头返回前没有写入,当前头同步写两次并在 308 毫秒后返回。每次写入的注入等待为 80 毫秒。 这是 DSH 本地诊断及其父提交的评审。重启接管单独在后续 PR。
改动思路 / Approach
这是 DSH 本地诊断及其父提交的评审。重启接管单独在后续 PR。 Core 持有准入和回执,DSH jobs 持有后台任务生命周期,Driver 持有本 Session 的观察、计时和队列。 日志是本地观察者。 等待和重验沿用现有 Session 保留状态及 typed notice。保住未激活时的被动边界。确需记录的事件交给有容量上限的异步诊断写入器,并验证慢写、失败及轮换时关键宿主回调仍能返回。
具体改动 / Changes
实际 merge base 到准确提交共有 3 个文件,增加 1135 行,删除 106 行。Driver 新增 JSONL、精确就绪原因、写入失败吞吐保护及轮换,用例补充默认目录、重写旧归档、写入失败和恢复。 admission-closeout 集成测试只隔离诊断目录。父提交增加请求恢复及 jobs 等待。
规范版本 a6872bba63df5e4a7af5a58fc1cbebc17b8769a7。SAME_SESSION 已实现。TURN_IDENTITY 未满足。PASSIVE_BEFORE_ACTIVATION 未满足。 同 Session Driver 和重试契约
关键代码讲解
- logDiagnostic 写本地 JSONL,执行轮换和就绪原因去重。 准确提交的代码
- readyBlockers 保持原就绪谓词,并产生用于诊断的逐项原因。 准确提交的代码
- evaluate 读同一 Session 的计划、记录诊断,再决定是否排队。 准确提交的代码
- checkHostJobWait 只看同一 Session 的运行中或停止中的 jobs,按完成的 Turn 保存等待边界。 准确提交的代码
- buildPlan 取当前绑定和同一 Turn 的准入判断,然后使用已暂存计划。 准确提交的代码
对主干的风险 / Risks
PASS。准确提交的 Driver 测试 177 项及包内 TypeScript 类型检查通过。本地快速预合并的失败项为 python3 examples/canary/dsh-loopx-plugin-validation.py --phase quality。 真实 DSH 0.2.2-rc.3 本地 jobs 服务对照确认,运行中零次 quota、一个 10 分钟计时,结算后一次 quota 和一条续跑。 真实 Core 完整 JSON 故障注入后,下一次 idle 的两次 guard 产出一条续跑。
FAIL。给同一个未激活 Session 的诊断写入注入受控阻塞,并在两版 Driver 上记录 observeAgent 返回前的写入次数、宿主回调和队列状态。 jobs 使用已安装的真实服务,Agent 和决定性延后反例使用隔离的宿主夹具。写盘等待是受控注入,未测生产磁盘时延。
语义与 CI 对齐
复用既有 Core 状态和 Turn 身份,故障回复指向原 Turn 的恢复。上游 #9298 的完整 JSON 普通首次准入已在本头通过。已暂存准入的反例仍会生成第二个 Turn。在 recoverable typed_failure 下保留已暂存计划,按原 Turn 重验;只有真实拒绝、绑定失效或用户停止才清除。 Core 返回契约 上游原评审
我的整体评价 / Verdict
后台等待的主路径已可用。长程续跑还需要在故障解除后交付原计划的结果,操作者才能把后台任务完成与后续进度对齐。诊断仍需要通过慢写条件下的宿主响应验收。 改动位于 Driver 事件消费、队列与本地诊断,页面布局无需验证。
English verdict: REQUEST_CHANGES at 4c841b7. Synchronous diagnostics block passive Session callbacks. The stack also discards the deferred Turn after a recoverable receipt error.
| const size = statSync(file, { throwIfNoEntry: false })?.size | ||
| if (size === undefined) mkdirSync(logs, { recursive: true }) | ||
| else if (size + bytes > DIAGNOSTIC_LOG_MAX_BYTES) renameSync(file, `${file}.1`) | ||
| appendFileSync(file, line, { mode: 0o600 }) |
There was a problem hiding this comment.
[P2] 诊断同步写盘阻塞未激活的 Session。同一个未激活 Session 的受控慢写对照里,上游头返回前没有写入,当前头同步写两次并在 308 毫秒后返回。每次写入的注入等待为 80 毫秒。 保住未激活时的被动边界。确需记录的事件交给有容量上限的异步诊断写入器,并验证慢写、失败及轮换时关键宿主回调仍能返回。
| this.warn(`dsh-loopx-driver: admission_failed stage=${stage} ${cliErrorFields(error)} signal_aborted=${admissionSignal?.aborted ?? controller.signal.aborted} elapsed_ms=${Math.round(performance.now() - startedAt)}`) | ||
| this.recordAdmissionFailure(state, admissionFailureCategory(error)) | ||
| 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
<DSH home>/logs/dsh-loopx-driver.jsonlreceives one JSON object per event: driver start/dispose, observe, skipped request, exact readiness blockers, built plan (binding status and Coreeffective_action/state/reason), queued Turn id, host-job wait, and every existing warn line with its Session id. DSH home follows@deepseek-ai/dsh-home-paths(DSH_HOME,~expansion, default~/.dsh).main.Author Declaration
Implemented against
resolveDshHome,logDiagnosticreadyBlockers,NOT_READY_LOG_INTERVAL_MS.1DIAGNOSTIC_LOG_MAX_BYTESlogDiagnostictry/catchwarn,requestEvaluationcheckHostJobWaitDSH_HOME, and a full run left no file in the real home.Scope And Continuation
Validation
unitpassedtests/driver.spec.ts177/177unitpassedmainat 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_runadmission-closeoutonly gainsDSH_HOMEisolation; 11 of its 14 cases fail on the Windows author host onmainas well.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