@monoes/monomindcli 2.16.12 → 2.16.13

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.
Files changed (217) hide show
  1. package/.claude/agents/core/coder.md +1 -1
  2. package/.claude/agents/engineering/engineering-devops-automator.md +1 -1
  3. package/.claude/agents/github/repo-architect.md +1 -1
  4. package/.claude/agents/testing/production-validator.md +1 -1
  5. package/.claude/agents/testing/testing-tool-evaluator.md +1 -1
  6. package/.claude/commands/github/pr-manager.md +1 -1
  7. package/.claude/helpers/pick-rank.cjs +34 -4
  8. package/.claude/skills/monolean-audit/SKILL.md +1 -1
  9. package/dist/src/commands/cleanup-data.d.ts +30 -0
  10. package/dist/src/commands/cleanup-data.d.ts.map +1 -0
  11. package/dist/src/commands/cleanup-data.js +138 -0
  12. package/dist/src/commands/cleanup-data.js.map +1 -0
  13. package/dist/src/commands/cleanup-scratch.d.ts +43 -0
  14. package/dist/src/commands/cleanup-scratch.d.ts.map +1 -0
  15. package/dist/src/commands/cleanup-scratch.js +125 -0
  16. package/dist/src/commands/cleanup-scratch.js.map +1 -0
  17. package/dist/src/commands/cleanup.d.ts +2 -39
  18. package/dist/src/commands/cleanup.d.ts.map +1 -1
  19. package/dist/src/commands/cleanup.js +5 -247
  20. package/dist/src/commands/cleanup.js.map +1 -1
  21. package/dist/src/commands/doctor-gitignore-checks.d.ts +10 -0
  22. package/dist/src/commands/doctor-gitignore-checks.d.ts.map +1 -0
  23. package/dist/src/commands/doctor-gitignore-checks.js +141 -0
  24. package/dist/src/commands/doctor-gitignore-checks.js.map +1 -0
  25. package/dist/src/commands/doctor-helpers-checks.d.ts +10 -0
  26. package/dist/src/commands/doctor-helpers-checks.d.ts.map +1 -0
  27. package/dist/src/commands/doctor-helpers-checks.js +292 -0
  28. package/dist/src/commands/doctor-helpers-checks.js.map +1 -0
  29. package/dist/src/commands/doctor-memory-checks.d.ts +47 -0
  30. package/dist/src/commands/doctor-memory-checks.d.ts.map +1 -0
  31. package/dist/src/commands/doctor-memory-checks.js +298 -0
  32. package/dist/src/commands/doctor-memory-checks.js.map +1 -0
  33. package/dist/src/commands/doctor-monograph-checks.d.ts +9 -0
  34. package/dist/src/commands/doctor-monograph-checks.d.ts.map +1 -0
  35. package/dist/src/commands/doctor-monograph-checks.js +331 -0
  36. package/dist/src/commands/doctor-monograph-checks.js.map +1 -0
  37. package/dist/src/commands/doctor-project-checks.d.ts +7 -66
  38. package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
  39. package/dist/src/commands/doctor-project-checks.js +10 -1331
  40. package/dist/src/commands/doctor-project-checks.js.map +1 -1
  41. package/dist/src/commands/doctor-routing-checks.d.ts +10 -0
  42. package/dist/src/commands/doctor-routing-checks.d.ts.map +1 -0
  43. package/dist/src/commands/doctor-routing-checks.js +194 -0
  44. package/dist/src/commands/doctor-routing-checks.js.map +1 -0
  45. package/dist/src/commands/doctor-worker-checks.d.ts +17 -0
  46. package/dist/src/commands/doctor-worker-checks.d.ts.map +1 -0
  47. package/dist/src/commands/doctor-worker-checks.js +122 -0
  48. package/dist/src/commands/doctor-worker-checks.js.map +1 -0
  49. package/dist/src/commands/hooks-routing-commands.js +1 -1
  50. package/dist/src/commands/hooks-routing-commands.js.map +1 -1
  51. package/dist/src/commands/init.d.ts.map +1 -1
  52. package/dist/src/commands/init.js +6 -15
  53. package/dist/src/commands/init.js.map +1 -1
  54. package/dist/src/index.js +2 -2
  55. package/dist/src/index.js.map +1 -1
  56. package/dist/src/init/never-commit.d.ts +3 -3
  57. package/dist/src/init/types.d.ts +1 -1
  58. package/dist/src/init/types.js +1 -1
  59. package/dist/src/knowledge/document-store.js +1 -1
  60. package/dist/src/knowledge/document-store.js.map +1 -1
  61. package/dist/src/mcp-tools/hooks-edit-command.d.ts +10 -0
  62. package/dist/src/mcp-tools/hooks-edit-command.d.ts.map +1 -0
  63. package/dist/src/mcp-tools/hooks-edit-command.js +247 -0
  64. package/dist/src/mcp-tools/hooks-edit-command.js.map +1 -0
  65. package/dist/src/mcp-tools/hooks-learning.d.ts +9 -0
  66. package/dist/src/mcp-tools/hooks-learning.d.ts.map +1 -0
  67. package/dist/src/mcp-tools/hooks-learning.js +408 -0
  68. package/dist/src/mcp-tools/hooks-learning.js.map +1 -0
  69. package/dist/src/mcp-tools/hooks-metrics-list.d.ts +8 -0
  70. package/dist/src/mcp-tools/hooks-metrics-list.d.ts.map +1 -0
  71. package/dist/src/mcp-tools/hooks-metrics-list.js +205 -0
  72. package/dist/src/mcp-tools/hooks-metrics-list.js.map +1 -0
  73. package/dist/src/mcp-tools/hooks-route.d.ts +12 -0
  74. package/dist/src/mcp-tools/hooks-route.d.ts.map +1 -0
  75. package/dist/src/mcp-tools/hooks-route.js +251 -0
  76. package/dist/src/mcp-tools/hooks-route.js.map +1 -0
  77. package/dist/src/mcp-tools/hooks-routing.d.ts +6 -27
  78. package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
  79. package/dist/src/mcp-tools/hooks-routing.js +6 -1727
  80. package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
  81. package/dist/src/mcp-tools/hooks-session.d.ts +9 -0
  82. package/dist/src/mcp-tools/hooks-session.d.ts.map +1 -0
  83. package/dist/src/mcp-tools/hooks-session.js +243 -0
  84. package/dist/src/mcp-tools/hooks-session.js.map +1 -0
  85. package/dist/src/mcp-tools/hooks-task.d.ts +17 -0
  86. package/dist/src/mcp-tools/hooks-task.d.ts.map +1 -0
  87. package/dist/src/mcp-tools/hooks-task.js +427 -0
  88. package/dist/src/mcp-tools/hooks-task.js.map +1 -0
  89. package/dist/src/mcp-tools/hooks-tools.d.ts +2 -1
  90. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  91. package/dist/src/mcp-tools/hooks-tools.js +2 -1
  92. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  93. package/dist/src/mcp-tools/memory-tools.js +1 -1
  94. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  95. package/dist/src/memory/bm25-index.d.ts +2 -2
  96. package/dist/src/memory/bm25-index.js +2 -2
  97. package/dist/src/memory/embedding-operations.js +2 -2
  98. package/dist/src/memory/embedding-operations.js.map +1 -1
  99. package/dist/src/memory/entity-name-key.d.ts +1 -1
  100. package/dist/src/memory/entity-name-key.js +1 -1
  101. package/dist/src/memory/hnsw-operations.d.ts +1 -1
  102. package/dist/src/memory/hnsw-operations.js +1 -1
  103. package/dist/src/memory/memory-bridge-backend.d.ts +43 -0
  104. package/dist/src/memory/memory-bridge-backend.d.ts.map +1 -0
  105. package/dist/src/memory/memory-bridge-backend.js +363 -0
  106. package/dist/src/memory/memory-bridge-backend.js.map +1 -0
  107. package/dist/src/memory/memory-bridge-core.d.ts +42 -0
  108. package/dist/src/memory/memory-bridge-core.d.ts.map +1 -0
  109. package/dist/src/memory/memory-bridge-core.js +126 -0
  110. package/dist/src/memory/memory-bridge-core.js.map +1 -0
  111. package/dist/src/memory/memory-bridge-entries.d.ts +131 -0
  112. package/dist/src/memory/memory-bridge-entries.d.ts.map +1 -0
  113. package/dist/src/memory/memory-bridge-entries.js +227 -0
  114. package/dist/src/memory/memory-bridge-entries.js.map +1 -0
  115. package/dist/src/memory/memory-bridge-feedback.d.ts +60 -0
  116. package/dist/src/memory/memory-bridge-feedback.d.ts.map +1 -0
  117. package/dist/src/memory/memory-bridge-feedback.js +118 -0
  118. package/dist/src/memory/memory-bridge-feedback.js.map +1 -0
  119. package/dist/src/memory/memory-bridge-paths.d.ts +123 -0
  120. package/dist/src/memory/memory-bridge-paths.d.ts.map +1 -0
  121. package/dist/src/memory/memory-bridge-paths.js +335 -0
  122. package/dist/src/memory/memory-bridge-paths.js.map +1 -0
  123. package/dist/src/memory/memory-bridge-search.d.ts +48 -0
  124. package/dist/src/memory/memory-bridge-search.d.ts.map +1 -0
  125. package/dist/src/memory/memory-bridge-search.js +383 -0
  126. package/dist/src/memory/memory-bridge-search.js.map +1 -0
  127. package/dist/src/memory/memory-bridge-sessions.d.ts +38 -0
  128. package/dist/src/memory/memory-bridge-sessions.d.ts.map +1 -0
  129. package/dist/src/memory/memory-bridge-sessions.js +109 -0
  130. package/dist/src/memory/memory-bridge-sessions.js.map +1 -0
  131. package/dist/src/memory/memory-bridge-store.d.ts +58 -0
  132. package/dist/src/memory/memory-bridge-store.d.ts.map +1 -0
  133. package/dist/src/memory/memory-bridge-store.js +201 -0
  134. package/dist/src/memory/memory-bridge-store.js.map +1 -0
  135. package/dist/src/memory/memory-bridge.d.ts +10 -438
  136. package/dist/src/memory/memory-bridge.d.ts.map +1 -1
  137. package/dist/src/memory/memory-bridge.js +14 -1787
  138. package/dist/src/memory/memory-bridge.js.map +1 -1
  139. package/dist/src/memory/memory-kg-claims.d.ts +52 -0
  140. package/dist/src/memory/memory-kg-claims.d.ts.map +1 -0
  141. package/dist/src/memory/memory-kg-claims.js +99 -0
  142. package/dist/src/memory/memory-kg-claims.js.map +1 -0
  143. package/dist/src/memory/memory-kg-index.d.ts +86 -0
  144. package/dist/src/memory/memory-kg-index.d.ts.map +1 -0
  145. package/dist/src/memory/memory-kg-index.js +256 -0
  146. package/dist/src/memory/memory-kg-index.js.map +1 -0
  147. package/dist/src/memory/memory-kg-ingest.d.ts +44 -0
  148. package/dist/src/memory/memory-kg-ingest.d.ts.map +1 -0
  149. package/dist/src/memory/memory-kg-ingest.js +361 -0
  150. package/dist/src/memory/memory-kg-ingest.js.map +1 -0
  151. package/dist/src/memory/memory-kg-model.d.ts +168 -0
  152. package/dist/src/memory/memory-kg-model.d.ts.map +1 -0
  153. package/dist/src/memory/memory-kg-model.js +158 -0
  154. package/dist/src/memory/memory-kg-model.js.map +1 -0
  155. package/dist/src/memory/memory-kg-names.d.ts +64 -0
  156. package/dist/src/memory/memory-kg-names.d.ts.map +1 -0
  157. package/dist/src/memory/memory-kg-names.js +187 -0
  158. package/dist/src/memory/memory-kg-names.js.map +1 -0
  159. package/dist/src/memory/memory-kg-promote.d.ts +79 -0
  160. package/dist/src/memory/memory-kg-promote.d.ts.map +1 -0
  161. package/dist/src/memory/memory-kg-promote.js +248 -0
  162. package/dist/src/memory/memory-kg-promote.js.map +1 -0
  163. package/dist/src/memory/memory-kg-rebuild.d.ts +77 -0
  164. package/dist/src/memory/memory-kg-rebuild.d.ts.map +1 -0
  165. package/dist/src/memory/memory-kg-rebuild.js +299 -0
  166. package/dist/src/memory/memory-kg-rebuild.js.map +1 -0
  167. package/dist/src/memory/memory-kg-rollback.d.ts +47 -0
  168. package/dist/src/memory/memory-kg-rollback.d.ts.map +1 -0
  169. package/dist/src/memory/memory-kg-rollback.js +193 -0
  170. package/dist/src/memory/memory-kg-rollback.js.map +1 -0
  171. package/dist/src/memory/memory-kg-rules.d.ts +64 -0
  172. package/dist/src/memory/memory-kg-rules.d.ts.map +1 -0
  173. package/dist/src/memory/memory-kg-rules.js +251 -0
  174. package/dist/src/memory/memory-kg-rules.js.map +1 -0
  175. package/dist/src/memory/memory-kg-scan.d.ts +118 -0
  176. package/dist/src/memory/memory-kg-scan.d.ts.map +1 -0
  177. package/dist/src/memory/memory-kg-scan.js +209 -0
  178. package/dist/src/memory/memory-kg-scan.js.map +1 -0
  179. package/dist/src/memory/memory-kg-search.d.ts +80 -0
  180. package/dist/src/memory/memory-kg-search.d.ts.map +1 -0
  181. package/dist/src/memory/memory-kg-search.js +239 -0
  182. package/dist/src/memory/memory-kg-search.js.map +1 -0
  183. package/dist/src/memory/memory-kg.d.ts +19 -547
  184. package/dist/src/memory/memory-kg.d.ts.map +1 -1
  185. package/dist/src/memory/memory-kg.js +10 -2389
  186. package/dist/src/memory/memory-kg.js.map +1 -1
  187. package/dist/src/ui/org-hil.mjs +1 -1
  188. package/dist/src/ui/routes-org-agents.mjs +318 -0
  189. package/dist/src/ui/routes-org-approvals.mjs +133 -0
  190. package/dist/src/ui/routes-org-config.mjs +459 -0
  191. package/dist/src/ui/routes-org-control.mjs +300 -0
  192. package/dist/src/ui/routes-org-files.mjs +172 -0
  193. package/dist/src/ui/routes-org-helpers.mjs +84 -0
  194. package/dist/src/ui/routes-org-knowledge.mjs +262 -0
  195. package/dist/src/ui/routes-org-lifecycle.mjs +224 -0
  196. package/dist/src/ui/routes-org-live.mjs +278 -0
  197. package/dist/src/ui/routes-org-mastermind.mjs +346 -0
  198. package/dist/src/ui/routes-org-planning.mjs +398 -0
  199. package/dist/src/ui/routes-org-runs.mjs +430 -0
  200. package/dist/src/ui/routes-org-status.mjs +342 -0
  201. package/dist/src/ui/routes-org-workflows.mjs +212 -0
  202. package/dist/src/ui/routes-org.mjs +26 -3847
  203. package/dist/src/ui/server.mjs +1 -1
  204. package/dist/src/utils/native-error.d.ts +1 -1
  205. package/dist/src/utils/native-error.js +1 -1
  206. package/dist/src/utils/paths.d.ts +2 -1
  207. package/dist/src/utils/paths.d.ts.map +1 -1
  208. package/dist/src/utils/paths.js +2 -1
  209. package/dist/src/utils/paths.js.map +1 -1
  210. package/dist/tsconfig.tsbuildinfo +1 -1
  211. package/org-skills/adversarial-reviewer/SKILL.md +1 -1
  212. package/org-skills/board-deck-builder/SKILL.md +1 -1
  213. package/org-skills/code-reviewer/SKILL.md +1 -1
  214. package/org-skills/debugging-wizard/SKILL.md +1 -1
  215. package/org-skills/scientific-thinking-literature-review/SKILL.md +1 -1
  216. package/org-skills/scientific-thinking-scholar-evaluation/SKILL.md +1 -1
  217. package/package.json +8 -8
@@ -0,0 +1,361 @@
1
+ /**
2
+ * Memory Knowledge Graph — ingest: kgIngest (entity resolution, claim
3
+ * merge under compare-and-swap, placeholder endpoints) and its per-call
4
+ * report. Split out of memory-kg.ts, which re-exports kgIngest.
5
+ */
6
+ import { bridgeGetEntry, bridgeStoreEntry } from './memory-bridge.js';
7
+ import { applyClaim } from './memory-kg-claims.js';
8
+ import { onEdgeWritten, onEntrySupported } from './memory-kg-index.js';
9
+ import { canonicalName, edgeKey, KG_ID_VERSION, kgNamespaces, kgQualifyOrigin, legacyEdgeKey, MAX_DESC_LEN, MAX_EDGES_PER_CALL, MAX_NODES_PER_CALL, normalizeName, typeBucket, } from './memory-kg-model.js';
10
+ import { resolveEntity, writeNameIndex } from './memory-kg-names.js';
11
+ import { FailureLog, MAX_FAILURES, withCasRetry } from './memory-kg-scan.js';
12
+ // ── Ingest ──────────────────────────────────────────────────────────
13
+ /** Merge extracted nodes/edges into the KG.
14
+ *
15
+ * Identity is the (type, name) tuple resolved through the name index, so an
16
+ * entity is idempotent under re-extraction but two different things sharing a
17
+ * name stay two things. Each write adds this origin's CONTRIBUTION to the
18
+ * element's claim ledger, from which the description and `origin_refs` are
19
+ * derived — which is what lets a later ingest correct an earlier one and lets
20
+ * rollback put the earlier one back.
21
+ *
22
+ * The COMPLETE payload is validated before anything is written, and every edge
23
+ * endpoint is made to exist (as a placeholder entity when the caller named one
24
+ * that does not) before the edge lands. An edge whose endpoint could not be
25
+ * created is rejected rather than written: retrieval is seeded from nodes, so
26
+ * an edge with a missing endpoint is a fact that cannot be found through
27
+ * either of the things it is about.
28
+ *
29
+ * NOT ATOMIC — the memory bridge has no transaction primitive, so a failure
30
+ * part-way through leaves earlier writes persisted. The counters therefore
31
+ * report only what actually landed, `failures` lists what did not, and
32
+ * `success` is false whenever anything was refused. A partial ingest is safe
33
+ * to retry: every write is a keyed upsert. */
34
+ export async function kgIngest(options) {
35
+ const { dbPath } = options;
36
+ const method = options.method ?? 'asserted';
37
+ const ns = kgNamespaces(options.scope);
38
+ const originRef = kgQualifyOrigin(options.originRef, options.scope);
39
+ const failures = new FailureLog();
40
+ const report = new IngestReport();
41
+ let nodesAdded = 0, nodesMerged = 0, edgesAdded = 0, edgesMerged = 0;
42
+ try {
43
+ // ── Validate the COMPLETE payload before mutating anything ──
44
+ // An invalid item that surfaces halfway through leaves the graph holding
45
+ // part of a payload the caller was told was rejected.
46
+ const allNodes = options.nodes ?? [];
47
+ const allEdges = options.edges ?? [];
48
+ const nodes = allNodes.slice(0, MAX_NODES_PER_CALL);
49
+ const edges = allEdges.slice(0, MAX_EDGES_PER_CALL);
50
+ report.nodesTruncated = allNodes.length - nodes.length;
51
+ report.edgesTruncated = allEdges.length - edges.length;
52
+ const validNodes = [];
53
+ nodes.forEach((n, i) => {
54
+ if (!n?.name?.trim())
55
+ return report.rejectNode(`node[${i}]: missing name`);
56
+ validNodes.push({
57
+ input: n,
58
+ type: n.type?.trim() || 'entity',
59
+ desc: (n.description ?? '').slice(0, MAX_DESC_LEN),
60
+ });
61
+ });
62
+ const validEdges = [];
63
+ edges.forEach((e, i) => {
64
+ const missing = !e?.source?.trim()
65
+ ? 'source'
66
+ : !e?.target?.trim()
67
+ ? 'target'
68
+ : !e?.relation?.trim()
69
+ ? 'relation'
70
+ : '';
71
+ if (missing)
72
+ return report.rejectEdge(`edge[${i}]: missing ${missing}`);
73
+ validEdges.push(e);
74
+ });
75
+ /** Entity IDs this call has already resolved AND confirmed to exist, so an
76
+ * edge does not re-resolve an endpoint the node loop just wrote. */
77
+ const resolved = new Map();
78
+ // Length-prefix the type so the split point is unambiguous regardless of
79
+ // what characters `name` contains (it can hold arbitrary text, including
80
+ // whatever separator a naive join might pick) — same discipline
81
+ // hashTuple() above uses for the same reason. A bare `\0`-joined string
82
+ // here was written as an actual NUL byte, not the literal two-character
83
+ // escape text, which is harmless at runtime (this key is an in-memory
84
+ // Map key only, never persisted) but made git treat this file as binary.
85
+ const memoKey = (name, type) => {
86
+ const t = typeBucket(type);
87
+ return `${t.length}:${t}${canonicalName(name)}`;
88
+ };
89
+ for (const { input: n, type, desc } of validNodes) {
90
+ const target = await resolveEntity(n.name, type, ns, dbPath);
91
+ if (!target) {
92
+ failures.note(`node ${n.name}: name index unreadable`);
93
+ continue;
94
+ }
95
+ report.noteAmbiguity(n.name, target.candidates);
96
+ const wrote = await writeEntity({
97
+ id: target.id,
98
+ name: n.name,
99
+ type,
100
+ description: desc,
101
+ nodeSet: n.nodeSet,
102
+ originRef,
103
+ method,
104
+ ns,
105
+ dbPath,
106
+ failures,
107
+ report,
108
+ });
109
+ if (wrote === null)
110
+ continue;
111
+ if (wrote)
112
+ nodesAdded++;
113
+ else
114
+ nodesMerged++;
115
+ resolved.set(memoKey(n.name, type), target.id);
116
+ if (target.index)
117
+ await writeNameIndex(n.name, target.index, ns, dbPath, failures);
118
+ await onEntrySupported(ns, ns.nodes, target.id, originRef, dbPath);
119
+ }
120
+ /** Resolve an edge endpoint, creating an explicit placeholder entity when
121
+ * the caller named something that does not exist. Returns null when the
122
+ * endpoint could not be made to exist — the edge is then rejected rather
123
+ * than written without it. */
124
+ const endpoint = async (name, type) => {
125
+ const memo = memoKey(name, type ?? 'entity');
126
+ const hit = resolved.get(memo);
127
+ if (hit)
128
+ return hit;
129
+ const target = await resolveEntity(name, type ?? 'entity', ns, dbPath);
130
+ if (!target) {
131
+ failures.note(`endpoint ${name}: name index unreadable`);
132
+ return null;
133
+ }
134
+ report.noteAmbiguity(name, target.candidates);
135
+ // Always write: naming an endpoint IS an assertion that it exists, so
136
+ // this origin joins the entity's support either way. A write that CREATES
137
+ // the entity is the placeholder case worth reporting.
138
+ const wrote = await writeEntity({
139
+ id: target.id,
140
+ name,
141
+ type: type ?? 'entity',
142
+ description: '',
143
+ placeholder: true,
144
+ originRef,
145
+ method,
146
+ ns,
147
+ dbPath,
148
+ failures,
149
+ report,
150
+ });
151
+ if (wrote === null)
152
+ return null;
153
+ if (wrote)
154
+ report.placeholders++;
155
+ if (target.index)
156
+ await writeNameIndex(name, target.index, ns, dbPath, failures);
157
+ resolved.set(memo, target.id);
158
+ await onEntrySupported(ns, ns.nodes, target.id, originRef, dbPath);
159
+ return target.id;
160
+ };
161
+ for (const e of validEdges) {
162
+ const srcKey = await endpoint(e.source, e.sourceType);
163
+ const dstKey = await endpoint(e.target, e.targetType);
164
+ if (!srcKey || !dstKey) {
165
+ report.rejectEdge(`edge ${e.source}-${e.relation}->${e.target}: endpoint not persisted`);
166
+ continue;
167
+ }
168
+ const desc = (e.description ?? '').slice(0, MAX_DESC_LEN);
169
+ const fallbackFact = `${e.source} ${e.relation} ${e.target}`;
170
+ // New key first, then the pre-KG_ID_VERSION shape: a legacy edge between
171
+ // two adopted legacy endpoints keeps its own key rather than being
172
+ // duplicated under a new one. Resolved once — a CAS retry re-reads this
173
+ // same key, it does not re-run legacy resolution.
174
+ let key = edgeKey(srcKey, e.relation, dstKey);
175
+ const probe = await bridgeGetEntry({ key, namespace: ns.edges, dbPath });
176
+ if (!probe?.found) {
177
+ const legacy = legacyEdgeKey(srcKey, e.relation, dstKey);
178
+ const hit = await bridgeGetEntry({ key: legacy, namespace: ns.edges, dbPath });
179
+ if (hit?.found && hit.entry)
180
+ key = legacy;
181
+ }
182
+ // Re-read and re-merge on every CAS attempt (see withCasRetry): a stale
183
+ // `md`/`derived` retried against a fresh row would silently re-lose
184
+ // whatever a concurrent writer just added (K5).
185
+ let md = {};
186
+ let derived;
187
+ let isNew = false;
188
+ const res = await withCasRetry(async () => {
189
+ const existing = await bridgeGetEntry({ key, namespace: ns.edges, dbPath });
190
+ isNew = !(existing?.found && existing.entry);
191
+ md = (existing?.entry?.metadata ?? {});
192
+ derived = applyClaim(md, originRef, desc, Date.now(), method);
193
+ const ver = existing?.entry?.version;
194
+ return bridgeStoreEntry({
195
+ key,
196
+ value: derived.description || fallbackFact,
197
+ namespace: ns.edges,
198
+ dbPath,
199
+ upsert: true,
200
+ generateEmbeddingFlag: false,
201
+ tags: ['kg', normalizeName(e.relation)],
202
+ metadata: {
203
+ ...md,
204
+ kg: 'edge',
205
+ id_version: KG_ID_VERSION,
206
+ src: srcKey,
207
+ dst: dstKey,
208
+ relation: normalizeName(e.relation),
209
+ source_name: e.source,
210
+ target_name: e.target,
211
+ ...derived,
212
+ valid_from: md.valid_from ?? Date.now(),
213
+ valid_to: null,
214
+ },
215
+ ifVersion: isNew ? 'absent' : typeof ver === 'number' ? ver : undefined,
216
+ });
217
+ });
218
+ if (failures.add(res, `edge ${key}`))
219
+ continue;
220
+ report.noteProvenanceLoss(md, derived);
221
+ if (isNew)
222
+ edgesAdded++;
223
+ else
224
+ edgesMerged++;
225
+ await onEntrySupported(ns, ns.edges, key, originRef, dbPath);
226
+ if (isNew)
227
+ await onEdgeWritten(ns, key, srcKey, dstKey, dbPath);
228
+ }
229
+ return {
230
+ success: !failures.failed,
231
+ nodesAdded,
232
+ nodesMerged,
233
+ edgesAdded,
234
+ edgesMerged,
235
+ ...(failures.failed ? { failures: failures.messages, error: failures.summary() } : {}),
236
+ ...report.fields(),
237
+ };
238
+ }
239
+ catch (err) {
240
+ return {
241
+ success: false,
242
+ nodesAdded,
243
+ nodesMerged,
244
+ edgesAdded,
245
+ edgesMerged,
246
+ ...(failures.messages.length ? { failures: failures.messages } : {}),
247
+ ...report.fields(),
248
+ error: err instanceof Error ? err.message : String(err),
249
+ };
250
+ }
251
+ }
252
+ /** Write one entity's claim contribution.
253
+ *
254
+ * @returns true when the entity was created, false when an existing one was
255
+ * merged into, and null when the bridge refused the write (the caller must not
256
+ * count it, and must not treat the entity as existing). */
257
+ async function writeEntity(o) {
258
+ // Re-read and re-merge on every CAS attempt (see withCasRetry) rather than
259
+ // once up front: a stale `md`/`derived` retried against a fresh row would
260
+ // silently re-lose whatever a concurrent writer just added (K5).
261
+ let md = {};
262
+ let derived;
263
+ let isNew = false;
264
+ const res = await withCasRetry(async () => {
265
+ const existing = await bridgeGetEntry({ key: o.id, namespace: o.ns.nodes, dbPath: o.dbPath });
266
+ isNew = !(existing?.found && existing.entry);
267
+ md = (existing?.entry?.metadata ?? {});
268
+ derived = applyClaim(md, o.originRef, o.description, Date.now(), o.method);
269
+ // Keep the most specific type: a generic heuristic 'entity' never
270
+ // overwrites an LLM-assigned one, and a specific one promotes an untyped
271
+ // entity.
272
+ const prevType = typeof md.type === 'string' ? md.type : '';
273
+ const bestType = typeBucket(prevType) ? prevType : o.type;
274
+ const nodeSet = o.nodeSet ?? (typeof md.node_set === 'string' ? md.node_set : null);
275
+ const ver = existing?.entry?.version;
276
+ return bridgeStoreEntry({
277
+ key: o.id,
278
+ value: `${o.name} — ${derived.description || bestType}`,
279
+ namespace: o.ns.nodes,
280
+ dbPath: o.dbPath,
281
+ upsert: true,
282
+ tags: ['kg', normalizeName(bestType), ...(nodeSet ? [normalizeName(nodeSet)] : [])],
283
+ metadata: {
284
+ ...md,
285
+ kg: 'node',
286
+ id_version: KG_ID_VERSION,
287
+ type: bestType,
288
+ name: o.name,
289
+ node_set: nodeSet,
290
+ ...derived,
291
+ // A placeholder stops being one the moment a real assertion describes it.
292
+ placeholder: o.placeholder === true && !derived.description ? true : undefined,
293
+ version: (typeof md.version === 'number' ? md.version : 0) + 1,
294
+ valid_from: md.valid_from ?? Date.now(),
295
+ valid_to: null,
296
+ },
297
+ // isNew ⇒ this row must not already exist; otherwise it must still be at
298
+ // the version we just read. Absent when the loaded backend/test double
299
+ // does not report a version, so behaviour is unchanged there (see
300
+ // bridgeGetEntry's `version` field).
301
+ ifVersion: isNew ? 'absent' : typeof ver === 'number' ? ver : undefined,
302
+ });
303
+ });
304
+ // Name first: the ID is a digest, and a failure message a human cannot map
305
+ // back to the thing that failed is not a diagnosis.
306
+ if (o.failures.add(res, `node ${o.name} (${o.id})`))
307
+ return null;
308
+ // Only after the write landed: a refused write dropped no provenance, because
309
+ // it changed nothing.
310
+ o.report.noteProvenanceLoss(md, derived);
311
+ return isNew;
312
+ }
313
+ /** The accepted/rejected/truncated bookkeeping a caller needs in order to know
314
+ * that what it sent is what the graph holds. */
315
+ class IngestReport {
316
+ nodesRejected = 0;
317
+ edgesRejected = 0;
318
+ nodesTruncated = 0;
319
+ edgesTruncated = 0;
320
+ placeholders = 0;
321
+ provenanceTruncated = 0;
322
+ rejections = [];
323
+ ambiguities = [];
324
+ rejectNode(message) {
325
+ this.nodesRejected++;
326
+ if (this.rejections.length < MAX_FAILURES)
327
+ this.rejections.push(message);
328
+ }
329
+ rejectEdge(message) {
330
+ this.edgesRejected++;
331
+ if (this.rejections.length < MAX_FAILURES)
332
+ this.rejections.push(message);
333
+ }
334
+ noteAmbiguity(name, candidates) {
335
+ if (!candidates.length || this.ambiguities.length >= MAX_FAILURES)
336
+ return;
337
+ const types = candidates.map((c) => c.type || 'untyped').join(', ');
338
+ this.ambiguities.push(`${name}: kept separate from ${candidates.length} same-name (${types})`);
339
+ }
340
+ noteProvenanceLoss(md, derived) {
341
+ const before = typeof md.origins_dropped === 'number' ? md.origins_dropped : 0;
342
+ if (derived.origins_dropped > before)
343
+ this.provenanceTruncated++;
344
+ }
345
+ /** Only non-zero counters are emitted, so a clean payload yields a clean
346
+ * result and the existing `KgIngestResult` shape is unchanged for callers
347
+ * that construct it themselves. */
348
+ fields() {
349
+ return {
350
+ ...(this.nodesRejected ? { nodesRejected: this.nodesRejected } : {}),
351
+ ...(this.edgesRejected ? { edgesRejected: this.edgesRejected } : {}),
352
+ ...(this.nodesTruncated ? { nodesTruncated: this.nodesTruncated } : {}),
353
+ ...(this.edgesTruncated ? { edgesTruncated: this.edgesTruncated } : {}),
354
+ ...(this.rejections.length ? { rejections: this.rejections } : {}),
355
+ ...(this.placeholders ? { placeholders: this.placeholders } : {}),
356
+ ...(this.ambiguities.length ? { ambiguities: this.ambiguities } : {}),
357
+ ...(this.provenanceTruncated ? { provenanceTruncated: this.provenanceTruncated } : {}),
358
+ };
359
+ }
360
+ }
361
+ //# sourceMappingURL=memory-kg-ingest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-kg-ingest.js","sourceRoot":"","sources":["../../../src/memory/memory-kg-ingest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAQvE,OAAO,EACL,aAAa,EACb,OAAO,EACP,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,UAAU,GACX,MA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AAM;QACJ,OAAO;YACL,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpE,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpE,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClE,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjE,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Memory Knowledge Graph — namespaces, limits, identity (entity/edge/rule
3
+ * keys), the ingest input/result types, and scope (org ownership). Split out
4
+ * of memory-kg.ts, which re-exports the public symbols; see that module's
5
+ * header for the design.
6
+ */
7
+ export declare const KG_NODES_NS = "kg:nodes";
8
+ export declare const KG_EDGES_NS = "kg:edges";
9
+ export declare const RULES_NS = "rules";
10
+ /** Name → entity index. Index rows are NOT claims, so they live outside the
11
+ * three claim namespaces: putting them in `kg:nodes` would make them seed
12
+ * candidates for `kgSearch` and rows in `kgStats`. */
13
+ export declare const KG_NAMES_NS = "kg:names";
14
+ /** Derived adjacency index namespace (K7). See `KgNamespaces.adj`. */
15
+ export declare const KG_ADJ_NS = "kg:adj";
16
+ /** Derived origin-support index namespace (K7). See `KgNamespaces.originIdx`. */
17
+ export declare const KG_ORIGIN_IDX_NS = "kg:origin-idx";
18
+ /** Derived-index status namespace (K7). See `KgNamespaces.indexStatus`. */
19
+ export declare const KG_INDEX_STATUS_NS = "kg:index-status";
20
+ export declare const MAX_DESC_LEN = 2000;
21
+ /** Nodes/edges/rules accepted per call. Overflow is REPORTED, never sliced away
22
+ * in silence — see `KgIngestResult.nodesTruncated`. */
23
+ export declare const MAX_NODES_PER_CALL = 500;
24
+ export declare const MAX_EDGES_PER_CALL = 1000;
25
+ export declare const MAX_RULES_PER_CALL = 50;
26
+ /** Per-origin description contributions retained on one element.
27
+ *
28
+ * A cap has to exist — the bridge caps a stored value, and an element asserted
29
+ * by ten thousand runs would otherwise stop being writable. What must NOT
30
+ * happen is the old `origin_refs.slice(-100)`, which dropped the oldest
31
+ * provenance and left the entry claiming complete history. Past this cap the
32
+ * oldest contributions are dropped AND the entry records `origins_dropped`
33
+ * with `provenance_complete: false`, so a reader can tell that a rollback of an
34
+ * old origin may find nothing to withdraw. */
35
+ export declare const MAX_CLAIMS = 200;
36
+ /**
37
+ * Version of the identity scheme implemented by `entityId`/`edgeKey`/`ruleKey`.
38
+ *
39
+ * Bump when a derivation changes. Entries written under an older scheme are not
40
+ * orphaned: resolution probes the previous key shape and adopts the row in
41
+ * place (see `resolveEntity`), so a bump costs a second keyed lookup on the
42
+ * miss path rather than a migration.
43
+ *
44
+ * Version 1 was the name-only scheme (`n:<normalized-name>`, truncated to 200
45
+ * characters), under which `Person:Alex` and `Service:Alex` were one entity and
46
+ * two names first differing at character 250 were one entity.
47
+ */
48
+ export declare const KG_ID_VERSION = 2;
49
+ /** Identity-grade name normalization: the same folding as `normalizeName` but
50
+ * WITHOUT its 200-character truncation, which silently merged long names that
51
+ * differ only past the cut. `normalizeName` keeps truncating because it feeds
52
+ * tags and display, where length matters and collisions do not. */
53
+ export declare function canonicalName(name: string): string;
54
+ /** The identity-bearing part of a type: '' when the caller told us nothing. */
55
+ export declare function typeBucket(type: string | undefined): string;
56
+ /** Hash a tuple injectively: every component is length-prefixed, so no
57
+ * component's content can masquerade as a delimiter or bleed into its
58
+ * neighbour, and no two distinct tuples share an input string. Same discipline
59
+ * as monograph's `symbolId`/`fileId` (packages/@monomind/monograph/src/types.ts),
60
+ * and adopted here for the same reason — the previous scheme lost distinctions
61
+ * to truncation and to an unescaped separator. */
62
+ export declare function hashTuple(components: string[]): string;
63
+ /** Mint an entity id from the full identity tuple.
64
+ *
65
+ * This MINTS; it does not RESOLVE. A caller that computes an id and writes to
66
+ * it bypasses the name index and re-forks the entities the index exists to
67
+ * keep together — every ingest path goes through `resolveEntity` instead. */
68
+ export declare function nodeKey(type: string, name: string): string;
69
+ /** The pre-`KG_ID_VERSION` key for a name: name-only, truncated at 200. Probed
70
+ * on a miss so existing graphs keep working without being re-keyed. */
71
+ export declare function legacyNodeKey(name: string): string;
72
+ export interface KgNodeInput {
73
+ name: string;
74
+ /** Basic type, cognee-style ("Person", "Tool", "Service") — not over-specific. */
75
+ type?: string;
76
+ description?: string;
77
+ nodeSet?: string;
78
+ }
79
+ export interface KgEdgeInput {
80
+ source: string;
81
+ target: string;
82
+ /** snake_case relation name. */
83
+ relation: string;
84
+ /** One-sentence concrete fact using the endpoint names. */
85
+ description?: string;
86
+ sourceType?: string;
87
+ targetType?: string;
88
+ }
89
+ export interface KgIngestResult {
90
+ success: boolean;
91
+ nodesAdded: number;
92
+ nodesMerged: number;
93
+ edgesAdded: number;
94
+ edgesMerged: number;
95
+ /** Writes the bridge refused, one message each (capped at MAX_FAILURES).
96
+ * Non-empty ⇒ `success` is false and the counters describe only what
97
+ * actually persisted. */
98
+ failures?: string[];
99
+ error?: string;
100
+ /** Items the payload asked for that this call refused. Present only when
101
+ * non-zero, so a caller who sent a clean payload sees a clean result. */
102
+ nodesRejected?: number;
103
+ edgesRejected?: number;
104
+ /** Items dropped because the payload exceeded the per-call cap. The cap has
105
+ * not changed; what has changed is that it is now REPORTED instead of being
106
+ * a silent `.slice()`. */
107
+ nodesTruncated?: number;
108
+ edgesTruncated?: number;
109
+ /** Why items were rejected, one message each (capped at MAX_FAILURES). */
110
+ rejections?: string[];
111
+ /** Endpoint entities created because an edge named them and they did not
112
+ * exist. Edge-only ingestion used to succeed with zero nodes and one edge,
113
+ * leaving a fact unreachable through both of its own endpoints. */
114
+ placeholders?: number;
115
+ /** Same-name entities this call did NOT merge with, one message each. A
116
+ * same-name match is a CANDIDATE, not a merge. */
117
+ ambiguities?: string[];
118
+ /** Elements whose support ledger hit `MAX_CLAIMS` on this call, so their
119
+ * oldest provenance was dropped. Never silent. */
120
+ provenanceTruncated?: number;
121
+ }
122
+ /** cognee DataPoint normalization: lowercase, spaces→_, strip apostrophes. */
123
+ export declare function normalizeName(name: string): string;
124
+ /** Edge identity: the endpoint IDs (already collision-free) plus the relation,
125
+ * hashed injectively so a relation containing the old `|` separator can no
126
+ * longer forge a different edge's key. */
127
+ export declare function edgeKey(srcKey: string, relation: string, dstKey: string): string;
128
+ /** The pre-`KG_ID_VERSION` edge key, for the same in-place adoption as
129
+ * `legacyNodeKey`. Composed from the RESOLVED endpoint keys, so it names the
130
+ * legacy edge exactly when both endpoints are themselves legacy rows. */
131
+ export declare function legacyEdgeKey(srcKey: string, relation: string, dstKey: string): string;
132
+ /** Rule identity: the full rule text. The old key truncated the normalized rule
133
+ * at 120 characters, so two rules sharing a long preamble were one rule. */
134
+ export declare function ruleKey(rule: string): string;
135
+ export declare function legacyRuleKey(rule: string): string;
136
+ /** Who owns a set of graph facts. `org` absent = project-shared knowledge. */
137
+ export interface KgScope {
138
+ org?: string;
139
+ }
140
+ export interface KgNamespaces {
141
+ nodes: string;
142
+ edges: string;
143
+ rules: string;
144
+ /** Name → entity index backing `resolveEntity`. Holds no claims. */
145
+ names: string;
146
+ /** Derived adjacency index: entity id -> edge keys touching it (K7). Holds
147
+ * no claims either — every entry is rebuildable from `edges`. */
148
+ adj: string;
149
+ /** Derived origin-support index: origin ref -> {ns,key} refs it supports,
150
+ * across nodes/edges/rules (K7). Rebuildable from all three. */
151
+ originIdx: string;
152
+ /** This scope's derived-index build/readiness state (K7). One row. */
153
+ indexStatus: string;
154
+ }
155
+ /** The namespaces a scope owns. Every read and write in this module resolves
156
+ * through here, which is what makes ownership enforced rather than advisory:
157
+ * there is no code path that reaches an org's facts without naming that org,
158
+ * and none that reaches every org at once. */
159
+ export declare function kgNamespaces(scope?: KgScope): KgNamespaces;
160
+ /** Stamp the asserting org onto a provenance ref, so a claim's origin says WHO
161
+ * asserted it and not merely which run id — `run:m4x2` alone is ambiguous
162
+ * across orgs, and a promoted claim in the shared graph would otherwise carry
163
+ * an origin no one owns.
164
+ *
165
+ * Applied by the ingest/rollback entry points rather than by callers: a
166
+ * caller that forgets is exactly how ownership stopped being enforced. */
167
+ export declare function kgQualifyOrigin(originRef: string, scope?: KgScope): string;
168
+ //# sourceMappingURL=memory-kg-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-kg-model.d.ts","sourceRoot":"","sources":["../../../src/memory/memory-kg-model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,QAAQ,UAAU,CAAC;AAChC;;uDAEuD;AACvD,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,sEAAsE;AACtE,eAAO,MA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