Skip to content

Implement fn snapshot / fn restore over the declared StateConfig contract #14

@hyperpolymath

Description

@hyperpolymath

Summary

crates/wharf-core/src/config.rs declares the snapshot-system
config surface:

  • StateConfig.snapshots_to_keep (default 10)
  • StateConfig.snapshot_dir (default .wharf/snapshots)

and crates/wharf-core/src/mooring_client.rs references
commit_resp.snapshot_id as the reference key returned from a
successful mooring commit.

But there is no actual snapshot implementation yet — a workspace-wide
search for fn snapshot, fn restore, fn recover, and
fn create_snapshot returns 0 hits across crates/, bin/, and
adapters/. The contract is documented; the runtime is nascent.

Surfacing

veridical-simulation-core's
wharf-veridicality-probe (Phase 4c of the Veridical Simulation
program-of-work, 2026-04-27) ran a reference snapshot ledger
against the declared contract — 10 rounds, snapshot-round-trip-T-N
= 1.0000, retention-policy-honoured = 1.0000 — and then probed the
project-wharf source for the real implementation:

implementation-presence: 0.0000
  fn snapshot         = 0
  fn restore          = 0
  fn recover          = 0
  fn create_snapshot  = 0

Per-shape geometric mean against the declared config contract is
0.9647; the impl gap is the standalone finding.

Acceptance criteria

A minimum viable snapshot subsystem under crates/wharf-core/src/
that:

  • Materialises each snapshot under <snapshot_dir>/<snapshot_id>/
    with at least a payload.bin plus a manifest.json carrying the
    ledger ID, round/sequence number, and SHA-256 of the payload.
  • Provides fn create_snapshot(state, id) -> Result<Snapshot>
    and fn restore(id) -> Result<State> with byte-exact round-trip:
    restore(id) returns the bytes that create_snapshot wrote.
  • Honours snapshots_to_keep retention on every write — never
    exceeds the budget on disk.
  • Exposes the snapshot_id key the mooring CommitResponse already
    surfaces, so the existing client wiring works unchanged.

The reference ledger inside wharf-veridicality-probe
(rust-core/wharf-veridicality-probe/src/main.rs, the
Snapshot / write_snapshot / read_snapshot / enforce_retention
functions) is a working blueprint that respects the same contract
and can be lifted into wharf-core more or less directly.

Reproducer

cargo run -p wharf-veridicality-probe -- \
  --wharf-config-rs /var/mnt/eclipse/repos/project-wharf/crates/wharf-core/src/config.rs \
  --wharf-root      /var/mnt/eclipse/repos/project-wharf \
  --snapshot-rounds 10 \
  --api 'http://[::1]:8080' \
  --out /tmp/wharf-phase4c.a2ml

After the impl lands, the same probe should report
implementation-presence: 1.0000 and the existing 1.0 round-trip /
retention scores should hold.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions