Expand description
§MementoLoader - Persistence layer
Loads ApplicationState memento JSON from disk during boot.
Two flavours: best-effort (returns empty on failure) and
result-typed (surfaces failures explicitly during recovery).
Layout (one export per file, file name = identity):
LoadInitialMementoFromDisk::Fn- best-effort loader forApplicationState::default(). Backs up corrupted files, creates the parent directory on read errors.LoadMementoWithRecovery::Fn- result-typed loader used during recovery flows; surfaces FS / parse failures.AttemptMementoRecovery::Fn(internal) - write a.backupsibling for the corrupted content.CreateCorruptedBackup::Fn(internal) - write a timestamped.json.corrupted.<ts>sibling.
TODO: zero callers as of 2026-05-02 - pending wire-up from
Environment::StorageProvider boot path.
Modules§
- Attempt
Memento Recovery - Side-channel: write the corrupted memento payload to a
.backupsibling so a human can inspect the original. Failure to write the backup is logged but doesn’t propagate - the load path stays best-effort. - Create
Corrupted Backup - Timestamped corruption backup: write the failed-to-parse content
to a
.json.corrupted.YYYYMMDD_HHMMSSsibling so several recovery attempts in a row don’t clobber each other. Pure side-effect; never fails the caller. - Load
Initial Memento From Disk - Best-effort synchronous memento loader for
ApplicationState’sdefault()path. Failures don’t propagate - corrupted files are backed up, missing directories are created, and an empty map is returned so initialisation always succeeds. - Load
Memento With Recovery - Result-typed memento loader. Returns
Ok(empty)for missing files,Err(FileSystemIO)for read failures, andErr(SerializationError)for parse failures (with a timestamped corruption backup written as a side effect). Used during recovery flows where the caller needs to know that loading actually failed.