@nxuss/lemma 1.19.0 → 1.21.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/skills/lemma/SKILL.md +124 -0
- package/README.md +5 -1
- package/bin/init.js +109 -29
- package/bin/lemma-call.js +269 -0
- package/dist/cjs/mcp/index.js +4 -2
- package/dist/cjs/mcp/index.js.map +1 -1
- package/dist/cjs/mcp/prompts.d.ts +1 -1
- package/dist/cjs/mcp/prompts.d.ts.map +1 -1
- package/dist/cjs/mcp/prompts.js +1 -1
- package/dist/cjs/mcp/tool-profiles.d.ts.map +1 -1
- package/dist/cjs/mcp/tool-profiles.js +9 -0
- package/dist/cjs/mcp/tool-profiles.js.map +1 -1
- package/dist/cjs/mcp/tools/analysis.d.ts.map +1 -1
- package/dist/cjs/mcp/tools/analysis.js +51 -20
- package/dist/cjs/mcp/tools/analysis.js.map +1 -1
- package/dist/cjs/mcp/tools/memory.d.ts +4 -4
- package/dist/cjs/mcp/tools/memory.d.ts.map +1 -1
- package/dist/cjs/mcp/tools/memory.js +217 -11
- package/dist/cjs/mcp/tools/memory.js.map +1 -1
- package/dist/cjs/mcp/tools.d.ts.map +1 -1
- package/dist/cjs/mcp/tools.js +4 -1
- package/dist/cjs/mcp/tools.js.map +1 -1
- package/dist/cjs/subconscious/TheBrainV2.d.ts +102 -1
- package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/cjs/subconscious/TheBrainV2.js +255 -10
- package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
- package/dist/esm/mcp/index.js +4 -2
- package/dist/esm/mcp/index.js.map +1 -1
- package/dist/esm/mcp/prompts.d.ts +1 -1
- package/dist/esm/mcp/prompts.d.ts.map +1 -1
- package/dist/esm/mcp/prompts.js +1 -1
- package/dist/esm/mcp/tool-profiles.d.ts.map +1 -1
- package/dist/esm/mcp/tool-profiles.js +9 -0
- package/dist/esm/mcp/tool-profiles.js.map +1 -1
- package/dist/esm/mcp/tools/analysis.d.ts.map +1 -1
- package/dist/esm/mcp/tools/analysis.js +52 -21
- package/dist/esm/mcp/tools/analysis.js.map +1 -1
- package/dist/esm/mcp/tools/memory.d.ts +4 -4
- package/dist/esm/mcp/tools/memory.d.ts.map +1 -1
- package/dist/esm/mcp/tools/memory.js +217 -11
- package/dist/esm/mcp/tools/memory.js.map +1 -1
- package/dist/esm/mcp/tools.d.ts.map +1 -1
- package/dist/esm/mcp/tools.js +4 -1
- package/dist/esm/mcp/tools.js.map +1 -1
- package/dist/esm/subconscious/TheBrainV2.d.ts +102 -1
- package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/esm/subconscious/TheBrainV2.js +253 -10
- package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
- package/lemma-proxy.cjs +12 -0
- package/package.json +11 -2
|
@@ -176,8 +176,15 @@ export interface ClaimFreshness {
|
|
|
176
176
|
* gets for a purged entry, a renamed symbol's old claim, or an id from another project.
|
|
177
177
|
*/
|
|
178
178
|
export interface VerifyMemoryResult {
|
|
179
|
+
/**
|
|
180
|
+
* 'fresh' means every tracked artifact still hashes the same. 'untracked' means the memory
|
|
181
|
+
* tracks nothing at all, so there was nothing to check — never folded into 'fresh', because
|
|
182
|
+
* a caller reading 'fresh' is being told the memory was validated against current code.
|
|
183
|
+
*/
|
|
184
|
+
status: 'fresh' | 'stale' | 'unverified' | 'unknown' | 'untracked';
|
|
179
185
|
id: string;
|
|
180
|
-
|
|
186
|
+
/** Files/symbols/upstream memories this id is judged against. 0 on 'untracked'. */
|
|
187
|
+
trackedArtifacts?: number;
|
|
181
188
|
staleFiles?: string[];
|
|
182
189
|
/** Only set when `id` resolved to an entry that itself has per-claim tracking. */
|
|
183
190
|
claimBreakdown?: ClaimFreshness[];
|
|
@@ -287,6 +294,12 @@ export interface BrainStats {
|
|
|
287
294
|
staleEntries?: number;
|
|
288
295
|
/** Only under { deep: true }: staleEntries as a fraction of entries that track anything. */
|
|
289
296
|
staleRatio?: number;
|
|
297
|
+
/**
|
|
298
|
+
* Entries tracking no file, symbol, claim evidence or upstream memory at all — the ones
|
|
299
|
+
* `verify_memory` reports as `untracked` because there is nothing there to check. Cheap
|
|
300
|
+
* (no hashing), so it is always computed, unlike staleEntries.
|
|
301
|
+
*/
|
|
302
|
+
untrackedEntries?: number;
|
|
290
303
|
}
|
|
291
304
|
/**
|
|
292
305
|
* Union two views of the corpus. Never subtracts: an id present in either side survives
|
|
@@ -419,6 +432,18 @@ export interface FreshnessOutcome {
|
|
|
419
432
|
* `fresh`.
|
|
420
433
|
*/
|
|
421
434
|
export declare function checkEntryFreshness(entry: BrainEntry, resolver: EvidenceResolver, resolveNode?: (id: string) => FreshnessNode | undefined, depth?: number, visited?: Set<string>, semanticDiff?: boolean): FreshnessOutcome;
|
|
435
|
+
/**
|
|
436
|
+
* How many artifacts an entry's freshness is actually judged against: tracked files, tracked
|
|
437
|
+
* symbols, upstream memories, and each claim's own evidence.
|
|
438
|
+
*
|
|
439
|
+
* Zero means a freshness check has nothing to compare — and reporting that as `fresh` conflates
|
|
440
|
+
* "validated against the code" with "there was nothing to validate", which are opposite
|
|
441
|
+
* guarantees for a caller about to act on the memory. `verify_memory` reports those as
|
|
442
|
+
* `untracked` instead; see VerifyMemoryResult.
|
|
443
|
+
*/
|
|
444
|
+
export declare function trackedArtifactCount(entry: BrainEntry): number;
|
|
445
|
+
/** Claim-level counterpart to trackedArtifactCount. */
|
|
446
|
+
export declare function trackedClaimArtifactCount(claim: Claim): number;
|
|
422
447
|
/**
|
|
423
448
|
* Same hash-compare as checkEntryFreshness, scoped to one claim's own evidence — a claim
|
|
424
449
|
* with no fileHashes/symbolHashes at all is always fresh (nothing tracked to go stale).
|
|
@@ -439,9 +464,20 @@ export declare class TheBrainV2 {
|
|
|
439
464
|
private diskStamp;
|
|
440
465
|
/** id -> ISO deletion time, for ids that must not come back through a merge. */
|
|
441
466
|
private tombstones;
|
|
467
|
+
/**
|
|
468
|
+
* id -> terms of that entry's own `query` field. Derived state, never persisted: `terms`
|
|
469
|
+
* covers query+response together, so scoring the query field on its own (see the
|
|
470
|
+
* QUERY_FIELD_BOOST block in search()) needs it split back out. Memoized because a search
|
|
471
|
+
* touches every candidate and re-tokenizing a prompt per candidate per search is pure waste.
|
|
472
|
+
* Dropped whenever the entry changes or leaves the corpus — a stale entry here would boost
|
|
473
|
+
* a memory for words its prompt no longer contains.
|
|
474
|
+
*/
|
|
475
|
+
private queryTermCache;
|
|
442
476
|
constructor();
|
|
443
477
|
private ensureDir;
|
|
444
478
|
private load;
|
|
479
|
+
/** Terms of an entry's own `query`, memoized. See queryTermCache. */
|
|
480
|
+
private queryTermsOf;
|
|
445
481
|
/** Recomputes the inverted index from scratch over the current entries. */
|
|
446
482
|
private rebuildIndex;
|
|
447
483
|
/**
|
|
@@ -551,6 +587,28 @@ export declare class TheBrainV2 {
|
|
|
551
587
|
* without deleting the entry — a bad-fit-today memory may still be exactly right for a
|
|
552
588
|
* differently-phrased query tomorrow.
|
|
553
589
|
*/
|
|
590
|
+
/**
|
|
591
|
+
* One memory, by id, body included.
|
|
592
|
+
*
|
|
593
|
+
* The Brain had no deterministic read: `verifyByIds` answers "is it still true" without
|
|
594
|
+
* returning the text, and `search()` — the only path to the body — is a ranking, so an agent
|
|
595
|
+
* holding an id could still fail to retrieve the memory it had just written. Editing a
|
|
596
|
+
* long-lived entry under those conditions means reconstructing its text from whatever a
|
|
597
|
+
* search happened to surface, which is how the accumulated content in it gets lost.
|
|
598
|
+
*
|
|
599
|
+
* Returns a copy: callers must not mutate the corpus by holding a reference. Use update()
|
|
600
|
+
* to change a memory.
|
|
601
|
+
*/
|
|
602
|
+
getEntry(id: string): BrainEntry | undefined;
|
|
603
|
+
/**
|
|
604
|
+
* The entry a claim id belongs to, plus the claim itself. Claim ids and entry ids are handed
|
|
605
|
+
* back side by side by search_memory and verify_memory, so an id pasted into a read is as
|
|
606
|
+
* likely to be one as the other — resolving only entries would report a live claim as missing.
|
|
607
|
+
*/
|
|
608
|
+
getClaim(id: string): {
|
|
609
|
+
entry: BrainEntry;
|
|
610
|
+
claim: Claim;
|
|
611
|
+
} | undefined;
|
|
554
612
|
downvote(id: string): {
|
|
555
613
|
ok: boolean;
|
|
556
614
|
message: string;
|
|
@@ -575,9 +633,11 @@ export declare class TheBrainV2 {
|
|
|
575
633
|
forgotten?: {
|
|
576
634
|
id: string;
|
|
577
635
|
query: string;
|
|
636
|
+
response: string;
|
|
578
637
|
timestamp: string;
|
|
579
638
|
hits: number;
|
|
580
639
|
};
|
|
640
|
+
archivePath?: string;
|
|
581
641
|
};
|
|
582
642
|
/**
|
|
583
643
|
* Re-verify a memory against the code as it stands now, keeping its identity.
|
|
@@ -598,6 +658,13 @@ export declare class TheBrainV2 {
|
|
|
598
658
|
* a memory that is itself stale is exactly what Fase B exists to catch, and silently
|
|
599
659
|
* clearing that would defeat it. Those come back in `stillStale` instead.
|
|
600
660
|
*/
|
|
661
|
+
/**
|
|
662
|
+
* Re-hash an entry's evidence, either in place or against newly named files/symbols.
|
|
663
|
+
* Shared by refresh() ("I checked, this is still true") and update() ("here is the corrected
|
|
664
|
+
* text"), which make the same assertion about the same code and so must anchor identically.
|
|
665
|
+
* Mutates `entry`; returns the labels of what it now tracks.
|
|
666
|
+
*/
|
|
667
|
+
private reanchorEvidence;
|
|
601
668
|
refresh(id: string, opts?: {
|
|
602
669
|
filePaths?: string[];
|
|
603
670
|
symbols?: SymbolRef[];
|
|
@@ -608,6 +675,40 @@ export declare class TheBrainV2 {
|
|
|
608
675
|
retracked?: string[];
|
|
609
676
|
stillStale?: string[];
|
|
610
677
|
};
|
|
678
|
+
/**
|
|
679
|
+
* Replace an existing memory's content, keeping its identity.
|
|
680
|
+
*
|
|
681
|
+
* The Brain could add and it could delete, but it could not correct: store() mints a new id
|
|
682
|
+
* per call, so re-storing a corrected version under the same query left the outdated one in
|
|
683
|
+
* place, and a later search returned an arbitrary slice of every historical version —
|
|
684
|
+
* including the ones that contradict each other. That is the mechanism behind an
|
|
685
|
+
* append-only pile of near-duplicate "canonical index" entries: not a convention nobody
|
|
686
|
+
* followed, a convention the API could not express. refresh() keeps identity but only
|
|
687
|
+
* re-hashes evidence, and has no way to accept new text. This is that missing operation.
|
|
688
|
+
*
|
|
689
|
+
* Kept: id, hits, demerits, creation timestamp, projectId, source, and every `derivedFrom`
|
|
690
|
+
* edge elsewhere in the corpus that points at this id. Replaced: whatever the patch names.
|
|
691
|
+
* Evidence is re-anchored exactly as refresh() does — rewriting a memory's content asserts
|
|
692
|
+
* the same thing refresh() records, that the caller checked it against the code as it is now.
|
|
693
|
+
*/
|
|
694
|
+
update(id: string, patch?: {
|
|
695
|
+
query?: string;
|
|
696
|
+
response?: string;
|
|
697
|
+
filePaths?: string[];
|
|
698
|
+
symbols?: SymbolRef[];
|
|
699
|
+
claims?: ClaimInput[];
|
|
700
|
+
outcome?: 'confirmed' | 'failed';
|
|
701
|
+
domain?: string;
|
|
702
|
+
derivedFrom?: string[];
|
|
703
|
+
}): {
|
|
704
|
+
ok: boolean;
|
|
705
|
+
message: string;
|
|
706
|
+
id?: string;
|
|
707
|
+
fresh?: boolean;
|
|
708
|
+
retracked?: string[];
|
|
709
|
+
stillStale?: string[];
|
|
710
|
+
charDelta?: number;
|
|
711
|
+
};
|
|
611
712
|
/**
|
|
612
713
|
* Revalidate ids from a prior search_memory/store_memory result via hash-compare only —
|
|
613
714
|
* no BM25, no `search()`. `ids` may mix entry ids and claim ids freely; each resolves
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TheBrainV2.d.ts","sourceRoot":"","sources":["../../../src/subconscious/TheBrainV2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAcxE,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM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GAAG,kBAAkB,EAAE;IAsDvH;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,iBAAiB;IAOzE;;;;;;;OAOG;IACH,YAAY,CAAC,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG;QACxF,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;KACtB;IA+BD;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG;QAC/D,EAAE,EAAE,OAAO,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB;IA6FD;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,UAAU;IA2DtD,KAAK,IAAI,IAAI;CAkBd;AAMD,wBAAgB,QAAQ,IAAI,UAAU,CAGrC"}
|
|
@@ -29,6 +29,8 @@ exports.resolveFreshnessNode = resolveFreshnessNode;
|
|
|
29
29
|
exports.buildClaimIndex = buildClaimIndex;
|
|
30
30
|
exports.findBlastRadius = findBlastRadius;
|
|
31
31
|
exports.checkEntryFreshness = checkEntryFreshness;
|
|
32
|
+
exports.trackedArtifactCount = trackedArtifactCount;
|
|
33
|
+
exports.trackedClaimArtifactCount = trackedClaimArtifactCount;
|
|
32
34
|
exports.checkClaimFreshness = checkClaimFreshness;
|
|
33
35
|
exports.getBrain = getBrain;
|
|
34
36
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -48,6 +50,15 @@ const defaultLocalResolver = new LocalFsResolver_1.LocalFsResolver();
|
|
|
48
50
|
// ─── BM25 Constants ───────────────────────────────────────────────────────────
|
|
49
51
|
const BM25_K1 = 1.5; // Term saturation (1.2-2.0)
|
|
50
52
|
const BM25_B = 0.75; // Length normalization (0-1)
|
|
53
|
+
/**
|
|
54
|
+
* Ceiling on the document-length term in BM25's normalization, in multiples of the average
|
|
55
|
+
* document. Uncapped, the divisor grows with the document forever, so a memory is buried for
|
|
56
|
+
* being long rather than for being a worse match — which is precisely what happened to the
|
|
57
|
+
* one entry a "living document" convention keeps rewriting and growing: it ranked below the
|
|
58
|
+
* 2 KB fragments it was written to supersede, under its own query. Past 3x average, extra
|
|
59
|
+
* length says nothing more about relevance, so the penalty stops there.
|
|
60
|
+
*/
|
|
61
|
+
const MAX_LENGTH_NORM_RATIO = 3;
|
|
51
62
|
// ─── Recency decay ────────────────────────────────────────────────────────────
|
|
52
63
|
//
|
|
53
64
|
// Deliberately gentle and grace-periodded. Age is a weak proxy for "no longer true" —
|
|
@@ -61,6 +72,18 @@ const RECENCY_GRACE_DAYS = 30;
|
|
|
61
72
|
const RECENCY_FULL_DECAY_DAYS = 365;
|
|
62
73
|
/** Cap, in the same 0-1 similarity space as the popularity/outcome/demerit adjustments. */
|
|
63
74
|
const MAX_RECENCY_PENALTY = 0.10;
|
|
75
|
+
// ─── Retrieval blend ──────────────────────────────────────────────────────────
|
|
76
|
+
//
|
|
77
|
+
// Three signals, weights summing to 1 so the blend stays a 0-1 similarity the caller can hold
|
|
78
|
+
// against a floor. The third is new: an entry's `terms` cover query and response together, so
|
|
79
|
+
// "these words are the memory's own prompt" scored exactly like "these words appear somewhere
|
|
80
|
+
// in a long body", and a document that keeps growing dilutes its own prompt out of contention.
|
|
81
|
+
// That is a retrieval signal, not a tie-break like the small additive adjustments in search(),
|
|
82
|
+
// so it takes its share of the blend rather than being added on top of it.
|
|
83
|
+
const BM25_WEIGHT = 0.55;
|
|
84
|
+
const JACCARD_WEIGHT = 0.20;
|
|
85
|
+
/** Share of the blend decided by how much of the search query the entry's own query covers. */
|
|
86
|
+
const QUERY_FIELD_WEIGHT = 0.25;
|
|
64
87
|
// ─── Storage Paths ────────────────────────────────────────────────────────────
|
|
65
88
|
/**
|
|
66
89
|
* LEMMA_BRAIN_DIR redirects storage — required so tests never write into the user's real
|
|
@@ -75,6 +98,14 @@ const META_FILE = path_1.default.join(BRAIN_DIR, 'meta.json');
|
|
|
75
98
|
const LOCK_FILE = path_1.default.join(BRAIN_DIR, '.write.lock');
|
|
76
99
|
/** Sidecar vector cache for the optional semantic re-rank. See BrainEmbeddings.ts. */
|
|
77
100
|
const EMBEDDINGS_FILE = path_1.default.join(BRAIN_DIR, 'embeddings.ndjson');
|
|
101
|
+
/**
|
|
102
|
+
* Append-only archive of everything forget() destroyed. Deletion is the one Brain operation
|
|
103
|
+
* with no undo, and the deleted body is by definition the only copy of that text — telling the
|
|
104
|
+
* caller "nothing else can recover it" and then handing back metadata only is the worst of both
|
|
105
|
+
* worlds. The id stays tombstoned (a deliberate deletion must not come back through a merge),
|
|
106
|
+
* so this file is an archive to read, not a bundle to re-import.
|
|
107
|
+
*/
|
|
108
|
+
const FORGOTTEN_FILE = path_1.default.join(BRAIN_DIR, 'forgotten.ndjson');
|
|
78
109
|
// ─── Cross-process durability ─────────────────────────────────────────────────
|
|
79
110
|
//
|
|
80
111
|
// Every MCP client session starts its own server process, and each one holds the whole
|
|
@@ -549,13 +580,16 @@ exports.BloomFilter = BloomFilter;
|
|
|
549
580
|
// ─── BM25 Scorer ─────────────────────────────────────────────────────────────
|
|
550
581
|
function bm25Score(queryTerms, docTermFreq, docLength, avgDocLength, idf) {
|
|
551
582
|
let score = 0;
|
|
583
|
+
// Bounded: see MAX_LENGTH_NORM_RATIO. A document 20x the average was effectively
|
|
584
|
+
// unretrievable next to a short one sharing the same rare term.
|
|
585
|
+
const lengthRatio = Math.min(docLength / avgDocLength, MAX_LENGTH_NORM_RATIO);
|
|
552
586
|
for (const term of queryTerms) {
|
|
553
587
|
if (!(term in docTermFreq))
|
|
554
588
|
continue;
|
|
555
589
|
const tf = docTermFreq[term];
|
|
556
590
|
const termIdf = idf[term] || 0;
|
|
557
591
|
const numerator = tf * (BM25_K1 + 1);
|
|
558
|
-
const denominator = tf + BM25_K1 * (1 - BM25_B + BM25_B *
|
|
592
|
+
const denominator = tf + BM25_K1 * (1 - BM25_B + BM25_B * lengthRatio);
|
|
559
593
|
score += termIdf * (numerator / denominator);
|
|
560
594
|
}
|
|
561
595
|
return score;
|
|
@@ -856,6 +890,28 @@ function checkEntryFreshness(entry, resolver, resolveNode, depth = 0, visited =
|
|
|
856
890
|
...(cosmeticChanges.length > 0 ? { cosmeticChanges } : {}),
|
|
857
891
|
};
|
|
858
892
|
}
|
|
893
|
+
/**
|
|
894
|
+
* How many artifacts an entry's freshness is actually judged against: tracked files, tracked
|
|
895
|
+
* symbols, upstream memories, and each claim's own evidence.
|
|
896
|
+
*
|
|
897
|
+
* Zero means a freshness check has nothing to compare — and reporting that as `fresh` conflates
|
|
898
|
+
* "validated against the code" with "there was nothing to validate", which are opposite
|
|
899
|
+
* guarantees for a caller about to act on the memory. `verify_memory` reports those as
|
|
900
|
+
* `untracked` instead; see VerifyMemoryResult.
|
|
901
|
+
*/
|
|
902
|
+
function trackedArtifactCount(entry) {
|
|
903
|
+
let n = Object.keys(entry.fileHashes || {}).length;
|
|
904
|
+
n += Object.keys(entry.symbolHashes || {}).length;
|
|
905
|
+
n += (entry.derivedFrom || []).length;
|
|
906
|
+
for (const claim of entry.claims || []) {
|
|
907
|
+
n += Object.keys(claim.fileHashes || {}).length + Object.keys(claim.symbolHashes || {}).length;
|
|
908
|
+
}
|
|
909
|
+
return n;
|
|
910
|
+
}
|
|
911
|
+
/** Claim-level counterpart to trackedArtifactCount. */
|
|
912
|
+
function trackedClaimArtifactCount(claim) {
|
|
913
|
+
return Object.keys(claim.fileHashes || {}).length + Object.keys(claim.symbolHashes || {}).length;
|
|
914
|
+
}
|
|
859
915
|
/** Builds the persisted `Claim[]` for an entry from the caller-supplied claim inputs. */
|
|
860
916
|
function buildClaims(inputs) {
|
|
861
917
|
return inputs
|
|
@@ -944,6 +1000,15 @@ class TheBrainV2 {
|
|
|
944
1000
|
this.diskStamp = null;
|
|
945
1001
|
/** id -> ISO deletion time, for ids that must not come back through a merge. */
|
|
946
1002
|
this.tombstones = new Map();
|
|
1003
|
+
/**
|
|
1004
|
+
* id -> terms of that entry's own `query` field. Derived state, never persisted: `terms`
|
|
1005
|
+
* covers query+response together, so scoring the query field on its own (see the
|
|
1006
|
+
* QUERY_FIELD_BOOST block in search()) needs it split back out. Memoized because a search
|
|
1007
|
+
* touches every candidate and re-tokenizing a prompt per candidate per search is pure waste.
|
|
1008
|
+
* Dropped whenever the entry changes or leaves the corpus — a stale entry here would boost
|
|
1009
|
+
* a memory for words its prompt no longer contains.
|
|
1010
|
+
*/
|
|
1011
|
+
this.queryTermCache = new Map();
|
|
947
1012
|
this.sidecar = null;
|
|
948
1013
|
this.ensureDir();
|
|
949
1014
|
this.load();
|
|
@@ -982,9 +1047,21 @@ class TheBrainV2 {
|
|
|
982
1047
|
this.tombstones = new Map();
|
|
983
1048
|
}
|
|
984
1049
|
}
|
|
1050
|
+
/** Terms of an entry's own `query`, memoized. See queryTermCache. */
|
|
1051
|
+
queryTermsOf(entry) {
|
|
1052
|
+
let set = this.queryTermCache.get(entry.id);
|
|
1053
|
+
if (!set) {
|
|
1054
|
+
set = new Set(tokenize(entry.query));
|
|
1055
|
+
this.queryTermCache.set(entry.id, set);
|
|
1056
|
+
}
|
|
1057
|
+
return set;
|
|
1058
|
+
}
|
|
985
1059
|
/** Recomputes the inverted index from scratch over the current entries. */
|
|
986
1060
|
rebuildIndex() {
|
|
987
1061
|
this.invertedIndex = new Map();
|
|
1062
|
+
// A merge can replace an id's entry with a peer's newer version whose query differs, so
|
|
1063
|
+
// the memo is rebuilt alongside the index rather than trusted across one.
|
|
1064
|
+
this.queryTermCache.clear();
|
|
988
1065
|
for (const entry of this.entries.values()) {
|
|
989
1066
|
for (const term of entry.terms) {
|
|
990
1067
|
let ids = this.invertedIndex.get(term);
|
|
@@ -1133,6 +1210,7 @@ class TheBrainV2 {
|
|
|
1133
1210
|
/** Removes an entry from the in-memory corpus and the inverted index. No persistence. */
|
|
1134
1211
|
dropEntry(entry) {
|
|
1135
1212
|
this.entries.delete(entry.id);
|
|
1213
|
+
this.queryTermCache.delete(entry.id);
|
|
1136
1214
|
for (const term of entry.terms) {
|
|
1137
1215
|
const ids = this.invertedIndex.get(term);
|
|
1138
1216
|
if (!ids)
|
|
@@ -1354,8 +1432,24 @@ class TheBrainV2 {
|
|
|
1354
1432
|
// see on their own: a memory's own track record. Small and additive by design — none of
|
|
1355
1433
|
// these can turn an unrelated result into a top hit, they only reorder among already-
|
|
1356
1434
|
// relevant candidates.
|
|
1435
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
1357
1436
|
const combined = scored.map(s => {
|
|
1358
|
-
|
|
1437
|
+
// How much of the search query appears in the entry's own prompt — see the weights above.
|
|
1438
|
+
const entryQueryTerms = this.queryTermsOf(s.entry);
|
|
1439
|
+
let covered = 0;
|
|
1440
|
+
for (const term of queryTermSet)
|
|
1441
|
+
if (entryQueryTerms.has(term))
|
|
1442
|
+
covered++;
|
|
1443
|
+
const queryFieldMatch = covered / queryTermSet.size;
|
|
1444
|
+
// A prompt that matches character for character is not one signal among three — it is
|
|
1445
|
+
// the entry filed under exactly this question. Blended, it could still lose to a short
|
|
1446
|
+
// fragment that repeated one rare term, which is how a memory became unfindable under
|
|
1447
|
+
// its own query. The adjustments below still apply on top: a downvoted or dead-end
|
|
1448
|
+
// exact match must not outrank a clean one.
|
|
1449
|
+
const exactPrompt = s.entry.query.trim().toLowerCase() === normalizedQuery;
|
|
1450
|
+
let similarity = exactPrompt
|
|
1451
|
+
? 1
|
|
1452
|
+
: (s.bm25 / maxBm25) * BM25_WEIGHT + s.jaccard * JACCARD_WEIGHT + queryFieldMatch * QUERY_FIELD_WEIGHT;
|
|
1359
1453
|
// Popularity prior: entries other searches actually reused are more likely to be
|
|
1360
1454
|
// reused again. Log-scaled and capped at +0.08 so a handful of hits can't outrank a
|
|
1361
1455
|
// much better textual match.
|
|
@@ -1542,6 +1636,38 @@ class TheBrainV2 {
|
|
|
1542
1636
|
* without deleting the entry — a bad-fit-today memory may still be exactly right for a
|
|
1543
1637
|
* differently-phrased query tomorrow.
|
|
1544
1638
|
*/
|
|
1639
|
+
// ─── Read by id ─────────────────────────────────────────────────────────────
|
|
1640
|
+
/**
|
|
1641
|
+
* One memory, by id, body included.
|
|
1642
|
+
*
|
|
1643
|
+
* The Brain had no deterministic read: `verifyByIds` answers "is it still true" without
|
|
1644
|
+
* returning the text, and `search()` — the only path to the body — is a ranking, so an agent
|
|
1645
|
+
* holding an id could still fail to retrieve the memory it had just written. Editing a
|
|
1646
|
+
* long-lived entry under those conditions means reconstructing its text from whatever a
|
|
1647
|
+
* search happened to surface, which is how the accumulated content in it gets lost.
|
|
1648
|
+
*
|
|
1649
|
+
* Returns a copy: callers must not mutate the corpus by holding a reference. Use update()
|
|
1650
|
+
* to change a memory.
|
|
1651
|
+
*/
|
|
1652
|
+
getEntry(id) {
|
|
1653
|
+
this.syncIfChanged();
|
|
1654
|
+
const entry = this.entries.get(id);
|
|
1655
|
+
return entry ? { ...entry } : undefined;
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* The entry a claim id belongs to, plus the claim itself. Claim ids and entry ids are handed
|
|
1659
|
+
* back side by side by search_memory and verify_memory, so an id pasted into a read is as
|
|
1660
|
+
* likely to be one as the other — resolving only entries would report a live claim as missing.
|
|
1661
|
+
*/
|
|
1662
|
+
getClaim(id) {
|
|
1663
|
+
this.syncIfChanged();
|
|
1664
|
+
for (const entry of this.entries.values()) {
|
|
1665
|
+
const claim = entry.claims?.find((c) => c.id === id);
|
|
1666
|
+
if (claim)
|
|
1667
|
+
return { entry: { ...entry }, claim };
|
|
1668
|
+
}
|
|
1669
|
+
return undefined;
|
|
1670
|
+
}
|
|
1545
1671
|
downvote(id) {
|
|
1546
1672
|
this.syncIfChanged();
|
|
1547
1673
|
const entry = this.entries.get(id);
|
|
@@ -1571,6 +1697,19 @@ class TheBrainV2 {
|
|
|
1571
1697
|
const entry = this.entries.get(id);
|
|
1572
1698
|
if (!entry)
|
|
1573
1699
|
return { ok: false, message: `No entry with id "${id}" in the Brain.` };
|
|
1700
|
+
// Archived before it is dropped: the body is the only copy of that text anywhere, and
|
|
1701
|
+
// "nothing else can recover it" has to be a description of the archive, not of a gap.
|
|
1702
|
+
let archivePath;
|
|
1703
|
+
try {
|
|
1704
|
+
this.ensureDir();
|
|
1705
|
+
const { terms: _terms, ...persisted } = entry;
|
|
1706
|
+
fs_1.default.appendFileSync(FORGOTTEN_FILE, JSON.stringify({ ...persisted, forgottenAt: new Date().toISOString() }) + '\n', 'utf8');
|
|
1707
|
+
archivePath = FORGOTTEN_FILE;
|
|
1708
|
+
}
|
|
1709
|
+
catch {
|
|
1710
|
+
// An unwritable archive must not block a deletion the user asked for — the body still
|
|
1711
|
+
// comes back in the result below, which is the copy that matters in the moment.
|
|
1712
|
+
}
|
|
1574
1713
|
this.dropEntry(entry);
|
|
1575
1714
|
this.tombstone(id);
|
|
1576
1715
|
this.recalcAvgDocLength();
|
|
@@ -1580,7 +1719,10 @@ class TheBrainV2 {
|
|
|
1580
1719
|
message: `Deleted memory "${id}". It will not come back from another session's copy.`,
|
|
1581
1720
|
// Echoed back so a deletion is auditable: the caller (and the user reading the
|
|
1582
1721
|
// transcript) can see exactly what was destroyed, since nothing else can recover it.
|
|
1583
|
-
|
|
1722
|
+
// The response is included, not just its metadata — a record of a deletion that omits
|
|
1723
|
+
// the deleted content is not a record of anything.
|
|
1724
|
+
forgotten: { id, query: entry.query, response: entry.response, timestamp: entry.timestamp, hits: entry.hits },
|
|
1725
|
+
...(archivePath ? { archivePath } : {}),
|
|
1584
1726
|
};
|
|
1585
1727
|
}
|
|
1586
1728
|
// ─── Re-anchoring ───────────────────────────────────────────────────────────
|
|
@@ -1603,11 +1745,13 @@ class TheBrainV2 {
|
|
|
1603
1745
|
* a memory that is itself stale is exactly what Fase B exists to catch, and silently
|
|
1604
1746
|
* clearing that would defeat it. Those come back in `stillStale` instead.
|
|
1605
1747
|
*/
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1748
|
+
/**
|
|
1749
|
+
* Re-hash an entry's evidence, either in place or against newly named files/symbols.
|
|
1750
|
+
* Shared by refresh() ("I checked, this is still true") and update() ("here is the corrected
|
|
1751
|
+
* text"), which make the same assertion about the same code and so must anchor identically.
|
|
1752
|
+
* Mutates `entry`; returns the labels of what it now tracks.
|
|
1753
|
+
*/
|
|
1754
|
+
reanchorEvidence(entry, opts) {
|
|
1611
1755
|
const retracked = [];
|
|
1612
1756
|
const rel = (abs) => {
|
|
1613
1757
|
const r = path_1.default.relative(process.cwd(), abs);
|
|
@@ -1660,6 +1804,14 @@ class TheBrainV2 {
|
|
|
1660
1804
|
}
|
|
1661
1805
|
}
|
|
1662
1806
|
}
|
|
1807
|
+
return retracked;
|
|
1808
|
+
}
|
|
1809
|
+
refresh(id, opts = {}) {
|
|
1810
|
+
this.syncIfChanged();
|
|
1811
|
+
const entry = this.entries.get(id);
|
|
1812
|
+
if (!entry)
|
|
1813
|
+
return { ok: false, message: `No entry with id "${id}" in the Brain.` };
|
|
1814
|
+
const retracked = this.reanchorEvidence(entry, opts);
|
|
1663
1815
|
// Re-stamp git context and the age clock: this memory was just re-verified here, now.
|
|
1664
1816
|
const git = currentGitContext();
|
|
1665
1817
|
if (git.commit)
|
|
@@ -1681,6 +1833,89 @@ class TheBrainV2 {
|
|
|
1681
1833
|
`A "derived:" entry here means an upstream memory it was built on is stale — refresh that one first.`,
|
|
1682
1834
|
};
|
|
1683
1835
|
}
|
|
1836
|
+
// ─── In-place rewrite ───────────────────────────────────────────────────────
|
|
1837
|
+
/**
|
|
1838
|
+
* Replace an existing memory's content, keeping its identity.
|
|
1839
|
+
*
|
|
1840
|
+
* The Brain could add and it could delete, but it could not correct: store() mints a new id
|
|
1841
|
+
* per call, so re-storing a corrected version under the same query left the outdated one in
|
|
1842
|
+
* place, and a later search returned an arbitrary slice of every historical version —
|
|
1843
|
+
* including the ones that contradict each other. That is the mechanism behind an
|
|
1844
|
+
* append-only pile of near-duplicate "canonical index" entries: not a convention nobody
|
|
1845
|
+
* followed, a convention the API could not express. refresh() keeps identity but only
|
|
1846
|
+
* re-hashes evidence, and has no way to accept new text. This is that missing operation.
|
|
1847
|
+
*
|
|
1848
|
+
* Kept: id, hits, demerits, creation timestamp, projectId, source, and every `derivedFrom`
|
|
1849
|
+
* edge elsewhere in the corpus that points at this id. Replaced: whatever the patch names.
|
|
1850
|
+
* Evidence is re-anchored exactly as refresh() does — rewriting a memory's content asserts
|
|
1851
|
+
* the same thing refresh() records, that the caller checked it against the code as it is now.
|
|
1852
|
+
*/
|
|
1853
|
+
update(id, patch = {}) {
|
|
1854
|
+
this.syncIfChanged();
|
|
1855
|
+
const entry = this.entries.get(id);
|
|
1856
|
+
if (!entry)
|
|
1857
|
+
return { ok: false, message: `No entry with id "${id}" in the Brain.` };
|
|
1858
|
+
const beforeChars = entry.charCount;
|
|
1859
|
+
// Out of the index before its terms change: a posting list built from the old text would
|
|
1860
|
+
// keep serving this entry under words the new text no longer contains.
|
|
1861
|
+
this.dropEntry(entry);
|
|
1862
|
+
if (typeof patch.query === 'string' && patch.query.trim())
|
|
1863
|
+
entry.query = patch.query.trim();
|
|
1864
|
+
if (typeof patch.response === 'string' && patch.response.trim())
|
|
1865
|
+
entry.response = patch.response.trim();
|
|
1866
|
+
if (patch.outcome)
|
|
1867
|
+
entry.outcome = patch.outcome;
|
|
1868
|
+
if (patch.domain !== undefined)
|
|
1869
|
+
entry.domain = patch.domain.trim() || undefined;
|
|
1870
|
+
if (patch.derivedFrom !== undefined) {
|
|
1871
|
+
entry.derivedFrom = patch.derivedFrom.length > 0 ? patch.derivedFrom : undefined;
|
|
1872
|
+
}
|
|
1873
|
+
if (patch.claims !== undefined) {
|
|
1874
|
+
entry.claims = patch.claims.length > 0 ? buildClaims(patch.claims) : undefined;
|
|
1875
|
+
}
|
|
1876
|
+
const terms = tokenize(entry.query + ' ' + entry.response);
|
|
1877
|
+
entry.terms = [...new Set(terms)];
|
|
1878
|
+
entry.termFreq = termFrequencies(terms);
|
|
1879
|
+
entry.charCount = entry.query.length + entry.response.length;
|
|
1880
|
+
// Claims supplied in this patch were just hashed by buildClaims; the helper re-anchors the
|
|
1881
|
+
// ones carried over, so either way the entry's evidence describes the code as it is now.
|
|
1882
|
+
const retracked = this.reanchorEvidence(entry, { filePaths: patch.filePaths, symbols: patch.symbols });
|
|
1883
|
+
const git = currentGitContext();
|
|
1884
|
+
if (git.commit)
|
|
1885
|
+
entry.gitCommit = git.commit;
|
|
1886
|
+
if (git.branch)
|
|
1887
|
+
entry.gitBranch = git.branch;
|
|
1888
|
+
// Same clock reset as refresh(): re-verified content really is current again. `timestamp`
|
|
1889
|
+
// is left alone so provenance is never rewritten.
|
|
1890
|
+
entry.refreshedAt = new Date().toISOString();
|
|
1891
|
+
this.entries.set(id, entry);
|
|
1892
|
+
for (const term of entry.terms) {
|
|
1893
|
+
let ids = this.invertedIndex.get(term);
|
|
1894
|
+
if (!ids) {
|
|
1895
|
+
ids = new Set();
|
|
1896
|
+
this.invertedIndex.set(term, ids);
|
|
1897
|
+
}
|
|
1898
|
+
ids.add(id);
|
|
1899
|
+
}
|
|
1900
|
+
this.bloom.add(entry.query.trim().toLowerCase().substring(0, 200));
|
|
1901
|
+
this.recalcAvgDocLength();
|
|
1902
|
+
this.scheduleSave();
|
|
1903
|
+
const claimIndex = buildClaimIndex(this.entries);
|
|
1904
|
+
const { fresh, staleFiles } = checkEntryFreshness(entry, defaultLocalResolver, (depId) => resolveFreshnessNode(this.entries, claimIndex, depId));
|
|
1905
|
+
const charDelta = entry.charCount - beforeChars;
|
|
1906
|
+
return {
|
|
1907
|
+
ok: true,
|
|
1908
|
+
id,
|
|
1909
|
+
fresh,
|
|
1910
|
+
retracked,
|
|
1911
|
+
charDelta,
|
|
1912
|
+
...(staleFiles.length > 0 ? { stillStale: staleFiles } : {}),
|
|
1913
|
+
message: fresh
|
|
1914
|
+
? `Memory "${id}" updated in place, keeping its id, ${entry.hits} hit(s) and every derivedFrom edge pointing at it.`
|
|
1915
|
+
: `Memory "${id}" updated in place, but still stale: ${staleFiles.join(', ')}. ` +
|
|
1916
|
+
`A "derived:" entry here means an upstream memory it was built on is stale — refresh that one first.`,
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1684
1919
|
// ─── Batch verification ─────────────────────────────────────────────────────
|
|
1685
1920
|
/**
|
|
1686
1921
|
* Revalidate ids from a prior search_memory/store_memory result via hash-compare only —
|
|
@@ -1704,9 +1939,13 @@ class TheBrainV2 {
|
|
|
1704
1939
|
if (entry) {
|
|
1705
1940
|
const { fresh, staleFiles, unverifiedFiles, cosmeticChanges } = checkEntryFreshness(entry, resolver, resolveNode, 0, new Set(), semanticDiff);
|
|
1706
1941
|
const unverified = unverifiedFiles.length > 0;
|
|
1942
|
+
// An entry that tracks nothing cannot be checked, and saying 'fresh' would answer a
|
|
1943
|
+
// question ("does this still match the code?") that was never asked of it.
|
|
1944
|
+
const tracked = trackedArtifactCount(entry);
|
|
1707
1945
|
return {
|
|
1708
1946
|
id,
|
|
1709
|
-
status: unverified ? 'unverified' : fresh ? '
|
|
1947
|
+
status: unverified ? 'unverified' : !fresh ? 'stale' : tracked === 0 ? 'untracked' : 'fresh',
|
|
1948
|
+
trackedArtifacts: tracked,
|
|
1710
1949
|
...(unverified || fresh ? {} : attributeStaleness(entry, git)),
|
|
1711
1950
|
...(staleFiles.length > 0 ? { staleFiles } : {}),
|
|
1712
1951
|
...(unverified ? { unverifiedFiles } : {}),
|
|
@@ -1718,9 +1957,11 @@ class TheBrainV2 {
|
|
|
1718
1957
|
if (claim) {
|
|
1719
1958
|
const cf = checkClaimFreshness(claim, resolver, semanticDiff);
|
|
1720
1959
|
const unverified = (cf.unverifiedFiles?.length ?? 0) > 0;
|
|
1960
|
+
const trackedClaim = trackedClaimArtifactCount(claim);
|
|
1721
1961
|
return {
|
|
1722
1962
|
id,
|
|
1723
|
-
status: cf.fresh ? '
|
|
1963
|
+
status: unverified ? 'unverified' : !cf.fresh ? 'stale' : trackedClaim === 0 ? 'untracked' : 'fresh',
|
|
1964
|
+
trackedArtifacts: trackedClaim,
|
|
1724
1965
|
...(cf.staleFiles ? { staleFiles: cf.staleFiles } : {}),
|
|
1725
1966
|
...(cf.unverifiedFiles ? { unverifiedFiles: cf.unverifiedFiles } : {}),
|
|
1726
1967
|
...(cf.cosmeticChanges ? { cosmeticChanges: cf.cosmeticChanges } : {}),
|
|
@@ -1902,6 +2143,7 @@ class TheBrainV2 {
|
|
|
1902
2143
|
let neverHit = 0;
|
|
1903
2144
|
let downvoted = 0;
|
|
1904
2145
|
let unscoped = 0;
|
|
2146
|
+
let untracked = 0;
|
|
1905
2147
|
let oldest = '';
|
|
1906
2148
|
const bySource = {};
|
|
1907
2149
|
const projects = new Set();
|
|
@@ -1914,6 +2156,8 @@ class TheBrainV2 {
|
|
|
1914
2156
|
unscoped++;
|
|
1915
2157
|
else
|
|
1916
2158
|
projects.add(entry.projectId);
|
|
2159
|
+
if (trackedArtifactCount(entry) === 0)
|
|
2160
|
+
untracked++;
|
|
1917
2161
|
const src = entrySource(entry);
|
|
1918
2162
|
bySource[src] = (bySource[src] || 0) + 1;
|
|
1919
2163
|
if (entry.timestamp && (!oldest || entry.timestamp < oldest))
|
|
@@ -1924,6 +2168,7 @@ class TheBrainV2 {
|
|
|
1924
2168
|
base.bySource = bySource;
|
|
1925
2169
|
base.projects = projects.size;
|
|
1926
2170
|
base.unscopedEntries = unscoped;
|
|
2171
|
+
base.untrackedEntries = untracked;
|
|
1927
2172
|
base.tombstones = this.tombstones.size;
|
|
1928
2173
|
if (oldest)
|
|
1929
2174
|
base.oldestEntry = oldest;
|