feat(memory): enforce the Step 4 divergent-write guarantees (#137) #145
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/step4-divergent-write-guarantees"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #137.
The Step 4 scaffold encoded the memory contract but permitted exactly the
duplicate-writer and authority-drift conditions the architecture forbids. This
makes the issue's three guarantees real, behind the same
Storeinterface.1. Divergent writes are preserved, not clobbered
Remembernow treats a second write to an existing(tenant, id)with adifferent content hash as a conflict, not an overwrite:
ConflictRecord(existing + candidate, eachwith its own provenance);
RememberreturnsErrConflictPendingand the incumbent stays canonical;Conflictsmethod lists unresolved conflicts andResolveConflictapplies an explicit operator disposition(
accept_candidateorkeep_existing), requiring a resolver identity.Accepting a candidate supersedes the incumbent and appends it to the record's
revision trail. Identical content stays idempotent.
2.
Improvecannot rewrite authorityThe silent
DerivationMethod = DerivationAgentSummarydowngrade is gone:ErrProvenanceRequired),and the replacement must target the same record and tenant;
replacement (
ErrOperatorApproval);Improveno longer mutates derivation in place; the superseded version goesto an append-only revision trail (
Revisions).An
operator_assertionenvelope is now invalid without an operator approval(
NewOperatorProvenanceis the supported constructor).3. Freshness is real and fails closed
QueryNodeCapacityreadsobservedAtfrom the graph instead of stampingtime.Now();BuildBoundary1Envelopecarriesevidence_observed_atand returnsMISSING_CAPACITY_EVIDENCE(ineligible) when the observation is missing,unparseable, or older than the max age (default 5 min, overridable with
WithMaxEvidenceAge).Also
FormatSPARQLTurtlenow emitssourceRef/derivationMethod/contentHashwhen given the projection's provenance.MemoryKindis documented as orthogonal to the storage planes andprojections.
Tests
internal/memory— 15 tests, all passing under-raceand the FreeBSDcross-build: conflict preservation, both dispositions, resolver identity,
revision trail,
ErrProvenanceRequired/ErrOperatorApproval,operator-assertion approval, staleness fail-closed and the max-age override.
Drive-by fix
432d244fixes a pre-existing red onmain: four prose ISO dates indocs/research/jev-second-brain-transcript.md(from #144) failed theuser-facing date gate. Same pattern as #136/#140 fixing the pre-existing
prettier break. Say the word if you'd rather have it as its own PR.
Gates
ci-checks.shall green (Go build/vet/test/race, FreeBSD cross-build,wiki-lint, date gate, okf, prettier, evidence, whitespace).