Skip to content

Commit 02517ef

Browse files
authored
feat(memory): ClawVM typed pages, MemReader quality gate, APEX-MEM graph (#3260)
* feat(memory): ClawVM typed pages, MemReader quality gate, APEX-MEM graph (#3221, #3222, #3223) Closes #3221, #3222, #3223. **#3221 — ClawVM-style typed page compaction (zeph-context)** - New `TypedPage` with BLAKE3 content-hash page id and `PageType` enum (ToolOutput, ConversationTurn, MemoryExcerpt, SystemContext) - Per-type `PageInvariant` trait with four implementations enforcing minimum-fidelity invariants at compaction boundaries - `InvariantRegistry` and bounded async `CompactionAuditSink` (mpsc) - `ContextAssembler::gather()` classifies every slot into a typed page and appends an audit record per compacted page **#3222 — MemReader write quality gate (zeph-memory)** - New `QualityGate` scoring three dimensions: information value (cosine similarity vs recent context), reference completeness (pronoun/deictic heuristic), contradiction risk (graph edge conflicts) - Fail-open contract: embed/LLM/graph errors yield neutral defaults - Wired into `SemanticMemory::remember()` and `remember_with_parts()` after A-MAC admission via `with_quality_gate()` builder - Disabled by default; configurable via `[memory.quality_gate]` TOML **#3223 — APEX-MEM append-only property graph for MAGMA (zeph-memory)** - SQLite migration 075: adds `supersedes`, `canonical_relation` to `graph_edges`; new `edge_reassertions` provenance table - `GraphStore::insert_or_supersede`: atomic supersession (single tx), byte-identical reassertion path, supersede depth cap (64 hops) - `OntologyTable` with ArcSwap + LRU-4096 cache for predicate normalization with LLM fallback - `ConflictResolver` with recency / confidence / llm strategies * build: update lru 0.12.5 → 0.17.0
1 parent e09e0ae commit 02517ef

24 files changed

Lines changed: 3848 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- **feat(memory): ClawVM-style typed page compaction for token-budget-aware context management** (#3221) —
12+
introduces `TypedPage` (BLAKE3 content-hash id), `PageType` enum (ToolOutput, ConversationTurn,
13+
MemoryExcerpt, SystemContext), per-type `PageInvariant` implementations, `InvariantRegistry`,
14+
and `CompactionAuditSink` (bounded async mpsc) in `zeph-context`. `ContextAssembler::gather()`
15+
classifies every context slot into a typed page, enforces minimum-fidelity invariants at
16+
compaction boundaries, and appends an audit record per compacted page.
17+
18+
- **feat(memory): MemReader write quality gate — score-based admission before long-term memory persistence** (#3222) —
19+
new `QualityGate` in `zeph-memory` scores each `remember()` call on three dimensions:
20+
information value (embedding cosine similarity vs recent context), reference completeness
21+
(pronoun/deictic heuristic), and contradiction risk (graph edge conflict check). Writes below
22+
the configurable threshold are rejected; rejection rate is tracked as a rolling metric.
23+
Gate is fail-open and disabled by default (`[memory.quality_gate]` TOML section).
24+
Wired into `SemanticMemory::remember()` and `remember_with_parts()` after A-MAC admission.
25+
26+
- **feat(memory): APEX-MEM append-only property graph with temporal supersession for MAGMA** (#3223) —
27+
extends `graph_edges` schema with `supersedes` (append-only pointer to prior head) and
28+
`canonical_relation` (normalized predicate) columns via migration 075. Adds `edge_reassertions`
29+
table for byte-identical reassertion provenance. New `OntologyTable` (ArcSwap + LRU-4096 cache)
30+
normalizes relation predicates with LLM fallback. New `ConflictResolver` (recency / confidence /
31+
llm strategies) resolves contradictory edges in SYNAPSE recall. `insert_or_supersede` and
32+
`check_supersede_depth` (recursive CTE, depth-capped) added to `GraphStore`.
33+
934
### Fixed
1035

1136
- **fix(index): wire `CodeRetriever` into `IndexState` for automatic code RAG injection** (#3236) —

Cargo.lock

Lines changed: 22 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ notify = "8.2.0"
5555
notify-debouncer-mini = "0.7"
5656
nucleo-matcher = "0.3.1"
5757
ollama-rs = { version = "0.3.4", default-features = false }
58-
open = "5.3.3"
58+
open = "5.3.4"
5959
opentelemetry = "0.31"
6060
opentelemetry-otlp = { version = "0.31.1", default-features = false }
6161
opentelemetry_sdk = { version = "0.31", default-features = false }
@@ -64,6 +64,7 @@ pdf-extract = "0.10"
6464
metrics = "0.24.3"
6565
metrics-util = "0.20.1"
6666
arc-swap = "1.9.1"
67+
lru = "0.17.0"
6768
parking_lot = "0.12.5"
6869
prometheus-client = "0.24.1"
6970
petgraph = "0.8.3"
@@ -106,8 +107,8 @@ tokio = "1"
106107
tokio-stream = "0.1"
107108
tokio-tungstenite = { version = "0.29", default-features = false }
108109
tokio-util = "0.7"
109-
toml = "1.1.2"
110-
toml_edit = "0.25.11"
110+
toml = "1.1.2+spec-1.1.0"
111+
toml_edit = "0.25.11+spec-1.1.0"
111112
tower = "0.5.3"
112113
tower-http = { version = "0.6.8", default-features = false }
113114
tracing = "0.1"

crates/zeph-context/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ description = "Context budget, manager, compaction strategy, and assembler for t
1313
readme = "README.md"
1414

1515
[dependencies]
16+
blake3.workspace = true
1617
futures.workspace = true
1718
parking_lot.workspace = true
1819
regex.workspace = true
20+
serde = { workspace = true, features = ["derive"] }
21+
serde_json.workspace = true
1922
thiserror.workspace = true
2023
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "sync", "time"] }
2124
tracing.workspace = true
@@ -25,7 +28,7 @@ zeph-llm.workspace = true
2528
zeph-memory.workspace = true
2629

2730
[dev-dependencies]
28-
serde_json.workspace = true
31+
tempfile.workspace = true
2932

3033
[lints]
3134
workspace = true

crates/zeph-context/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ pub mod manager;
2929
pub mod microcompact;
3030
pub mod slot;
3131
pub mod summarization;
32+
pub mod typed_page;

0 commit comments

Comments
 (0)