Documentation
¶
Overview ¶
Package readback derives "what has writ deployed" from the store's graph and trace documents (phase-8 step 47 slice 1).
The deployed state is not a file of its own — it is a time-ordered, best-effort fold over the writ-tool runs recorded in the store: a run's successful deploying units (link / copy / write / decrypt) mark their targets deployed; successful removing units (unlink / remove) mark them gone; failed and undispatched units count for nothing. Per-unit file metadata comes from the graph origin's `files` annotation (stamped at plan time by the deploy package); per-unit outcomes come from the trace's receipt stack. The store is user territory — deleted documents fold as missing pieces (reported, never fatal), but a missing run index is an error per the settled design: `writ reconcile` refuses to report from silence.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentDigest ¶
ContentDigest renders `data`'s canonical content identity ("sha256:<hex>").
For comparison against a recorded Entry.RecordedDigest.
Parameters:
- `data`: the content to hash.
Returns:
- `string`: the canonical digest form.
Types ¶
type Entry ¶
type Entry struct {
// Target is the absolute target path — the fold key.
Target string
// Source is the absolute source path the target was deployed from.
Source string
// Action is the target-producing action name (e.g. "file.link", "file.write_text").
Action string
// Scope is the graph origin's scope ("system" / "home", or "" for unscoped runs).
Scope string
// Project is the owning project recorded at plan time.
Project string
// Layer is the contributing layer recorded at plan time, or "" in single-source mode.
Layer string
// TargetRoot is the scope's target root from the run's origin annotations (e.g. $HOME for home) — the
// confinement root and prune boundary for removal consumers.
TargetRoot string
// RecordedEtag is the target's cheap change-detection token captured in the run's ledger snapshot
// (phase-8 step 48), or "" for runs traced before the capture existed.
RecordedEtag string
// RecordedDigest is the target's as-deployed content identity ("<algo>:<hex>") captured in the run's
// ledger snapshot (phase-8 step 48) — what drift attribution compares against; "" for pre-capture runs.
RecordedDigest string
// RecordedSourceDigest is the SOURCE file's content identity from the same snapshot, when the run
// cataloged the source (encrypted chains use it: the encrypted source's bytes are hashable without
// decrypting); "" when the source was not cataloged or the run predates the capture.
RecordedSourceDigest string
// GraphChecksum identifies the graph whose run last touched this target.
GraphChecksum string
// At is the trace timestamp of the run that last touched this target.
At time.Time
}
Entry is one folded target: the deployed state of one absolute target path.
func (Entry) AsRecorded ¶
AsRecorded reports whether the occupant at the entry's target is what the record wrote (#883, ruled 2026-09-23).
A link is as recorded when the target is a symlink whose literal endpoint, absolutized against the target's own directory, is the recorded source -- whether or not that source still exists, so a link that dangles because its source moved between layers is still writ's own. A copy is as recorded when the target's content digest is the recorded as-deployed digest. Neither side is resolved: the source is never consulted, and a record that carries no digest for a copy cannot vouch for it.
Returns:
- `bool`: true when the occupant matches what the record wrote.
type Inventory ¶
type Inventory struct {
// Entries maps each deployed absolute target path to its folded state.
Entries map[string]Entry
// Packages records the successful package operations (`pkg.*` receipts) writ's runs performed, in fold
// order — fact-of-record for reporting; package-manager drift is not writ's concern.
Packages []PackageRecord
// Findings are the store-health observations: index entries whose documents are gone, and documents the
// index never recorded. Informational — the fold proceeds over whatever survives.
Findings []string
// Runs is the number of traces folded.
Runs int
}
Inventory is the fold's output: the deployed entries plus the store-health findings.
func Fold ¶
Fold derives the deployed-state inventory from the store: the record.
The record is the current lifetime (#922): one `writ deploy` invocation across every scope it ran, and the upgrades, reconciliations and adoptions written into it since. Fold reads cli.CurrentLifetime, then that lifetime's runs in write order, and folds each run's per-unit outcomes over its graph's `files` annotation. Nothing else is read: the run index is a detection hint and not consulted, and a trace on disk that the lifetime does not name belongs to none. A trace the lifetime names that is gone folds as a finding.
Parameters:
- `ctx`: the context for the document-loading runtime environment.
Returns:
- `*Inventory`: the folded entries, findings, and run count.
- `error`: os.ErrNotExist when the store has no current lifetime -- a machine never deployed, or one decommissioned -- or when the loading environment cannot be built.
type PackageRecord ¶
type PackageRecord struct {
// Action is the package action name (e.g. "pkg.install").
Action string
// UnitID is the dispatched unit's id within its graph.
UnitID string
// GraphChecksum identifies the graph whose run performed the operation.
GraphChecksum string
// At is the run's trace timestamp.
At time.Time
}
PackageRecord is one successful package operation from a writ trace.