Prisma's Bytes input is Uint8Array<ArrayBuffer>; a Buffer (ArrayBufferLike)
does not satisfy it under strict types. The vitest run (esbuild, no
type-check) and nest build (excludes test files) both passed locally, so
`tsc --noEmit` in CI was the first to see it. Use a fresh Uint8Array copy in
the test fixtures.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PGdhRiwU1WRL4XxJfZYipY
Update logs grow with every edit; compaction bounds storage and load time.
- prisma: `collab_open_sessions` table (page_id, heartbeat_at) — the
live-session registry that lets the compaction job avoid pages being
edited, decoupled from collab (no api↔collab network call) and self-
healing (a crashed collab's rows age out of the freshness window).
- collab: `PostgresSessionRegistry` marks a page open on document load and
closed on unload, and refreshes an every-30s heartbeat for all open docs;
wired into the server hooks and started/stopped in index.ts.
- api: `CompactionService` runs hourly via the shared scheduler (#31). For
pages with > 500 log rows and no fresh session it merges `page_updates`
into `ydoc_state` and deletes the merged rows in one FOR UPDATE
transaction — atomic, so a mid-run crash leaves the page untouched and the
next run resumes. Content is unchanged (merged state = base + all updates),
so the content cache is left as-is; updated_at is deliberately not bumped.
Metric log line with pages compacted / rows / bytes removed.
Tests: DB-backed compaction test (content hash unchanged, below-threshold
skipped, active session skipped then picked up next run, stale heartbeat
ignored, idempotent); session-registry DB test (open/close, heartbeat
refresh).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PGdhRiwU1WRL4XxJfZYipY