♻️ SQLite state foundation with migrations and full metadata parity#231
♻️ SQLite state foundation with migrations and full metadata parity#231
Conversation
This comment has been minimized.
This comment has been minimized.
PR Review: SQLite state foundation with migrations and full metadata parityOverall this is a solid, well-scoped migration. The schema versioning story is clean, the file/SQLite backends share a coherent interface, and the dependency injection pattern preserves testability throughout. A few things worth addressing before merge: Performance: store opened/closed per HTTP requestIn The events router shows the right pattern — create one store, subscribe, close on disconnect. Dashboard and health should receive the store as a dependency (injected at server startup) the same way the TDD handler does with Per-operation store opening in metadata modules
function withStateStore(workingDir, operation) {
let store = createStateStore({ workingDir });
try { return operation(store); }
finally { store.close(); }
}Every Module-level
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Introduce schema-versioned SQLite migrations for reporter state and metadata.\nPort baseline/hotspot/region/baseline-build metadata and server registry off JSON files with one-time legacy imports.\nUpdate routers, context, handlers, and tests to read/write through the DB-backed state store.
Break the monolithic state store into a small facade plus dedicated files for schema migrations, sqlite backend, file backend, events, constants, and shared helpers. This keeps DB evolution isolated and gives us a cleaner foundation for future migrations.
- remove file state-store fallback and backend toggles\n- tighten registry/event/state utilities for cleaner behavior\n- move handler/service coverage to real sqlite-backed tests
Introduce explicit read/write store modes, enforce a single writer path, and add one-time legacy JSON bootstrap on CLI startup.\n\nAlso updates routers/services/tests for read-mode access, resets in-memory TDD runtime state on baseline reset, and adds migration/mode contract coverage.
826ba94 to
7c9dfbb
Compare
Vizzly - Visual Test ResultsCLI TUI - 2 changes need review
Changes needing review (2)vizzly-tdd-help · 1202×578 · 14.7% diff vizzly-help · 1202×1430 · 3.0% diff
|
|
@claude rereview this PR please |
|
Claude finished @Robdel12's task in 3m 33s —— View job PR Re-Review
Good progress since the February review. Two of the six previous issues are cleanly resolved, one is effectively resolved with a smarter approach, and a couple of new issues emerged in the latest commits. Here's the full picture: Previous Issues: Status✅ Fixed:
|
Fixes server registry migration retry/port exhaustion handling, read-path DB open guards, and resetBaselines dependency-safe file deletion with coverage.


Why
This refactor is about making local TDD state durable and predictable as the CLI grows.
The old JSON files worked for early usage, but they were starting to create complexity around consistency, migration, and multi-process behavior. SQLite gives us a real schema, safer state evolution, and cleaner concurrency boundaries.
What changed
src/tdd/state-store/sqlite-store.jssrc/tdd/state-store/migrations.jsmode: 'write'for the TDD writer pathmode: 'read'for routers/services/commands that should never mutate statesrc/server/handlers/tdd-handler.jsstate.dbis created for the first timestate.db)Follow-up fixes from re-review
legacy_json_migratedon parse/read failure, so migration can retry on a later invocation.write()no longer does dead in-transaction deletes after a full table clear.nullon exhaustion, andtdd startshows a clear actionable error instead of failing later with a bind error.resetBaselinesnow uses the existingsafeDeleteFilehelper (and injectedunlinkSync) instead of dynamicnode:fsimports.Migration behavior (final)
.vizzly/exists,state.dbdoes not exist, and legacy state files exist, we bootstrap migration once.state.dbexists, migration does not run again.This keeps startup safe and predictable, and avoids hidden write behavior in read-only code paths.
Test plan
npm run lintnode --test tests/tdd/state-store-mode.test.js tests/tdd/metadata/baseline-metadata.test.js tests/tdd/metadata/hotspot-metadata.test.js tests/tdd/metadata/region-metadata.test.js tests/server/routers/events.test.js tests/tdd/tdd-service.integration.test.jsnode --test tests/server/handlers/tdd-handler.test.js tests/server/http-server.test.js tests/server/routers/dashboard.test.js tests/tdd/tdd-service.test.js tests/utils/context.test.jsnode --test tests/tdd/server-registry.test.js tests/server/routers/dashboard.test.js tests/server/routers/health.test.js tests/server/handlers/tdd-handler.test.jsNotes:
npm testin this sandbox still reports existingtests/utils/colors.test.jscolor assertions (TTY/env behavior). The SQLite/state suites above are green.