Skip to content

feat(orchestration): return a fleet echo from orchestration check - #14891

Closed
Tauri-EPO wants to merge 6 commits into
stablyai:mainfrom
Tauri-EPO:feat/orchestration-fleet-echo-check
Closed

Tauri-EPO wants to merge 6 commits into
stablyai:mainfrom
Tauri-EPO:feat/orchestration-fleet-echo-check

Conversation

@Tauri-EPO

@Tauri-EPO Tauri-EPO commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #14889. That PR is a test-file split this one needs in order to add coverage without tripping the max-lines budget. Until it merges, its single commit shows up in this diff. Review only the second commit here, or wait for #14889 to land.

ELI5

You dispatch a task to a worker terminal. Sometimes the prompt never actually reaches the agent — it sits in the composer, or the dispatch was recorded but never delivered. Today you find out minutes later, by noticing that nobody ever replied.

This makes orca orchestration check tell you. Every response now carries a small table of your Run's live lanes, and one column says whether each lane's prompt actually started a turn.

What Changed

orchestration.check responses gain an optional fleet block: one row per active dispatch in the caller's Run.

fleet run_7f3a (3 lanes):
  term_a1  task_31  ctx_9f  dispatched  12s    accepted
  term_c3  task_33  ctx_a1  dispatched  3m02s  NOT_ACCEPTED
  term_d4  task_34  ctx_a2  dispatched  14m0s  accepted (dead)

Columns are handle, task, dispatch, lifecycle, quiet time, and delivery; processState is appended in parentheses only when it is not healthy.

  • delivery is the point. not_accepted means the prompt never started a turn — that lane needs re-dispatching, and waiting on it will never resolve.
  • check --wait returns the block on timeout too, so a timeout says why nobody spoke instead of only that nobody did.
  • Only active dispatches appear (pending, dispatched), capped at 12 lanes with truncated: true beyond that.
  • --no-fleet suppresses it. Under --json it stays in the payload.

delivery has two sources: worker_dispatches.stage reaching input_accepted for worker-start lanes, and — for a plain dispatch --inject onto an existing terminal, which creates no worker_dispatches row at all — comparing dispatched_at against the terminal's lastOutputAt, since a delivered prompt makes the terminal emit.

processState reports dead or unknown, never live. A connected PTY does not prove the agent inside it is alive, so the runtime does not claim liveness it has not established.

New files: a dependency-free builder in src/shared/, a runtime adapter, and a CLI renderer. OrchestrationDb gains one query; OrcaRuntimeService gains one handle-scoped accessor.

Why

Relates to #14809 (dispatch without --inject records the dispatch, never delivers it, and says nothing) and #14523 ("an orchestrator triaging 5+ worker terminals cannot use terminal list to decide who is stuck vs working; every decision requires a per-handle terminal read, which is O(n) round-trips").

The design choice worth arguing about: this rides on an existing response rather than adding a health command. A coordinating agent forgets to poll — an envelope does not. There is no new command to learn and no turn spent checking; the truth arrives with work the coordinator was already doing.

Deliberately not in this PR: any supervisor. No nudging, no escalation ladder, no state table. This only reports.

Linked Issue

Part of #14907. Not Fixes, because that issue asks for the block on the commands a coordinator already runs and this PR delivers it only on check; #14892 completes it and carries the Fixes.

Also relates to #14809 (the silence it removes, though the --inject default is unchanged) and #14523 (the O(n) triage round-trips it removes, though terminal list preview freshness is untouched).

Visual Proof

N/A for UI — this is CLI/RPC surface only, no renderer changes. The before/after is in What Changed above: previously check returned only its messages, now it additionally returns the fleet block shown there. Under --json the block is an additive field older clients already strip.

Testing

  • Unit: builder, adapter, check wiring, CLI renderer, DB query — 131 passing across 6 files.
  • Regression: full sweep of src/main/runtime/rpc/methods/ and src/cli/handlers/ — 1143 passing.
  • pnpm exec tsc --noEmit on both the node and CLI projects — clean.
  • pnpm exec oxlint src/ config/ — clean.
  • pnpm run lint and pnpm build — both pass locally.
  • Timezone: pinned test under TZ=America/Sao_Paulo. See the note in Review.

