feat(state): land State, Managed, history, reconciliation, failure types#6
Merged
Conversation
Chunk M1-W1-D of M1 plan: pearlite-state type scaffolding only, no I/O yet. Types match PRD §7.2's state.toml schema verbatim. Public types (re-exported from lib.rs): - State — top-level aggregate; the in-memory mirror of state.toml. - SCHEMA_VERSION (= 1) — current on-disk shape; bumps go through migrate.rs in chunk M1-W1-F. - Managed — [managed.*] namespace: pacman, cargo, config_files, services, user_env, kernel. - ConfigFileRecord, ServicesState, UserEnvRecord, KernelRecord. - Adopted — [adopted.*] namespace: pacman + cargo "leave alone" lists. - HistoryEntry, SnapshotRef — [[history]] entries (one per successful apply; full plan lives at /var/lib/pearlite/plans/<plan-id>.json). - ReconciliationEntry, ReconciliationAction — [[reconciliations]]. - FailureRef — [[failures]] pointers; full record JSON lives at /var/lib/pearlite/failures/<plan-id>.json per PRD §11.4. - StateError (thiserror). Internal modules: schema, history, reconciliation, failure, errors — one per type cluster. Design notes: - `State` derives PartialEq but not Eq because the `reserved` forward-compat map (BTreeMap<String, toml::Value>) carries `toml::Value::Float` which wraps a non-Eq f64. Tests use PartialEq exclusively; Hash is not required. Documented inline. - `reserved` is excluded from the emitted JSON Schema via #[schemars(skip)]; its values are untyped by design (forward-compat for fields this Pearlite build doesn't yet know about). - Every OffsetDateTime field uses #[serde(with = "time::serde::iso8601")] per Plan §11. Optional timestamps use the matching ::option helper. - Uuid fields use the workspace v7 + serde features and are described as String in the JSON Schema via #[schemars(with = "String")]. What's NOT in this chunk: - FileSystem trait (chunk M1-W1-E). - StateStore + read/write_atomic + append_* (chunk M1-W1-E). - Migration framework (chunk M1-W1-F). - MockFs feature-gate (chunk M1-W1-F). - Property tests (chunk M1-W1-F). Verification: - cargo build -p pearlite-state - cargo clippy --workspace --all-targets -- -D warnings - cargo fmt --all --check - scripts/ci/check-spdx.sh - pearlite-audit check . (1 check, 0 violations) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cargo-machete flagged toml_edit as unused in chunk M1-W1-D's type-only scope. The dep is needed for the atomic-write implementation's unknown-field preservation, which lands in chunk M1-W1-E. Comment in Cargo.toml records the intent. Co-Authored-By: Claude Opus 4.7 (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.
Chunk M1-W1-D: `pearlite-state` type scaffolding only, no I/O yet. Types match PRD §7.2's `state.toml` schema verbatim.
Public surface
`pearlite_state::*` now re-exports:
Design notes
Out of scope
Verification
🤖 Generated with Claude Code