Repository navigation
fix(decopilot): stop purging the run stream on RUN_FAILED — the consume step still projects it - #4337
Merged
Merged
Conversation
…me step still projects it The run-reactor purged `decopilot.stream.<runId>` on every RUN_FAILED, under the pre-#4179 assumption that failed runs skip the projector. Since the unified consume step, EVERY dispatched run is projected (its entry guard deliberately ignores terminal status), and projection requires the contiguous seq 1..N log. The purge beheads that log in two live ways: - The 10-min idle reaper force-fails a run whose producer is still alive (e.g. a hung long tool); the purge wipes seq 1..K, late chunks resume at K+1, and the consume step then poisons the thread with a persisted "Error: missing seq 1" as the user-visible assistant message. - An ordinary in-band failure fires RUN_FAILED right before the consume step reads the subject; the fire-and-forget purge races that read. Purge ownership now lives solely with the projector (terminal projection) plus the dispatch-start cleanup of the previous turn; the stream's 24h max_age bounds never-projected runs. `RunReactorDeps` drops `streamBuffer` so the guarantee is structural. Co-Authored-By: Claude Fable 5 <[email protected]>
decocms Bot
pushed a commit
that referenced
this pull request
Jul 6, 2026
PR: #4337 fix(decopilot): stop purging the run stream on RUN_FAILED — the consume step still projects it Bump type: patch - decocms (apps/mesh/package.json): 3.99.0 -> 3.99.1 Deploy-Scope: server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Self-host report (b2g): a slide-generation run "executed for a very long time"; after F5 the thread showed
Error: missing seq 1as the assistant's reply.Root cause
run-reactor.tspurgeddecopilot.stream.<runId>on everyRUN_FAILED. That purge is a leftover from the pre-#4179 architecture — its own comment/test said "failed runs are NOT projected, so the reactor purges as explicit cleanup". Since the unified consume step (#4179), every dispatched run is projected (consumeRunProjection's entry guard deliberately ignores terminal status), and projection asserts a contiguousseq 1..Nlog.The purge beheads that log in two live ways:
RUN_IDLE_TIMEOUT_MS) → reaperFORCE_FAIL→ reactor purgesseq 1..Kwhile the producer is still alive (abort isn't forwarded to the hung tool). When the tool finally returns, chunks resume atseq K+1; dispatch completes; the consume step reads the beheaded log →missing seq 1→markRunFailed+ the raw error persisted as a visible error part.RUN_FAILEDright before the gate workflow's consume step reads the subject; the purge is fire-and-forget, so it races theDeliverPolicy.Allread and can produce the same poisoned projection on an otherwise ordinary failure.Fix
Remove the purge from the reactor and drop
streamBufferfromRunReactorDepsentirely, so "the reactor never purges" is structural. Purge ownership is now single-owner, matching the projection design:runProjectorWorkflowBodypurges after a terminal projection (already the case),dispatchRunclears the previous turn's remnants at turn start (already the case),max_agebounds never-projected runs (the documented backstop).With this, the incident scenario projects the run's real content once the producer finishes (thread status stays
failedfrom the reaper —completeRunIfNotCompletedonly flips fromin_progress), instead of destroying the log and fabricatingmissing seq 1.Known separate edges (not this PR)
missing seq N, idle-timeout) are still persisted verbatim as user-visible error parts when they do happen — sanitizing that is a separable change inconsume-harness-stream.Testing
bun test apps/mesh/src/api/routes/decopilot/ apps/mesh/src/dispatch-queue/— unit suites pass (458 pass; the only failures are the(real Postgres)integration specs when no local PG is up).run-reactor.integration.test.ts,run-registry.integration.test.ts) pass against a disposablepostgres:16+ migrations: 13 pass / 0 fail.bun run checkclean;bun run lint0 errors (7 pre-existing warnings, none in touched files);bun run fmtapplied.🤖 Generated with Claude Code
Summary by cubic
Stop purging the run’s JetStream subject on RUN_FAILED in Decopilot. This prevents beheading the stream and fixes “missing seq 1” projections from reaped or raced failures.
Bug Fixes
Refactors
dispatchRun(previous turn cleanup). The 24hmax_ageremains the backstop.streamBufferfromRunReactorDepsand related wiring/tests. Updated comments to reflect the new ownership.Written for commit bca0724. Summary will update on new commits.