perf(server): bound orchestration replay and slow-client live buffers - #216
Open
leoisadev1 wants to merge 2 commits into
Open
perf(server): bound orchestration replay and slow-client live buffers#216leoisadev1 wants to merge 2 commits into
leoisadev1 wants to merge 2 commits into
Conversation
Catch-up replay used to load a global event range, then filter per chat. A stale cursor or a few huge tool payloads could decode gigabytes, and a slow WebSocket client could retain live events without a memory bound. Recursive page concatenation also kept consumed pages alive. Thread resume now measures and reads only that chat's rows through a captured head, with 1,000-event and 8 MiB payload budgets. Shell resume still uses the global range but measures serialized payload bytes before decoding. Live shell and thread subscriptions share a per-subscription budget that includes the unacknowledged RPC batch; overflow detaches the producer and tells the client to resume from its last sequence. Event-store pages are released as they are consumed. Adapted from T3 Code pingdotgg#8992, pingdotgg#9521, pingdotgg#9715, pingdotgg#9726, and pingdotgg#10777. Preserves Akeru bot/group/channel shell fields and Chat error copy. Old clients that omit afterSequence still get a snapshot. Grok 4.6 High in Grok Build via Orca.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummarySummary
No changes requiring attention were identified. Confidence Score: 5/5Safe to merge. There are no outstanding findings requiring changes. Reviews (2): Last reviewed commit: "test(server): bound replay-stat fixtures..." | Re-trigger Greptile |
The shared projection-query layer keeps SQLite AUTOINCREMENT after DELETE, so a hard-coded 1..4 range could miss the inserted rows. Use RETURNING sequence. Grok 4.6 High in Grok Build via Orca.
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
WebSocket catch-up replay loaded a global event range and filtered per chat afterwards. A stale cursor, or a handful of large tool payloads, could decode gigabytes and OOM the server. Slow clients could also retain live shell and thread events without a memory bound, including the batch waiting for an RPC ACK. Recursive event-store page concatenation kept consumed pages alive.
Adaptation
Thread resume now measures and reads only that chat's rows through a captured head, with a 1,000-event cap and an 8 MiB serialized payload budget. A recreated chat ID falls back to a fresh snapshot. Shell resume still uses the global range, but it measures payload bytes in SQL before decoding and snapshots when the gap or budget is unsafe.
Live shell and thread subscriptions share a per-subscription budget that includes queued, coalescing, and unacknowledged work. Overflow detaches the producer even without another pull and returns
OrchestrationGetSnapshotErrorso the client can resume from its last sequence. Event-store pages are released as they are consumed.Akeru bot, group, channel, and people fields on the shell snapshot stay in place. Missing-chat errors still say Chat, not Thread. Clients that omit
afterSequencestill get a snapshot, including pre-pagination clients.Upstream credits
Reviewed adaptations of T3 Code:
Local #16 bootstrap replay, #143 coalescing, and #198 raw-observer policy are preserved. Provider adapters are unchanged.
Scope
Server wire/replay only. Client stream lifetime, config bootstrap, reducer reference stability, and static HTTP caching are separate PRs.
Verification
Focused tests:
vp run --filter akeru-bot typecheckpassedIsolated web client, home
/tmp/akeru-replay-verify.VTW8Fb, populated fixture, worktree ports 6892/14932:/bots/ui-scout. Scout chat, roster, reply/react/read-aloud, and composer rendered./bots/ui-scoutand the same messages, so reconnect resumed the subscription instead of an empty load.These stills are the screens after those actions. They do not replace the pair, reload, second-client, and viewport steps above.
Limitations
This PR does not change provider adapters. Effect stays at beta.103;
Stream.paginateis available locally. Native mobile was not required for this server change.Grok 4.6 High in Grok Build via Orca.