# MNEMOSYNE: One Check on Every Memory Write: v1.1 → v1.2

From v1.1 (2 Jun) to v1.2 (2 Jun): 6,542 words to 6,718 words, 409 words in new or rewritten paragraphs and 233 taken out, 32 paragraphs changed.

## Change note of v1.2

**Two diagrams and a test plan for the new validity layer**

Two figures arrive: one shows the four hooks over the library's search and write paths, the other follows one fact through a supersede event on a timeline. A new section, 9.5.6, lists the tests that would prove the validity layer works: the old period closes, a "now" search returns only the new fact, a dated search returns the old one, and nothing is deleted. The changelog block at the end and the version header are dropped from the text.

## Changed paragraphs

Marks: [-removed-] {+added+}.

### MNEMOSYNE: A Plugin-Layered Enhancement Suite for Personal-Agent Memory Systems

[-# MNEMOSYNE: A Plugin-Layered Enhancement Suite for Personal-Agent Memory Systems-]

### MNEMOSYNE: A Plugin-Layered Enhancement Suite for Personal-Agent Memory Systems

[-**Paper:** J14 — MNEMOSYNE **Version:** 1.1 **Date:** 2026-06-02 **Author:** Oscar Serra **Plugin:** tinkerclaw-memory-enhancements (v0.1) **Status:** Production scaffold; hippocampus index + compaction capture live; task scoring + contradiction gate scaffolded. Bi-temporal substrate now live in memory-core (validity columns, temporal search predicate, supersede writer); MNEMOSYNE's validity layer (§9.5) is the plugin-side behavior on top.-]

### MNEMOSYNE: A Plugin-Layered Enhancement Suite for Personal-Agent Memory Systems

[-----]

### Abstract

Personal AI assistants that accumulate months of memory face four gaps that upstream retrieval systems do not close: constant-time concept lookup degrades to linear search at scale, retrieval scoring ignores the agent's current task, memory writes can silently introduce contradictions, and context compaction permanently destroys information that was used once but never queried again. We present **MNEMOSYNE**, a plugin-layered enhancement suite that addresses all four gaps without modifying the upstream memory-core codebase. MNEMOSYNE registers four hooks — `retrieval_pre`, `before_message_write`, `before_compaction`, and `after_compaction` — on top of OpenClaw's markdown-first memory system. The hippocampus concept index and compaction-aware capture are deployed in production (v0.1); task-conditioned retrieval scoring and the contradiction gate are scaffolded for v0.2. We also describe how the contradiction gate evolves into a bi-temporal validity layer (§9.5): rather than blocking or warning, a contradicting write *supersedes* the prior fact by closing its validity interval, so the corpus retains full history and every retrieval can ask "what is true now" versus "what was true then." {+This evolution is no longer speculative — memory-core now ships the validity columns, the temporal search predicate, and the supersede writer, leaving MNEMOSYNE to route the gate's decision into a substrate that already exists.+} The plugin architecture permits marketplace distribution as a single installable unit.

### Abstract

[-----]

### 1.3 Contributions

[-----]

### 2.3 Related Systems

[-----]

### 3.1 Plugin-Layered Design

{+Figure 1 shows the full data flow: how a query enters through the two `retrieval_pre` hooks, how a write passes the contradiction gate before promotion, and where the supersede path routes the gate's decision into memory-core's bi-temporal writer (§9.5).+}

### 3.1 Plugin-Layered Design

{+![Figure 1: MNEMOSYNE's four hooks layered over memory-core's retrieval and write pipelines, with the supersede path routing a contradicting write into the bi-temporal validity writer.](images/mnemosyne-architecture.png)+}

### 3.4 Storage Isolation

[-----]

### 4.8 Persistence

[-----]

### 5.5 Interaction with Concept Index

[-----]

### 6.3 Modes: Warn, Block, Supersede

**Supersede mode** (§9.5): The contradiction is resolved rather than logged or blocked. The prior fact's validity interval is closed and the new fact opens its own — both rows are retained, so nothing is lost. This is the non-lossy resolution that the v1.0 [-paper's two-mode-] design lacked; §9.5 describes the mechanism and its grounding in memory-core's now-live bi-temporal substrate.

### 6.3 Modes: Warn, Block, Supersede

In v1.0, warn was the default precisely because block is lossy. With supersede [-available (§9.5),-] {+available,+} the default question is revisited [-there.-] {+in §9.5.4.+}

### 6.4 Relationship to J1 and J4

[-----]

### 7.5 Relationship to J1 ENGRAM

[-----]

### Restart gateway (SIGUSR1 does not reload ES modules) openclaw-restart --full ```

[-----]

### 9.5 Bi-Temporal Validity: From Contradiction-Logger to Contradiction-Resolver

{+Figure 2 illustrates a single fact's life across a supersede event: fact A is written with an open interval, a contradicting fact B closes A's interval and opens its own, and a `current` query returns only B while a `valid-at` query before B's write still returns A.+}

### 9.5 Bi-Temporal Validity: From Contradiction-Logger to Contradiction-Resolver

{+![Figure 2: A fact's validity timeline across a supersede event. Fact A's interval is closed at B's ingestion; both rows persist, so 'current' returns B and 'valid-at-T' returns A.](images/bitemporal-timeline.png)+}

### 9.5.1 Division of Labor: J2 Owns the Schema, J14 Owns the Behavior

- The `chunks` table now carries `validity_start`, `validity_end`, `ingestion_time`, and `superseded_by` columns, added idempotently via `ensureColumn()` in `memory-schema.ts`, with a covering index `idx_chunks_validity` on `validity_end` so the hot-path "current" filter does not table-scan. (`validity_end IS NULL` means currently-valid / unbounded; back-filled legacy rows are NULL and so remain retrievable in the default mode.) - `StoredChunk` (`storage/types.ts`) carries the matching optional [-fields `validityStart`, `validityEnd`, `ingestionTime`, `supersededBy`,-] {+fields,+} and `SearchParams` gains `temporalMode: "current" | "valid-at" | "all"` plus `asOfTime`. - The read path is already temporal-aware: `manager-search.ts` [-builds a `temporalPredicate()` clause-] {+exports `temporalPredicate()`,+} threaded into the vector, FTS, and hybrid SELECTs — `current` appends `validity_end IS NULL OR validity_end > now`, `valid-at` binds `validity_start <= asOf AND (validity_end IS NULL OR validity_end > asOf)`, and `all` drops the predicate entirely.

### 9.5.2 The Supersede Write Decision

MNEMOSYNE extends the gate's `WriteDecision` with a `supersede` variant alongside the legacy `warn`/`block`. memory-core already ships the executor: `engram/supersede-writer.ts` exposes `decideSupersede(db, candidate, mode = "supersede")`, which finds the currently-valid (`validity_end IS NULL`) prior chunk(s) at the candidate's identity and returns `{ action, supersedes: ChunkId[], reason }`; and `applySupersede(db, decision, candidate)`, which — only in `supersede` mode — calls `invalidate()` once per superseded chunk. `invalidate()` (in [-`temporal-invalidation.ts`)-] {+`temporal-invalidation.ts`, at the memory module root)+} stamps `validity_end` and `superseded_by` on rows that are *still [-open*,-] {+open* (`WHERE … AND validity_end IS NULL`),+} never deleting and never resurrecting a closed row. The behavior is non-lossy: the prior row stays queryable in `all` / `valid-at` mode.

### On apply (supersede mode only): close each prior interval as of the candidate's validity_start applySupersede(db, decision, { id: candidate.id, validityStart: now }) ```

[-memory-core's-] `decideSupersede` defaults its [-mode-] {+`mode`+} argument to [-`"supersede"`, and-] {+`"supersede"`. `applySupersede` exposes+} an [-`onClosed` producer hook emits-] {+`onClosed(closedIds, reason)` callback that fires only when an interval is actually closed; the production caller (`manager-embedding-ops.ts`) uses that seam to emit+} a [-`recipe-supersede` trail event-] {+`fork.prefrontal.trailEvent` of kind `recipe-supersede`,+} so the UI renders a supersede [-icon when an interval is actually closed.-] {+icon.+} The MNEMOSYNE side is the configuration default it advertises — see §9.5.4.

### 9.5.5 What Is Not Yet Built

[-----]

### 9.5.6 Test Plan for the Validity Layer

{+#### 9.5.6 Test Plan for the Validity Layer+}

### 9.5.6 Test Plan for the Validity Layer

{+The substrate ships with tests; the plugin-side behavior needs its own, matching the subsystem's vitest convention (`pnpm vitest src/memory/...`). The cases that pin the supersede semantics:+}

### 9.5.6 Test Plan for the Validity Layer

{+- **Supersede closes the prior interval.** Insert fact A (`validity_end = NULL`); write a contradicting fact B in `supersede` mode. Assert A's `validity_end` equals B's `ingestion_time` and B's `validity_end` is NULL, and that both rows are still present — no `DELETE`. - **Current-mode filter.** `search(temporalMode: 'current')` returns B, not A. - **Valid-at query.** `search(temporalMode: 'valid-at', asOfTime: T)` with `A.validity_start < T < B.validity_start` returns A — the "what was true then" path. - **All-mode.** `search(temporalMode: 'all')` returns both A and B. - **Scoring honesty.** In `valid-at` mode a superseded chunk that matches the task descriptor scores below the current chunk despite higher textual similarity (`HISTORICAL_TASK_DAMP` applied). - **Index guard.** `PRAGMA index_list(chunks)` includes `idx_chunks_validity`, since every `current`-mode search filters on `validity_end`.+}

### 9.5.6 Test Plan for the Validity Layer

{+The end-to-end target is the §6.1 calendar-conflict reproduction: a recipe-conditioned query at `asOf = now` never surfaces the superseded "Wednesday" fact once the "Thursday" write has passed through the gate in `supersede` mode.+}

### 10.5 Capture Volume

[-----]

### 11. Conclusion

[-----]

### References

[-----]

### Changelog

[-## Changelog-]

### Changelog

[-- **v1.1 (2026-06-02):** Added §9.5 Bi-Temporal Validity — the contradiction gate's evolution from logger to resolver via supersession, grounded against the now-live memory-core substrate (`validity_*`/`ingestion_time`/`superseded_by` columns + `idx_chunks_validity` in `memory-schema.ts`; `temporalPredicate()` in `manager-search.ts`; `decideSupersede`/`applySupersede`/`invalidate` in `engram/supersede-writer.ts` + `temporal-invalidation.ts`). Added `supersede` as a third contradiction mode (§6.3, §8.1 configSchema, §8.2). Corrected the status table (§8.3) and limitations (§10.3/§10.4) to reflect the landed schema. Stated honestly what is NOT built (no cascade in v1, chunk-level not fact-level granularity, ingestion-time vs event-time boundary). Tightened prose throughout (removed product-claim of a specific corpus size where unverifiable; trimmed hedges). Abstract and §1.3 updated to name the bi-temporal contribution. - **v1.0 (2026-04-16):** Initial paper. Covers 4 features (hippocampus O(1) index, task-conditioned scoring, contradiction gate, compaction capture), v0.1 plugin scaffold with 680 LOC, v0.2 roadmap.-]
