Two doc/code contradictions left by memory unification slice 2 #1368
Notifications
Due Date
No due date set.
Depends on
Reference: sam/archie#1368
Reference in new issue
Block a user
Both are claims the merged code does not honour; each is a comment/doc edit, no behaviour change.
internal/domain/memory/contract.go:147-148 says "An invalid scope returns "", which a storage key can never legitimately be: callers must Validate first." That is false for a partial scope: Key() only returns "" for an unknown Kind. Scope{Kind: ScopeAgentUser, Agent: "a1"} (user missing, so Validate fails) returns "agent-user:2:a1:0:". The invariant the sentence defends is real but it is enforced by Validate() at every entry point, not by Key(). Either make Key() return "" when Validate() fails, or correct the sentence and the matching claim in internal/infrastructure/memory/builtin_engine.go (scopeStoresFor: "Scope.Key() is empty for an invalid scope, and caching on "" would pool every invalid scope into one store").
internal/infrastructure/memory/builtin_engine.go:436 says the superseded state "is durable in" HISTORY.md before the live block is touched. internal/infrastructure/memory/builtin/store.go writeFileAtomic (write, close, chmod, rename) has no fsync on the file or the directory, so the two renames are not ordered across a power loss: the live file can land without its history entry. Process-crash semantics do hold. Either fsync the temp file (and once, its directory) before the rename, or scope the claim to process crashes. The same over-claim is echoed by docs/prds/memory-engine-unification.md section 2, so if the fix is wording, fix both.
Found as findings 5 and 10 of the adversarial review of the superseded local slice-2 branch; both confirmed still present on main.
Imported from beads
archie-core-i1k9· GitHub #945 · type task · priority P3 · created 2026-09-19