Repository navigation
feat(server): event feed for followers - #216
Merged
Merged
Conversation
GET /api/orchestration/events?after=<seq>&limit=<1..1000>&wait=<0..25> returns events after a cursor in sequence order, shaped like the WebSocket replay. An empty read is held until the engine publishes a newer event or the wait elapses (woken by the live event stream, no polling). A cursor ahead of the log gets 410 cursor-invalid. This lets the Linear bridge stop polling the full shell every 2 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
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
The Linear bridge learns about thread and project changes by polling bkt3. In a 648 s prod trace:
GET /api/orchestration/shell: ~623 KB each, 420 ms average server time, 2.6 s max.GET /api/orchestration/threads/:id.That is ~26 MB/min of JSON and 20–30% of the server's single event loop. The shell snapshot also competes with every client's pings and reconnects.
Fix
A new fork route,
GET /api/orchestration/events?after=<seq>&limit=<1..1000, default 500>&wait=<0..25 s, default 0>, implementing section 1 of the bridge API contract (~/perf-audit-bkt3/80-api-contract.md).What it returns:
after, read from thesequenceprimary key in ascending order.replayEventsRPC: project events carry the resolved repository identity, and activity payloads go throughprojectActivityEvent.{ events, nextAfter, headSequence }.How waiting works:
after, the request subscribes to the engine's live event stream before reading, then parks until an event pastafteris published orwaitelapses.Status codes:
410 { error: "cursor-invalid", headSequence }whenafter > headSequence, meaning the database was replaced. The event log is never pruned, so an old cursor is always served.400 { error: "invalid-request", detail }for bad parameters.403 insufficient_scopewithoutorchestration:read, the same scope as/api/orchestration/shell.Access and wiring:
OrchestrationAccessControl: one lookup per aggregate per page, not a shell rebuild.nextAfterstill advances past hidden events, so a follower never re-reads them.orchestration/eventFeedHttp.expbkt3.tsandorchestration/forkRouteAuth.expbkt3.ts, the bearer auth that PR 9 reuses.PlannotatorAndMcpRoutesLiveinserver.ts, plus a marked import.Evidence
eventFeedHttp.expbkt3.test.ts, 7 tests:limit+nextAfter/headSequence;vp run typecheckinapps/serveris clean, lint is clean, and the fork-marker check passes.After the expbkt3 deploy I will curl the endpoint with a token minted on expbkt3.
Model/harness: Claude Opus 5.5 via Claude Code in T3 Code.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.