@@ -116,6 +116,72 @@ The system SHALL The recall tool SHALL partition returned memories into authorit
116116
117117> Decision recorded: dbe6a95e
118118> Date: 2026-06-16
119+
120+ ### Requirement: AuthoritativeRecallInvariant
121+
122+ The system SHALL guarantee, as a single named and test-enforced invariant, that ** no
123+ memory whose freshness verdict is ` drifted ` or ` orphaned ` ever appears in an authoritative
124+ recall path unlabeled** . The authoritative recall paths are the ` recall ` tool and the
125+ memory (decision) section of ` orient ` . An ` orphaned ` memory SHALL be fully withheld from
126+ the authoritative set (surfaced only under ` needsReanchoring ` / ` staleDecisions ` ); a
127+ ` drifted ` memory MAY remain in the authoritative set only when it carries an explicit
128+ ` verify ` label. This invariant is the operational definition of the project promise:
129+ * OpenLore never serves an unverified or stale fact as authoritative.* It SHALL be enforced
130+ by a property-based test (` memory-invariant.test.ts ` ) that generates arbitrary memories and
131+ arbitrary code mutations and asserts the property holds for every generated case.
132+
133+ #### Scenario: A drifted memory is excluded from the authoritative set unlabeled
134+
135+ - ** GIVEN** a memory whose anchor verdict is ` drifted `
136+ - ** WHEN** ` recall ` or ` orient ` produces its response
137+ - ** THEN** the memory does not appear in the authoritative set unlabeled; it is withheld or
138+ carries an explicit verify/non-authoritative label
139+
140+ #### Scenario: The invariant holds under generated mutation
141+
142+ - ** GIVEN** an arbitrary memory and an arbitrary mutation to the code it anchors
143+ - ** WHEN** the authoritative recall path is computed
144+ - ** THEN** the authoritative set contains only ` fresh ` memories and explicitly-labeled
145+ ` drifted ` ones, never an ` orphaned ` memory
146+
147+ ### Requirement: FreshnessFailsSafeTowardDistrust
148+
149+ The freshness computation (` anchorFreshness ` , ` hashSpan ` ) SHALL fail safe toward distrust:
150+ any ambiguity, hash collision, or boundary error SHALL bias the verdict toward ` drifted ` or
151+ ` orphaned ` , never toward a false ` fresh ` . A renamed, moved, or deleted symbol SHALL yield
152+ ` orphaned ` (or ` drifted ` only when a confident relocation is established). ` hashSpan ` SHALL
153+ slice spans by byte offset so multibyte UTF-8 boundaries hash correctly. A test that
154+ produces a false ` fresh ` SHALL be treated as a correctness failure; a false ` orphaned ` is
155+ acceptable. This is guarded by the adversarial suite (` anchor-adversarial.test.ts ` ).
156+
157+ #### Scenario: A forced collision does not produce false fresh
158+
159+ - ** GIVEN** two distinct source spans
160+ - ** WHEN** freshness is computed for a memory anchored to one after the other replaces it
161+ - ** THEN** the verdict is ` drifted ` or ` orphaned ` , never ` fresh ` (distinct spans do not
162+ collide on the truncated content hash; a collision would fail the suite loudly)
163+
164+ #### Scenario: A multibyte span boundary hashes correctly
165+
166+ - ** GIVEN** an anchored span whose start or end falls on a multibyte UTF-8 boundary
167+ - ** WHEN** ` hashSpan ` computes the content hash before and after an unrelated edit elsewhere
168+ - ** THEN** the hash is byte-correct and stable, producing ` fresh ` only when the span bytes
169+ are unchanged
170+
171+ ### Requirement: ConcurrentMemoryWriteSafety
172+
173+ The ` remember ` and ` record_decision ` tools SHALL be safe under concurrent invocation: two
174+ concurrent writes to the same store SHALL NOT cause either write to be lost. On a write
175+ conflict the system SHALL re-read the current store and re-apply the pending
176+ append/upsert (compare-and-swap on a monotonic ` sequence ` ), rather than overwrite the
177+ competing write.
178+
179+ #### Scenario: Concurrent remember calls lose no write
180+
181+ - ** GIVEN** N concurrent ` remember ` calls against the same memory store
182+ - ** WHEN** all calls complete
183+ - ** THEN** the persisted store contains all N memories
184+
119185### Requirement: DecisionsCarryStructuralAnchorsForSelfinvalidation
120186
121187The system SHALL resolve structural anchors against the call graph when recording a decision, falling back to file-level anchors when no analysis is available.
0 commit comments