@seanhogg/builderforce-memory 2026.6.19 → 2026.6.27

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.
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Evermind — Write-Through Cognition engine.
3
+ *
4
+ * `commit()` is the model-knowledge analogue of a write-through cache write with
5
+ * a conflict resolver: Canonicalize (stable subject key) → Recall incumbent →
6
+ * Evaluate evidence → Reconcile (augment | confirm | supersede | reject) →
7
+ * write-through. `recall()` is the read side, served through a version-token
8
+ * cache that invalidates for free whenever knowledge changes.
9
+ *
10
+ * This is the layer the append-only knowledge loop skipped: it derives a STABLE
11
+ * subject key (not a per-run id) and replaces-on-write, so beliefs never drift
12
+ * into a manual reconciliation step.
13
+ */
14
+ import type { Claim, CognitionFactStore, CommitResult, EvidenceGatherer } from './types.js';
15
+ export interface EvermindCognitionOptions {
16
+ store: CognitionFactStore;
17
+ /** Default evidence gatherer used when `commit()` is not given one. */
18
+ gather?: EvidenceGatherer;
19
+ /**
20
+ * Optional embedding-capable runtime (e.g. SSMRuntime) forwarded to the
21
+ * store's `recallSimilar` so recall sharpens as the model adapts.
22
+ */
23
+ runtime?: unknown;
24
+ }
25
+ export declare class EvermindCognition {
26
+ private readonly _store;
27
+ private readonly _defaultGather?;
28
+ private readonly _runtime?;
29
+ /**
30
+ * Knowledge-generation token. Bumped on every change to the fact set
31
+ * (augment / supersede). Doubles as the recall-cache namespace so a write
32
+ * invalidates cached reads for free — the "invalidate on write" rule applied
33
+ * to model knowledge.
34
+ */
35
+ private _version;
36
+ /**
37
+ * L1 recall cache, namespaced by `_version`. After any knowledge change the
38
+ * version moves, so prior-generation entries are never read again (and are
39
+ * cleared to bound growth) — not an ad-hoc TTL map; a version-token cache.
40
+ */
41
+ private readonly _recallCache;
42
+ constructor(opts: EvermindCognitionOptions);
43
+ /** Current knowledge-generation token. */
44
+ get version(): number;
45
+ /**
46
+ * Commit a candidate fact write-through. Evidence decides conflicts; a
47
+ * supersede replaces the incumbent under the same stable key and invalidates
48
+ * recall. Never appends a competing belief for the same subject.
49
+ */
50
+ commit(claim: Claim, gather?: EvidenceGatherer | undefined): Promise<CommitResult>;
51
+ /**
52
+ * Write-through recall: the top-K most relevant facts for `query`, served
53
+ * from a version-namespaced cache that invalidates on the next knowledge
54
+ * change. Falls back to an empty set when the store can't rank similarity.
55
+ */
56
+ recall(query: string, topK?: number): Promise<string[]>;
57
+ private _write;
58
+ private _bumpVersion;
59
+ private _result;
60
+ }
61
+ //# sourceMappingURL=EvermindCognition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvermindCognition.d.ts","sourceRoot":"","sources":["../../src/cognition/EvermindCognition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACR,KAAK,EACL,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAGnB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,wBAAwB;IACrC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,uEAAuE;IACvE,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAWD,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAmB;IACnD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAU;IAEpC;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAK;IAErB;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA+B;gBAEhD,IAAI,EAAE,wBAAwB;IAM1C,0CAA0C;IAC1C,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,gBAAgB,GAAG,SAA+B,GAAG,OAAO,CAAC,YAAY,CAAC;IAsC7G;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAe1C,MAAM;IAIpB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,OAAO;CASlB"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Evermind — Write-Through Cognition engine.
3
+ *
4
+ * `commit()` is the model-knowledge analogue of a write-through cache write with
5
+ * a conflict resolver: Canonicalize (stable subject key) → Recall incumbent →
6
+ * Evaluate evidence → Reconcile (augment | confirm | supersede | reject) →
7
+ * write-through. `recall()` is the read side, served through a version-token
8
+ * cache that invalidates for free whenever knowledge changes.
9
+ *
10
+ * This is the layer the append-only knowledge loop skipped: it derives a STABLE
11
+ * subject key (not a per-run id) and replaces-on-write, so beliefs never drift
12
+ * into a manual reconciliation step.
13
+ */
14
+ function hasRecallSimilar(store) {
15
+ return typeof store.recallSimilar === 'function';
16
+ }
17
+ export class EvermindCognition {
18
+ _store;
19
+ _defaultGather;
20
+ _runtime;
21
+ /**
22
+ * Knowledge-generation token. Bumped on every change to the fact set
23
+ * (augment / supersede). Doubles as the recall-cache namespace so a write
24
+ * invalidates cached reads for free — the "invalidate on write" rule applied
25
+ * to model knowledge.
26
+ */
27
+ _version = 0;
28
+ /**
29
+ * L1 recall cache, namespaced by `_version`. After any knowledge change the
30
+ * version moves, so prior-generation entries are never read again (and are
31
+ * cleared to bound growth) — not an ad-hoc TTL map; a version-token cache.
32
+ */
33
+ _recallCache = new Map();
34
+ constructor(opts) {
35
+ this._store = opts.store;
36
+ this._defaultGather = opts.gather;
37
+ this._runtime = opts.runtime;
38
+ }
39
+ /** Current knowledge-generation token. */
40
+ get version() {
41
+ return this._version;
42
+ }
43
+ /**
44
+ * Commit a candidate fact write-through. Evidence decides conflicts; a
45
+ * supersede replaces the incumbent under the same stable key and invalidates
46
+ * recall. Never appends a competing belief for the same subject.
47
+ */
48
+ async commit(claim, gather = this._defaultGather) {
49
+ const incumbent = await this._store.recall(claim.subjectKey);
50
+ const audit = [];
51
+ // ── Brand-new subject ────────────────────────────────────────────────
52
+ if (!incumbent) {
53
+ if (gather && claim.requireEvidence) {
54
+ const e = await gather({ claim });
55
+ audit.push(...e.notes);
56
+ if (!e.supportsNew) {
57
+ return this._result('reject', claim.subjectKey, claim.content, undefined, audit);
58
+ }
59
+ }
60
+ await this._write(claim, claim.importance ?? 0.6);
61
+ this._bumpVersion();
62
+ return this._result('augment', claim.subjectKey, claim.content, undefined, audit);
63
+ }
64
+ // ── Identical incumbent — confirm (refresh confidence, no replace) ────
65
+ if (incumbent.content === claim.content) {
66
+ await this._write(claim, Math.min(1, (claim.importance ?? 0.6) + 0.1));
67
+ return this._result('confirm', claim.subjectKey, claim.content, undefined, audit);
68
+ }
69
+ // ── Conflict — evidence decides ──────────────────────────────────────
70
+ const e = gather
71
+ ? await gather({ claim, incumbent: incumbent.content })
72
+ : { supportsNew: true, notes: ['no evidence gatherer supplied; trusting newer observation'] };
73
+ audit.push(...e.notes);
74
+ if (e.supportsNew) {
75
+ await this._write(claim, Math.max(claim.importance ?? 0.6, 0.9));
76
+ this._bumpVersion();
77
+ return this._result('supersede', claim.subjectKey, claim.content, incumbent.content, audit);
78
+ }
79
+ return this._result('reject', claim.subjectKey, incumbent.content, undefined, audit);
80
+ }
81
+ /**
82
+ * Write-through recall: the top-K most relevant facts for `query`, served
83
+ * from a version-namespaced cache that invalidates on the next knowledge
84
+ * change. Falls back to an empty set when the store can't rank similarity.
85
+ */
86
+ async recall(query, topK = 5) {
87
+ const cacheKey = `${this._version}:${topK}:${query}`;
88
+ const cached = this._recallCache.get(cacheKey);
89
+ if (cached)
90
+ return cached;
91
+ const facts = hasRecallSimilar(this._store)
92
+ ? (await this._store.recallSimilar(query, topK, this._runtime)).map((e) => e.content)
93
+ : [];
94
+ this._recallCache.set(cacheKey, facts);
95
+ return facts;
96
+ }
97
+ // ── internals ────────────────────────────────────────────────────────────
98
+ async _write(claim, importance) {
99
+ await this._store.remember(claim.subjectKey, claim.content, { tags: claim.tags, importance });
100
+ }
101
+ _bumpVersion() {
102
+ this._version++;
103
+ this._recallCache.clear();
104
+ }
105
+ _result(verdict, subjectKey, content, superseded, evidence) {
106
+ return { verdict, subjectKey, content, superseded, evidence, version: this._version };
107
+ }
108
+ }
109
+ //# sourceMappingURL=EvermindCognition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvermindCognition.js","sourceRoot":"","sources":["../../src/cognition/EvermindCognition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA2BH,SAAS,gBAAgB,CAAC,KAAc;IACpC,OAAO,OAAQ,KAAgC,CAAC,aAAa,KAAK,UAAU,CAAC;AACjF,CAAC;AAED,MAAM,OAAO,iBAAiB;IACT,MAAM,CAAqB;IAC3B,cAAc,CAAoB;IAClC,QAAQ,CAAW;IAEpC;;;;;OAKG;IACK,QAAQ,GAAG,CAAC,CAAC;IAErB;;;;OAIG;IACc,YAAY,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE5D,YAAY,IAA8B;QACtC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,0CAA0C;IAC1C,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,KAAY,EAAE,SAAuC,IAAI,CAAC,cAAc;QACjF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC7D,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,wEAAwE;QACxE,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,IAAI,MAAM,IAAI,KAAK,CAAC,eAAe,E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,CAAC;IAED,4EAA4E;IAEpE,KAAK,CAAC,MAAM,CAAC,KAAY,EAAE,UAAkB;QACjD,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IAClG,CAAC;IAEO,YAAY;QAChB,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAEO,OAAO,CACX,OAAgB,EAChB,UAAkB,EAClB,OAAe,EACf,UAA8B,EAC9B,QAAkB;QAElB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC1F,CAAC;CACJ"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Evermind — reusable evidence gatherers.
3
+ *
4
+ * Concrete, surface-agnostic evidence rules. The presence rule is the one the
5
+ * IDE self-correction loop uses (ground a claim by listing the workspace), kept
6
+ * here so the IDE, the proof harness, and tests share one implementation.
7
+ */
8
+ import type { EvidenceGatherer } from './types.js';
9
+ export interface WorkspacePresenceRule {
10
+ /** Lists the workspace (e.g. the IDE `list_files('.')` control tool). */
11
+ list: () => Promise<string[]>;
12
+ /** Entries that MUST be present for the new claim to hold. */
13
+ mustExist?: string[];
14
+ /** Entries that MUST be absent for the new claim to hold. */
15
+ mustBeAbsent?: string[];
16
+ }
17
+ /**
18
+ * Evidence rule: the new claim is supported iff every `mustExist` entry is
19
+ * present and every `mustBeAbsent` entry is gone from the listing.
20
+ */
21
+ export declare function workspacePresenceGatherer(rule: WorkspacePresenceRule): EvidenceGatherer;
22
+ //# sourceMappingURL=gatherers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gatherers.d.ts","sourceRoot":"","sources":["../../src/cognition/gatherers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IAClC,yEAAyE;IACzE,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9B,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,qBAAqB,GAAG,gBAAgB,CAgBvF"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Evermind — reusable evidence gatherers.
3
+ *
4
+ * Concrete, surface-agnostic evidence rules. The presence rule is the one the
5
+ * IDE self-correction loop uses (ground a claim by listing the workspace), kept
6
+ * here so the IDE, the proof harness, and tests share one implementation.
7
+ */
8
+ /**
9
+ * Evidence rule: the new claim is supported iff every `mustExist` entry is
10
+ * present and every `mustBeAbsent` entry is gone from the listing.
11
+ */
12
+ export function workspacePresenceGatherer(rule) {
13
+ const mustExist = rule.mustExist ?? [];
14
+ const mustBeAbsent = rule.mustBeAbsent ?? [];
15
+ return async () => {
16
+ const listing = await rule.list();
17
+ const present = mustExist.filter((d) => listing.includes(d));
18
+ const absent = mustBeAbsent.filter((d) => !listing.includes(d));
19
+ const supportsNew = present.length === mustExist.length && absent.length === mustBeAbsent.length;
20
+ return {
21
+ supportsNew,
22
+ notes: [
23
+ `present: ${present.join(', ') || '—'}`,
24
+ `absent (as expected): ${absent.join(', ') || '—'}`,
25
+ ],
26
+ };
27
+ };
28
+ }
29
+ //# sourceMappingURL=gatherers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gatherers.js","sourceRoot":"","sources":["../../src/cognition/gatherers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAA2B;IACjE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACvC,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,OAAO,KAAK,IAAI,EAAE;QACd,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,CAAC;QACjG,OAAO;YACH,WAAW;YACX,KAAK,EAAE;gBACH,YAAY,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE;gBACvC,yBAAyB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE;aACtD;SACJ,CAAC;IACN,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Evermind — Write-Through Cognition.
3
+ *
4
+ * The layer that keeps model knowledge current without a reconciliation step:
5
+ * stable-subject-key beliefs, evidence-gated conflict resolution, replace-on-write.
6
+ */
7
+ export { EvermindCognition } from './EvermindCognition.js';
8
+ export type { EvermindCognitionOptions } from './EvermindCognition.js';
9
+ export { workspacePresenceGatherer } from './gatherers.js';
10
+ export type { WorkspacePresenceRule } from './gatherers.js';
11
+ export type { Claim, CognitionFactStore, CommitResult, EvidenceContext, EvidenceGatherer, EvidenceResult, Verdict, } from './types.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cognition/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,YAAY,EACR,KAAK,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,OAAO,GACV,MAAM,YAAY,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Evermind — Write-Through Cognition.
3
+ *
4
+ * The layer that keeps model knowledge current without a reconciliation step:
5
+ * stable-subject-key beliefs, evidence-gated conflict resolution, replace-on-write.
6
+ */
7
+ export { EvermindCognition } from './EvermindCognition.js';
8
+ export { workspacePresenceGatherer } from './gatherers.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cognition/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Evermind — Write-Through Cognition types.
3
+ *
4
+ * The cognition layer is what lets the model's KNOWLEDGE stay current without a
5
+ * reconciliation step: every incoming fact is evaluated against EVIDENCE and the
6
+ * incumbent belief, then committed write-through (replace-on-write by a STABLE
7
+ * subject key) instead of being appended under a fresh per-run key. These types
8
+ * are intentionally store- and surface-agnostic so the same logic runs in the
9
+ * IDE, on-prem, cloud, and the browser.
10
+ */
11
+ /** Outcome of evaluating a candidate fact against its incumbent + evidence. */
12
+ export type Verdict =
13
+ /** No incumbent on this subject — stored as a new belief. */
14
+ 'augment'
15
+ /** Incumbent identical — recency/confidence refreshed, nothing replaced. */
16
+ | 'confirm'
17
+ /** Incumbent conflicted and evidence favoured the new fact — replaced. */
18
+ | 'supersede'
19
+ /** Incumbent conflicted but evidence did NOT favour the new fact — dropped. */
20
+ | 'reject';
21
+ /**
22
+ * Minimal write-through fact store the cognition layer needs. `MemoryStore`
23
+ * satisfies this structurally (no adapter required) — kept narrow so cloud
24
+ * (Postgres) / browser (IndexedDB) backends can satisfy it too.
25
+ */
26
+ export interface CognitionFactStore {
27
+ remember(key: string, content: string, opts?: {
28
+ tags?: string[];
29
+ importance?: number;
30
+ ttlMs?: number;
31
+ }): Promise<void>;
32
+ recall(key: string): Promise<{
33
+ content: string;
34
+ } | undefined>;
35
+ forget(key: string): Promise<void>;
36
+ }
37
+ /** A fact asserted about a subject, keyed by a STABLE canonical key. */
38
+ export interface Claim {
39
+ /**
40
+ * STABLE canonical key naming the SUBJECT of the fact (e.g. `pkg:ssm-stack`).
41
+ * This is the anti-drift fix: logically-superseding facts collide on this key
42
+ * and replace, instead of accumulating under per-run keys.
43
+ */
44
+ subjectKey: string;
45
+ /** The asserted fact content. */
46
+ content: string;
47
+ tags?: string[];
48
+ importance?: number;
49
+ /**
50
+ * When true, a brand-new subject is only stored if the gatherer's evidence
51
+ * supports it (guards against recording unverified first-observations).
52
+ */
53
+ requireEvidence?: boolean;
54
+ }
55
+ /** The verdict of an evidence probe: does ground truth favour the new claim? */
56
+ export interface EvidenceResult {
57
+ supportsNew: boolean;
58
+ /** Audit-readable lines describing what was checked and found. */
59
+ notes: string[];
60
+ }
61
+ export interface EvidenceContext {
62
+ claim: Claim;
63
+ /** Incumbent belief content for this subject, when one exists. */
64
+ incumbent?: string;
65
+ }
66
+ /**
67
+ * Gathers ground-truth evidence for a claim. Injected by the caller because the
68
+ * evidence source is surface-specific (IDE file tools, cloud DB, HTTP probe…).
69
+ */
70
+ export type EvidenceGatherer = (ctx: EvidenceContext) => Promise<EvidenceResult>;
71
+ /** Result of committing a claim through the cognition pipeline. */
72
+ export interface CommitResult {
73
+ verdict: Verdict;
74
+ subjectKey: string;
75
+ /** The belief now held for this subject (incumbent's content on reject). */
76
+ content: string;
77
+ /** Prior content, present only when `verdict === 'supersede'`. */
78
+ superseded?: string;
79
+ /** Evidence audit trail. */
80
+ evidence: string[];
81
+ /** Knowledge-generation token after this commit (bumps on augment/supersede). */
82
+ version: number;
83
+ }
84
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cognition/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,+EAA+E;AAC/E,MAAM,MAAM,OAAO;AACf,6DAA6D;AAC3D,SAAS;AACX,4EAA4E;GAC1E,SAAS;AACX,0EAA0E;GACxE,WAAW;AACb,+EAA+E;GAC7E,QAAQ,CAAC;AAEf;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,CACJ,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAChE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IAC9D,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED,wEAAwE;AACxE,MAAM,WAAW,KAAK;IAClB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC3B,WAAW,EAAE,OAAO,CAAC;IACrB,kEAAkE;IAClE,KAAK,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;AAEjF,mEAAmE;AACnE,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Evermind — Write-Through Cognition types.
3
+ *
4
+ * The cognition layer is what lets the model's KNOWLEDGE stay current without a
5
+ * reconciliation step: every incoming fact is evaluated against EVIDENCE and the
6
+ * incumbent belief, then committed write-through (replace-on-write by a STABLE
7
+ * subject key) instead of being appended under a fresh per-run key. These types
8
+ * are intentionally store- and surface-agnostic so the same logic runs in the
9
+ * IDE, on-prem, cloud, and the browser.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cognition/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
package/dist/index.d.ts CHANGED
@@ -22,6 +22,10 @@ export { MODEL_PRESETS, resolveLayerSchedule, resolveModelConfig } from './sessi
22
22
  export type { SessionErrorCode } from './session/index.js';
23
23
  export type { LayerSchedulePreset } from './session/index.js';
24
24
  export type { MambaSessionOptions, CompleteOptions, AdaptOptions, AdaptResult, SaveOptions, LoadOptions, StorageTarget, CreateProgressEvent, CreateStage, CreateCallbacks, SessionInternals, GpuMode, Tokenizer, } from './session/index.js';
25
+ export { LimbicSession } from './limbic/LimbicSession.js';
26
+ export type { LimbicSessionOptions, LimbicGpuMode } from './limbic/LimbicSession.js';
27
+ export { LimbicModel, LimbicTrainer, LIMBIC_DIM, LIMBIC_DIM_NAMES, LIMBIC_STATE_DIM, LIMBIC_BOUNDS, NEUTRAL_STATE, REGION, clampState, neutralState, stateToRecord, recordToState, } from '@seanhogg/builderforce-memory-engine';
28
+ export type { LimbicModelConfig, LimbicForward, LimbicSample, LimbicTrainOptions, LimbicDimName, Region, } from '@seanhogg/builderforce-memory-engine';
25
29
  export { SSMRuntime } from './runtime/SSMRuntime.js';
26
30
  export type { SSMRuntimeOptions, GenerateOptions } from './runtime/SSMRuntime.js';
27
31
  export type { TransformerBridge, BridgeGenerateOptions } from './bridges/TransformerBridge.js';
