Skip to main content

Module derivation

Module derivation 

Source
Expand description

Derivation baselines — “my source changed” computed, never stamped (agent-trust plan 12).

When a schema declares a rel-type derivation: true, explicitly writing such an edge records the TARGET’s content hash at write time as the edge’s baseline. The include-gated stale_derivations health axis compares each such edge’s baseline against the target’s CURRENT hash: differ → the source is stale against the target; no baseline recorded → unbaselined, distinctly — never fabricated as fresh or stale.

Baselines are engine-owned sidecar state at DERIVATION_SIDECAR_PATH (.memstead/derivations.json) — the anchors-sidecar precedent: staged through the backend’s normal entity-path write so it rides the SAME commit as the mutation that produced it, filtered from entity listings by the .memstead/ rule, invisible in the mem’s markdown, and excluded from _hash by construction. Export/import behaviour follows the anchors sidecar’s decisions (the archive path carries .memstead/ members as-is).

Baseline hashes are the engine’s per-entity content_hash — SHA-256 over the raw markdown truncated to 16 hex characters, the same 64-bit form optimistic locking uses.

Only EXPLICITLY written edges record baselines (create relations, update declare_relations, memstead_relate) — alias-synthesized body-link edges and hierarchy edges are load-derived, not written, and never carry one. Rows whose edge has since been removed are inert (the axis walks live edges, so an orphaned row can never surface); relate-remove prunes its row eagerly.

Structs§

DerivationBaseline
One recorded baseline: the target’s content hash when the edge was (last) asserted.
DerivationSidecar
The sidecar document: baselines keyed by source entity id.

Constants§

DERIVATION_SIDECAR_PATH
Where the sidecar lives inside a mem — sibling of the anchors sidecar, inside the .memstead/ prefix every backend filters from entity listings.