feat: Lattice.save/load — accumulator snapshot persistence - #46
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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,__levelall preserved) +manifest.yamlsidecar (dimensions,aggregates,partition_key).Lattice.load(dir)rehydrates through the public constructor;is_composedround-trips honestly (__prime_producttravels 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
savestays pure (relation(...).to_polars().write_parquet(...)).loadcarries the package's third# allow:-taggedimport polars(snapshot parquet read), documented in CLAUDE.md.LatticeManifest—dimensions/aggregatesshapes are byte-compatible, so babel/service tooling reads rules-written snapshots unchanged (pydantic ignores the extrapartition_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-manifestFileNotFoundError. 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