Skip to content

fix(session): bound in-memory session mirror - #1225

Merged
code-yeongyu merged 21 commits into
mainfrom
fix/mem-session-mirror-budget
Aug 31, 2026
Merged

fix(session): bound in-memory session mirror#1225
code-yeongyu merged 21 commits into
mainfrom
fix/mem-session-mirror-budget

Conversation

@code-yeongyu

@code-yeongyu code-yeongyu commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Bound the ResidentStringStore to a conservative 64 MiB FIFO cache; the JSONL remains authoritative when a blob is evicted.
  • Trim superseded pre-compaction message entries from the live SessionManager mirror while preserving metadata and reloading pruned entries from disk for branching.
  • Added regression coverage for resident bytes, compaction trimming, and disk-backed branch reload.

TDD evidence

RED (commit 4c7cc71cc, before implementation):

Test Files  1 failed (1)
Tests       3 failed (3)
expected 73400520 to be less than or equal to 67108864
expected ... to have a length of 3 but got 4

GREEN (commit 91d6a12b1 plus final fixture commit, current HEAD):

Test Files  14 passed (14)
Tests       142 passed (142)

The literal requested filter src/core/session-manager was also attempted, but this repository's Vitest roots contain tests under test/; that invocation exits 1 with No test files found. The valid remote filters used above are test/session-manager/session-mirror-budget.test.ts and test/session-manager.

Verification

  • Remote Mac runner: MAC_TEST_TIMEOUT_S=2400 bun /tmp/senpi-mac-test.mjs fix/mem-session-mirror-budget -- test/session-manager (exit 0).
  • Rebased onto current origin/main (b618e8cd4) before final push.

Summary by cubic

Bounds the in-memory session mirror so long-lived sessions no longer consume unbounded RAM; the JSONL stays authoritative and evicted or trimmed data reloads from disk when read.

  • ResidentStringStore now evicts the oldest externalized strings past a 64 MiB per-session budget; evicted blobs reload from the JSONL when read.
  • Compaction trims superseded pre-compaction message entries from the live mirror while preserving metadata; branching or reading a pruned entry reloads it from disk instead of throwing.
  • Full-history and compact context reads cache separately; the compact cache holds externalized references so it stays bounded, and missing compact entries are recovered in one batched disk read and stay re-evictable.
  • Adds regression tests covering the byte budget, compaction trimming, cache behavior, and disk-backed branch reload.

Written for commit 2a99856. Summary will update on new commits.

Review in cubic

@code-yeongyu
code-yeongyu force-pushed the fix/mem-session-mirror-budget branch 4 times, most recently from 679c636 to 0a570a0 Compare August 31, 2026 08:12
@code-yeongyu
code-yeongyu force-pushed the fix/mem-session-mirror-budget branch from 2662896 to 2a99856 Compare August 31, 2026 09:48
@code-yeongyu
code-yeongyu merged commit 087c608 into main Aug 31, 2026
16 checks passed
@code-yeongyu
code-yeongyu deleted the fix/mem-session-mirror-budget branch August 31, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant