Skip to content

fix(orchestration): keep Goals and queued turns working in the live read model - #18

Merged
sheehanmunim merged 1 commit into
mainfrom
fix/project-thread-goals
Aug 19, 2026
Merged

fix(orchestration): keep Goals and queued turns working in the live read model#18
sheehanmunim merged 1 commit into
mainfrom
fix/project-thread-goals

Conversation

@sheehanmunim

Copy link
Copy Markdown
Member

Problem

Two features were dead at runtime in the fork:

  • Goals: /goal set an Objective, but the thread never continued working. thread.goal.continue was rejected with "has no Active Goal to continue".
  • Queued turns: a message queued while the agent was busy could never be dispatched — "Queued user message is no longer waiting on thread".

Both had the same root cause. apps/server/src/orchestration/projector.ts — the in-memory projection that OrchestrationEngine builds the read model from, and that the decider validates commands against — handled 39 event types and silently dropped the rest via its default branch. Every thread.goal-* and queued-turn event fell through, so thread.goal stayed null and queued messages never got deliveryState: "queued". The SQL projection handled them, but the decider does not read from SQL.

A third gap sat on top: ProviderCommandReactor.processTurnStartRequested required 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: project thread.goal-set/-paused/-resumed/-blocked/-usage-limited/-completed/-cleared and thread.turn-queued / -dispatched / -cancelled.
  • ProjectionPipeline.ts: write the goal cases to SQL too — goal_json has had a column since migration 041 and nothing ever wrote it.
  • ProviderCommandReactor.ts: restore the message-less Continuation path, using buildGoalContinuationPrompt(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 the activeOrderKey the shell snapshot now returns.

Verification

vp test run src/orchestration439 passing, 36 files. Before: 433 passing, 6 failing across ProviderCommandReactor, decider.queuedTurns and ProjectionSnapshotQuery. Server typecheck clean.

Model: Claude Opus 5, harness: Claude Code

…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
@sheehanmunim
sheehanmunim merged commit bc64887 into main Aug 19, 2026
3 of 7 checks passed
@sheehanmunim
sheehanmunim deleted the fix/project-thread-goals branch August 19, 2026 19:44
@github-actions github-actions Bot added size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant