Skip to content

feat(state): land State, Managed, history, reconciliation, failure types#6

Merged
UnbreakableMJ merged 2 commits into
mainfrom
feat/state-types
Apr 27, 2026
Merged

feat(state): land State, Managed, history, reconciliation, failure types#6
UnbreakableMJ merged 2 commits into
mainfrom
feat/state-types

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Contributor

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:

  • `State` — top-level aggregate; the in-memory mirror of `state.toml`.
  • `SCHEMA_VERSION = 1` — current on-disk shape.
  • `Managed`, `ConfigFileRecord`, `ServicesState`, `UserEnvRecord`, `KernelRecord`.
  • `Adopted`.
  • `HistoryEntry`, `SnapshotRef`.
  • `ReconciliationEntry`, `ReconciliationAction`.
  • `FailureRef`.
  • `StateError`.

Design notes

  • `State` derives `PartialEq` but not `Eq` — the `reserved` forward-compat map carries `toml::Value` whose `Float` variant wraps a non-`Eq` `f64`. Tests use `PartialEq` exclusively. Documented inline.
  • `reserved` is excluded from the emitted JSON Schema via `#[schemars(skip)]`; its values are untyped by design (forward-compat).
  • Every `OffsetDateTime` field uses `#[serde(with = "time::serde::iso8601")]` per Plan §11.
  • `Uuid` fields described as `String` in the JSON Schema via `#[schemars(with = "String")]`.

Out of scope

  • `FileSystem` trait + `StateStore` + `read` / `write_atomic` / `append_*` — chunk M1-W1-E.
  • Migration framework + `MockFs` feature-gate + property tests — chunk M1-W1-F.

Verification

  • `cargo build -p pearlite-state`
  • `cargo clippy --workspace --all-targets -- -D warnings` — zero warnings
  • `cargo fmt --all --check`
  • `scripts/ci/check-spdx.sh`
  • `pearlite-audit check .` — 1 check, 0 violations

🤖 Generated with Claude Code

UnbreakableMJ and others added 2 commits April 27, 2026 17:27
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>
@UnbreakableMJ
UnbreakableMJ merged commit f104d88 into main Apr 27, 2026
3 checks passed
@UnbreakableMJ
UnbreakableMJ deleted the feat/state-types branch April 27, 2026 14:33
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