Add StorePolicy: declarative, config-selected backend (0.1.2) - #2
Merged
Conversation
WHAT: StorePolicy + BackendKind — a flat, serde-deserializable policy that selects the storage backend from configuration. Default = Sqlite (today's behavior, no daemon). Adds a serde dep; toml dev-dep for the deserialization tests. Bump 0.1.1 -> 0.1.2. WHY: the backend a consumer opens should be a reviewed config choice, not a hardcoded commitment — lowering risk (safe default, reversible) and letting the fleet change direction (to Postgres, later) by editing config rather than code. The crate owns only the vocabulary; resolution stays in each consumer, because open semantics (pragmas, connection ownership) are consumer-specific. Regression test: default_is_safe_sqlite — adopting a policy is a no-op until a value is deliberately set. 20 tests green; fmt + clippy -D warnings clean. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Summary
Adds the policy seam that keeps backend selection in reviewed configuration, not code:
BackendKind(sqlite|postgres) — the shared backend vocabulary.StorePolicy— a flat, serde-deserializable policy ([store] backend = "sqlite").Default= SQLite, so adopting a policy is a no-op until a value is deliberately set (the low-risk guarantee). Grows new knobs (Postgres URL ref, doorbell mode) as features land.The crate owns only the vocabulary; resolution stays in each consumer (open semantics — pragmas, connection ownership, domain SQL — are consumer-specific). Consumed first by modulex (folded into #59); newt reuses it.
Test plan
just checkgreen (fmt + clippy -D warnings + tests).default_is_safe_sqlite(regression — default stays SQLite), flat lowercase deserialize, empty-config-is-default, unknown-backend-errors.risk:low — additive (new module + serde dep), regression-tested, no CI/hook changes.