Solution: Event Log, Checkpoints, Memory and Deterministic Replay
Выбранный подход#
Use the existing shared vertical-slice public ports rather than creating a second event model. Events remain authoritative; live state and checkpoints are derived. The owned study supplies adversarial acceptance tests and records uncovered contract gaps.
Архитектура и поток данных#
validated command
-> authoritative engine transition
-> immutable event clone appended with sequence/state versions/visibility
-> live materialized GameState
recovery
-> replayEvents(genesis, allEvents)
-> verifyCheckpoint(genesis, allEvents, checkpoint)
-> replayFromCheckpoint(genesis, allEvents, checkpoint)
-> reject verification mismatch
-> replay suffix from verified checkpoint state
-> projectState(actor) using preserved visibility
replayFromCheckpoint owns verification, so a caller cannot accidentally use a
tampered checkpoint through the public replay path. Summaries and retrieved
memories remain outside the authority boundary.
Структура прототипа#
prototype/event-log.verification.test.tsimports:- shared engine and seeded RNG;
InMemoryEventLog, checkpoint and replay functions;- canonical
stateHash; projectState;runLongSessionReplay.
prototype/README.mdlists exact coverage and gaps.
No duplicate event/reducer/hash implementation is owned by this study.
Требования#
- Verified environment: macOS 26.4 (
25E246), arm64. - Runtime: Node.js
v24.14.0with built-in TypeScript stripping. - Root dependencies installed according to the shared repository lockfile.
- External services:
none.
Установка#
From repository root:
npm install
node --version
This study adds no dependency.
Запуск#
From repository root:
node --test RnD/technical/2026-07-25-event-log-memory-replay/prototype/event-log.verification.test.ts
The AC-05 test emits the full JSON replay report as a test diagnostic.
Тестирование#
node --test RnD/technical/2026-07-25-event-log-memory-replay/prototype/event-log.verification.test.ts
npm run typecheck
Fresh scoped result: 5 pass, 0 fail, 0 TODO. Fresh root TypeScript result:
exit 0.
Конфигурация#
No environment variables or services are used. The shared long fixture has seed
20260725; the owned short fixture uses the same seed and checkpoints at half.
Ограничения и безопасность#
InMemoryEventLogis not a durability proof.- A checkpoint contains a full state clone and hash; storage authentication and encryption are out of scope.
- The event union lacks correction metadata.
- The long fixture lacks primary-event-reference and branch-chronology models.
- Synthetic fixtures contain no real player data.
Условия переноса в production#
- Preserve verification inside the checkpoint-replay authority boundary.
- Add an immutable correction event with authorized author, reason and corrected event reference.
- Add persistent append atomicity, authorization, backup/restore and migration tests.
- Establish cross-runtime canonical-hash vectors.
- Extend the fixed long fixture with branch chronology and primary-event references before marking the campaign gate fully passed.