Skip to content

S12.6 — Chronicler save / load (bincode roundtrip) #272

Description

@BemusedVermin

Sprint S12 story 6 of 7 — tracker for epic #24.

Scope

PatternObservation, PatternSignature, Label, etc. already derive Serialize/Deserialize. S12.6 wires the Chronicler itself for bincode roundtrip + adds a determinism-gated test that asserts byte-identical encodings across two runs.

API sketch

impl Chronicler {
    pub fn to_bincode(&self) -> Vec<u8>;
    pub fn from_bincode(bytes: &[u8]) -> Result<Self, ChroniclerLoadError>;
}

#[derive(Serialize, Deserialize)] on Chronicler itself (the few fields it owns are already derive-friendly) + a workspace-aligned bincode dep.

DoD

  • Chronicler is Serialize + Deserialize. Round-tripping via bincode produces a value that compares equal to the original (PartialEq on Chronicler + member types).
  • Determinism gate: serialise → bytes; serialise again → byte-identical. Locked in by a unit test.
  • Bincode bytes are size-bounded under representative load (1000 ingestions, ~50 species → expect < 200 KB; exact figure reported in test).
  • ChroniclerLoadError covers the three failure modes: corrupted bytes (bincode error), schema-version mismatch, signature checksum mismatch.
  • cargo fmt + clippy clean.
  • No new ability-label strings reach the persisted bytes (existing no_hardcoded_label_strings.rs audit stays green; the chronicler persists only what S10.5–S12.4 already track).

INVARIANTS compliance

  • §6 (UI vs sim state) — only sim-side data is persisted (observations, events, label assignments, clusters). Derived UI state (bestiary_discovered flags, ranked-confidence caches) is not serialised.

Out of scope

  • Schema migrations across game versions (open a separate epic if/when v1 → v2 save migration becomes a goal).
  • Compression — bincode raw is fine until the size budget bites.

Effort

2 pts.

Dependencies

  • All previous S12 stories landed (12.1 events, 12.2 clusters, 12.3 cluster labels, 12.4 cluster confidence are all sub-state of the chronicler).

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate:beast-chroniclerWorkspace crate: beast-chroniclersprint:s12Sprint S12 — Chronicler Events & LabelingstorySingle story within a sprint

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions