Repository navigation
fix(server): history trim stops on activity and publishes what it removed - #264
Conversation
…oved Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: 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. |
|
Randy reviewed head 6940c4a. The fixes from the #259 review are verified:
117 targeted tests passed, and so did the 7 package typechecks and changed-file lint. Still needed:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Randy's round 2 at 5363779. These fixes are verified:
34 focused tests pass, and Still needed:
|
…dations Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nvalidations Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged at b4868b6. Randy's round 3 confirmed the two remaining fixes: the descendant of a deleted fork now advances (sequence 331 → 375), and the 1,000-fork payload dropped from 12 MB to 218 KB. The earlier fixes still hold. Randy's only blocker was the per-item |
Follow-up to #259, covering Randy's post-merge review (#259 (comment)) and his reviews of this PR. A history trim checked eligibility once per thread, so a thread opened mid-pass still lost rows. Its deletes bypassed the event log: the snapshot sequence stayed the same for the thread and its forks, live clients and the timeline and search caches kept stale rows, and the preview counted ancestors the delete keeps.
Fix
thread.history-trimmednames the source thread and the turn items and nodes removed from it. The projection deletes those rows when it applies the event, in the same transaction that appends it. The thread's sequence advances, so the timeline index and ThreadFind refresh. Web and mobile apply the event inclient-runtime, and a reconnect replays it. Older clients skip the unknown event type. Trim events don't count as thread activity, so threads keep their place in lists sorted by activity.EventSink.writeBuiltbuilds a write's events inside the commit transaction. Each page of up to 200 rows rechecks the current setting and the thread's idle eligibility there. A thread that is opened, messaged, run, pinned, snoozed or PR-linked stops its trim; setting trimming to 0 stops the whole pass.Tests (
ThreadHistoryTrim.test.ts,ws.test.ts,orchestrationV2Projection.test.ts)ws.test.ts: a fork's copy in a replay, and another in the live tail, each arrive as a fresh snapshot.send_to_user, HTML renders, MCP apps,delegate_task) survive a trim. They stay in the snapshot timeline (which transcript export uses), the wire snapshot web and mobile receive, and the rows thread transfer reads. These pass on main too; they guard against regressions.Transfer budget fix (b4868b6): 2b5b815 checked each live thread-stream item for a fork invalidation with
Stream.mapEffect, which handles one item at a time, so every batch went out as one WebSocket message per item: 26 for the measured turn, against a budget of 8. The check now runs per batch (Stream.mapArrayEffect). A batch without a fork invalidation passes through unchanged as one message; only a batch that contains one is mapped to a fresh snapshot. Locally,transferBudgetV2.integration.test.tsfails without this commit (26 messages against 8, the same as CI) and passes with it. The budget is unchanged.The 30-day default and the opt-in behaviour are unchanged.
vp run check:changedpasses: format, lint, knip, typecheck of 37 packages, and the 8 test files beside the changes (162 tests).Done by Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code