@@ -45,6 +49,8 @@ export { InferenceRouter } from './router/InferenceRouter.js';
45
49
  export type { RoutingStrategy, RoutingDecision, RouterContext, InferenceRouterOptions, RoutingAuditEntry, } from './router/InferenceRouter.js';
46
50
  export { MemoryStore } from './memory/MemoryStore.js';
47
51
  export type { MemoryEntry, MemoryStoreOptions, RememberOptions, FactType, } from './memory/MemoryStore.js';
52
+ export { EvermindCognition, workspacePresenceGatherer } from './cognition/index.js';
53
+ export type { EvermindCognitionOptions, WorkspacePresenceRule, Claim, CognitionFactStore, CommitResult, EvidenceContext, EvidenceGatherer, EvidenceResult, Verdict, } from './cognition/index.js';
48
54
  export { DistillationEngine } from './distillation/DistillationEngine.js';
49
55
  export type { DistillOptions, DistillResult, DistillBatchResult, DistillationLog, QualityGate, } from './distillation/DistillationEngine.js';
50
56
  export { SSMAgent } from './agent/SSMAgent.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EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,QAAQ,GACX,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACpF,YAAY,EACR,wBAAwB,EACxB,qBAAqB,EACrB,KAAK,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,OAAO,GACV,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,YAAY,EACR,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,WAAW,GACd,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,QAAQ,EAAE,MAAO,qBAAqB,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGpG,OAAO,EAAE,QAAQ,EAAE,MAAO,sBAAsB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAMzD,OAAO,EAAE,UAAU,EAAE,MAAe,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,eAAO,MAAM,GAAG;IACZ;;;;;OAKG;4BACY,iBAAiB;CAC1B,CAAC"}