Tested on Windows 11.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Written with Claude Opus 5 via Claude Code. Design decisions were made in collaboration with the author; implementation and review passes were agent-assisted, then verified by the author.

Review

  • Security: the block is scoped to the caller's own Run, resolved the same way the surrounding handlers already resolve it. No new data crosses a Run boundary.
  • Cross-platform: no path or shell assumptions. One bug worth naming: the dispatched_at fallback initially used a bare Date.parse on SQLite's space-separated, timezone-less UTC, which V8 reads as local time — that made every --inject lane read NOT_ACCEPTED west of UTC and accepted east of it. Now normalised through the existing exposeUtcTimestamp, with a TZ-pinned regression test.
  • Remote SSH / federation: supervision facts are host-local by design — only the runtime that owns the PTY has them. A federated lane reports processState: unknown rather than guessing. No new wire opcode; the block is an additive field on an existing result, which older clients strip.
  • Mobile: unaffected.
  • Backwards compatibility: additive only. Omitting the fleet param means on; --no-fleet opts out.
  • Performance, stated honestly: the block costs one SQLite read plus one handle-scoped terminal read per command. That terminal read reaches ptyController.listProcesses(), bounded at 3000ms, once per command — not per lane. It is skipped entirely when the Run has no active lanes, and the whole build sits inside a try/catch that returns the untouched result on any failure, so the block can never fail the command carrying it. If reviewers would rather this be opt-in rather than default-on, that is a one-line change and I am happy to make it.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Note on the last box: pnpm lint and both typechecks pass locally. The full pnpm test suite cannot start on Windows from a clean install of this repo — see #14918. Briefly: [email protected] installs with an empty build/, so the Windows branch of ensure-native-runtime refuses to run the suite. Not specific to this branch, and not a Node version problem (reproduced identically on Node 22 and 24).

Running vitest directly, bypassing that wrapper, the suite has pre-existing failures on this Windows machine unrelated to this change (missing POSIX shell, spawnSync … EINVAL, assertions expecting / and receiving \). I verified attribution by running the entire suite on the merge base and on this branch and diffing the failing-file lists: the base fails 81 files, this branch fails the same 81 plus one timing-flaky test in remote-runtime-shared-control-connection.test.ts that this branch does not touch and that passes 28/28 in isolation.

Author

  • X / Twitter: @EnricoPin

@coderabbitai

coderabbitai Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 82824335-a776-4f97-a126-5603458eeae9

📥 Commits

Reviewing files that changed from the base of the PR and between dfd297df1ca8c77084e35706bf68e4ede597ab47 and dde27ee.

📒 Files selected for processing (2)
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • skill-guides/orchestration.md

Included review availability: Your plan includes up to 10 reviews per rolling hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Adds Fleet Echo contracts and bounded lane derivation for orchestration dispatches. Runtime integration collects dispatch, worker-stage, terminal, and timestamp data, then attaches fleet data to check responses across mailbox paths and timeout states. The CLI supports --no-fleet, renders text output, and preserves JSON payloads. Tests cover derivation, runtime mapping, database liveness, RPC behavior, and formatting. Documentation describes the new response block and lane semantics.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding a fleet echo to orchestration check responses.
Description check ✅ Passed The description covers the required sections, linked issues, behavior, testing, compatibility, review considerations, and checklist items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (1)
src/cli/handlers/orchestration-fleet-echo-format.ts (1)

38-40: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten this comment.

Lines 38-40 describe implementation behavior and build state in three lines. Keep only the reason for showing a non-live process state. As per coding guidelines, comments must be concise, non-obvious, and brief; prefer one line.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 366c25ae-56a9-47c8-8622-76351dc399ad

📥 Commits

Reviewing files that changed from the base of the PR and between e4e54a1 and 9dbe9e9352647ca10a6a1e7c82c085e57c87f716.

