persistence: SubstrateStore enable_persistence(dir)

Same pattern as carriers: per-substrate binary record (.sub) with
atomic .tmp+rename, replay on enable, delete on remove. Records
current state across all three E90 axes (location / processing /
ID-status), plus substid / carrierid / slot / free-form location
label. History is deliberately NOT journaled — it's an in-memory
ring buffer and rebuilding from replayed state would mislead.

Five new tests cover full-axis replay, every terminal processing
state, remove-deletes-journal, corrupt-record drop, and the
history-is-transient invariant.

Closes #2 in the test-gap backlog.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 10:31:54 +02:00
parent f56639ba17
commit 1548b49afd
4 changed files with 372 additions and 19 deletions
+9
View File
@@ -127,6 +127,15 @@ class SubstrateStateMachine {
bool on_processing_event(SubstrateProcessingEvent e);
bool on_id_event(SubstrateIDEvent e);
// Direct state-restore (persistence replay only). Bypasses the
// transition tables and does NOT fire change handlers.
void restore_state(SubstrateState loc, SubstrateProcessingState proc,
SubstrateIDStatus id) {
loc_ = loc;
proc_ = proc;
id_ = id;
}
private:
SubstrateTable loc_table_;
SubstrateProcessingTable proc_table_;