package/dist/index.js CHANGED
@@ -20,6 +20,11 @@
20
20
  export { MambaSession } from './session/index.js';
21
21
  export { SessionError } from './session/index.js';
22
22
  export { MODEL_PRESETS, resolveLayerSchedule, resolveModelConfig } from './session/index.js';
23
+ // ── Limbic system (trainable affective dynamics) ──────────────────────────────
24
+ export { LimbicSession } from './limbic/LimbicSession.js';
25
+ // Re-export the limbic engine primitives so consumers can use the model/trainer
26
+ // and the region schema directly from @seanhogg/builderforce-memory.
27
+ export { LimbicModel, LimbicTrainer, LIMBIC_DIM, LIMBIC_DIM_NAMES, LIMBIC_STATE_DIM, LIMBIC_BOUNDS, NEUTRAL_STATE, REGION, clampState, neutralState, stateToRecord, recordToState, } from '@seanhogg/builderforce-memory-engine';
23
28
  // ── Runtime ───────────────────────────────────────────────────────────────────
24
29
  export { SSMRuntime } from './runtime/SSMRuntime.js';
25
30
  export { OpenAIBridge } from './bridges/OpenAIBridge.js';
@@ -37,6 +42,8 @@ export { cosineSimilarity, jaccardSimilarity, tokenize } from './similarity/inde
37
42
  export { InferenceRouter } from './router/InferenceRouter.js';
38
43
  // ── Memory ────────────────────────────────────────────────────────────────────
39
44
  export { MemoryStore } from './memory/MemoryStore.js';
45
+ // ── Cognition (Evermind — Write-Through Cognition) ────────────────────────────
46
+ export { EvermindCognition, workspacePresenceGatherer } from './cognition/index.js';
40
47
  // ── Distillation ──────────────────────────────────────────────────────────────
41
48
  export { DistillationEngine } from './distillation/DistillationEngine.js';
42
49
  // ── Agent ─────────────────────────────────────────────────────────────────────
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iFAAiF;AACjF,OAAO,EAAE,YAAY,EAAE,MAAmB,oBAAoB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAmB,oBAAoB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAoB7F,iFAAiF;AACjF,OAAO,EAAE,UAAU,EAAE,MAAS,yBAAyB,CAAC;AAKxD,OAAO,EAAE,YAAY,EAAE,MAAS,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAU,0BAA0B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAQ,4BAA4B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAA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iFAAiF;AACjF,mDAAmD;AACnD,qEAAqE;AAErE,OAAO,EAAE,UAAU,EAAE,MAAe,yBAAyB,CAAC;AAG9D,MAAM,CAAC,MAAM,GAAG,GAAG;IACf;;;;;OAKG;IACH,MAAM,EAAE,CAAC,IAAuB,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC;CACtD,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * LimbicSession.ts – high-level facade over the limbic affect model.
3
+ *
4
+ * Mirrors {@link MambaSession}: collapses GPU acquisition, model construction,
5
+ * checkpoint load, and the trainer into a single `LimbicSession.create()` call,
6
+ * with the same WebGPU-or-CPU-fallback contract. The agent runtime consumes
7
+ * this through `@seanhogg/builderforce-memory` to run the limbic system on a
8
+ * self-hosted node (GPU via @webgpu/node when present, CPU otherwise).
9
+ *
10
+ * const limbic = await LimbicSession.create({ gpuAdapter, checkpointBuffer });
11
+ * const { delta, reward } = await limbic.step(experienceEmbedding, state);
12
+ * await limbic.train(samples, { epochs: 30 });
13
+ * const bin = limbic.exportWeights({ fp16: true });
14
+ */
15
+ import { LimbicModel, LimbicTrainer, type LimbicModelConfig, type LimbicForward, type LimbicSample, type LimbicTrainOptions } from "@seanhogg/builderforce-memory-engine";
16
+ export type LimbicGpuMode = "webgpu" | "cpu-fallback" | "cpu";
17
+ export interface LimbicSessionOptions {
18
+ /** Pre-created GPUAdapter (e.g. from @webgpu/node). When set, navigator.gpu is not used. */
19
+ gpuAdapter?: GPUAdapter;
20
+ /** Attempt a software (CPU) WebGPU adapter when no GPU is available. Default false. */
21
+ allowCpuFallback?: boolean;
22
+ /** Pre-read checkpoint bytes (Node: read the .bin with fs and pass the ArrayBuffer). */
23
+ checkpointBuffer?: ArrayBuffer;
24
+ /** IndexedDB key for save()/load(). Default 'limbic-default'. */
25
+ name?: string;
26
+ /** Injected IDBFactory (e.g. fake-indexeddb in Node). */
27
+ idbFactory?: IDBFactory;
28
+ /** Model configuration overrides. */
29
+ modelConfig?: Partial<LimbicModelConfig>;
30
+ /** Deterministic init seed. */
31
+ seed?: number;
32
+ }
33
+ export declare class LimbicSession {
34
+ readonly model: LimbicModel;
35
+ readonly trainer: LimbicTrainer;
36
+ readonly device: GPUDevice | null;
37
+ readonly gpuMode: LimbicGpuMode;
38
+ private readonly _name;
39
+ private readonly _idbFactory;
40
+ private _pipeline;
41
+ private _dimsBuf;
42
+ private _paramBufs;
43
+ private _paramsDirty;
44
+ private constructor();
45
+ static create(options?: LimbicSessionOptions): Promise<LimbicSession>;
46
+ /** One affect step. Uses the GPU kernel when a device is available, else CPU. */
47
+ step(input: ArrayLike<number>, state: ArrayLike<number>, hidden?: ArrayLike<number>): Promise<LimbicForward>;
48
+ private _ensureGpuStep;
49
+ private _stepGpu;
50
+ /** Train the affect model on observed experiences. Marks GPU step buffers dirty. */
51
+ train(samples: LimbicSample[], opts?: LimbicTrainOptions): Promise<number[]>;
52
+ evaluate(samples: LimbicSample[]): number;
53
+ exportWeights(opts?: {
54
+ fp16?: boolean;
55
+ }): ArrayBuffer;
56
+ /** Persist weights to IndexedDB under the session name. */
57
+ save(): Promise<void>;
58
+ /** Load weights from IndexedDB; returns true if a checkpoint was found. */
59
+ load(): Promise<boolean>;
60
+ private _destroyParamBufs;
61
+ destroy(): void;
62
+ }
63
+ //# sourceMappingURL=LimbicSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LimbicSession.d.ts","sourceRoot":"","sources":["../../src/limbic/LimbicSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,WAAW,EACX,aAAa,EASb,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,sCAAsC,CAAC;AAI9C,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,cAAc,GAAG,KAAK,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,4FAA4F;IAC5F,UAAU,CAAC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