@mneme-ai/core 2.19.46 → 2.19.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/chronosheaf/aczel.d.ts +72 -0
  2. package/dist/chronosheaf/aczel.d.ts.map +1 -0
  3. package/dist/chronosheaf/aczel.js +161 -0
  4. package/dist/chronosheaf/aczel.js.map +1 -0
  5. package/dist/chronosheaf/chronosheaf.test.d.ts +12 -0
  6. package/dist/chronosheaf/chronosheaf.test.d.ts.map +1 -0
  7. package/dist/chronosheaf/chronosheaf.test.js +360 -0
  8. package/dist/chronosheaf/chronosheaf.test.js.map +1 -0
  9. package/dist/chronosheaf/free_energy.d.ts +109 -0
  10. package/dist/chronosheaf/free_energy.d.ts.map +1 -0
  11. package/dist/chronosheaf/free_energy.js +142 -0
  12. package/dist/chronosheaf/free_energy.js.map +1 -0
  13. package/dist/chronosheaf/index.d.ts +35 -0
  14. package/dist/chronosheaf/index.d.ts.map +1 -0
  15. package/dist/chronosheaf/index.js +27 -0
  16. package/dist/chronosheaf/index.js.map +1 -0
  17. package/dist/chronosheaf/pain_catalog.d.ts +50 -0
  18. package/dist/chronosheaf/pain_catalog.d.ts.map +1 -0
  19. package/dist/chronosheaf/pain_catalog.js +108 -0
  20. package/dist/chronosheaf/pain_catalog.js.map +1 -0
  21. package/dist/chronosheaf/persistence.d.ts +79 -0
  22. package/dist/chronosheaf/persistence.d.ts.map +1 -0
  23. package/dist/chronosheaf/persistence.js +173 -0
  24. package/dist/chronosheaf/persistence.js.map +1 -0
  25. package/dist/chronosheaf/rg_flow.d.ts +81 -0
  26. package/dist/chronosheaf/rg_flow.d.ts.map +1 -0
  27. package/dist/chronosheaf/rg_flow.js +146 -0
  28. package/dist/chronosheaf/rg_flow.js.map +1 -0
  29. package/dist/chronosheaf/sheaf.d.ts +116 -0
  30. package/dist/chronosheaf/sheaf.d.ts.map +1 -0
  31. package/dist/chronosheaf/sheaf.js +278 -0
  32. package/dist/chronosheaf/sheaf.js.map +1 -0
  33. package/dist/chronosheaf/tropical.d.ts +98 -0
  34. package/dist/chronosheaf/tropical.d.ts.map +1 -0
  35. package/dist/chronosheaf/tropical.js +140 -0
  36. package/dist/chronosheaf/tropical.js.map +1 -0
  37. package/dist/chronosheaf/wasserstein.d.ts +75 -0
  38. package/dist/chronosheaf/wasserstein.d.ts.map +1 -0
  39. package/dist/chronosheaf/wasserstein.js +189 -0
  40. package/dist/chronosheaf/wasserstein.js.map +1 -0
  41. package/dist/cosmic/aurelian_v1947.test.d.ts +2 -0
  42. package/dist/cosmic/aurelian_v1947.test.d.ts.map +1 -0
  43. package/dist/cosmic/aurelian_v1947.test.js +34 -0
  44. package/dist/cosmic/aurelian_v1947.test.js.map +1 -0
  45. package/dist/index.d.ts +1 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +8 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/whats_new.d.ts.map +1 -1
  50. package/dist/whats_new.js +8 -0
  51. package/dist/whats_new.js.map +1 -1
  52. package/package.json +1 -1
@@ -0,0 +1,173 @@
1
+ /**
2
+ * v2.19.47 — CHRONOSHEAF P2-c · persistent homology.
3
+ *
4
+ * Math foundation (Edelsbrunner / Carlsson, ~2002-2008):
5
+ *
6
+ * A filtration is a nested sequence of simplicial complexes
7
+ *
8
+ * ∅ = K_0 ⊆ K_1 ⊆ K_2 ⊆ … ⊆ K_n.
9
+ *
10
+ * For each k, the inclusion K_i ↪ K_j induces a map
11
+ * H_k(K_i) → H_k(K_j). A class c ∈ H_k IS BORN at filtration b if
12
+ * it appears in K_b but not in K_{b−1}, and DIES at d > b if it
13
+ * becomes a boundary in K_d. The persistence pair (b, d) with
14
+ * pers(b, d) = d − b measures structural robustness; long-lived
15
+ * features survive coarse-graining + noise and represent
16
+ * real structure, while short-lived ones are noise.
17
+ *
18
+ * The Persistence Diagram (or Bar Code) PD_k = {(b, d) : (b, d)
19
+ * is a persistence pair} is the canonical invariant. It satisfies
20
+ * a stability theorem (Cohen-Steiner / Edelsbrunner / Harer 2007):
21
+ * bottleneck distance W_∞(PD(f), PD(g)) ≤ ‖f − g‖_∞.
22
+ *
23
+ * AI-memory mapping (PAIN-002 scale-mismatch + PAIN-003 drift-surface):
24
+ *
25
+ * We filter the tool-catalog over releases: K_i = the catalog at
26
+ * release v_i, with each tool name as a 0-simplex and each
27
+ * "is registered" relation as a 1-simplex. A persistent 0-class
28
+ * = a tool present continuously across releases. A 0-class that
29
+ * dies = a tool removed/renamed. A 1-class = a co-registration
30
+ * pattern.
31
+ *
32
+ * The persistence diagram answers "which facts survived the last
33
+ * N releases" in a single picture, and bottleneck distance gives a
34
+ * rigorous "how much did the catalog drift" metric for PAIN-003.
35
+ *
36
+ * Implementation: standard column-reduction algorithm (Zomorodian-
37
+ * Carlsson 2005), over ℝ coefficients. We implement the 0-dim
38
+ * variant (most useful for catalog facts) + a generic kth-dim wrapper.
39
+ */
40
+ /**
41
+ * Compute 0-dimensional persistent homology from a vertex filtration.
42
+ * Algorithm: Union-Find with elder rule (Eldership: when two components
43
+ * merge, the YOUNGER one dies at the merge filtration value).
44
+ */
45
+ export function persistentHomology0(filtration) {
46
+ const pairs = [];
47
+ const parent = new Map();
48
+ const birthTime = new Map();
49
+ let maxFinite = 0;
50
+ let essential = 0;
51
+ const find = (x) => {
52
+ let r = x;
53
+ while (parent.get(r) !== r)
54
+ r = parent.get(r);
55
+ let c = x;
56
+ while (c !== r) {
57
+ const n = parent.get(c);
58
+ parent.set(c, r);
59
+ c = n;
60
+ }
61
+ return r;
62
+ };
63
+ for (const step of filtration) {
64
+ // First add all 0-simplices at this filtration (vertices).
65
+ for (const simplex of step.add) {
66
+ if (simplex.length === 1) {
67
+ const v = simplex[0];
68
+ if (!parent.has(v)) {
69
+ parent.set(v, v);
70
+ birthTime.set(v, step.value);
71
+ }
72
+ }
73
+ }
74
+ // Then process 1-simplices = edges (each merges 0-components or creates a 1-class).
75
+ for (const simplex of step.add) {
76
+ if (simplex.length !== 2)
77
+ continue;
78
+ const a = simplex[0];
79
+ const b = simplex[1];
80
+ // Edge implicitly adds endpoints if missing.
81
+ for (const v of [a, b]) {
82
+ if (!parent.has(v)) {
83
+ parent.set(v, v);
84
+ birthTime.set(v, step.value);
85
+ }
86
+ }
87
+ const ra = find(a);
88
+ const rb = find(b);
89
+ if (ra === rb)
90
+ continue;
91
+ // Merge components — younger dies (elder rule).
92
+ const ta = birthTime.get(ra) ?? step.value;
93
+ const tb = birthTime.get(rb) ?? step.value;
94
+ const youngerRoot = ta > tb ? ra : rb;
95
+ const elderRoot = ta > tb ? rb : ra;
96
+ const deathTime = step.value;
97
+ const birthValue = Math.max(ta, tb);
98
+ parent.set(youngerRoot, elderRoot);
99
+ pairs.push({
100
+ dim: 0, birth: birthValue, death: deathTime,
101
+ persistence: deathTime - birthValue,
102
+ birthSimplex: [youngerRoot], deathSimplex: [a, b],
103
+ });
104
+ if (deathTime - birthValue > maxFinite)
105
+ maxFinite = deathTime - birthValue;
106
+ }
107
+ }
108
+ // Surviving components → essential classes (death = +∞).
109
+ const roots = new Set();
110
+ for (const v of parent.keys())
111
+ roots.add(find(v));
112
+ for (const r of roots) {
113
+ essential++;
114
+ pairs.push({
115
+ dim: 0, birth: birthTime.get(r) ?? 0, death: Infinity,
116
+ persistence: Infinity, birthSimplex: [r],
117
+ });
118
+ }
119
+ return {
120
+ pairs,
121
+ maxFinitePersistence: maxFinite,
122
+ essentialByDim: { 0: essential },
123
+ };
124
+ }
125
+ /**
126
+ * Bottleneck distance between two persistence diagrams (1D matching).
127
+ * Uses Wasserstein-∞ approximation via greedy nearest-neighbour matching
128
+ * (good enough for the AI-memory PAIN-003 drift use case where diagrams
129
+ * are small). Bottleneck distance W_∞ = max_pair |Δb| ∨ |Δd|.
130
+ */
131
+ export function bottleneckDistance(a, b) {
132
+ // Take only finite-persistence pairs for matching; essential classes
133
+ // count toward the "infinity diagonal".
134
+ const ap = a.pairs.filter((p) => isFinite(p.persistence));
135
+ const bp = b.pairs.filter((p) => isFinite(p.persistence));
136
+ const matched = new Set();
137
+ let worst = 0;
138
+ for (const p1 of ap) {
139
+ let bestIdx = -1;
140
+ let bestDist = Infinity;
141
+ for (let i = 0; i < bp.length; i++) {
142
+ if (matched.has(i))
143
+ continue;
144
+ const p2 = bp[i];
145
+ const d = Math.max(Math.abs(p1.birth - p2.birth), Math.abs(p1.death - p2.death));
146
+ if (d < bestDist) {
147
+ bestDist = d;
148
+ bestIdx = i;
149
+ }
150
+ }
151
+ if (bestIdx >= 0) {
152
+ matched.add(bestIdx);
153
+ if (bestDist > worst)
154
+ worst = bestDist;
155
+ }
156
+ else {
157
+ // Unmatched — distance to diagonal = persistence/2.
158
+ const diag = p1.persistence / 2;
159
+ if (diag > worst)
160
+ worst = diag;
161
+ }
162
+ }
163
+ // Account for unmatched pairs in b.
164
+ for (let i = 0; i < bp.length; i++) {
165
+ if (matched.has(i))
166
+ continue;
167
+ const diag = bp[i].persistence / 2;
168
+ if (diag > worst)
169
+ worst = diag;
170
+ }
171
+ return worst;
172
+ }
173
+ //# sourceMappingURL=persistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../src/chronosheaf/persistence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AA+BH;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAyC;IAC3E,MAAM,KAAK,GAAsB,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,MAAM,IAAI,GAAG,CAAC,CAAS,EAAU,EAAE;QACjC,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,OAAO,MAAM,CAAC,GAAG,CAAC,CA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,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * v2.19.47 — CHRONOSHEAF P2-b · Renormalization Group flow.
3
+ *
4
+ * Math foundation (Wilson / Kadanoff, 1971):
5
+ *
6
+ * For a scale s ∈ ℝ⁺ and a Hamiltonian (or generic "system state")
7
+ * H_s, the RG operator R_b shifts the scale by a factor b:
8
+ *
9
+ * H_{s + log b} = R_b · H_s, R_b R_{b'} = R_{bb'}.
10
+ *
11
+ * Fixed points H* satisfying R_b H* = H* for some b are
12
+ * SCALE-INVARIANT — they survive every coarse-graining step.
13
+ * Operators (degrees of freedom) split into RELEVANT (eigenvalue
14
+ * |λ| > 1, grow under flow → matter at every scale), MARGINAL
15
+ * (|λ| = 1, neither grow nor decay), IRRELEVANT (|λ| < 1, vanish
16
+ * under flow → noise that washes out).
17
+ *
18
+ * AI-memory mapping (PAIN-002 scale-mismatch + PAIN-003 drift-surface):
19
+ *
20
+ * A coarse-graining is an aggregation step on tool catalog data:
21
+ *
22
+ * state s_0 = full catalog list (~700 tool names)
23
+ * R_2 s_0 = family-grouped (governor/fossil/...) (~20 groups)
24
+ * R_2² s_0 = category-grouped (memory/audit/meta...) (9 cats)
25
+ * R_2³ s_0 = single "all tools" scalar (1 number)
26
+ *
27
+ * Fixed points of this flow are descriptors that DON'T change as we
28
+ * zoom out — they're the right-detail-level for any consumer.
29
+ * The skinny capabilities tool from v2.19.41 is a hand-rolled
30
+ * RG fixed point at scale 2 (category-grouped); CHRONOSHEAF lets
31
+ * callers pick any scale by passing `b`.
32
+ *
33
+ * Implementation: linear coarse-graining on vector-valued states,
34
+ * eigendecomposition via power iteration for the relevance classifier.
35
+ * Pure-function; no fancy numerics required for the AI-memory use case
36
+ * because catalog states are small (≤ 1000 dims).
37
+ */
38
+ export interface RGState {
39
+ /** Numeric state vector at scale s. */
40
+ vector: number[];
41
+ /** Scale exponent (log_b of physical scale). */
42
+ scale: number;
43
+ /** Optional label for human inspection. */
44
+ label?: string;
45
+ }
46
+ export interface RGStep {
47
+ /** From-scale → to-scale (factor b). */
48
+ factor: number;
49
+ /** Aggregator that merges groups of size `factor` into one component. */
50
+ aggregator: "mean" | "sum" | "max" | "min";
51
+ }
52
+ /** Apply a single RG step: aggregate groups of `factor` adjacent components. */
53
+ export declare function rgStep(s: RGState, step: RGStep): RGState;
54
+ /** Iterate the RG flow until the state stops changing (fixed point) or N steps. */
55
+ export declare function rgFixedPoint(s0: RGState, step: RGStep, maxIter?: number, tol?: number): {
56
+ state: RGState;
57
+ iterations: number;
58
+ reachedFixedPoint: boolean;
59
+ };
60
+ /**
61
+ * Classify operators by their behaviour under the linearised RG flow.
62
+ * We treat the state vector as a perturbation around the fixed point and
63
+ * estimate the leading eigenvalue via power iteration on (R_b)' (linear
64
+ * approximation).
65
+ */
66
+ export type Relevance = "relevant" | "marginal" | "irrelevant";
67
+ export declare function classifyRelevance(s0: RGState, step: RGStep, perturbation: number[], iterations?: number): {
68
+ eigenvalue: number;
69
+ class: Relevance;
70
+ };
71
+ /**
72
+ * AI-memory specific: given a catalog snapshot (one number per tool —
73
+ * e.g. recent invocation count), find the SMALLEST scale b at which
74
+ * coarse-graining yields ≤ targetSize components. Used by the skinny-
75
+ * capabilities surface to pick the right family-grouping automatically.
76
+ */
77
+ export declare function smallestScaleForBudget(s0: RGState, step: RGStep, targetSize: number, maxIter?: number): {
78
+ state: RGState;
79
+ iterations: number;
80
+ };
81
+ //# sourceMappingURL=rg_flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rg_flow.d.ts","sourceRoot":"","sources":["../../src/chronosheaf/rg_flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,WAAW,OAAO;IACtB,uCAAuC;IACvC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,MAAM;IACrB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,UAAU,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CAC5C;AAED,gFAAgF;AAChF,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAmBxD;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,SAAK,EAAE,GAAG,SAAQ,GAAG;IAClF,KAAK,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,OAAO,CAAC;CAChE,CAaA;AAQD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAE/D,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,OAAO,EACX,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EAAE,EACtB,UAAU,SAAK,GACd;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAwB1C;AAQD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,OAAO,EACX,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,SAAK,GACX;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAOxC"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * v2.19.47 — CHRONOSHEAF P2-b · Renormalization Group flow.
3
+ *
4
+ * Math foundation (Wilson / Kadanoff, 1971):
5
+ *
6
+ * For a scale s ∈ ℝ⁺ and a Hamiltonian (or generic "system state")
7
+ * H_s, the RG operator R_b shifts the scale by a factor b:
8
+ *
9
+ * H_{s + log b} = R_b · H_s, R_b R_{b'} = R_{bb'}.
10
+ *
11
+ * Fixed points H* satisfying R_b H* = H* for some b are
12
+ * SCALE-INVARIANT — they survive every coarse-graining step.
13
+ * Operators (degrees of freedom) split into RELEVANT (eigenvalue
14
+ * |λ| > 1, grow under flow → matter at every scale), MARGINAL
15
+ * (|λ| = 1, neither grow nor decay), IRRELEVANT (|λ| < 1, vanish
16
+ * under flow → noise that washes out).
17
+ *
18
+ * AI-memory mapping (PAIN-002 scale-mismatch + PAIN-003 drift-surface):
19
+ *
20
+ * A coarse-graining is an aggregation step on tool catalog data:
21
+ *
22
+ * state s_0 = full catalog list (~700 tool names)
23
+ * R_2 s_0 = family-grouped (governor/fossil/...) (~20 groups)
24
+ * R_2² s_0 = category-grouped (memory/audit/meta...) (9 cats)
25
+ * R_2³ s_0 = single "all tools" scalar (1 number)
26
+ *
27
+ * Fixed points of this flow are descriptors that DON'T change as we
28
+ * zoom out — they're the right-detail-level for any consumer.
29
+ * The skinny capabilities tool from v2.19.41 is a hand-rolled
30
+ * RG fixed point at scale 2 (category-grouped); CHRONOSHEAF lets
31
+ * callers pick any scale by passing `b`.
32
+ *
33
+ * Implementation: linear coarse-graining on vector-valued states,
34
+ * eigendecomposition via power iteration for the relevance classifier.
35
+ * Pure-function; no fancy numerics required for the AI-memory use case
36
+ * because catalog states are small (≤ 1000 dims).
37
+ */
38
+ /** Apply a single RG step: aggregate groups of `factor` adjacent components. */
39
+ export function rgStep(s, step) {
40
+ const b = Math.max(1, Math.floor(step.factor));
41
+ if (b <= 1)
42
+ return { ...s, scale: s.scale + 1 };
43
+ const out = [];
44
+ for (let i = 0; i < s.vector.length; i += b) {
45
+ const block = s.vector.slice(i, Math.min(i + b, s.vector.length));
46
+ let v;
47
+ switch (step.aggregator) {
48
+ case "sum":
49
+ v = block.reduce((a, x) => a + x, 0);
50
+ break;
51
+ case "max":
52
+ v = Math.max(...block);
53
+ break;
54
+ case "min":
55
+ v = Math.min(...block);
56
+ break;
57
+ case "mean":
58
+ default:
59
+ v = block.reduce((a, x) => a + x, 0) / block.length;
60
+ break;
61
+ }
62
+ out.push(v);
63
+ }
64
+ const result = { vector: out, scale: s.scale + Math.log2(b) };
65
+ if (s.label !== undefined)
66
+ result.label = s.label;
67
+ return result;
68
+ }
69
+ /** Iterate the RG flow until the state stops changing (fixed point) or N steps. */
70
+ export function rgFixedPoint(s0, step, maxIter = 50, tol = 1e-12) {
71
+ let cur = s0;
72
+ for (let i = 0; i < maxIter; i++) {
73
+ const next = rgStep(cur, step);
74
+ if (vecClose(cur.vector, next.vector, tol)) {
75
+ return { state: next, iterations: i + 1, reachedFixedPoint: true };
76
+ }
77
+ if (next.vector.length <= 1) {
78
+ return { state: next, iterations: i + 1, reachedFixedPoint: true };
79
+ }
80
+ cur = next;
81
+ }
82
+ return { state: cur, iterations: maxIter, reachedFixedPoint: false };
83
+ }
84
+ function vecClose(a, b, tol) {
85
+ if (a.length !== b.length)
86
+ return false;
87
+ for (let i = 0; i < a.length; i++)
88
+ if (Math.abs((a[i] ?? 0) - (b[i] ?? 0)) > tol)
89
+ return false;
90
+ return true;
91
+ }
92
+ export function classifyRelevance(s0, step, perturbation, iterations = 20) {
93
+ // Apply RG `iterations` times to the perturbation only; measure growth.
94
+ let cur = [...perturbation];
95
+ let firstNorm = vecNorm(cur);
96
+ if (firstNorm < 1e-15)
97
+ return { eigenvalue: 0, class: "irrelevant" };
98
+ void s0; // RG flow linearised about fixed point — only step shape matters
99
+ let lastNorm = firstNorm;
100
+ let lastRatio = 1;
101
+ for (let k = 0; k < iterations; k++) {
102
+ const next = rgStep({ vector: cur, scale: 0 }, step).vector;
103
+ const nNorm = vecNorm(next);
104
+ if (nNorm < 1e-15) {
105
+ lastRatio = 0;
106
+ break;
107
+ }
108
+ lastRatio = nNorm / lastNorm;
109
+ cur = next;
110
+ lastNorm = nNorm;
111
+ if (cur.length <= 1)
112
+ break;
113
+ }
114
+ // Eigenvalue λ ≈ growth ratio per iteration.
115
+ const eigenvalue = lastRatio;
116
+ let cls;
117
+ if (eigenvalue > 1 + 1e-3)
118
+ cls = "relevant";
119
+ else if (eigenvalue < 1 - 1e-3)
120
+ cls = "irrelevant";
121
+ else
122
+ cls = "marginal";
123
+ return { eigenvalue, class: cls };
124
+ }
125
+ function vecNorm(v) {
126
+ let s = 0;
127
+ for (const x of v)
128
+ s += x * x;
129
+ return Math.sqrt(s);
130
+ }
131
+ /**
132
+ * AI-memory specific: given a catalog snapshot (one number per tool —
133
+ * e.g. recent invocation count), find the SMALLEST scale b at which
134
+ * coarse-graining yields ≤ targetSize components. Used by the skinny-
135
+ * capabilities surface to pick the right family-grouping automatically.
136
+ */
137
+ export function smallestScaleForBudget(s0, step, targetSize, maxIter = 50) {
138
+ let cur = s0;
139
+ for (let i = 0; i < maxIter; i++) {
140
+ if (cur.vector.length <= targetSize)
141
+ return { state: cur, iterations: i };
142
+ cur = rgStep(cur, step);
143
+ }
144
+ return { state: cur, iterations: maxIter };
145
+ }
146
+ //# sourceMappingURL=rg_flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rg_flow.js","sourceRoot":"","sources":["../../src/chronosheaf/rg_flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAkBH,gFAAgF;AAChF,MAAM,UAAU,MAAM,CAAC,CAAU,EAAE,IAAY;IAC7C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;IAChD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,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AAE,CAAC;AACpC,CAAC;AAED,SAAS,OAAO,CAAC,CAAW;IAC1B,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,CAAC,IAAI,CAAC;QAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,EAAW,EACX,IAAY,EACZ,UAAkB,EAClB,OAAO,GAAG,EAAE;IAEZ,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,UAAU;YAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAC1E,GAAG,GAAG,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * v2.19.47 — CHRONOSHEAF P2-a · sheaf cohomology over ℝ-valued presheaves.
3
+ *
4
+ * Math foundation (Leray / Grothendieck / Čech):
5
+ *
6
+ * For a base space X (we model as a finite set of "sites"), an open
7
+ * cover U = {U₀, U₁, ...}, and a presheaf F : Open(X)ᵒᵖ → Vec_ℝ,
8
+ * the Čech complex is
9
+ *
10
+ * Č^p(U, F) = ⊕_{i₀<…<i_p} F(U_{i₀} ∩ … ∩ U_{i_p})
11
+ *
12
+ * with coboundary
13
+ *
14
+ * (δσ)_{i₀…i_{p+1}} = Σ_{k=0}^{p+1} (−1)^k · ρ(σ_{i₀…î_k…i_{p+1}})
15
+ *
16
+ * and the p-th Čech cohomology
17
+ *
18
+ * H^p(U, F) = ker δ^p / im δ^{p−1}.
19
+ *
20
+ * We focus on H¹: dim H¹(U, F) = (number of independent 1-cocycles)
21
+ * − (number of independent 1-coboundaries). H¹ ≠ 0 ⟺ there exist
22
+ * local sections that agree pairwise on overlaps but cannot be glued
23
+ * into a single global section — the canonical "local OK, global
24
+ * contradiction" signal CHRONOSHEAF chases.
25
+ *
26
+ * Implementation strategy (performance + accuracy):
27
+ *
28
+ * We restrict to ℝ-valued (scalar) sections per site — sufficient
29
+ * for the AI-memory use case where each verifier returns a single
30
+ * number per overlap (a "claim value"). For overlaps the restriction
31
+ * map is the identity on ℝ.
32
+ *
33
+ * The δ⁰ matrix is the signed incidence of pairs to sites:
34
+ *
35
+ * δ⁰[ij, k] = +1 if k == j, −1 if k == i, 0 otherwise
36
+ *
37
+ * For overlaps with NO triple overlap (most code-base covers), every
38
+ * 1-cochain is automatically a cocycle (ker δ¹ = whole space), so
39
+ *
40
+ * dim H¹ = E − rank(δ⁰)
41
+ *
42
+ * where E is the number of pairs and rank(δ⁰) = N − c (vertices N
43
+ * minus connected components c of the nerve 1-skeleton). This
44
+ * reduces to a graph-theoretic computation that runs in O(N + E).
45
+ *
46
+ * When triple overlaps exist we compute δ¹ explicitly and rank-reduce
47
+ * via integer Gaussian elimination (O(min(E,T)² · max(E,T))) — fast
48
+ * enough for a Mneme catalog cover of a few hundred sites.
49
+ *
50
+ * Composes with PAIN-001 (time-direction), PAIN-004 (self-reference
51
+ * via reflexive cover), PAIN-005 (interface-coherence as global section).
52
+ */
53
+ export type Site = string;
54
+ export interface SheafCover {
55
+ /** Sites (open sets) — identified by string keys. */
56
+ sites: ReadonlyArray<Site>;
57
+ /** Pairwise overlaps as unordered pairs [i, j] with i < j (by sites index). */
58
+ overlaps: ReadonlyArray<[Site, Site]>;
59
+ /** Optional triple overlaps [i, j, k] with i < j < k. */
60
+ triples?: ReadonlyArray<[Site, Site, Site]>;
61
+ }
62
+ /** Section on each site (the 0-cochain): site → real value. */
63
+ export type Section0 = ReadonlyMap<Site, number>;
64
+ /** Section on each overlap (the 1-cochain): pair-key → real value. */
65
+ export type Section1 = ReadonlyMap<string, number>;
66
+ export interface SheafResult {
67
+ /** Number of 1-cochains (= |overlaps|). */
68
+ cochainDim: number;
69
+ /** rank δ⁰ — dim image of 0→1 coboundary. */
70
+ rankDelta0: number;
71
+ /** Estimated dim ker δ¹. With no triples = |overlaps|. */
72
+ kerDelta1: number;
73
+ /** dim H¹ = ker δ¹ − im δ⁰. ≥0 by construction. */
74
+ h1: number;
75
+ /** True when H¹ > 0 — pairwise OK but globally inconsistent. */
76
+ hasObstruction: boolean;
77
+ /** Minimal witnesses: 1-cochains that are cocycles but not coboundaries. */
78
+ obstructions: Array<{
79
+ pair: [Site, Site];
80
+ value: number;
81
+ }>;
82
+ /** Connected components of the nerve 1-skeleton (auxiliary). */
83
+ components: number;
84
+ }
85
+ /**
86
+ * Compute δ⁰(σ) for a 0-cochain σ — returns 1-cochain on every overlap.
87
+ * (δ⁰σ)_{ij} = σ_j − σ_i.
88
+ */
89
+ export declare function delta0(cover: SheafCover, sigma0: Section0): Section1;
90
+ /**
91
+ * Compute δ¹(σ) for a 1-cochain σ — returns 2-cochain on every triple.
92
+ * (δ¹σ)_{ijk} = σ_{jk} − σ_{ik} + σ_{ij}.
93
+ */
94
+ export declare function delta1(cover: SheafCover, sigma1: Section1): Map<string, number>;
95
+ /** Check the cocycle condition δ¹σ = 0 on all triples. */
96
+ export declare function isCocycle(cover: SheafCover, sigma1: Section1, tol?: number): boolean;
97
+ /**
98
+ * Compute dim H¹(U, F) by reducing to graph connectivity when triples
99
+ * are absent + Gaussian elimination when they're present.
100
+ */
101
+ export declare function cohomologyH1(cover: SheafCover): SheafResult;
102
+ /**
103
+ * Given a presheaf assignment (each site → numeric "claim value"), check
104
+ * whether the implied pairwise differences glue: returns the same
105
+ * SheafResult plus the gluing-residual vector.
106
+ *
107
+ * residual_{ij} = (claim_j - claim_i) restricted to U_i ∩ U_j
108
+ *
109
+ * If H¹ = 0, the residual lies in im δ⁰ → there exists a global section
110
+ * (effectively the user's claim values are all consistent). If H¹ > 0,
111
+ * the residual carries a non-trivial cocycle component.
112
+ */
113
+ export declare function gluingDiagnostic(cover: SheafCover, claimPerSite: Section0): SheafResult & {
114
+ residual: Section1;
115
+ };
116
+ //# sourceMappingURL=sheaf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheaf.d.ts","sourceRoot":"","sources":["../../src/chronosheaf/sheaf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,qDAAqD;IACrD,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3B,+EAA+E;IAC/E,QAAQ,EAAE,aAAa,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACtC,yDAAyD;IACzD,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;CAC7C;AAED,+DAA+D;AAC/D,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAEjD,sEAAsE;AACtE,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,cAAc,EAAE,OAAO,CAAC;IACxB,4EAA4E;IAC5E,YAAY,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,CAAC,IAAI,EAAE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