📒 Files selected for processing (16)
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/handlers/orchestration-fleet-echo-format.test.ts
  • src/cli/handlers/orchestration-fleet-echo-format.ts
  • src/cli/handlers/orchestration.ts
  • src/cli/specs/orchestration.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/orchestration/db-dispatch-liveness.test.ts
  • src/main/runtime/orchestration/db.test.ts
  • src/main/runtime/orchestration/db.ts
  • src/main/runtime/rpc/methods/orchestration-check.test.ts
  • src/main/runtime/rpc/methods/orchestration-fleet-echo-sources.test.ts
  • src/main/runtime/rpc/methods/orchestration-fleet-echo-sources.ts
  • src/main/runtime/rpc/methods/orchestration.ts
  • src/shared/orchestration-fleet-echo.test.ts
  • src/shared/orchestration-fleet-echo.ts
💤 Files with no reviewable changes (1)
  • src/main/runtime/orchestration/db.test.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review.

Comment thread skill-guides/orchestration.md Resolved
Comment thread src/cli/specs/orchestration.ts Resolved
Comment thread src/main/runtime/orchestration/db.ts Resolved
Comment thread src/shared/orchestration-fleet-echo.ts Resolved
@Tauri-EPO

Copy link
Copy Markdown
Contributor Author

Listing what this PR deliberately leaves out, so reviewers do not have to find it by reading for absences.

Left out on purpose, with reasoning:

  • truncated carries no count. Past 12 active lanes the footer says more lanes exist but not how many, so a coordinator cannot tell one hidden lane from fifty. Adding a count means changing the shared FleetEcho type and its consumers; it seemed better as a follow-up than as extra surface in a first PR. Happy to include it here if you would rather it ship complete.

  • The block is attached per return site rather than at a choke point. check has 22 return paths and each is wrapped individually, so a future contributor adding a 23rd ships it without the block and nothing fails. There is a real single choke point — before successResponse in dispatch() and dispatchStreaming() in src/main/runtime/rpc/dispatcher.ts — and I chose not to use it here: ask and reset are deliberately excluded from the feature, so a generic attach needs an explicit method allowlist anyway, and a transport-layer change touching every RPC call in the app is a much larger blast radius than this PR should carry. If you would prefer the choke point, it is a better end state and I am glad to do it — it just felt like the wrong thing to land unreviewed underneath a feature.

  • Two tests I know are missing. Cross-run scoping on listActiveDispatchesForRun — the SQL joins tasks t ON t.id = dc.task_id WHERE t.run_id = ? and was read and confirmed correct, but no test proves a second Run's lanes stay out. And no test exercises an async rejection from the handle-scoped terminal read; the call sits inside the same try that guards everything else, so it is structurally covered but unproven.

One thing I would like a steer on: the block is default-on, suppressed with --no-fleet. That is the right default for the problem it solves — a coordinator that has to remember to ask is the failure mode — but it does put a bounded listProcesses() call on every Run-scoped orchestration command. If you would rather it were opt-in, that inverts with a one-line change.

Also opened while working on this, all independent of these PRs: #14896 (a lane blocked on an agent question is invisible to the coordinator), #14897 (nudging a silent dispatch without taking completion authority), #14898 (a pre-existing dispatchShow Run-isolation gap that this PR is careful not to widen).

@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

@Tauri-EPO

Copy link
Copy Markdown
Contributor Author

Thanks @coderabbitai — all seven addressed in 8d6d67f3e0, and the two you asked for regression tests on now have them. Taking the three Major ones in order, since two changed real behaviour:

Run isolation on listActiveDispatchesForRun — you are right that joining only through tasks.run_id trusts a relationship nothing enforces. The query now demands both:

WHERE dc.run_id = ? AND t.run_id = dc.run_id AND dc.status IN ('pending', 'dispatched')

so a row whose denormalized run_id has drifted from its task's drops out instead of leaking. The regression test asserts both halves: another Run's lane never appears, and a row whose two ids disagree disappears from both Runs rather than surfacing in the wrong one.

This matters more than a defensive tidy-up here: #14898 is an open report of dispatchShow handing out another Run's dispatch context, so Run isolation in this area is already known to be thin.

Remote worker mailbox runId: undefined — correct, and it silently removed the feature for exactly the callers who most need it. The attachment row carries no run_id, so it now resolves through the task:

{ dispatchId: remoteAttachment.dispatch_id, runId: db.getTask(remoteAttachment.task_id)?.run_id }

Fixture task in the legacy Run — also correct, and worth flagging how close this came to being invisible. The test passed either way; it just was not proving what it claimed. It now creates the task in activeRunId explicitly. With the stricter query above the two changes constrain each other, so the assertion cannot silently go vacuous again.

The four minor ones: quietMs now null-checks the timestamp rather than testing truthiness, so epoch-zero means the same thing to it as it does to resolveDelivery — with a regression case pinning that a lastOutputAt of 0 yields a real quietMs and not_accepted rather than null/unknown. The TZ-pinned test deletes TZ when it was originally unset instead of restoring the string "undefined" into sibling tests. check's usage string documents --no-fleet. The guide's output example carries a text fence.

The usage-string point applies to the stacked #14892 as well, where the flag reaches eight more commands; fixed there in 34e0dbdd6f so every command that accepts --no-fleet documents it.

Verification: 131 tests across the six affected files, plus 164 across the four on #14892 after rebasing it onto this. Both typechecks and oxlint clean.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@Tauri-EPO Thanks for the detailed update.

The Run isolation fix now rejects mismatched dispatch_contexts.run_id and tasks.run_id values. The regression test covers both cross-Run exclusion and mismatched IDs.

The remote mailbox path now resolves the Run from its task. The fixture now uses activeRunId. The remaining fixes also address the timestamp, environment restoration, CLI documentation, and guide formatting findings.

ᕕ(ᐛ)ᕗ 🐇


✏️ Learnings added
Learnt from: Tauri-EPO
URL: https://github.com/stablyai/orca/pull/14891

Timestamp: 2026-08-16T19:29:31.299Z
Learning: In `src/main/runtime/orchestration/db.ts`, `OrchestrationDb.listActiveDispatchesForRun` must enforce Run isolation through both the dispatch-context and task relationships: filter by `dc.run_id = ?` and require `t.run_id = dc.run_id`. A mismatched denormalized `dispatch_contexts.run_id` and `tasks.run_id` must not appear for either Run.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: artile
Repo: stablyai/orca PR: 13763
File: src/cli/specs/terminal.ts:40-50
Timestamp: 2026-08-11T08:28:56.946Z
Learning: In the TypeScript CLI command-spec tests, the existing validation checks that every flag named in a command `usage` string is present in `allowedFlags`, but it does not check the reverse direction. Therefore, flags can be accepted by `allowedFlags` without being advertised in `usage`; review both fields for parity when CLI flags are added.

If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

You are interacting with an AI system.

@Tauri-EPO
Tauri-EPO force-pushed the feat/orchestration-fleet-echo-check branch from f049d33 to dfd297d Compare August 17, 2026 19:58
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Tauri-EPO

Copy link
Copy Markdown
Contributor Author

Rebased onto main (60805f5c)

The branch was 91 commits behind and conflicting; it is MERGEABLE again. No behaviour change — but the code moved, so here is what a reviewer comparing against the previous head will see, rather than leaving it to be discovered.

main split orchestration/db.ts. What was a 7,697-line file is now a 46-line barrel plus a db/ directory of focused modules. listActiveDispatchesForRun no longer has a class body to live in, so it moved to db/dispatch-context/dispatch-lookup.ts in the shape that file uses:

export function listActiveDispatchesForRun(
  this: OrchestrationDb,
  runId: string,
  limit: number
): DispatchContextRow[]

registered in DispatchLookupMethods and attachDispatchLookup alongside its siblings. The SQL is unchanged, Run-isolation predicate included (dc.run_id = ? AND t.run_id = dc.run_id).

One consequence I would rather state than have someone find. That predicate now lands in the commit that introduces the method (echo fleet lane state on check) instead of the later address review findings commit. Re-homing the weaker version into the new file only to rewrite it one commit later would have shipped a known Run-leak inside an intermediate commit of a branch that has already been reviewed for exactly that. The regression test proving it stays where it was, in the review-findings commit, so that commit still reads as the review round it was. The final tree is identical either way.

