@gamaze/hicortex 0.14.3 → 0.15.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/dist/storage.js CHANGED
@@ -15,6 +15,7 @@ exports.deleteMemory = deleteMemory;
15
15
  exports.setMemoryTags = setMemoryTags;
16
16
  exports.getMemoryTags = getMemoryTags;
17
17
  exports.getMemoryTagsWeighted = getMemoryTagsWeighted;
18
+ exports.getStoredEmbedding = getStoredEmbedding;
18
19
  exports.vectorSearch = vectorSearch;
19
20
  exports.searchFts = searchFts;
20
21
  exports.addLink = addLink;
@@ -115,6 +116,10 @@ const ALLOWED_UPDATE_FIELDS = new Set([
115
116
  "base_strength",
116
117
  "last_accessed",
117
118
  "access_count",
119
+ // shown_count is normally maintained by touchMemoriesShown (bulk +1 per
120
+ // recall-index appearance); it's also allowed here so `hicortex dedup`
121
+ // (#100) can sum a merged cluster's counters onto the canonical row.
122
+ "shown_count",
118
123
  "source_agent",
119
124
  "source_session",
120
125
  "project",
@@ -239,6 +244,24 @@ function getMemoryTagsWeighted(db, memoryId) {
239
244
  .all(memoryId);
240
245
  return rows;
241
246
  }
247
+ /**
248
+ * Read the stored embedding for a memory from memory_vectors.
249
+ * Returns null when the row is missing (caller falls back to re-embedding).
250
+ *
251
+ * Shared by `hicortex relink` and the nightly's supersession stage
252
+ * (consolidate.ts) — lives here (not in relink.ts) so consolidate.ts can use
253
+ * it without importing from relink.ts, which itself imports from
254
+ * consolidate.ts (BudgetTracker, discoverLinkCandidates).
255
+ */
256
+ function getStoredEmbedding(db, memoryId) {
257
+ const row = db
258
+ .prepare("SELECT embedding FROM memory_vectors WHERE id = ?")
259
+ .get(memoryId);
260
+ if (!row?.embedding)
261
+ return null;
262
+ const buf = row.embedding;
263
+ return new Float32Array(buf.buffer, buf.byteOffset, buf.byteLength / 4);
264
+ }
242
265
  // ---------------------------------------------------------------------------
243
266
  // Vector search
244
267
  // ---------------------------------------------------------------------------
package/dist/types.d.ts CHANGED
@@ -108,6 +108,21 @@ export interface ConsolidationReport {
108
108
  heuristic_fallback?: number;
109
109
  failed: number;
110
110
  };
111
+ /** Supersession detection (#191 Phase B) — runs after linking, before decay/prune. */
112
+ supersession?: {
113
+ /** Decision/correction-shaped candidates examined this run. */
114
+ scanned: number;
115
+ /** Older-neighbor pairs actually sent to the classify-tier LLM. */
116
+ evaluated: number;
117
+ /** Pairs the LLM judged superseded — a `superseded_by` link was created. */
118
+ superseded: number;
119
+ /** Pairs skipped on a parse/infra error (retried naturally next night). */
120
+ skipped_infra: number;
121
+ /** Pairs skipped because a superseded_by link already existed (either direction). */
122
+ skipped_idempotent: number;
123
+ /** supersessionCursor after this run (unchanged in dry-run). */
124
+ cursor: number;
125
+ };
111
126
  decay_prune?: {
112
127
  candidates: number;
113
128
  pruned: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamaze/hicortex",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "description": "Self-learning memory for AI agents — experience captured automatically, distilled into lessons overnight, shared across your whole fleet. Works with Hermes, OpenClaw, Claude Code, and Pi.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -37,6 +37,7 @@
37
37
  "build": "rm -rf dist && tsc",
38
38
  "test": "vitest run",
39
39
  "test:watch": "vitest",
40
+ "eval": "node dist/eval/run-eval.js",
40
41
  "prepack": "npm run build && rm -rf ./hermes-plugin && mkdir -p ./hermes-plugin && cp -r ../../hermes-plugin/hicortex ./hermes-plugin/ && find ./hermes-plugin -name __pycache__ -type d -exec rm -rf {} + 2>/dev/null || true",
41
42
  "prepublishOnly": "npm run build && rm -rf ./hermes-plugin && mkdir -p ./hermes-plugin && cp -r ../../hermes-plugin/hicortex ./hermes-plugin/ && find ./hermes-plugin -name __pycache__ -type d -exec rm -rf {} + 2>/dev/null || true"
42
43
  },