Skip to content

perf(server): bootstrap engine from persisted projections#1648

Merged
juliusmarminge merged 2 commits intomainfrom
codex/backend-perf-bootstrap
Apr 1, 2026
Merged

perf(server): bootstrap engine from persisted projections#1648
juliusmarminge merged 2 commits intomainfrom
codex/backend-perf-bootstrap

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Apr 1, 2026

Summary

  • initialize the orchestration engine read model from persisted projections after projection bootstrap
  • remove the extra startup replay pass over the full orchestration event log
  • update orchestration test harnesses to provide the snapshot query dependency during engine startup

Stack

Validation

  • bun run test src/orchestration/Layers/OrchestrationEngine.test.ts
  • bun run test src/orchestration/Layers/ProjectionSnapshotQuery.test.ts src/checkpointing/Layers/CheckpointDiffQuery.test.ts src/persistence/Layers/ProjectionThreadMessages.test.ts src/orchestration/Layers/ProjectionPipeline.test.ts src/orchestration/Layers/OrchestrationEngine.test.ts src/orchestration/Layers/CheckpointReactor.test.ts src/orchestration/Layers/ProviderRuntimeIngestion.test.ts src/orchestration/Layers/ProviderCommandReactor.test.ts
  • bun fmt
  • bun lint
  • bun typecheck (currently fails in apps/web due pre-existing @effect/atom-react / Layer.suspend errors)

Note

Medium Risk
Changes orchestration engine startup semantics to seed in-memory state from projection snapshots rather than replaying the full event log; incorrect/missing snapshots could lead to stale read models at boot. Also touches server layer wiring and multiple harness/test compositions, which can cause runtime DI/startup regressions.

Overview
Orchestration engine startup now initializes its in-memory read model from persisted projection snapshots by calling ProjectionSnapshotQuery.getSnapshot() after projection bootstrap, removing the extra full OrchestrationEventStore.readAll() replay pass.

Wires OrchestrationProjectionSnapshotQueryLive as a required dependency throughout runtime composition: refactors server.ts orchestration layers to separate infrastructure vs engine, and updates integration/test harness layers to provide the snapshot query to OrchestrationEngineLive.

Adds a new engine test asserting bootstrap uses snapshots (and fails if historical replay is attempted).

Written by Cursor Bugbot for commit 379bef6. This will update automatically on new commits. Configure here.

Note

Bootstrap orchestration engine read model from persisted projection snapshots instead of event replay

  • makeOrchestrationEngine now calls ProjectionSnapshotQuery.getSnapshot() at startup instead of replaying all historical events via OrchestrationEventStore.readAll(), reducing bootstrap time proportional to event history.
  • A new OrchestrationProjectionSnapshotQueryLive layer is wired into OrchestrationEngineLive across server.ts, integration harnesses, and all affected test modules.
  • ProjectionThreadMessageRepository gains a getByMessageId method returning Option<ProjectionThreadMessage>, used by the thread.message-sent projector in ProjectionPipeline.ts to look up messages directly instead of listing by thread.
  • Behavioral Change: the engine's in-memory read model is now seeded from the snapshot store at startup; if snapshots are stale or missing, the engine will not replay missing events to catch up.

Macroscope summarized 379bef6.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c8a500a3-aea7-4f8a-9f28-17337bd50529

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/backend-perf-bootstrap

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

@github-actions github-actions bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Apr 1, 2026
@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-bootstrap branch from 2131e68 to 5c2fe46 Compare April 1, 2026 16:37
@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-message-projection branch from f07a69d to ed2220e Compare April 1, 2026 16:37
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 1, 2026

Approvability

Verdict: Needs human review

This PR changes the orchestration engine's bootstrap mechanism from event replay to loading from persisted projection snapshots - a significant change to startup behavior that affects how the engine initializes its in-memory state. While the intent is performance improvement, the change to core initialization logic warrants human review.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-message-projection branch from ed2220e to acc331e Compare April 1, 2026 16:59
@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-bootstrap branch from 5c2fe46 to 4a2c81a Compare April 1, 2026 16:59
@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-message-projection branch from acc331e to f23d141 Compare April 1, 2026 17:06
@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-bootstrap branch from 4a2c81a to 3938930 Compare April 1, 2026 17:06
@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Apr 1, 2026
@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-bootstrap branch from 2d09204 to 362933c Compare April 1, 2026 21:41
@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-message-projection branch from f23d141 to 059ff5b Compare April 1, 2026 21:41
@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-bootstrap branch from 362933c to 8bb2822 Compare April 1, 2026 21:45
Base automatically changed from codex/backend-perf-message-projection to main April 1, 2026 21:48
juliusmarminge and others added 2 commits April 1, 2026 14:49
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge force-pushed the codex/backend-perf-bootstrap branch from 8bb2822 to 379bef6 Compare April 1, 2026 21:49
@juliusmarminge juliusmarminge merged commit 823d69f into main Apr 1, 2026
12 checks passed
@juliusmarminge juliusmarminge deleted the codex/backend-perf-bootstrap branch April 1, 2026 22:07
gigq pushed a commit to gigq/t3code that referenced this pull request Apr 6, 2026
…1648)

Co-authored-by: codex <codex@users.noreply.github.com>
Chrono-byte pushed a commit to Chrono-byte/t3code that referenced this pull request Apr 7, 2026
…1648)

Co-authored-by: codex <codex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). 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