Skip to content

feat: Lattice.save/load — accumulator snapshot persistence - #46

Merged
discreteds merged 2 commits into
developfrom
feature/lattice-snapshot-save-load
Jul 18, 2026
Merged

feat: Lattice.save/load — accumulator snapshot persistence#46
discreteds merged 2 commits into
developfrom
feature/lattice-snapshot-save-load

Conversation

@discreteds

Copy link
Copy Markdown
Member

First-class build-offline/serve-online persistence for accumulator lattices.

What

  • Lattice.save(dir) writes a snapshot directory: lattice.parquet (combinations frame verbatim — co_*, __agg_*, __prime_product, __level all preserved) + manifest.yaml sidecar (dimensions, aggregates, partition_key).
  • Lattice.load(dir) rehydrates through the public constructor; is_composed round-trips honestly (__prime_product travels in the parquet).

Why

Build-offline → serve-online had no first-class persistence — consumers (mountainash-rules-service LatticeRegistry) hand-rolled parquet + sidecar. Babel CSV can't serve accumulated values (its importer strips __agg_* by contract). This retires the hand-rolled loader.

Design notes

  • Backend purity preserved. save stays pure (relation(...).to_polars().write_parquet(...)). load carries the package's third # allow:-tagged import polars (snapshot parquet read), documented in CLAUDE.md.
  • Manifest is a strict superset of babel's LatticeManifestdimensions/aggregates shapes are byte-compatible, so babel/service tooling reads rules-written snapshots unchanged (pydantic ignores the extra partition_key). One-way by design; documented in the spec.

Tests

5 new tests in tests/accumulator/test_lattice.py: round-trip identity, apply-equivalence (accumulated values compared), file creation, manifest-superset shape, missing-manifest FileNotFoundError. Full quick suite 758 passed / 36 skipped / 31 xfailed; ruff clean; purity gate green.

Spec: docs/superpowers/specs/2026-07-16-lattice-snapshot-save-load-design.md · Plan: docs/superpowers/plans/2026-07-16-lattice-snapshot-save-load.md

🤖 Generated with Claude Code

discreteds and others added 2 commits July 18, 2026 22:52
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@discreteds
discreteds merged commit ec490bf into develop Jul 18, 2026
6 checks passed
@discreteds
discreteds deleted the feature/lattice-snapshot-save-load branch July 18, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant