Skip to content

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

Open
code-yeongyu wants to merge 15 commits into
mainfrom
fix/mem-session-mirror-budget
Open

fix(session): bound in-memory session mirror#1225
code-yeongyu wants to merge 15 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.

  • ResidentStringStore now evicts the oldest externalized strings past a 64 MiB per-session budget; the JSONL stays authoritative and evicted blobs reload from disk when read.
  • Compaction trims superseded pre-compaction message entries from the live mirror while preserving metadata, and getEntries() loads full history from the JSONL once and caches it so reads stay complete without repeated disk access.
  • Branching on a pruned entry reloads it from disk instead of throwing.
  • Adds regression tests covering the resident byte budget, compaction trimming, cached full-history reads, and disk-backed branch reload.

Written for commit 5d4e83a. Summary will update on new commits.

Review in cubic

@code-yeongyu
code-yeongyu force-pushed the fix/mem-session-mirror-budget branch from 91d6a12 to cac7253 Compare August 31, 2026 05:41
@code-yeongyu
code-yeongyu force-pushed the fix/mem-session-mirror-budget branch from d6089d2 to 1cb8faa Compare August 31, 2026 06:59
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