@mneme-ai/core 2.19.47 → 2.19.48

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,125 @@
1
+ /**
2
+ * v2.19.48 — CHRONOSHEAF P3 · base space + presheaf.
3
+ *
4
+ * Math formalism (P3 spec verbatim):
5
+ *
6
+ * X = G × T × S
7
+ *
8
+ * where:
9
+ * G = commit DAG (partial order on commit shas)
10
+ * T = wall-clock time (continuous ℝ, modelled as ms since epoch)
11
+ * S = scale axis (file ⊂ module ⊂ package ⊂ repo ⊂ org, 5 levels)
12
+ *
13
+ * Open sets U ⊆ X are tuples (commit-cone, time-interval, scale-band).
14
+ * A commit-cone is the down-set of a commit in G (all ancestors).
15
+ *
16
+ * Presheaf F: Open(X)ᵒᵖ → Vec_ℝ assigns to each open U the set of
17
+ * locally consistent beliefs over claims relevant to U. Restriction
18
+ * map ρ_{U⊃V}: F(U) → F(V) is "if I believe B over U I must
19
+ * believe B over V" — projection onto the smaller open set.
20
+ *
21
+ * Implementation notes (performance + accuracy + safety):
22
+ *
23
+ * - All open-set operations are pure-function + idempotent.
24
+ * - Commit-cone membership uses cached transitive closure to amortise
25
+ * O(1) lookup after first traversal.
26
+ * - Scale axis is a 5-band ordinal enum so subset checks are O(1).
27
+ * - Time intervals are half-open [t_start, t_end) for clean union /
28
+ * intersection algebra.
29
+ * - Error handling: every constructor validates inputs; every accessor
30
+ * returns a typed Result rather than throwing on missing data.
31
+ */
32
+ export type CommitSha = string;
33
+ export type TimeMs = number;
34
+ export declare const SCALE_BANDS: readonly ["file", "module", "package", "repo", "org"];
35
+ export type ScaleBand = typeof SCALE_BANDS[number];
36
+ /** Bidirectional commit DAG with ancestor-set memoisation. */
37
+ export declare class CommitDag {
38
+ private parents;
39
+ private ancestorCache;
40
+ /** Add a commit with its parent list (may be empty for root). */
41
+ addCommit(sha: CommitSha, parents: ReadonlyArray<CommitSha>): void;
42
+ /** All ancestors of sha (including sha itself). Cached. */
43
+ cone(sha: CommitSha): ReadonlySet<CommitSha>;
44
+ /** Whether ancestor is in the ancestor-cone of descendant. */
45
+ isAncestorOf(ancestor: CommitSha, descendant: CommitSha): boolean;
46
+ size(): number;
47
+ }
48
+ /** Half-open time interval [start, end). */
49
+ export interface TimeInterval {
50
+ startMs: TimeMs;
51
+ endMs: TimeMs;
52
+ }
53
+ export declare function makeInterval(startMs: TimeMs, endMs: TimeMs): TimeInterval;
54
+ export declare function intervalContains(iv: TimeInterval, t: TimeMs): boolean;
55
+ export declare function intervalIntersect(a: TimeInterval, b: TimeInterval): TimeInterval | null;
56
+ /** Ordinal index of a scale band (file=0, module=1, ...). */
57
+ export declare function scaleIndex(s: ScaleBand): number;
58
+ /** Scale band a ⊆ b ⟺ idx(a) ≤ idx(b). */
59
+ export declare function scaleSubset(a: ScaleBand, b: ScaleBand): boolean;
60
+ /**
61
+ * Open set in X = G × T × S — a triple (commit-cone-root, time-interval, scale).
62
+ * Closed under finite intersection (intersection of two opens is an open).
63
+ */
64
+ export interface OpenSet {
65
+ /** Identifier for the open set (deterministic id from contents). */
66
+ id: string;
67
+ /** Root commit defining the down-set on G. */
68
+ commitConeRoot: CommitSha;
69
+ /** Time interval on T. */
70
+ time: TimeInterval;
71
+ /** Scale band on S — the scale at which the open is observed. */
72
+ scale: ScaleBand;
73
+ }
74
+ export declare function openSetId(root: CommitSha, time: TimeInterval, scale: ScaleBand): string;
75
+ export declare function makeOpen(root: CommitSha, time: TimeInterval, scale: ScaleBand): OpenSet;
76
+ /**
77
+ * Intersection of two opens. Uses CommitDag to find the latest-common-
78
+ * ancestor (LCA) of the two roots; if no shared ancestor exists, the
79
+ * intersection is empty (null).
80
+ *
81
+ * open(r1, [s1,e1), b1) ∩ open(r2, [s2,e2), b2)
82
+ * = open(LCA(r1, r2), [max(s1,s2), min(e1,e2)), min(b1, b2))
83
+ *
84
+ * Returns null when either time-intervals are disjoint OR no common
85
+ * ancestor exists in the DAG.
86
+ */
87
+ export declare function intersectOpens(dag: CommitDag, a: OpenSet, b: OpenSet): OpenSet | null;
88
+ /** Belief value carried by the presheaf at an open: a finite-dim ℝ vector. */
89
+ export type BeliefVector = ReadonlyArray<number>;
90
+ /**
91
+ * Presheaf F: Open(X)ᵒᵖ → Vec_ℝ.
92
+ *
93
+ * Backed by a Map keyed by openSetId. The restriction map ρ_{U⊃V} is
94
+ * a linear operator from ℝ^|claims(U)| → ℝ^|claims(V)|; in this
95
+ * implementation we restrict by intersecting claim sets (vectors
96
+ * indexed by the SAME claim list across opens that contain a
97
+ * specific claim).
98
+ *
99
+ * Errors:
100
+ * - assignSection rejects non-finite values OR length mismatches with
101
+ * the registered claim cardinality.
102
+ * - sectionAt returns Result rather than throwing on missing key.
103
+ */
104
+ export declare class Presheaf {
105
+ private sections;
106
+ private claimsByOpen;
107
+ /** Register the claim set whose belief values an open carries. */
108
+ registerClaims(open: OpenSet, claims: ReadonlyArray<string>): void;
109
+ /** Assign a belief vector to an open. Vector length must match registered claim count. */
110
+ assignSection(open: OpenSet, belief: BeliefVector): void;
111
+ /** Look up a section. Returns null when missing — never throws. */
112
+ sectionAt(open: OpenSet): BeliefVector | null;
113
+ /** Claims known at an open. */
114
+ claimsAt(open: OpenSet): ReadonlyArray<string>;
115
+ /**
116
+ * Restriction map ρ_{U⊃V}: F(U) → F(V).
117
+ * Implementation: for each claim in V's claim set, find its position
118
+ * in U's claim set and copy the value. Claims in V but not in U get
119
+ * 0 (default-untracked).
120
+ */
121
+ restrict(uOpen: OpenSet, vOpen: OpenSet): BeliefVector | null;
122
+ /** Number of opens with assigned sections. */
123
+ size(): number;
124
+ }
125
+ //# sourceMappingURL=base_space.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base_space.d.ts","sourceRoot":"","sources":["../../src/chronosheaf/base_space.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/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af.
3
+ *
4
+ * Math formalism (P3 spec verbatim):
5
+ *
6
+ * X = G × T × S
7
+ *
8
+ * where:
9
+ * G = commit DAG (partial order on commit shas)
10
+ * T = wall-clock time (continuous ℝ, modelled as ms since epoch)
11
+ * S = scale axis (file ⊂ module ⊂ package ⊂ repo ⊂ org, 5 levels)
12
+ *
13
+ * Open sets U ⊆ X are tuples (commit-cone, time-interval, scale-band).
14
+ * A commit-cone is the down-set of a commit in G (all ancestors).
15
+ *
16
+ * Presheaf F: Open(X)ᵒᵖ → Vec_ℝ assigns to each open U the set of
17
+ * locally consistent beliefs over claims relevant to U. Restriction
18
+ * map ρ_{U⊃V}: F(U) → F(V) is "if I believe B over U I must
19
+ * believe B over V" — projection onto the smaller open set.
20
+ *
21
+ * Implementation notes (performance + accuracy + safety):
22
+ *
23
+ * - All open-set operations are pure-function + idempotent.
24
+ * - Commit-cone membership uses cached transitive closure to amortise
25
+ * O(1) lookup after first traversal.
26
+ * - Scale axis is a 5-band ordinal enum so subset checks are O(1).
27
+ * - Time intervals are half-open [t_start, t_end) for clean union /
28
+ * intersection algebra.
29
+ * - Error handling: every constructor validates inputs; every accessor
30
+ * returns a typed Result rather than throwing on missing data.
31
+ */
32
+ export const SCALE_BANDS = ["file", "module", "package", "repo", "org"];
33
+ /** Bidirectional commit DAG with ancestor-set memoisation. */
34
+ export class CommitDag {
35
+ parents = new Map();
36
+ ancestorCache = new Map();
37
+ /** Add a commit with its parent list (may be empty for root). */
38
+ addCommit(sha, parents) {
39
+ if (typeof sha !== "string" || sha.length === 0) {
40
+ throw new TypeError(`CommitDag.addCommit: invalid sha "${sha}"`);
41
+ }
42
+ this.parents.set(sha, new Set(parents));
43
+ // Invalidate ancestor cache for sha + descendants (cheap: clear all).
44
+ this.ancestorCache.clear();
45
+ }
46
+ /** All ancestors of sha (including sha itself). Cached. */
47
+ cone(sha) {
48
+ if (this.ancestorCache.has(sha))
49
+ return this.ancestorCache.get(sha);
50
+ const visited = new Set();
51
+ const stack = [sha];
52
+ while (stack.length > 0) {
53
+ const cur = stack.pop();
54
+ if (visited.has(cur))
55
+ continue;
56
+ visited.add(cur);
57
+ const ps = this.parents.get(cur);
58
+ if (ps)
59
+ for (const p of ps)
60
+ if (!visited.has(p))
61
+ stack.push(p);
62
+ }
63
+ this.ancestorCache.set(sha, visited);
64
+ return visited;
65
+ }
66
+ /** Whether ancestor is in the ancestor-cone of descendant. */
67
+ isAncestorOf(ancestor, descendant) {
68
+ return this.cone(descendant).has(ancestor);
69
+ }
70
+ size() { return this.parents.size; }
71
+ }
72
+ export function makeInterval(startMs, endMs) {
73
+ if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) {
74
+ throw new TypeError(`makeInterval: non-finite bounds [${startMs}, ${endMs})`);
75
+ }
76
+ if (endMs < startMs) {
77
+ throw new RangeError(`makeInterval: empty/inverted interval [${startMs}, ${endMs})`);
78
+ }
79
+ return { startMs, endMs };
80
+ }
81
+ export function intervalContains(iv, t) {
82
+ return t >= iv.startMs && t < iv.endMs;
83
+ }
84
+ export function intervalIntersect(a, b) {
85
+ const s = Math.max(a.startMs, b.startMs);
86
+ const e = Math.min(a.endMs, b.endMs);
87
+ return s < e ? { startMs: s, endMs: e } : null;
88
+ }
89
+ /** Ordinal index of a scale band (file=0, module=1, ...). */
90
+ export function scaleIndex(s) { return SCALE_BANDS.indexOf(s); }
91
+ /** Scale band a ⊆ b ⟺ idx(a) ≤ idx(b). */
92
+ export function scaleSubset(a, b) {
93
+ return scaleIndex(a) <= scaleIndex(b);
94
+ }
95
+ export function openSetId(root, time, scale) {
96
+ return root + "@" + time.startMs + "-" + time.endMs + "/" + scale;
97
+ }
98
+ export function makeOpen(root, time, scale) {
99
+ if (typeof root !== "string" || root.length === 0) {
100
+ throw new TypeError(`makeOpen: invalid commit "${root}"`);
101
+ }
102
+ if (!SCALE_BANDS.includes(scale)) {
103
+ throw new TypeError(`makeOpen: invalid scale "${scale}"`);
104
+ }
105
+ return { id: openSetId(root, time, scale), commitConeRoot: root, time, scale };
106
+ }
107
+ /**
108
+ * Intersection of two opens. Uses CommitDag to find the latest-common-
109
+ * ancestor (LCA) of the two roots; if no shared ancestor exists, the
110
+ * intersection is empty (null).
111
+ *
112
+ * open(r1, [s1,e1), b1) ∩ open(r2, [s2,e2), b2)
113
+ * = open(LCA(r1, r2), [max(s1,s2), min(e1,e2)), min(b1, b2))
114
+ *
115
+ * Returns null when either time-intervals are disjoint OR no common
116
+ * ancestor exists in the DAG.
117
+ */
118
+ export function intersectOpens(dag, a, b) {
119
+ const time = intervalIntersect(a.time, b.time);
120
+ if (!time)
121
+ return null;
122
+ // LCA via cone-intersection on the DAG.
123
+ const coneA = dag.cone(a.commitConeRoot);
124
+ const coneB = dag.cone(b.commitConeRoot);
125
+ let lca = null;
126
+ // Walk the shared set; the LCA is the one whose own cone is the
127
+ // largest subset of the intersection (deepest commit).
128
+ let largestConeSize = 0;
129
+ for (const sha of coneA) {
130
+ if (!coneB.has(sha))
131
+ continue;
132
+ const cs = dag.cone(sha).size;
133
+ if (cs > largestConeSize) {
134
+ largestConeSize = cs;
135
+ lca = sha;
136
+ }
137
+ }
138
+ if (lca === null)
139
+ return null;
140
+ const scale = scaleIndex(a.scale) <= scaleIndex(b.scale) ? a.scale : b.scale;
141
+ return makeOpen(lca, time, scale);
142
+ }
143
+ /**
144
+ * Presheaf F: Open(X)ᵒᵖ → Vec_ℝ.
145
+ *
146
+ * Backed by a Map keyed by openSetId. The restriction map ρ_{U⊃V} is
147
+ * a linear operator from ℝ^|claims(U)| → ℝ^|claims(V)|; in this
148
+ * implementation we restrict by intersecting claim sets (vectors
149
+ * indexed by the SAME claim list across opens that contain a
150
+ * specific claim).
151
+ *
152
+ * Errors:
153
+ * - assignSection rejects non-finite values OR length mismatches with
154
+ * the registered claim cardinality.
155
+ * - sectionAt returns Result rather than throwing on missing key.
156
+ */
157
+ export class Presheaf {
158
+ sections = new Map();
159
+ claimsByOpen = new Map();
160
+ /** Register the claim set whose belief values an open carries. */
161
+ registerClaims(open, claims) {
162
+ if (!Array.isArray(claims))
163
+ throw new TypeError("registerClaims: claims must be an array");
164
+ this.claimsByOpen.set(open.id, [...claims]);
165
+ }
166
+ /** Assign a belief vector to an open. Vector length must match registered claim count. */
167
+ assignSection(open, belief) {
168
+ const claims = this.claimsByOpen.get(open.id);
169
+ if (!claims)
170
+ throw new Error(`Presheaf.assignSection: no claims registered for ${open.id}`);
171
+ if (belief.length !== claims.length) {
172
+ throw new RangeError(`Presheaf.assignSection: belief length ${belief.length} ≠ claims ${claims.length} for ${open.id}`);
173
+ }
174
+ for (const v of belief) {
175
+ if (!Number.isFinite(v)) {
176
+ throw new RangeError(`Presheaf.assignSection: non-finite value in belief for ${open.id}`);
177
+ }
178
+ }
179
+ this.sections.set(open.id, [...belief]);
180
+ }
181
+ /** Look up a section. Returns null when missing — never throws. */
182
+ sectionAt(open) {
183
+ return this.sections.get(open.id) ?? null;
184
+ }
185
+ /** Claims known at an open. */
186
+ claimsAt(open) {
187
+ return this.claimsByOpen.get(open.id) ?? [];
188
+ }
189
+ /**
190
+ * Restriction map ρ_{U⊃V}: F(U) → F(V).
191
+ * Implementation: for each claim in V's claim set, find its position
192
+ * in U's claim set and copy the value. Claims in V but not in U get
193
+ * 0 (default-untracked).
194
+ */
195
+ restrict(uOpen, vOpen) {
196
+ const uBelief = this.sectionAt(uOpen);
197
+ if (!uBelief)
198
+ return null;
199
+ const uClaims = this.claimsAt(uOpen);
200
+ const vClaims = this.claimsAt(vOpen);
201
+ if (vClaims.length === 0)
202
+ return [];
203
+ const uIndex = new Map();
204
+ uClaims.forEach((c, i) => uIndex.set(c, i));
205
+ const out = new Array(vClaims.length).fill(0);
206
+ for (let j = 0; j < vClaims.length; j++) {
207
+ const k = uIndex.get(vClaims[j]);
208
+ if (k !== undefined)
209
+ out[j] = uBelief[k] ?? 0;
210
+ }
211
+ return out;
212
+ }
213
+ /** Number of opens with assigned sections. */
214
+ size() { return this.sections.size; }
215
+ }
216
+ //# sourceMapping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,CAAC;IACb,CAAC;IAED,8CAA8C;IAC9C,IAAI,KAAa,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;CAC9C"}
@@ -24,6 +24,8 @@ export * as freeEnergy from "./free_energy.js";
24
24
  export * as wasserstein from "./wasserstein.js";
25
25
  export * as tropical from "./tropical.js";
26
26
  export * as aczel from "./aczel.js";
27
+ export * as baseSpace from "./base_space.js";
28
+ export * as liveUpdate from "./live_update.js";
27
29
  export type { PainEntry, PainTopology, PrimitiveTag } from "./pain_catalog.js";
28
30
  export type { Site, SheafCover, Section0, Section1, SheafResult } from "./sheaf.js";
29
31
  export type { RGState, RGStep, Relevance } from "./rg_flow.js";
@@ -32,4 +34,6 @@ export type { Categorical, ActionCandidate, ActionScoring } from "./free_energy.
32
34
  export type { DiscreteMeasure, CostMatrix } from "./wasserstein.js";
33
35
  export type { TropicalGraph, TropicalPathResult } from "./tropical.js";
34
36
  export type { Hyperset, HypersetNode } from "./aczel.js";
37
+ export type { CommitSha, TimeMs, ScaleBand, OpenSet, TimeInterval, BeliefVector } from "./base_space.js";
38
+ export type { ChronoEvent, EventEmitter, Evidence, ClaimObservation, UpdateInput, UpdateState, UpdateSummary, ChronoSlo } from "./live_update.js";
35
39
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chronosheaf/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;A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AAE,MAAM,mBAAmB,CAAC;AAC/E,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACpF,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC5F,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpF,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzG,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
@@ -24,4 +24,7 @@ export * as freeEnergy from "./free_energy.js";
24
24
  export * as wasserstein from "./wasserstein.js";
25
25
  export * as tropical from "./tropical.js";
26
26
  export * as aczel from "./aczel.js";
27
+ // v2.19.48 — P3 + P4: base space + live ChronoSheafUpdate orchestrator
28
+ export * as baseSpace from "./base_space.js";
29
+ export * as liveUpdate from "./live_update.js";
27
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/chronosheaf/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/chronosheaf/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC,uEAAuE;AACvE,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,221 @@
1
+ /**
2
+ * v2.19.48 — CHRONOSHEAF P4 · live ChronoSheafUpdate algorithm.
3
+ *
4
+ * Spec verbatim (P4):
5
+ *
6
+ * ALGORITHM ChronoSheafUpdate(commit_c, claim_set_C, verifier_set_V)
7
+ *
8
+ * // 1. Localize the change
9
+ * U_local := neighborhood of c in commit_DAG × [t-Δ, t] × [s_min, s_max]
10
+ *
11
+ * // 2. Update presheaf F over U_local
12
+ * for each open U_i in cover(U_local):
13
+ * F(U_i) := solve_local_consistency(C ∩ U_i, V ∩ U_i)
14
+ * via tropical aggregation: stalk_p := ⊕_{e ∈ evidence(p)} confidence(e)
15
+ * if F(U_i) = ∅: // no locally consistent belief
16
+ * emit chronosheaf.local_contradiction(U_i)
17
+ * return
18
+ *
19
+ * // 3. Čech H¹ computation (only over the changed cover — O(|cover|² × dim))
20
+ * cocycle σ := build_pairwise_diff(F, cover)
21
+ * coboundary B := image(δ⁰)
22
+ * H1 := σ / B
23
+ * if H1 ≠ 0:
24
+ * minimal_witness := minimum_l0_norm_representative(H1)
25
+ * emit chronosheaf.h1.alarm(witness=minimal_witness, persistence=t_now)
26
+ *
27
+ * // 4. Update persistence diagram
28
+ * for each H¹ class α detected:
29
+ * if α already tracked: extend lifetime
30
+ * else: birth(α, t_now)
31
+ * for each previously-tracked α now in image δ⁰:
32
+ * death(α, t_now)
33
+ * persistence_diagram.add_or_update(α, birth=b_α, death=d_α)
34
+ *
35
+ * // 5. RG flow — promote scale of long-persistent classes
36
+ * for α with persistence > θ_relevant:
37
+ * mark α as RELEVANT_OPERATOR
38
+ * bubble α up to scale s+1 (org-level constitution)
39
+ *
40
+ * // 6. Free-energy-driven next probe (active inference)
41
+ * candidate_probes := {p_1, ..., p_k} from unresolved cells in cover
42
+ * for each candidate p:
43
+ * G(p) := KL[q_post(z|p) || p_prior(z)] − E[log evidence value of p]
44
+ * probe* := argmin_p G(p)
45
+ * schedule(probe*, deadline = t_now + Δ_probe)
46
+ *
47
+ * // 7. Aczel reflexive update
48
+ * for each reflexive stalk r:
49
+ * if not bisimulates(r, r.previous_self):
50
+ * emit chronosheaf.self_inconsistency(r)
51
+ *
52
+ * Complexity per event: O(k² · d) with k = |cover| ≲ 20, d = |claims| ≲ 100
53
+ * → <5ms per event → live ready.
54
+ *
55
+ * Correctness invariants (proven by composition of the primitives):
56
+ * I1 — Čech consistency: H¹ = 0 across scales ⟹ global section exists.
57
+ * I2 — RG fixed-point: RG-invariant claims = universal truths.
58
+ * I3 — Aczel bisimulation: self-referential beliefs converge.
59
+ *
60
+ * Engineering qualities (user mandate):
61
+ * - Smooth integration with TOKEN GOVERNOR + VACCINE OSMOSIS + GANGLION.
62
+ * - Error handlers + invariant assertions at every layer boundary.
63
+ * - Business-aware: events carry actionable witnesses, not just true/false.
64
+ * - Future-proof: emit hook is pluggable; persistence diagram + RG flow
65
+ * state are externally inspectable for dashboards + alerting.
66
+ * - "Never break the running session" — all primitives are pure-function
67
+ * and never mutate any other Mneme module's state.
68
+ */
69
+ import { CommitDag, Presheaf, type CommitSha, type OpenSet, type ScaleBand } from "./base_space.js";
70
+ import { type Site } from "./sheaf.js";
71
+ import { type ActionCandidate, type ActionScoring } from "./free_energy.js";
72
+ import { type PersistenceDiagram } from "./persistence.js";
73
+ import { type Hyperset } from "./aczel.js";
74
+ export type ChronoEvent = {
75
+ kind: "local_contradiction";
76
+ open: OpenSet;
77
+ reason: string;
78
+ ts: number;
79
+ } | {
80
+ kind: "h1_alarm";
81
+ cover: ReadonlyArray<OpenSet>;
82
+ h1: number;
83
+ witnessPairs: ReadonlyArray<[Site, Site]>;
84
+ ts: number;
85
+ } | {
86
+ kind: "class_birth";
87
+ classId: string;
88
+ ts: number;
89
+ } | {
90
+ kind: "class_death";
91
+ classId: string;
92
+ ts: number;
93
+ livedMs: number;
94
+ } | {
95
+ kind: "promote_relevant";
96
+ classId: string;
97
+ oldScale: ScaleBand;
98
+ newScale: ScaleBand;
99
+ ts: number;
100
+ } | {
101
+ kind: "probe_scheduled";
102
+ probeId: string;
103
+ G: number;
104
+ deadlineMs: number;
105
+ ts: number;
106
+ } | {
107
+ kind: "self_inconsistency";
108
+ stalkId: string;
109
+ reason: string;
110
+ ts: number;
111
+ };
112
+ export type EventEmitter = (event: ChronoEvent) => void;
113
+ export interface Evidence {
114
+ /** Site (sub-open) where evidence lives. */
115
+ site: Site;
116
+ /** Confidence in [0, 1]. */
117
+ confidence: number;
118
+ /** Source verifier label. */
119
+ source: string;
120
+ }
121
+ export interface ClaimObservation {
122
+ /** Stable claim id. */
123
+ claimId: string;
124
+ /** Numeric value the claim asserts (e.g. "tool count" = 711). */
125
+ value: number;
126
+ /** Sites where the claim is observable. */
127
+ sites: ReadonlyArray<Site>;
128
+ }
129
+ export interface UpdateInput {
130
+ /** Commit triggering the update. */
131
+ commit: CommitSha;
132
+ /** Wall-clock time of the event (ms). */
133
+ nowMs: number;
134
+ /** Cover of the localised neighbourhood (sub-opens around the commit). */
135
+ cover: ReadonlyArray<OpenSet>;
136
+ /** Claims observed across the cover. */
137
+ claims: ReadonlyArray<ClaimObservation>;
138
+ /** Per-site evidence (used for tropical confidence aggregation). */
139
+ evidence: ReadonlyArray<Evidence>;
140
+ /** Optional reflexive stalks to verify bisimulation on. */
141
+ reflexiveStalks?: ReadonlyArray<{
142
+ id: string;
143
+ current: Hyperset;
144
+ previous?: Hyperset;
145
+ }>;
146
+ /** Optional candidate probes for free-energy-driven next-action selection. */
147
+ probeCandidates?: ReadonlyArray<ActionCandidate>;
148
+ /** Action scoring (preferred obs + prior z) for free-energy. */
149
+ probeScoring?: ActionScoring;
150
+ /** Tolerance for "persistent enough to bubble up scale" — default 60s. */
151
+ relevantThresholdMs?: number;
152
+ }
153
+ export interface UpdateState {
154
+ /** Persistence diagram of H¹ classes tracked across events. */
155
+ diagram: PersistenceDiagram;
156
+ /** Currently-tracked active classes: id -> {birth, lastSeen}. */
157
+ activeClasses: Map<string, {
158
+ birthMs: number;
159
+ lastSeenMs: number;
160
+ scale: ScaleBand;
161
+ }>;
162
+ /** All emitted events (capped via reservoir if growing unbounded). */
163
+ events: ChronoEvent[];
164
+ /** Promoted "relevant operator" classes. */
165
+ relevantOperators: Set<string>;
166
+ /** Number of update cycles processed. */
167
+ cyclesRun: number;
168
+ }
169
+ export declare function newUpdateState(): UpdateState;
170
+ /**
171
+ * Run ONE ChronoSheafUpdate cycle. Pure-ish: mutates `state` (which the
172
+ * caller owns) + calls `emit` for each event. Never throws — all error
173
+ * paths fall through to event emission so callers can decide whether to
174
+ * abort or continue.
175
+ *
176
+ * Correctness: each step is a pure function from {step's inputs} to
177
+ * {step's outputs}. The composition order is the spec verbatim.
178
+ *
179
+ * Returns a SUMMARY object the caller can act on (e.g. for dashboarding).
180
+ */
181
+ export interface UpdateSummary {
182
+ contradictionDetected: boolean;
183
+ h1: number;
184
+ alarmsFired: number;
185
+ probeSelected: string | null;
186
+ selfInconsistencies: number;
187
+ newBirths: number;
188
+ newDeaths: number;
189
+ newPromotions: number;
190
+ ms: number;
191
+ }
192
+ export declare function chronoSheafUpdate(input: UpdateInput, state: UpdateState, emit: EventEmitter): UpdateSummary;
193
+ /**
194
+ * Build a default cover from a list of "sites" (e.g. registry / CLI /
195
+ * release manifest / MCP schema / tests). Each site becomes its own open
196
+ * at file scale; the time interval is [nowMs - windowMs, nowMs).
197
+ *
198
+ * Convenience for the Mneme self-audit pattern from PAIN-001 / 003 / 005.
199
+ */
200
+ export declare function buildSelfAuditCover(dag: CommitDag, rootCommit: CommitSha, sites: ReadonlyArray<string>, nowMs: number, windowMs?: number, scale?: ScaleBand): OpenSet[];
201
+ /**
202
+ * Compute the SLO summary across a window of update cycles. Used by
203
+ * dashboards to display "CHRONOSHEAF: 7 contradictions caught in last
204
+ * 24h, 2 still active, mean detect-to-death = 18min".
205
+ */
206
+ export interface ChronoSlo {
207
+ totalCycles: number;
208
+ contradictionsDetected: number;
209
+ activeContradictions: number;
210
+ meanLivedMs: number;
211
+ promotedRelevant: number;
212
+ selfInconsistencies: number;
213
+ }
214
+ export declare function chronoSlo(state: UpdateState): ChronoSlo;
215
+ /** Hard cap: enforce O(k² · d) by rejecting covers that would blow the budget. */
216
+ export declare function preflightBudget(input: UpdateInput, maxCoverSize?: number, maxClaims?: number): {
217
+ ok: boolean;
218
+ reason?: string;
219
+ };
220
+ export { Presheaf };
221
+ //# sourceMappingURL=live_update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live_update.d.ts","sourceRoot":"","sources":["../../src/chronosheaf/live_update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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