Expand description
Substrate-wide LockLifecyclePrimitive trait.
The deterministic-lock pattern (transient build artifacts +
explicit operator snapshots + typed diffs) generalizes across
every package-manager adapter. cargo today, npm/bundler/poetry/
gomod/helm tomorrow. This trait is the typed contract: implement
these methods, get the gen lock CLI surface + substrate
refusal-on-drift gating for free.
§Required substrate-side guarantees
An implementor promises:
-
Stateis a closed typed enum with at least the canonical four states —Unlocked/Locked/Drifted/MissingLock. Concrete adapters may add more (e.g.gen-npmmight addWorkspaceProtocolMismatch). The state IS observable from filesystem alone (no daemons, no network, no cached state). -
LockDiffis a structured value type (not text). Two consecutiveupdatecalls with no Cargo.lock/package-lock.json movement between produce byte-equal diffs. -
current_stateis pure — same filesystem state → same output. Idempotent and deterministic. -
snapshot/update/resetare explicit operator verbs — they NEVER fire as a side-effect ofcurrent_stateor any other read.
§Trait-boundary testing
Each implementation provides a parallel mock impl (e.g.
MockCargoLifecycle for tests) that lets gen-cli’s dispatcher
exercise every state transition hermetically — same shape as
PathDepResolver + MetadataSource already use.
Enums§
- Lock
Error - Typed errors emitted by any
LockLifecyclePrimitive. Adapters that need richer context wrap their domain errors inSource.
Traits§
- Lock
Lifecycle Primitive - Typed lock-lifecycle primitive — one impl per adapter.