open-memex 0.9.0-alpha.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +27 -2
- package/CHANGELOG.md +5 -7
- package/README.md +43 -1
- package/README.zh-CN.md +26 -1
- package/dist/.build-stamp +1 -1
- package/dist/cli.js +167 -2
- package/dist/config.js +11 -0
- package/dist/graph/extract.js +234 -0
- package/dist/graph/lint.js +89 -0
- package/dist/graph/outline.js +146 -0
- package/dist/graph/queries.js +122 -0
- package/dist/plugin-core.js +4 -0
- package/dist/retrieve/inject.js +26 -2
- package/dist/review.js +9 -0
- package/dist/store/db.js +8 -2
- package/dist/store/graph.js +225 -0
- package/dist/store/sync.js +7 -3
- package/dist/tools/ops.js +10 -1
- package/docs/V2-DESIGN.md +2 -2
- package/docs/design/decisions.md +3 -0
- package/docs/design/knowledge-graph.md +1 -1
- package/package.json +1 -1
- package/scripts/smoke-pure.ts +203 -0
- package/scripts/test-full.ts +76 -4
- package/server.json +2 -2
- package/skills/open-memex/SKILL.md +17 -0
- package/src/cli.ts +181 -4
- package/src/config.ts +17 -0
- package/src/graph/extract.ts +276 -0
- package/src/graph/lint.ts +107 -0
- package/src/graph/outline.ts +167 -0
- package/src/graph/queries.ts +143 -0
- package/src/plugin-core.ts +4 -0
- package/src/retrieve/inject.ts +27 -2
- package/src/review.ts +9 -0
- package/src/store/db.ts +8 -2
- package/src/store/graph.ts +293 -0
- package/src/store/sync.ts +6 -2
- package/src/tools/ops.ts +11 -2
package/dist/review.js
CHANGED
|
@@ -26,6 +26,7 @@ import { resolveProjectScope } from "./scope.js";
|
|
|
26
26
|
import { parse as parseMemory, serialize, atomicWriteTextSync, ulid, writeMemoryFile, } from "./store/markdown.js";
|
|
27
27
|
import { findMemoryFile } from "./store/lifecycle.js";
|
|
28
28
|
import { upsertFromFile } from "./store/sync.js";
|
|
29
|
+
import { refreshGraphQuiet } from "./store/graph.js";
|
|
29
30
|
import { recordUseful } from "./store/usage.js";
|
|
30
31
|
/** Best-effort author identity: git user.name, else the OS user. */
|
|
31
32
|
export function currentAuthor() {
|
|
@@ -116,6 +117,8 @@ function copyPersonalToProject(sourceId, srcFm, srcBody, opts = {}) {
|
|
|
116
117
|
// later `approved → published` promote stays non-counting for both paths.
|
|
117
118
|
if (targetState === "approved")
|
|
118
119
|
recordUseful(fm.id, "team", "promote");
|
|
120
|
+
// D91 ingest: a propose-copy is a new project node (derived_from edge).
|
|
121
|
+
refreshGraphQuiet(project.key);
|
|
119
122
|
return { id: fm.id, filePath, reviewState: fm.review_state };
|
|
120
123
|
}
|
|
121
124
|
/**
|
|
@@ -216,6 +219,12 @@ export function promoteMemory(id, opts = {}) {
|
|
|
216
219
|
// Always useful_team: promoteMemory is project-only by contract above.
|
|
217
220
|
if (to === "approved")
|
|
218
221
|
recordUseful(id, "team", "promote");
|
|
222
|
+
// D91 ingest: keep the write-path invariant uniform — every mutating
|
|
223
|
+
// review transition refreshes the owning scope's graph, even though a
|
|
224
|
+
// promote changes no node/edge field the extractor reads today. The
|
|
225
|
+
// refresh is cheap and the invariant ("all mutating paths refresh") is
|
|
226
|
+
// what keeps the layer from drifting as new fields are added.
|
|
227
|
+
refreshGraphQuiet(mf.fm.scope_key);
|
|
219
228
|
return { id, from, to, history: fm.review_history };
|
|
220
229
|
}
|
|
221
230
|
/** Render a memory's audit trail as compact human-readable lines (D29). */
|
package/dist/store/db.js
CHANGED
|
@@ -42,6 +42,10 @@ CREATE TABLE IF NOT EXISTS memories (
|
|
|
42
42
|
cjk TEXT NOT NULL DEFAULT '',
|
|
43
43
|
content_hash TEXT NOT NULL DEFAULT '',
|
|
44
44
|
superseded_by TEXT,
|
|
45
|
+
-- D91: the propose-copy's source memory id (frontmatter derived_from),
|
|
46
|
+
-- so the graph layer can extract derived-from edges from the index
|
|
47
|
+
-- alone. Nullable -- ordinary memories have none.
|
|
48
|
+
derived_from TEXT,
|
|
45
49
|
source TEXT NOT NULL DEFAULT '',
|
|
46
50
|
file_path TEXT NOT NULL,
|
|
47
51
|
mtime_ms REAL NOT NULL,
|
|
@@ -109,8 +113,10 @@ CREATE TRIGGER IF NOT EXISTS memories_au AFTER UPDATE ON memories BEGIN
|
|
|
109
113
|
VALUES (new.rowid, new.content, new.tags, new.aliases, new.expansions, new.type, new.cjk, new.scope_key);
|
|
110
114
|
END;
|
|
111
115
|
`;
|
|
112
|
-
/** Current index schema version. Bump when TABLE_SCHEMA/FTS_SCHEMA change.
|
|
113
|
-
|
|
116
|
+
/** Current index schema version. Bump when TABLE_SCHEMA/FTS_SCHEMA change.
|
|
117
|
+
* 10 = D91 added the `derived_from` column (graph layer reads the chain
|
|
118
|
+
* and derive edges from the index alone). */
|
|
119
|
+
const SCHEMA_VERSION = 10;
|
|
114
120
|
// D77-L2: reuse counters live in their own table, keyed by memory id. It is
|
|
115
121
|
// created on every open (CREATE IF NOT EXISTS) and deliberately NOT part of
|
|
116
122
|
// the rebuildable index: `rebuildIndexSchema` drops memories/memories_fts
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* §20 (D88), D91: the graph's persistence. The graph is a DERIVED layer —
|
|
3
|
+
* rebuildable from the Markdown source of truth at any time — so it stores
|
|
4
|
+
* into SQLite beside the FTS index, into tables created with
|
|
5
|
+
* CREATE TABLE IF NOT EXISTS outside the versioned schema (same treatment
|
|
6
|
+
* as the D77 `memory_usage` counters): `rebuildIndexSchema` never has to
|
|
7
|
+
* think about it, and `refreshGraph` is the healer for any staleness.
|
|
8
|
+
*
|
|
9
|
+
* Storage per scope key:
|
|
10
|
+
* - `graph_edges` — the structural edge list (see graph/extract.ts).
|
|
11
|
+
* - `graph_meta` — build stamp + the rendered compiled outline. The
|
|
12
|
+
* outline is stored text: the session-start injection reads it and is
|
|
13
|
+
* never responsible for rendering.
|
|
14
|
+
*
|
|
15
|
+
* Project scope only in D91 (decision): personal memories stay out of the
|
|
16
|
+
* graph per §20.5's sync rule; the entry point no-ops for the personal key
|
|
17
|
+
* so the write-path hooks can call it unconditionally.
|
|
18
|
+
*/
|
|
19
|
+
import { db } from "./db.js";
|
|
20
|
+
import { PERSONAL_SCOPE } from "../scope.js";
|
|
21
|
+
import { extractEdges, } from "../graph/extract.js";
|
|
22
|
+
import { renderOutline } from "../graph/outline.js";
|
|
23
|
+
const GRAPH_SCHEMA = `
|
|
24
|
+
CREATE TABLE IF NOT EXISTS graph_edges (
|
|
25
|
+
scope_key TEXT NOT NULL,
|
|
26
|
+
from_id TEXT NOT NULL,
|
|
27
|
+
to_id TEXT NOT NULL,
|
|
28
|
+
edge_type TEXT NOT NULL,
|
|
29
|
+
provenance TEXT NOT NULL,
|
|
30
|
+
confidence TEXT NOT NULL,
|
|
31
|
+
via TEXT NOT NULL,
|
|
32
|
+
PRIMARY KEY (scope_key, from_id, to_id, edge_type)
|
|
33
|
+
);
|
|
34
|
+
CREATE TABLE IF NOT EXISTS graph_meta (
|
|
35
|
+
scope_key TEXT PRIMARY KEY,
|
|
36
|
+
built_at TEXT NOT NULL,
|
|
37
|
+
node_count INTEGER NOT NULL,
|
|
38
|
+
edge_count INTEGER NOT NULL,
|
|
39
|
+
outline TEXT NOT NULL DEFAULT '',
|
|
40
|
+
outline_ids TEXT NOT NULL DEFAULT '[]'
|
|
41
|
+
);
|
|
42
|
+
`;
|
|
43
|
+
let _graphSchemaReady = false;
|
|
44
|
+
function ensureSchema() {
|
|
45
|
+
if (_graphSchemaReady)
|
|
46
|
+
return;
|
|
47
|
+
db().exec(GRAPH_SCHEMA);
|
|
48
|
+
_graphSchemaReady = true;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Rebuild the graph for one scope from the index in a single pass:
|
|
52
|
+
* read rows → extract structural edges → replace the scope's edge set →
|
|
53
|
+
* render + store the outline. Reads everything it needs up front so the
|
|
54
|
+
* DELETE + INSERT sequence is short. The Markdown files are untouched.
|
|
55
|
+
*/
|
|
56
|
+
export function refreshGraph(scopeKey, cfg) {
|
|
57
|
+
ensureSchema();
|
|
58
|
+
// The index carries the chain as `superseded_by` (old → forward pointer,
|
|
59
|
+
// §3.3); the frontmatter's back pointer (`supersedes` on the new file)
|
|
60
|
+
// is not an indexed column. The graph derives the new → old direction
|
|
61
|
+
// from the indexed one instead of adding yet another column the sync
|
|
62
|
+
// layer must keep in lockstep.
|
|
63
|
+
const rows = db()
|
|
64
|
+
.prepare(`SELECT id, type, tags, content, status, superseded_by, derived_from
|
|
65
|
+
FROM memories WHERE scope_key = ?`)
|
|
66
|
+
.all(scopeKey);
|
|
67
|
+
// new → old: every row pointing forward via superseded_by means the
|
|
68
|
+
// TARGET of that pointer is a newer memory that superseded it.
|
|
69
|
+
const supersedesByTarget = new Map();
|
|
70
|
+
for (const r of rows) {
|
|
71
|
+
if (r.superseded_by && r.superseded_by !== r.id)
|
|
72
|
+
supersedesByTarget.set(r.superseded_by, r.id);
|
|
73
|
+
}
|
|
74
|
+
const nodes = rows.map((r) => ({
|
|
75
|
+
id: r.id,
|
|
76
|
+
status: r.status,
|
|
77
|
+
type: r.type,
|
|
78
|
+
tags: r.tags ? r.tags.split(",").map((t) => t.trim()).filter(Boolean) : [],
|
|
79
|
+
body: r.content,
|
|
80
|
+
supersedes: supersedesByTarget.get(r.id) ?? null,
|
|
81
|
+
derived_from: r.derived_from,
|
|
82
|
+
snippet: r.content.replace(/\s+/g, " ").trim().slice(0, 140),
|
|
83
|
+
}));
|
|
84
|
+
const edges = extractEdges(nodes);
|
|
85
|
+
const d = db();
|
|
86
|
+
d.exec("BEGIN");
|
|
87
|
+
try {
|
|
88
|
+
d.prepare(`DELETE FROM graph_edges WHERE scope_key = ?`).run(scopeKey);
|
|
89
|
+
const insert = d.prepare(`INSERT OR IGNORE INTO graph_edges
|
|
90
|
+
(scope_key, from_id, to_id, edge_type, provenance, confidence, via)
|
|
91
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`);
|
|
92
|
+
for (const e of edges) {
|
|
93
|
+
insert.run(scopeKey, e.from, e.to, e.type, e.provenance, e.confidence, e.via);
|
|
94
|
+
}
|
|
95
|
+
// The outline compiles the VISIBLE set (active memories — superseded
|
|
96
|
+
// versions are history, not "what is in memory"; §20.4's query side
|
|
97
|
+
// keeps the full graph including chains).
|
|
98
|
+
const visible = nodes.filter((n) => n.status === "active");
|
|
99
|
+
const visibleIds = new Set(visible.map((n) => n.id));
|
|
100
|
+
const visibleEdges = edges.filter((e) => visibleIds.has(e.from) && visibleIds.has(e.to));
|
|
101
|
+
const linesCfg = cfg ?? { graphOutlineLines: 10 };
|
|
102
|
+
const rendered = renderOutline(visible, visibleEdges, {
|
|
103
|
+
maxLines: linesCfg.graphOutlineLines ?? 10,
|
|
104
|
+
});
|
|
105
|
+
d.prepare(`INSERT INTO graph_meta (scope_key, built_at, node_count, edge_count, outline, outline_ids)
|
|
106
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
107
|
+
ON CONFLICT(scope_key) DO UPDATE SET
|
|
108
|
+
built_at = excluded.built_at,
|
|
109
|
+
node_count = excluded.node_count,
|
|
110
|
+
edge_count = excluded.edge_count,
|
|
111
|
+
outline = excluded.outline,
|
|
112
|
+
outline_ids = excluded.outline_ids`).run(scopeKey, new Date().toISOString(), nodes.length, edges.length, rendered.lines.join("\n"), JSON.stringify(rendered.exposureIds));
|
|
113
|
+
d.exec("COMMIT");
|
|
114
|
+
return {
|
|
115
|
+
scopeKey,
|
|
116
|
+
nodes: nodes.length,
|
|
117
|
+
edges: edges.length,
|
|
118
|
+
topics: rendered.topics.length,
|
|
119
|
+
outlineLines: rendered.lines.length,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
d.exec("ROLLBACK");
|
|
124
|
+
throw e;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The write-path ingest hook (§20.4): deterministic extraction is cheap at
|
|
129
|
+
* memory-store sizes, so every mutating surface refreshes the project
|
|
130
|
+
* graph right after its write. Never throws — the memory write is the
|
|
131
|
+
* source of truth and must not fail on a derived-layer hiccup; problems
|
|
132
|
+
* say so on stderr like every other diagnostic. Personal scope no-ops.
|
|
133
|
+
*/
|
|
134
|
+
export function refreshGraphQuiet(scopeKey, cfg) {
|
|
135
|
+
if (!scopeKey || scopeKey === PERSONAL_SCOPE.key)
|
|
136
|
+
return false;
|
|
137
|
+
try {
|
|
138
|
+
refreshGraph(scopeKey, cfg);
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
console.error(`[open-memex] graph refresh failed (outlines and graph queries may be stale): ${e.message}`);
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Read the stored graph, building it first when never built (lazy first
|
|
148
|
+
* ingest so a fresh install shows the outline on turn one without waiting
|
|
149
|
+
* for an explicit `graph build`). Refresh is quiet — a failed derived-layer
|
|
150
|
+
* build yields null and the injection proceeds without it.
|
|
151
|
+
*/
|
|
152
|
+
export function ensureGraph(scopeKey, cfg) {
|
|
153
|
+
ensureSchema();
|
|
154
|
+
const has = db()
|
|
155
|
+
.prepare(`SELECT built_at FROM graph_meta WHERE scope_key = ?`)
|
|
156
|
+
.get(scopeKey);
|
|
157
|
+
if (!has)
|
|
158
|
+
refreshGraphQuiet(scopeKey, cfg);
|
|
159
|
+
return getStoredGraph(scopeKey);
|
|
160
|
+
}
|
|
161
|
+
/** Read the stored outline for a scope, or null when never built. */
|
|
162
|
+
export function getStoredGraph(scopeKey) {
|
|
163
|
+
ensureSchema();
|
|
164
|
+
const row = db()
|
|
165
|
+
.prepare(`SELECT built_at, node_count, edge_count, outline, outline_ids
|
|
166
|
+
FROM graph_meta WHERE scope_key = ?`)
|
|
167
|
+
.get(scopeKey);
|
|
168
|
+
if (!row)
|
|
169
|
+
return null;
|
|
170
|
+
let ids = [];
|
|
171
|
+
try {
|
|
172
|
+
ids = JSON.parse(row.outline_ids);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
ids = [];
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
builtAt: row.built_at,
|
|
179
|
+
nodes: row.node_count,
|
|
180
|
+
edges: row.edge_count,
|
|
181
|
+
outline: row.outline,
|
|
182
|
+
outlineIds: ids,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/** All edges for a scope (query layer input). */
|
|
186
|
+
export function loadGraphEdges(scopeKey) {
|
|
187
|
+
ensureSchema();
|
|
188
|
+
const rows = db()
|
|
189
|
+
.prepare(`SELECT from_id, to_id, edge_type, provenance, confidence, via
|
|
190
|
+
FROM graph_edges WHERE scope_key = ?`)
|
|
191
|
+
.all(scopeKey);
|
|
192
|
+
return rows.map((r) => ({
|
|
193
|
+
from: r.from_id,
|
|
194
|
+
to: r.to_id,
|
|
195
|
+
type: r.edge_type,
|
|
196
|
+
provenance: r.provenance,
|
|
197
|
+
confidence: r.confidence,
|
|
198
|
+
via: r.via,
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
/** All nodes for a scope, as the query/lint layers see them. */
|
|
202
|
+
export function loadGraphNodes(scopeKey) {
|
|
203
|
+
const rows = db()
|
|
204
|
+
.prepare(`SELECT id, type, tags, content, status FROM memories WHERE scope_key = ?`)
|
|
205
|
+
.all(scopeKey);
|
|
206
|
+
return rows.map((r) => ({
|
|
207
|
+
id: r.id,
|
|
208
|
+
status: r.status,
|
|
209
|
+
type: r.type,
|
|
210
|
+
tags: r.tags ? r.tags.split(",").map((t) => t.trim()).filter(Boolean) : [],
|
|
211
|
+
body: r.content,
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Every id in the store across scopes (lint's cross-scope set): a propose
|
|
216
|
+
* copy's derived_from legitimately points at the personal original, which
|
|
217
|
+
* is not a node in the project graph — lint must skip it, not report it.
|
|
218
|
+
*/
|
|
219
|
+
export function loadAllMemoryIds() {
|
|
220
|
+
ensureSchema();
|
|
221
|
+
const rows = db()
|
|
222
|
+
.prepare(`SELECT id FROM memories`)
|
|
223
|
+
.all();
|
|
224
|
+
return rows.map((r) => r.id);
|
|
225
|
+
}
|
package/dist/store/sync.js
CHANGED
|
@@ -8,8 +8,8 @@ import { iterMemoryFiles, iterInRepoMemoryFiles, readMemoryFile, timeToMs, } fro
|
|
|
8
8
|
import { projectRoot, paths } from "../paths.js";
|
|
9
9
|
import { loadConfig } from "../config.js";
|
|
10
10
|
const UPSERT_SQL = `
|
|
11
|
-
INSERT INTO memories (id, scope_key, scope, visibility, project_name, type, role, importance, status, tags, aliases, expansions, alias, target, content, cjk, content_hash, superseded_by, source, file_path, mtime_ms, created_at, updated_at, review_state)
|
|
12
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
11
|
+
INSERT INTO memories (id, scope_key, scope, visibility, project_name, type, role, importance, status, tags, aliases, expansions, alias, target, content, cjk, content_hash, superseded_by, derived_from, source, file_path, mtime_ms, created_at, updated_at, review_state)
|
|
12
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
13
13
|
ON CONFLICT(id) DO UPDATE SET
|
|
14
14
|
scope_key = excluded.scope_key,
|
|
15
15
|
scope = excluded.scope,
|
|
@@ -28,6 +28,7 @@ const UPSERT_SQL = `
|
|
|
28
28
|
cjk = excluded.cjk,
|
|
29
29
|
content_hash = excluded.content_hash,
|
|
30
30
|
superseded_by = excluded.superseded_by,
|
|
31
|
+
derived_from = excluded.derived_from,
|
|
31
32
|
source = excluded.source,
|
|
32
33
|
review_state = excluded.review_state,
|
|
33
34
|
file_path = excluded.file_path,
|
|
@@ -71,7 +72,10 @@ function writeRow(mf, mtimeMs) {
|
|
|
71
72
|
const aliases = supplied.join(",");
|
|
72
73
|
const expansions = auto.join(",");
|
|
73
74
|
// D81: user-defined alias vocabulary (single nickname → referent pair).
|
|
74
|
-
db().prepare(UPSERT_SQL).run(fm.id, fm.scope_key, fm.scope, fm.visibility, fm.project_name, fm.type, fm.role, fm.importance, fm.status, tags, aliases, expansions, fm.alias ?? "", fm.target ?? "", body, cjkIndexText(body + "\n" + tags + "\n" + aliases + "\n" + expansions), contentHash(body), fm.superseded_by ?? null,
|
|
75
|
+
db().prepare(UPSERT_SQL).run(fm.id, fm.scope_key, fm.scope, fm.visibility, fm.project_name, fm.type, fm.role, fm.importance, fm.status, tags, aliases, expansions, fm.alias ?? "", fm.target ?? "", body, cjkIndexText(body + "\n" + tags + "\n" + aliases + "\n" + expansions), contentHash(body), fm.superseded_by ?? null,
|
|
76
|
+
// D91: derived_from joins the index so the graph layer reads the
|
|
77
|
+
// derive copy → original edge from the same store as everything else.
|
|
78
|
+
fm.derived_from ?? null, fm.source ?? "", filePath, mtimeMs, timeToMs(fm.created_at), timeToMs(fm.updated_at), fm.review_state ?? "draft");
|
|
75
79
|
}
|
|
76
80
|
export function deleteFromIndex(id) {
|
|
77
81
|
db().prepare(`DELETE FROM memories WHERE id = ?`).run(id);
|
package/dist/tools/ops.js
CHANGED
|
@@ -22,6 +22,7 @@ import { redact } from "../redact.js";
|
|
|
22
22
|
import { getSyncStatus, formatSyncStatus, submitMemories, outboxDraftCount } from "../submit.js";
|
|
23
23
|
import { getPrStatus, formatPrStatus, applyPrStatus } from "../github.js";
|
|
24
24
|
import { isInRepoMemoryFile } from "../paths.js";
|
|
25
|
+
import { refreshGraphQuiet } from "../store/graph.js";
|
|
25
26
|
import { writeWorkingState, readWorkingState, clearWorkingState, } from "../working-state.js";
|
|
26
27
|
import { proposeMemories, promoteMemory, listConflicts, resolveConflict, formatReviewHistory, } from "../review.js";
|
|
27
28
|
/**
|
|
@@ -294,6 +295,9 @@ export async function addMemory(getScope, cfg, args) {
|
|
|
294
295
|
const mf = readMemoryFile(filePath);
|
|
295
296
|
if (mf)
|
|
296
297
|
upsertFromFile(mf);
|
|
298
|
+
// D91 ingest: the project graph (edges + compiled outline) refreshes on
|
|
299
|
+
// the write path — quiet, never fails the save.
|
|
300
|
+
refreshGraphQuiet(s.key, cfg);
|
|
297
301
|
let output = `Saved to ${s.kind} scope (${s.key}) as ${fm.type}. id=${fm.id}${secretNote}`;
|
|
298
302
|
for (const n of dups.near) {
|
|
299
303
|
output += `\nNote: similar memory exists (score ${n.score.toFixed(2)}): id=${n.id} — ${n.snippet}. Use memory_supersede if this replaces it.`;
|
|
@@ -396,6 +400,8 @@ export async function supersedeMemory(cfg, args) {
|
|
|
396
400
|
});
|
|
397
401
|
upsertFromFile(oldMf);
|
|
398
402
|
upsertFromFile(newMf);
|
|
403
|
+
// D91 ingest: the chain has changed — refresh the owning scope quietly.
|
|
404
|
+
refreshGraphQuiet(oldMf.fm.scope_key, cfg);
|
|
399
405
|
return {
|
|
400
406
|
title: `memory: superseded ${oldMf.fm.id}`,
|
|
401
407
|
output: `Replaced ${oldMf.fm.id} with ${newMf.fm.id} (old kept as history).${secretNote}`,
|
|
@@ -410,7 +416,7 @@ export async function supersedeMemory(cfg, args) {
|
|
|
410
416
|
}
|
|
411
417
|
export async function forgetMemory(args) {
|
|
412
418
|
const row = db()
|
|
413
|
-
.prepare(`SELECT file_path FROM memories WHERE id = ?`)
|
|
419
|
+
.prepare(`SELECT file_path, scope_key FROM memories WHERE id = ?`)
|
|
414
420
|
.get(args.id);
|
|
415
421
|
if (!row) {
|
|
416
422
|
return { title: "memory: not found", output: `No memory with id ${args.id}.` };
|
|
@@ -422,6 +428,7 @@ export async function forgetMemory(args) {
|
|
|
422
428
|
try {
|
|
423
429
|
const mf = setStatus(args.id, "retracted");
|
|
424
430
|
upsertFromFile(mf);
|
|
431
|
+
refreshGraphQuiet(row.scope_key);
|
|
425
432
|
return {
|
|
426
433
|
title: "memory: hidden",
|
|
427
434
|
output: `Hidden ${args.id} (retracted). It no longer appears in lists or search, but the file is kept. This is one-way — to bring the fact back, save it again as a new memory.` +
|
|
@@ -460,6 +467,8 @@ export async function forgetMemory(args) {
|
|
|
460
467
|
// Only the hard path prunes the usage row; status flips and index removal
|
|
461
468
|
// (branch switches remove in-repo files transiently) keep it.
|
|
462
469
|
deleteUsage(args.id);
|
|
470
|
+
// D91 ingest: a node left the graph — refresh its scope quietly.
|
|
471
|
+
refreshGraphQuiet(row.scope_key);
|
|
463
472
|
// D64: forgetting an in-repo memory deletes a file inside the user's
|
|
464
473
|
// git working tree. Say so — the deletion should ride a commit, or the
|
|
465
474
|
// file silently diverges from what teammates have.
|
package/docs/V2-DESIGN.md
CHANGED
|
@@ -582,7 +582,7 @@ requirement: personal data never touches third-party services). Benchmarks to tr
|
|
|
582
582
|
for enterprise knowledge systems.
|
|
583
583
|
- **Near-term backlog — committed direction, not yet built (2026-10-07).** Stone's rule: anything said as "later" is written down here. D77-L2 ✅ built 2026-11-03 (0.9.0-alpha.2): per-memory `retrieved_count`/`useful_count` (`useful_self` vs `useful_team`) + `memory_useful` tool, counters in a `memory_usage` table beside the rebuildable index. D77-L3 ✅ built 2026-11-04 (0.9.0-alpha.3): `memory_status`/`sync-status` reuse report — per-scope rates, top reused, zero-reuse "zombies". D77: external bench — LongMemEval-S run 2026-10-07 (`scripts/bench-longmemeval.ts`, 470 questions, recall_any@k: R@5 97.0% / MRR 0.909 per-question, R@5 40.6% on a pooled 22k corpus; ahead of agentmemory’s BM25-only, level with their BM25+vector). MemoryAgentBench still open as a second external data point. D79 follow-up SUPERSEDED → built as **D80** (2026-10-07): index-time synonym/translation expansion shipped; 41-query fixture recall@5 0.854 → 0.976, MRR 0.791 → 0.859. Embedding-model configurability (Stone 2026-10-07): the multilingual model is his personal need (EN↔ZH), not everyone’s — the model must be user-configurable. Timing: (1) NOW in the bench only — a `--model` flag to measure the multilingual tax (multilingual vs English-only on English data), which decides the DEFAULT. (2) AT SHIP TIME — `embedding.model` in `MyOMemoryConfig` + `SETTABLE_KEYS`, model-agnostic storage from day one (dim + model id stored with vectors, cache dir), download UX and `doctor` checks. Not before the gate passes: building config UX for a layer we haven’t decided to ship is premature. If multilingual tax ≈ 0, default multilingual (covers everyone); else default English-only with a docs note.D78: curate+submit — pre-submit lint, then confidence-tier auto-curation (auto-apply / batch-confirm / explicit human). D79 follow-ups: feedback-weighted ranking once D77 counters land; embeddings gate decision against the published baseline; reranker evaluation. Cross-lingual embedding rerank (Stone 2026-10-16, from obsidian-mind comparison): ablation showed multilingual vectors beat BM25 by +12pp R@5 on the cross-lingual slice — the one gap lexical can't cover. Design as opt-in rerank for EN↔ZH queries only, not a default path; local stays BM25-first per the retrieval split above. TDQS nit (separate PR): tighten search/list `type` to `z.enum`. Retrieval eval: grow the fixture (project-scope tier cases) as retrieval logic evolves. Retrieval split — local vs share server (Stone 2026-10-07): the two environments emphasize different mechanisms. Local (personal machine): BM25 + curated index-time expansion as the primary — deterministic, zero model download (D7), fast on CPU, index bloat bounded by the small corpus; embeddings opt-in only. Share server (team/org, enterprise): embeddings + ANN + reranker as the primary — server-grade compute with models resident, corpus too large and multi-author for any curated map; the curated map stays as a precision layer plus org glossary. The server additionally aggregates D77 useful_count across users into feedback-weighted ranking (already in D79 follow-ups) — a signal a single machine can never have. Bottom-up loop: curated pairs that many users converge on locally become org-glossary candidates. Economics flip: N users each downloading a model vs one model amortized on the server. OptMem lessons (Stone 2026-10-16, from kafkaup's OptMem post): three friction-reduction ideas worth stealing from the minimalist end of the spectrum. (1) **Token cost as spec** — measure and publish open-memex's prompt/token overhead in the README, the way OptMem advertises its "426-token prompt"; acquisition copy, not just engineering. (2) **`wake` convention** — document a session-start ritual (one `memory_recall` call at the beginning of every session), mirroring OptMem's `memo wake`; the MCP tools exist but the habit isn't specified. (3) **Capture length nudge** — a soft length cap or conciseness hint at capture time, inspired by OptMem's 280-byte hard cap; forces conciseness at write time, cheap to implement, aligned with the distill-to-AGENTS.md direction (D40). Three-tier memory zones (Stone 2026-10-18, from Westenberg "I Deleted My Second Brain" + his own reflection): the second brain should have zones like cache vs database, not "keep everything" vs "delete everything". **Hot** (active zone, cache-like: small, curated, always in context — D81 aliases, WHAT-level) · **Warm** (compost/incubation: not active but not cold; periodic review, rotted items deleted — this is "forget on purpose" as engineering) · **Cold** (full archive, searchable, not resident). The hard part is the **promotion/demotion policy** — what moves between zones, when, by what rule (the cache-replacement problem for knowledge; "useful" ≠ "recently used"). Capture restraint is a separate gate: not everything deserves to enter even cold storage. Spec the policy before building the zones. Auto-capture design brief (Stone 2026-10-19, from ai-memory comparison): open-memex wants auto-capture but under the restraint philosophy (not ai-memory's capture-everything). Five design questions: (1) **End-session trigger** — what hooks does opencode actually expose? (check before designing; ai-memory built finalize-session fallback for harnesses without SessionEnd); candidates: native hook / idle timeout / explicit command / context-near-full. (2) **Distillation** — rules first (what happened: git diff, tool calls, decision sentences; zero LLM), interpretation layer (what it means) left to human/LLM. (3) **Save-value triage** — three tiers: clearly valuable → save; clearly noise → drop; ambiguous → ask human. Boundary principle: **rather over-ask than over-save** (polluted retrieval costs more than a missed memory). (4) **Routing** — four exits: project memory / personal memory / AGENTS.md proposal (distill-agents exists) / discard; keep v1 routing rules simple. (5) **Human interaction** — one batch confirmation at session end ("save these 3? [y/n/edit]"), never per-item popups. Relations: D73 keyword capture is turn-level (no conflict); `wake` convention is session-start (this is session-end — the other bookend); three-tier zones govern where auto-captured items land. Cross-agent study (Stone 2026-10-19): open-memex has cross-agent on the roadmap — study how ai-memory does it (handoff claim-once semantics, lifecycle hooks per harness, VSCode support via MCP-only) before designing ours; borrow the semantics, not the push-injection behavior (discoverability > injection). Injection cost discipline (Stone 2026-10-19, from Harness² paper arXiv:2610.14224): "ALWAYS-ON PROSE IS THE EXPENSIVE OPTION" — every always-on word competes with the agent's output budget. Current session-start injection (8 project + 5 personal) is the expensive path; direction: move "important but not needed every turn" memories to on-demand (tool/skill-triggered loading), keep only truly every-turn items resident. Tolerable now, better not to tolerate. Component cost ladder for reference: SKILL (default, zero-cost until invoked) > SCRIPT > SUBAGENT > PLUGIN ("prose can be skipped, a hook cannot") > ALWAYS-ON TEXT (last resort). Read-less compression (Stone 2026-10-19, from caveman https://github.com/JuliusBrussee/caveman): the execution layer of injection cost discipline — compress what the agent READS before it reaches context, not just what we inject. Caveman's measured numbers: 33.2% fewer input tokens per session (CSV 98.9%, logs 98.5%, YAML 99.1%, JSON 98.5% per-file; HTML has no compressor yet). Direction for open-memex: a pre-retrieval compression pass on tool outputs and retrieved passages (structured data → compact form), originals stay on disk and pullable on demand. Two design principles borrowed: (1) never compress the user's own prompt/input (Adobe CAVEWOMAN finding: cavemanning user prompts makes answers worse); (2) leave code/tool calls/payloads verbatim — compress the wrapper, not the payload. Caveats: caveman's own rules cost ~1,160 input tokens fixed; per-request billing (Copilot-style) nullifies the saving — compression pays off on per-token billing only. Knowledge upkeep as a first-class direction (Stone 2026-10-23; external validation: Hedy Zhang's FDE field retrospective on enterprise AI knowledge bases, X article 2026-10-22 — enterprise knowledge bases die on unowned upkeep, not on retrieval: stale answers served silently, conflicts with no owner, updates nobody owns after delivery). The mechanisms already exist (supersede chains, lifecycle states, `audit` health check, curator convention); the direction is driving the human cost of upkeep toward zero: (1) staleness signals — age, contradiction with newer captures, D77 zero-reuse counters — feeding a standing review queue instead of waiting for someone to remember to run `audit`; (2) a conflict inbox — semantic conflicts and broken chains as a persistent todo; (3) the endgame is D78 confidence-tier auto-curation (auto-apply the safe tier, batch-confirm the rest). Success metric: the base stays trustworthy on minutes-per-week of human attention, not a curator shift. README pitches the shipped half of this as core concept 4 (Knowledge stays current) plus a "When facts change" comparison row. Session working state note (D89, 2026-11-02) → BUILT, shipped 2026-11-03 as D90: 12th tool `memory_workingstate` on both hosts, session-start surfacing, `audit` expiry report, `wstate` CLI; opencode write path is instruction + tool (plugin API has no Stop hook).
|
|
584
584
|
|
|
585
|
-
- **Build order after D77-L3 (2026-11-04, Stone approved).** Once PR #74 (D77-L3 reuse report) merges, the queue is: (1) §20 / D88 deterministic half — `graph build` (structural edges only), compiled outline injected at session start, `graph neighbours` / `graph path`
|
|
585
|
+
- **Build order after D77-L3 (2026-11-04, Stone approved; (1) shipped 2026-11-06).** Once PR #74 (D77-L3 reuse report) merges, the queue is: (1) §20 / D88 deterministic half — **shipped 0.9.0-alpha.6 (D91)**: `graph build` (structural edges only), compiled outline injected at session start, `graph neighbours` / `graph path` / `graph outline` / `graph lint` CLI (orphans / dangling / stale; missing-page alerts are part of the LLM half, still open); no LLM, no ranking change. Remaining under §20: **the LLM half** — semantic insights, missing-page alerts that propose new memories (through the D61 propose-first flow), compiled wiki pages — plus D78's pre-submit integration of the lint report. (2) D79 feedback-weighted ranking — D77-L2 counters landed 2026-11-03, so this is newly unblocked; fixture + baseline first (measurement before mechanism). (3) D78 curate+submit — the upkeep endgame; consumes §20 lint output. (4) Embeddings gate decision (bench `--model` measures the multilingual tax) + opt-in cross-lingual rerank for EN↔ZH queries only; local stays BM25-first. (5) OptMem small items — token cost in README, `wake` session-start ritual, capture length nudge. (6) Three-tier memory zones policy spec (Hot/Warm/Cold promotion/demotion rules) before building; §20's compiled outline already covers part of Hot. (7) Auto-capture design — answer the five open questions first (notably which session-end trigger opencode exposes). Then measurement/candidates: MemoryAgentBench second external data point; Phase 2C native plugins (candidate, not committed); D9 LAN reference server likely dropped; D2/D11 iron-rule gate is a known safety gap awaiting a build/drop decision. Non-code track: Phase 2B 1–2 colleague pilot (needs people, not code). Dependency chain: §20 lint → D78; D77-L2 counters → D79; gate decision → rerank. Tension to respect: §20's resident outline must stay compact per the injection-cost discipline (2026-10-19) — "important but not every turn" stays on-demand.
|
|
586
586
|
|
|
587
587
|
- **Phase 5 — Candidates recorded 2026-10-04 (not committed).** From the competitor scan (D75): an offline FTS5 retrieval eval with a published recall number (gates any semantic-layer decision) [promoted to next build, D77] · per-client trust levels on the review ladder · cold-start Markdown import into outbox drafts · `doctor` check that each editor's MCP registration points at the intended data root (mis-rooted servers are a real failure mode elsewhere). Sequencing and scope TBD per candidate.
|
|
588
588
|
- **Phase 5 — Candidates recorded 2026-10-11 (not committed).** From the XERJ review (xerj-org/xerj, Apache-2.0; founder Ivan N requested open-memex D81 for the XERJ Corpus Hub — agreed 2026-10-11, attribution + repo link): schema-first querying (`xerj_map` — agent fetches the field map before writing query DSL; candidate: a schema/describe helper ahead of `memory_search` to cut dead queries) · token-budgeted MCP results (their `token_budget.rs` — truncate to a token budget, not a fixed row limit) · hybrid retrieval as the scale answer (BM25 + vector kNN with fused ranking, e.g. RRF — the reference pattern for the eventual embedding layer; our lexical ceiling is already measured at R@5 40.6% pooled) · NL-to-validated-query planning (`xerj_plan` — natural language in, validated query out; candidate: a query lint/validate step before search executes) · evidence-carrying memory links (typed links with evidence + confidence, soft-retire never hard-delete — same spirit as our review-state ladder; prior art for a future memory-graph direction) · honest isolation docs (state what a namespace guarantees and does NOT — query-level vs trust boundary; same spirit as our Limitations section) · cost-accounted evals (report tokens + dollars per approach, as in their case studies — the format for proving "memory makes agents cheaper"). Sequencing and scope TBD per candidate.
|
|
@@ -607,7 +607,7 @@ requirement: personal data never touches third-party services). Benchmarks to tr
|
|
|
607
607
|
|
|
608
608
|
> v0.3 candidate (D88). Does not change the frozen v0.2 protocol; the graph/wiki is a derived layer. Full text: [docs/design/knowledge-graph.md](design/knowledge-graph.md).
|
|
609
609
|
|
|
610
|
-
*Status (2026-11-
|
|
610
|
+
*Status (2026-11-06): 部分实现 — the deterministic half shipped in 0.9.0-alpha.6 (D91): structural edges (supersedes / derived-from / body-mention / shared-tag with EXTRACTED/INFERRED provenance), `graph build|neighbours|path|lint`, auto-refresh on write, and the compiled outline injected at session start. Project scope only; CLI only (MCP stays at 13 tools). Still unbuilt: the LLM half (semantic insights, missing-page proposals, compiled wiki pages). See [docs/design/knowledge-graph.md](design/knowledge-graph.md) §20 status.*
|
|
611
611
|
|
|
612
612
|
---
|
|
613
613
|
|
package/docs/design/decisions.md
CHANGED
|
@@ -1144,3 +1144,6 @@
|
|
|
1144
1144
|
- **D89 — session working state note (2026-11-02).** Closes the "Session working state" open question (open since 2026-10-04, deferred "until there is signal that users lose work context, not just facts"). The signal is Stone's 2026-11-02 request, following the Muse working-state comparison: durable knowledge is not enough — an interrupted task needs its working state to resume. Design adopted (§3.6): one ephemeral per-project Markdown note, agent-written at wrap-up, surfaced at session start alongside injection, outside the review ladder, 7-day default TTL. Answers the open sub-questions: contents are task summary / open files / last commands / where the work stands / next step; the writer is the agent at Stop (explicit user command where no Stop hook exists); the overlap with retrospective distillation is resolved by routing through the D61 checkpoint-proposal flow (the note is raw material, the ladder is the gate). Doc-level decision only — no code in this change; implementation is deferred to the §18 near-term backlog.
|
|
1145
1145
|
*Status (2026-11-03): 已实现(0.9.0-alpha.1)— §3.6 落地:`src/working-state.ts`(写入/读取/过期/浮现块,`atomicWriteTextSync`、`redact` 照用)、`memory_workingstate`(第 12 个工具,插件与 MCP 同批)、会话开始浮现 `surfaceWorkingStateOnce`(插件两代适配器)、`audit` 增加 `workingStateExpired`、`open-memex wstate`(--clear)、配置 `workingStateEnabled`/`workingStateTtlDays`。**对原文的一个条款级修正**:opencode 插件 API 没有宿主 Stop 钩子(按已装 @opencode-ai/plugin 类型实地核对,Hooks 无 stop;SDK 事件里的 `session.idle` 每轮都触发,无法区分会话结束,也不生成内容),所以 opencode 的写入路径按 D"otherwise on an explicit user command"分支落地为 **指令 + 工具**——浮现块/工具描述/MCP 握手一致教 agent 在用户收尾信号时刷新;Claude Code 的 Stop 钩子归 Phase 2C 原生插件。权宜取舍(可接受):写笔记不过评审阶梯(从不入存储),`clear` 无墓碑直接删——§3.6 明说这是过期草稿。*
|
|
1146
1146
|
- **D90 — working-state note implementation & write-path correction (2026-11-03).** Supersedes D89's Stop-hook assumption where reality differs: the opencode plugin surface (checked `@opencode-ai/plugin` Hooks today) has no `stop` hook, and the SDK `session.idle` event fires after every turn with no content the plugin could write — so the write path on opencode is instruction + tool (session-start block and tool description teach the agent to refresh the note when the user signals wrap-up), exactly the "explicit user command" branch D89 already allowed. The full feature lands: `memory_workingstate` as the 12th tool on both hosts (ops.ts once), session-start surfacing `surfaceWorkingStateOnce` (once per session, same in-memory Set discipline as injection), `audit` gains `workingStateExpired` (reports only, never auto-deletes — D57 posture), CLI `wstate` / `wstate --clear`, config `workingStateEnabled` (default on) + `workingStateTtlDays` (default 7, flat keys — the `loadConfig` merge is shallow, so nested objects would drop fields). The note passes through `redact()` on write (agent-composed command recall can quote credentials) and uses `atomicWriteTextSync` like every write path. A per-note `ttl_days` frontmatter frees the human edit from later config changes. `clear` has no tombstone — acceptable, per §3.6 the note is expired scratch. Claude Code's Stop hook arrives with the Phase 2C native plugin.
|
|
1147
|
+
|
|
1148
|
+
- **D91 — the knowledge graph, deterministic half (§20, 2026-11-06).** Implements the graph layer D88 designed, split at the derivation boundary: this change ships only edges the code can *prove* or derive from structure, with no LLM call anywhere. Edge extraction (`src/graph/extract.ts`, pure): (1) **supersedes** edges from the index chain (`superseded_by`, plus the reverse derived from that column — the index has no `supersedes` column), EXTRACTED/high; (2) **derived-from** edges from the propose-copy's `derived_from` frontmatter (now also an index column, schema v10), EXTRACTED/high; (3) **relates-to** edges from `[[wiki-link]]` body mentions of a node's ULID, EXTRACTED/high, and from bare ULID mentions, INFERRED/high; (4) **relates-to** from shared tags at a fixed ladder — 1 shared tag → low, 2 → medium, ≥3 → high — INFERRED, capped at `MAX_SHARED_TAG_EDGES_PER_NODE = 12` per node and `MAX_SHARED_TAG_NODES = 2000` overall so one universal tag cannot produce an O(n²) edge set; one relational edge per unordered pair, EXTRACTED beats INFERRED on the same pair. Stored in `graph_edges`/`graph_meta` beside the rebuildable index with `CREATE TABLE IF NOT EXISTS` (like `memory_usage`, D77), so the graph is derived, disposable, and never touches Markdown or the source of truth. Every mutating path refreshes it automatically (`refreshGraphQuiet` on the write hooks: add/supersede/soft + hard forget on both hosts, keyword capture, propose, review promotion, CLI add/supersede/status/forget); `refreshGraph` is the explicit `graph build` path and reports honestly (D63 — a missing id fails, findings never invent nodes). **Outline** (`src/graph/outline.ts`, pure): connected components joined **only by medium+ INFERRED shared-tag edges** (the universal-tag collapse guard — a single low/medium tag must not merge unrelated memories; fixture-pinned in `smoke-pure.ts`), rendered `topic (n): titles…` with the cut disclosed at `maxLines` (config `graphOutlineLines`, default 10, cap 30); the compiled outline is stored in `graph_meta` and injected once at session start next to the working-state note (`graphOutline`, default on; injected lines contribute exposure ids to D77 `recordRetrieved`, never usefulness). **Queries** (`src/graph/queries.ts`, pure): `graph neighbours <id> [--depth 1-6]` (BFS, default 1, per-edge receipts with type/provenance/confidence) and `graph path <a> <b>` (shortest path, default depth 4, per-hop receipts). **Lint** (`src/graph/lint.ts`, pure): orphans (active, no topic, no edges), dangling edges (endpoint absent from the index — but an endpoint that exists in *another* scope is a legitimate foreign link, e.g. a propose copy deriving from its personal original, and is skipped), and near-stale pairs (similarity ≥ 0.8, chains excluded) via the existing lifecycle `similarity()`; reports only, nothing auto-resolved — this is the report D78's pre-submit lint consumes later. Scope contract: the graph covers the cwd's **project** scope only, no `--scope` flag, `personal` never graphs (§20.5). The interface is **CLI only** (`open-memex graph build|neighbours|path|lint|outline`) — the MCP surface stays at 13 tools; the outline reaches sessions through injection, not a tool (§20.6). Schema bump: added `derived_from TEXT` to `memories` (`SCHEMA_VERSION` 9 → 10, rebuild-from-Markdown migration — the frontmatter field already existed at `markdown.ts`). The **LLM half** — abstracted insights and missing-page alerts that propose new memories — remains open in §18/§20 and must go through the D61 propose-first flow.
|
|
1149
|
+
*Status (2026-11-06): 部分实现 (0.9.0-alpha.6) — deterministic half shipped: `src/graph/{extract,outline,queries,lint}.ts` + `src/store/graph.ts`, auto-refresh on every mutating path, outline injection, CLI `graph` group; smoke-pure + test-full (154 checks) green. LLM half (abstracted insights, missing-page → new memories) remains 未实现.*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## 20. Knowledge Graph & Compiled Wiki (v0.3 candidate)
|
|
2
2
|
|
|
3
|
-
*Status (2026-11-
|
|
3
|
+
*Status (2026-11-06): 部分实现 — the **deterministic half** shipped in 0.9.0-alpha.6 (D91): §20.3 structural edge extraction (supersedes / derived-from / body-mention / shared-tag at a fixed confidence ladder, EXTRACTED-vs-INFERRED provenance, stored in `graph_edges`/`graph_meta`), §20.4's build + query + lint operations (`graph build` / `neighbours` / `path` / `lint`, auto-refresh on every mutating write), and the compiled outline injected at session start. The graph is project-scope only and the interface is CLI-only (the MCP surface stays at 13 tools); §20.5's no-LLM extraction path is what shipped; §20.7 holds unchanged. **Still unbuilt:** the LLM half — semantic extraction/insights (§20.3 semantic edges, §20.5's confirmation flow), missing-page alerts that propose new memories, and the wiki compiled pages (§20.2 third layer).*
|
|
4
4
|
> v0.3 candidate (D88). Does not change the frozen v0.2 protocol; the graph/wiki is a derived layer (see §20.2). Sources: Karpathy's *LLM Wiki* (three layers / three operations) and Graphify (a working implementation of the same pattern on codebases, measured on muse-thinktank 2026-10-31: curated graph, 1029 nodes, edges tagged EXTRACTED/INFERRED with confidence). Both point to the same pattern: compile knowledge once, instead of re-deriving it on every query.
|
|
5
5
|
|
|
6
6
|
### 20.1 Why add a graph (motivation)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-memex",
|
|
3
|
-
"version": "0.9.0
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"mcpName": "io.github.stoneskin/open-memex",
|
|
5
5
|
"description": "Local-first memory layer and protocol for AI coding agents. Markdown source of truth, SQLite FTS5 index, zero cloud.",
|
|
6
6
|
"keywords": [
|