Skip to content

feat(2-4): SqliteStore persistence layer#20

Merged
slabgorb merged 2 commits intodevelopfrom
feat/2-4-sqlite-persistence
Mar 26, 2026
Merged

feat(2-4): SqliteStore persistence layer#20
slabgorb merged 2 commits intodevelopfrom
feat/2-4-sqlite-persistence

Conversation

@slabgorb
Copy link
Copy Markdown
Owner

Summary

  • Adds SessionStore trait and SqliteStore implementation alongside existing GameStore
  • Singleton tables (session_meta, game_state) + append-only narrative_log
  • WAL mode, atomic transactions, idempotent schema creation
  • SavedSession bundles meta + snapshot + recap in one load
  • "Previously On..." recap from last 20 narrative entries
  • Directory tree scanning for save.db files via list_saves()
  • PersistError with typed variants (#[non_exhaustive])
  • Backward compat: existing GameStore/PersistenceError/SaveInfo preserved

Test plan

  • 28 tests covering all 11 acceptance criteria
  • Save/load roundtrip, atomic overwrites, last_saved_at stamping
  • Narrative append, limit-based query, insertion order
  • Recap generation and empty recap
  • Directory scanning (single, multiple, empty)
  • Schema idempotency (reopen same DB)
  • In-memory store for testing
  • Full workspace tests pass

🤖 Generated with Claude Code

slabgorb and others added 2 commits March 25, 2026 21:30
RED phase — 30 tests covering all 11 ACs:
- SessionStore trait / SqliteStore implementation
- Save/load roundtrip with SavedSession, SessionMeta
- Narrative append, recent_narrative with limit
- "Previously On" recap generation / empty recap
- Directory tree scanning for list_saves
- Schema idempotency (reopen same DB)
- PersistError variants
- In-memory constructor for testing
- tempfile dev-dependency for directory tests

Compile errors expected:
- SqliteStore, SessionStore, SavedSession, SessionMeta, PersistError
  types do not exist yet (need refactoring from GameStore)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add SessionStore trait with save/load/append_narrative/recent_narrative/generate_recap
- SqliteStore implementation with singleton tables (session_meta, game_state, narrative_log)
- SavedSession bundles meta + snapshot + recap in one load
- "Previously On..." recap from last 20 narrative entries
- Directory tree scanning via list_saves() for save.db files
- WAL mode, schema idempotency (CREATE IF NOT EXISTS)
- PersistError with typed variants (#[non_exhaustive])
- Backward compat: GameStore/PersistenceError/SaveInfo preserved

All 28 tests GREEN.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@slabgorb slabgorb merged commit a6c3b2d into develop Mar 26, 2026
@slabgorb slabgorb deleted the feat/2-4-sqlite-persistence branch March 26, 2026 02:57
slabgorb added a commit that referenced this pull request Apr 4, 2026
Bug #1/#3 (agency): Inject PC agency constraint every turn regardless of
multiplayer state. Explicitly list all PC names. Prohibit PC-to-PC physical
scripting. Previously only fired when other_pcs was non-empty.

Bug #6 (GM watcher): Send GameStateSnapshot for all active sessions on
watcher WebSocket connect. Previously forward-only stream with no replay —
late-connecting GM panel showed "Waiting for first turn..." indefinitely.

Bug #20 (music rotation): Increase ThemeRotator history depth from 3 to 6
and candidate pool from 3 to 5. History of 3 was too shallow for 8+ tracks
per mood, causing same-track repetition within the selection window.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
slabgorb added a commit that referenced this pull request Apr 4, 2026
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