Two smaller adjustments:

  • exposeUtcTimestamp no longer needs the export this PR added — main already exports it from db/utc-timestamp.ts. Only the import in orchestration-fleet-echo-sources.ts changed.
  • The conflicts in orca-runtime.ts and rpc/methods/orchestration.ts were both the same shape: main added a method and an import at the spot this branch adds one. Both sides kept, nothing dropped.

Verification on the rebased head dfd297df1c, Node 24:

tsc --noEmit -p config/tsconfig.node.json      ok
tsc --noEmit -p config/tsconfig.tc.cli.json    ok
vitest (5 affected files)   Test Files 5 passed | Tests 80 passed
oxlint src config tests --deny-warnings        clean
generate-bundled-skill-guides.mjs --check      clean
check-max-lines-ratchet.mjs   OK — 190 grandfathered, no new bypasses

pnpm build and the full suite were not run here.

CI still reports nothing on this PR, and not for a reason in the diff. Every PR Checks and PR test LoC run on this fork branch ends action_required — the fork-workflow approval gate — so no check has ever executed. That is what keeps mergeStateStatus at UNSTABLE. A maintainer approving the workflow run is the only thing that changes it.

db.test.ts sits just under the 800-line max-lines budget, leaving no
room for new coverage. Move the recordHeartbeat and getStaleDispatches
tests into a new db-dispatch-liveness.test.ts — a coherent unit around
detecting whether a dispatched task is still alive — and leave the
dispatch-context CRUD coverage behind, which is a different concern.

No assertions or fixture behaviour changed; only file location.
Add a `fleet` block that orchestration methods can attach to their
response: a live snapshot of the caller's active dispatch lanes
(handle, task, dispatch, lifecycle, quiet time, and delivery state),
capped at 12 lanes with truncation reported. The `delivery` column is
the point: `not_accepted` means a dispatched prompt never actually
started a turn in the worker terminal, something a coordinator would
otherwise only discover minutes later by noticing silence.

This wires the fleet echo into `orchestration.check` only, including
every wait/timeout return path — a complete, reviewable vertical
slice covering the builder, runtime adapter, the check RPC method,
CLI rendering, and the skill guide. The remaining eight orchestration
methods (send, reply, inbox, task-create/list/update, dispatch,
dispatch-show) get the same wiring in a follow-up PR.
- listActiveDispatchesForRun now requires dispatch_contexts.run_id to match
  the caller's Run and to agree with the task's, so a divergent denormalized
  row cannot leak another Run's lane. Regression test covers both.
- A remote worker mailbox resolves its Run from the task instead of passing
  undefined, which had omitted the block entirely for remote worker checks.
- The check fixture now creates its task in the bound Run; without it the
  assertion could pass against the legacy Run rather than the caller's.
- quietMs null-checks the timestamp instead of testing truthiness, so an
  epoch-zero value means the same thing to it as it does to delivery.
- The TZ-pinned test deletes TZ when it was originally unset, rather than
  restoring the literal string "undefined" into sibling tests.
- check's usage string documents --no-fleet, and the guide's output example
  carries a fence language.
… a blind re-dispatch

buildFleetEcho now clamps a caller-supplied limit to FLEET_ECHO_MAX_LANES.
The cap is the response contract, not a default, and this block rides on
every orchestration response.

The guide told a coordinator to re-dispatch on `not_accepted`. That is
right for a worker-start lane, where the verdict comes from the worker
never reaching `input_accepted`. For a plain `dispatch --inject` there is
no acceptance signal to read, so the verdict is inferred from the terminal
having produced no output since the dispatch — and acting on a false
positive duplicates work that is already running. The guide now
distinguishes the two sources and says to confirm with `terminal read`
first.
@Tauri-EPO
Tauri-EPO force-pushed the feat/orchestration-fleet-echo-check branch from dfd297d to dde27ee Compare August 17, 2026 21:19
…from

