fix(orchestration): keep Goals and queued turns working in the live read model - #18
Merged
Merged
Conversation
…ead model Goals could be set but never drove work, and a queued message could never be dispatched. Two gaps, both in the read model the decider validates against: - `projector.ts` (the in-memory projection behind `OrchestrationEngine`) ignored every `thread.goal-*` and queued-turn event, so `thread.goal` stayed null and a queued message never got `deliveryState: "queued"`. The SQL pipeline handled them; the live model did not, so the decider refused both `thread.goal.continue` and `thread.queued-turn.dispatch`. - `ProviderCommandReactor` still required a user message for every turn start. A Continuation starts a Turn with no message, so the whole autonomous loop died with "User message 'undefined' was not found". Restored the Objective prompt path that an earlier integration merge dropped. Also adds the goal cases to the SQL pipeline (`goal_json` had a column since migration 041 and nothing wrote it) and the `activeOrderKey` the shell snapshot now returns. Orchestration suite: 439 passing, was 433 with 6 failures. Model: Claude Opus 5, harness: Claude Code
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.
Problem
Two features were dead at runtime in the fork:
/goalset an Objective, but the thread never continued working.thread.goal.continuewas rejected with "has no Active Goal to continue".Both had the same root cause.
apps/server/src/orchestration/projector.ts— the in-memory projection thatOrchestrationEnginebuilds the read model from, and that the decider validates commands against — handled 39 event types and silently dropped the rest via itsdefaultbranch. Everythread.goal-*and queued-turn event fell through, sothread.goalstayednulland queued messages never gotdeliveryState: "queued". The SQL projection handled them, but the decider does not read from SQL.A third gap sat on top:
ProviderCommandReactor.processTurnStartRequestedrequired a user message for every turn start. A Continuation starts a Turn with no message — the Objective is rendered into T3-authored prompt text instead — so even a correctly-projected Goal died with "User message 'undefined' was not found for turn start request." That hunk came in with the Goals feature and was dropped by a later integration merge.Fix
projector.ts: projectthread.goal-set/-paused/-resumed/-blocked/-usage-limited/-completed/-clearedandthread.turn-queued/-dispatched/-cancelled.ProjectionPipeline.ts: write the goal cases to SQL too —goal_jsonhas had a column since migration 041 and nothing ever wrote it.ProviderCommandReactor.ts: restore the message-less Continuation path, usingbuildGoalContinuationPrompt(objective)as the turn input and skipping first-turn work (branch rename, title generation) since there is no user message to seed from.Schemas.ts: re-export the three queued-turn payload schemas.ProjectionSnapshotQuery.test.ts: expect theactiveOrderKeythe shell snapshot now returns.Verification
vp test run src/orchestration— 439 passing, 36 files. Before: 433 passing, 6 failing acrossProviderCommandReactor,decider.queuedTurnsandProjectionSnapshotQuery. Server typecheck clean.Model: Claude Opus 5, harness: Claude Code