You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(state): review follow-ups from #142/#149 — idempotency ordering, head verification, replay across migrations (#171)
Codex review follow-ups on the state kernel and drivers, re-verified
against the Effect-native internals from #154:
- Both drivers consult the idempotency key before running the reducer
(#142/#149 P1): a committed key replays its stored result even when the
reducer would now fail against the current head. Payload validation and
canonicalization moved ahead of the key lookup; the reducer runs only on
the append path.
- Committed results replay across migrations (#142 P1): every journal
record stores its post-commit state (event rows too, in the sqlite
driver's existing nullable column), and migrations run the same chain
over the stored results, so replay no longer depends on exact-revision
history that migrations rebase. Legacy event rows without a stored state
fall back to journal replay.
- The sqlite driver verifies storage on open (#149 P1): journal continuity
via expectConsistentJournal (a deleted intermediate row fails closed) and
the materialized head against journal replay (a schema-valid hand-edited
head fails closed); with a pending migration the head is checked against
the last stored post-commit state instead.
- sanitizedFileName hashes the complete definition id (sha-256) instead of
hex-encoding its first six bytes (#149 P2), so ids sharing a sanitized
prefix get isolated database files.
- isJsonSafe rejects sparse arrays (#142 P2): holes no longer canonicalize
like dense arrays under permissive schemas.
The conformance suite pins the corrected semantics for both drivers:
replay-before-reduce, replay across migrations, and prefix-colliding id
isolation; sqlite corruption tests cover the two new fail-closed opens.
0 commit comments