The block reported accepted/not_accepted from two observations of unequal
strength under the same word. A worker-start lane reads stage from the
worker-dispatch row; an unsupervised `dispatch --inject` lane has no such row
and the verdict was inferred from the terminal having stayed quiet since
dispatched_at. Lanes now carry deliveryEvidence, rendered as NOT_ACCEPTED:output
or accepted:stage, so a coordinator can tell a read verdict from an inferred one
without consulting the guide.

The guide's claim that a worker-start verdict is authoritative was also stronger
than the code supports, and is corrected here. markWorkerDispatchReady writes
stage='input_accepted' as soon as sendTerminalAgentPrompt returns, so it records
that the runtime wrote the prompt, not that the agent began a turn: a composer
that swallowed the submit still reports accepted (stablyai#14525). Only not_accepted is
authoritative on that path.
@Tauri-EPO

Tauri-EPO commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Correcting a claim this PR made, and labelling a verdict it was flattening

Pushed a88d3fcf93. Two things, both prompted by reading markWorkerDispatchReady more carefully than I had.

The guide overstated what a worker-start verdict proves. It said the verdict "is authoritative (the worker never reached input_accepted)". That is true of not_accepted and not of accepted. In orchestration-workers.ts:

await runtime.sendTerminalAgentPrompt(terminalHandle, preamble)
effects.push({ kind: 'dispatch_input', role: 'agent', id: terminalHandle, state: 'accepted' })
const worker = db.markWorkerDispatchReady(started.dispatch.id, effects)   // stage = 'input_accepted'

The stage is written as soon as the prompt write returns. Nothing between those lines consults the agent, so accepted means the runtime wrote the prompt, not that a turn began — which is exactly the failure #14525 describes and #14608 partially fixed. A composer that swallowed the submit reports accepted today. The guide now says so.

The block was flattening two observations into one word. accepted/not_accepted was reported from the worker row on one lane and inferred from terminal silence on another, and nothing in the payload said which. Lanes now carry deliveryEvidence:

term_a1  task_31  ctx_9f  dispatched  12s    accepted:stage
term_c3  task_33  ctx_a1  dispatched  3m02s  NOT_ACCEPTED:output
term_d4  task_34  ctx_a2  pending     —      unknown

:stage was read from the worker-dispatch row; :output was inferred from the terminal staying quiet since dispatched_at; no suffix means nothing was available to read. The verdict vocabulary is unchanged, so a coordinator keeps one rule — not_accepted means look now — and the confidence travels beside it instead of living only in prose.

This is the narrow version of the steer I asked for above ("if maintainers would rather the inferred verdict carry its own value"). I did not widen the delivery enum, because a second verdict word would make the coordinator's rule conditional on how the lane was created; the basis is a separate axis and now has a separate field.

Why now: #15105 landed today and gave the lane class this affects a name — dispatch --inject lanes report unsupervised, and the guide it added says the missing worker_dispatches row is deliberate. Inferring a verdict for exactly those lanes without saying it was inferred sat badly next to that.

I have filed the larger finding as #15180 rather than pulling it into this PR: neither basis observes the agent, and the signal that would answer it — a turn boundary from the harness hook stream — is on main already, while the two open PRs that read it (#13762, #13763) do so for their own purposes and neither makes it durable on the dispatch. That is a question for @artile and the maintainers, not a change to smuggle into a stacked feature branch.

Verification on a88d3fcf93, Node 24: 4 affected suites, 74 tests passed; typecheck:node, typecheck:cli, oxlint src config tests --deny-warnings and the bundled-skill-guide check all clean.

…p repeating a healthy table

Three changes to the same problem: the block rides on every run-scoped response,
so what it costs and what it hides both matter.

Ranking. The cap was applied by the query's oldest-first order, so a Run past 12
active lanes truncated its newest — which is where a freshly broken lane lives.
Severity cannot be a SQL predicate because it needs runtime signals, so the query
now reads a wider bounded window and the builder ranks it before cutting: a
not_accepted read from the worker row, then one inferred from silence, then a dead
process, then the longest silence. Truncation lands on the healthy tail. Past the
window ranking degrades to age, which the guide states rather than hides.

Repetition. A healthy fleet says the same thing on every response. Text mode now
collapses it to one line and opens the full table as soon as any lane needs
attention, so the table itself is the signal. JSON keeps every lane: a machine
consumer can summarize, and a payload that changes shape with its contents is a
worse contract than one that does not.

Honesty. The guide now says the block answers which lane to look at, and does not
cover a coordinator parked in check --wait, since it only arrives when asked. It
also drops the lifecycle column from the table, which delivery already implies.
@Tauri-EPO

Copy link
Copy Markdown
Contributor Author

Pushed 2c8441382f. Three changes to the same problem — this block rides on every run-scoped response, so what it costs and what it hides both matter more than they would on a command you opt into.

Ranking, because the cap was cutting the wrong end. Lanes came back in the query's oldest-first order, so a Run past 12 active lanes truncated its newest — which is exactly where a freshly broken lane lives. Severity cannot be a SQL predicate, since it needs runtime signals the query cannot see, so the read is now a wider bounded window and the builder ranks it before cutting:

not_accepted read from the worker row  →  not_accepted inferred from silence
  →  dead process  →  longest silence  →  everything else

Truncation now lands on the healthy tail. Past the window it degrades to oldest-first, and the guide says so rather than leaving it to be discovered. Equal-severity lanes keep query order, so two identical responses do not shuffle.

Repetition, because a healthy fleet says the same thing every time. Text mode collapses to one line when no lane needs attention and opens the full table — every lane, not just the degraded one — as soon as any does:

fleet run_7f3a: 6 lanes, none needing attention, quietest 12s

That makes the table itself the signal. JSON keeps every lane in every response: a machine consumer can summarize, and a payload whose shape depends on its contents is a worse contract than one whose shape is fixed.

Honesty, because the guide was selling more than the block does. It now states that this answers which lane to look at, and does not cover a coordinator parked in check --wait — the block only arrives when you ask, so a coordinator that is not asking learns nothing, for as long as its own timeout. That case is push, not pull, and belongs to work like #13762. Building a supervision strategy that assumes this block will interrupt you is the mistake the guide now names.

The lifecycle column also left the table. It has two values, pending is transient, and it already implies delivery: unknown in the resolver — it stays in the JSON, where it costs nothing and a consumer may want it.

Verification on 2c8441382f, Node 24: 5 affected suites, 91 tests passed; typecheck:node, typecheck:cli, oxlint src config tests --deny-warnings, the bundled-skill-guide check and the max-lines ratchet all clean. One pre-existing test changed with it — the table case now uses a lane that needs attention, because a healthy one renders the summary instead.

@Tauri-EPO

Copy link
Copy Markdown
Contributor Author

Closing this, and #14892 with it. Recording why here rather than just hitting the button, because the reason is about ordering, not about the code.

What changed underneath it

This branch was written on 2026-08-16. Three things have shipped since that it re-derives by hand:

Each of those is fixable with a rebase and a rename. That is not why I am closing it.

The ordering problem

A fleet read has to report a delivery verdict per lane, and what that verdict is has not been decided. It is DEC-01 on #15190, and #14962 landing the throwing guard in v1.4.187 changed that question rather than settling it. Landing this PR would have written my guess at an open contract into a src/shared/ type, which is the hardest place to change afterwards.

So this was built at the wrong point in the sequence: a read surface over an unsettled contract, using hand-rolled inference for three things that now have shipped answers.

What this is not

Nothing here says the capability is unnecessary. READ-01 and READ-02 on #15190 stay open as reports, and they now read blank for implementation — an honest statement that no attempt reaches them, mine included. If I rebuild this, it should read agentWait, unsupervised and the pinned vocabulary from the shipped code and add only the aggregation, which would make it a considerably smaller change.

The review rounds on this branch produced two things worth carrying into whatever replaces it: the Run-isolation fix on listActiveDispatchesForRun, which demanded dispatch_contexts.run_id and tasks.run_id agree rather than trusting the join, and the severity ranking that reads a wider bounded window before capping, so truncation drops the healthy tail instead of the newest lane.

@Tauri-EPO Tauri-EPO closed this Aug 22, 2026
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.

5 participants