pi-mega-compact 0.20.11 → 0.20.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/vector-cortex-breakers.js +31 -0
- package/dist/config/vector-cortex.js +17 -26
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/api-contracts/vector-cortex-cache.js +11 -0
- package/dist/extensions/dashboard-server/route-dispatch.js +6 -0
- package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-crystals.js +65 -0
- package/dist/src/config/vector-cortex-breakers.js +31 -0
- package/dist/src/config/vector-cortex.js +17 -26
- package/dist/src/config.js +1 -1
- package/dist/src/vector-cortex/cache/_crystal-fixture.js +71 -0
- package/dist/src/vector-cortex/cache/crystal-emit.js +76 -0
- package/dist/src/vector-cortex/cache/crystal.js +201 -0
- package/dist/src/vector-cortex/cache/store.js +196 -0
- package/dist/vector-cortex/cache/_crystal-fixture.js +71 -0
- package/dist/vector-cortex/cache/crystal-emit.js +76 -0
- package/dist/vector-cortex/cache/crystal.js +201 -0
- package/dist/vector-cortex/cache/store.js +196 -0
- package/dist/vector-cortex/cache/types.js +73 -0
- package/extensions/dashboard-client/dist/assets/{AreaChart-BDMjyRQp.js → AreaChart-CB-U7ViX.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-BDMjyRQp.js.map → AreaChart-CB-U7ViX.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-CqzPzOkj.js → BarChart-DnLw0fxA.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-CqzPzOkj.js.map → BarChart-DnLw0fxA.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-Bo8SH9q8.js → CacheTab-CjyTVDiP.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-Bo8SH9q8.js.map → CacheTab-CjyTVDiP.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-DIEs6zC-.js → EventsTab-Bz3QEWam.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-DIEs6zC-.js.map → EventsTab-Bz3QEWam.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-3a8IjwIK.js → HealthTab-CUylEvEY.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-3a8IjwIK.js.map → HealthTab-CUylEvEY.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-CdKwAcXo.js → MaintenanceTab-Cz_hj_E7.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-CdKwAcXo.js.map → MaintenanceTab-Cz_hj_E7.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-D2hHuNj-.js → MemoryMapTab-Dh8brIR1.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-D2hHuNj-.js.map → MemoryMapTab-Dh8brIR1.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-CFhIhqrr.js → MetricsTab-CkqSXc6e.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-CFhIhqrr.js.map → MetricsTab-CkqSXc6e.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-Dzp5ZoiA.js → OverviewTab-DGbJcx6d.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-Dzp5ZoiA.js.map → OverviewTab-DGbJcx6d.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-CFJT9mDR.js → ReposTab-BawS3nfF.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-CFJT9mDR.js.map → ReposTab-BawS3nfF.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-BhP1z6_y.js → SessionsTab-CUVnmYks.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-BhP1z6_y.js.map → SessionsTab-CUVnmYks.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SetupTab-2Glh7MKk.js → SetupTab-cxTuyZNk.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SetupTab-2Glh7MKk.js.map → SetupTab-cxTuyZNk.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DmwBDhkw.js → TimeSavedCard-Cv5SENkE.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DmwBDhkw.js.map → TimeSavedCard-Cv5SENkE.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-CYIaOUUZ.js → TurnsTab-yl6BBG_F.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-CYIaOUUZ.js.map → TurnsTab-yl6BBG_F.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-94fqVjat.js +2 -0
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-94fqVjat.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{WikiTab-CP-JEd17.js → WikiTab-DKv-0xCQ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-CP-JEd17.js.map → WikiTab-DKv-0xCQ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-B1RhLsGs.js → button-CVPrO4UU.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-B1RhLsGs.js.map → button-CVPrO4UU.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-BLPT2-8G.js → card-BFLnQJEo.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-BLPT2-8G.js.map → card-BFLnQJEo.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DVOMJzL2.js → generateCategoricalChart-B-IUoLd1.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DVOMJzL2.js.map → generateCategoricalChart-B-IUoLd1.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-CuLdiHRl.js → index-Do749WlW.js} +3 -3
- package/extensions/dashboard-client/dist/assets/{index-CuLdiHRl.js.map → index-Do749WlW.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{switch-C5tqzhcl.js → switch-3uFnZmtq.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-C5tqzhcl.js.map → switch-3uFnZmtq.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-HcM6W2Yl.js → toggle-C1rYLeXe.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-HcM6W2Yl.js.map → toggle-C1rYLeXe.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-BtWUs2kL.js → useSSE-D1qzLzgR.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-BtWUs2kL.js.map → useSSE-D1qzLzgR.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/api/vector-cortex.ts +9 -0
- package/extensions/dashboard-client/src/tabs/VectorCortexCrystalsCard.tsx +46 -0
- package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +8 -0
- package/extensions/dashboard-client/src/types/vector-cortex.ts +20 -0
- package/extensions/dashboard-server/api-contracts/vector-cortex-cache.ts +53 -0
- package/extensions/dashboard-server/route-dispatch.ts +5 -0
- package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +6 -0
- package/extensions/dashboard-server/routes-vector-cortex-crystals.ts +74 -0
- package/package.json +1 -1
- package/src/config/vector-cortex-breakers.ts +32 -0
- package/src/config/vector-cortex.ts +31 -26
- package/src/config.ts +1 -0
- package/src/vector-cortex/cache/_crystal-fixture.ts +126 -0
- package/src/vector-cortex/cache/crystal-emit.ts +99 -0
- package/src/vector-cortex/cache/crystal.ts +217 -0
- package/src/vector-cortex/cache/store.ts +213 -0
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-DD7vGaRS.js +0 -2
- package/extensions/dashboard-client/dist/assets/VectorCortexTab-DD7vGaRS.js.map +0 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/cache/crystal.ts — canonical crystal key encoding (VC7A).
|
|
3
|
+
*
|
|
4
|
+
* Turns a `CrystalKeyV1` into a single stable digest. Everything about the
|
|
5
|
+
* encoding exists to make two properties simultaneously true:
|
|
6
|
+
*
|
|
7
|
+
* 1. IDENTICAL INPUTS ⇒ IDENTICAL KEY, regardless of how the caller ordered
|
|
8
|
+
* its ranges or which host produced them. Hence the explicit sort and the
|
|
9
|
+
* length-prefixed field framing below.
|
|
10
|
+
* 2. ANY IDENTITY CHANGE ⇒ DIFFERENT KEY, with no accidental aliasing. Hence
|
|
11
|
+
* length prefixes rather than delimiters: a delimiter-joined encoding lets
|
|
12
|
+
* an attacker (or an unlucky session name) push a separator into a field
|
|
13
|
+
* and forge a collision — `("a|b", "c")` and `("a", "b|c")` hash the same.
|
|
14
|
+
* Prefixing every variable-length field with its byte length makes the
|
|
15
|
+
* encoding injective, so a collision requires an actual SHA-256 collision.
|
|
16
|
+
*
|
|
17
|
+
* WHAT IS DELIBERATELY ABSENT. The global ledger frontier. It is not a
|
|
18
|
+
* parameter, it is not readable from here, and there is no code path that could
|
|
19
|
+
* fold it in. An unrelated append advances the frontier constantly; including it
|
|
20
|
+
* would invalidate every crystal on every turn and the cache would never hit.
|
|
21
|
+
* The key covers what the render DEPENDED ON, not what the world has since done.
|
|
22
|
+
*
|
|
23
|
+
* OVERLAP IS REJECTED, NOT MERGED. Two overlapping ranges in the same session
|
|
24
|
+
* make "the covered bytes" ambiguous: the overlap region would be hashed twice,
|
|
25
|
+
* and if the two spans pinned different digests the key would silently encode a
|
|
26
|
+
* contradiction. `CRY_RANGE_OVERLAP` fails the key closed instead. Ranges in
|
|
27
|
+
* DIFFERENT sessions never conflict — they cover disjoint byte streams by
|
|
28
|
+
* construction — so cross-session keys are legal and common.
|
|
29
|
+
*
|
|
30
|
+
* PURE. No clock, no storage, no console, no network (PREVENT-PI-004 /
|
|
31
|
+
* PREVENT-011). Runs identically with `MEGACOMPACT_VC7A` on or off — the flag
|
|
32
|
+
* gates only the reporter/dashboard seam in `crystal-emit.ts`.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import { createHash } from "node:crypto";
|
|
36
|
+
|
|
37
|
+
import {
|
|
38
|
+
CRYSTAL_LIMIT_BYTES,
|
|
39
|
+
CRYSTAL_LIMIT_RANGES,
|
|
40
|
+
type CrystalFailureCode,
|
|
41
|
+
type CrystalKeyResult,
|
|
42
|
+
type CrystalKeyV1,
|
|
43
|
+
type DagSpan,
|
|
44
|
+
} from "./types.js";
|
|
45
|
+
|
|
46
|
+
/** Encoding version, folded into the digest so a future change cannot alias. */
|
|
47
|
+
const KEY_ENCODING_VERSION = "crystal-key-v1";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Length-prefixed field append. `<byteLength>:<bytes>` makes the concatenation
|
|
51
|
+
* injective, so no combination of field contents can impersonate another.
|
|
52
|
+
*/
|
|
53
|
+
function field(parts: string[], value: string): void {
|
|
54
|
+
parts.push(`${Buffer.byteLength(value, "utf8")}:${value}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Total order over covered ranges: session, then start seq, then start byte.
|
|
59
|
+
*
|
|
60
|
+
* Ordering by SOURCE START (not by insertion, not by digest) is what makes the
|
|
61
|
+
* key independent of how the planner happened to enumerate its spans. `sessionId`
|
|
62
|
+
* leads because seq numbers are only comparable within a session.
|
|
63
|
+
*/
|
|
64
|
+
export function compareSpans(a: DagSpan, b: DagSpan): number {
|
|
65
|
+
if (a.sessionId !== b.sessionId) return a.sessionId < b.sessionId ? -1 : 1;
|
|
66
|
+
if (a.startSeq !== b.startSeq) return a.startSeq < b.startSeq ? -1 : 1;
|
|
67
|
+
if (a.startByte !== b.startByte) return a.startByte - b.startByte;
|
|
68
|
+
if (a.endSeq !== b.endSeq) return a.endSeq < b.endSeq ? -1 : 1;
|
|
69
|
+
return a.endByte - b.endByte;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Sort covered ranges into canonical order (never mutates the input array). */
|
|
73
|
+
export function sortSpans(spans: readonly DagSpan[]): readonly DagSpan[] {
|
|
74
|
+
return [...spans].sort(compareSpans);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** A range is malformed if either bound runs backwards or a byte bound is negative. */
|
|
78
|
+
function isMalformed(s: DagSpan): boolean {
|
|
79
|
+
return (
|
|
80
|
+
s.endSeq < s.startSeq ||
|
|
81
|
+
s.startByte < 0 ||
|
|
82
|
+
s.endByte < s.startByte ||
|
|
83
|
+
!Number.isSafeInteger(s.startByte) ||
|
|
84
|
+
!Number.isSafeInteger(s.endByte)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Byte-range overlap between two spans of the SAME session. Byte bounds are
|
|
90
|
+
* half-open (`[startByte, endByte)`), so touching ranges (`a.end === b.start`)
|
|
91
|
+
* are adjacent, not overlapping, and are legal.
|
|
92
|
+
*/
|
|
93
|
+
function overlaps(a: DagSpan, b: DagSpan): boolean {
|
|
94
|
+
return a.sessionId === b.sessionId && a.startByte < b.endByte && b.startByte < a.endByte;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Validate covered ranges: non-empty, bounded, well-formed, and disjoint within
|
|
99
|
+
* each session. Returns deduplicated codes in a deterministic order.
|
|
100
|
+
*/
|
|
101
|
+
export function validateRanges(spans: readonly DagSpan[]): readonly CrystalFailureCode[] {
|
|
102
|
+
const codes = new Set<CrystalFailureCode>();
|
|
103
|
+
if (spans.length === 0) codes.add("CRY_RANGE_EMPTY");
|
|
104
|
+
if (spans.length > CRYSTAL_LIMIT_RANGES) codes.add("CRY_KEY_LIMIT");
|
|
105
|
+
|
|
106
|
+
let totalBytes = 0;
|
|
107
|
+
for (const s of spans) {
|
|
108
|
+
if (isMalformed(s)) codes.add("CRY_RANGE_INVALID");
|
|
109
|
+
else totalBytes += s.endByte - s.startByte;
|
|
110
|
+
}
|
|
111
|
+
if (totalBytes > CRYSTAL_LIMIT_BYTES) codes.add("CRY_KEY_LIMIT");
|
|
112
|
+
|
|
113
|
+
// Sorted order makes overlap a neighbour check within each session run.
|
|
114
|
+
const sorted = sortSpans(spans);
|
|
115
|
+
for (let i = 1; i < sorted.length; i += 1) {
|
|
116
|
+
const prev = sorted[i - 1];
|
|
117
|
+
const cur = sorted[i];
|
|
118
|
+
if (prev !== undefined && cur !== undefined && overlaps(prev, cur)) {
|
|
119
|
+
codes.add("CRY_RANGE_OVERLAP");
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const order: CrystalFailureCode[] = [
|
|
125
|
+
"CRY_RANGE_EMPTY",
|
|
126
|
+
"CRY_RANGE_INVALID",
|
|
127
|
+
"CRY_RANGE_OVERLAP",
|
|
128
|
+
"CRY_KEY_LIMIT",
|
|
129
|
+
];
|
|
130
|
+
return order.filter((c) => codes.has(c));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The covered-bytes digest: SHA-256 over the SORTED ranges' identities and their
|
|
135
|
+
* pinned span digests, `sha256:` prefixed (matching the `DagSpan.digest`
|
|
136
|
+
* convention the ranges themselves carry).
|
|
137
|
+
*
|
|
138
|
+
* The span digests are what make this sensitive to a single covered BYTE: the
|
|
139
|
+
* ranges alone would be identical if a byte inside an unchanged range mutated,
|
|
140
|
+
* but the span's pinned digest would not be (CRY-COVERED-002).
|
|
141
|
+
*/
|
|
142
|
+
export function computeCoveredDigest(spans: readonly DagSpan[]): string {
|
|
143
|
+
const h = createHash("sha256");
|
|
144
|
+
for (const s of sortSpans(spans)) {
|
|
145
|
+
const parts: string[] = [];
|
|
146
|
+
field(parts, s.sessionId);
|
|
147
|
+
field(parts, s.startSeq.toString());
|
|
148
|
+
field(parts, s.endSeq.toString());
|
|
149
|
+
field(parts, String(s.startByte));
|
|
150
|
+
field(parts, String(s.endByte));
|
|
151
|
+
field(parts, s.digest);
|
|
152
|
+
h.update(parts.join(""), "utf8");
|
|
153
|
+
}
|
|
154
|
+
return `sha256:${h.digest("hex")}`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Canonical key bytes. Field order is fixed and every field is length-prefixed;
|
|
159
|
+
* the ranges are emitted in canonical sort order with an explicit count so a
|
|
160
|
+
* key with N ranges can never encode the same bytes as one with M.
|
|
161
|
+
*/
|
|
162
|
+
export function encodeCrystalKeyBytes(key: CrystalKeyV1): string {
|
|
163
|
+
const parts: string[] = [];
|
|
164
|
+
field(parts, KEY_ENCODING_VERSION);
|
|
165
|
+
field(parts, key.profileId);
|
|
166
|
+
field(parts, key.profileVersion);
|
|
167
|
+
field(parts, key.requestDigest);
|
|
168
|
+
field(parts, key.rendererVersion);
|
|
169
|
+
field(parts, key.dependencyHighWater.toString());
|
|
170
|
+
field(parts, key.coveredDigest);
|
|
171
|
+
const sorted = sortSpans(key.sourceRanges);
|
|
172
|
+
field(parts, String(sorted.length));
|
|
173
|
+
for (const s of sorted) {
|
|
174
|
+
field(parts, s.sessionId);
|
|
175
|
+
field(parts, s.startSeq.toString());
|
|
176
|
+
field(parts, s.endSeq.toString());
|
|
177
|
+
field(parts, String(s.startByte));
|
|
178
|
+
field(parts, String(s.endByte));
|
|
179
|
+
field(parts, s.digest);
|
|
180
|
+
}
|
|
181
|
+
return parts.join("");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Build the canonical key digest for a crystal identity.
|
|
186
|
+
*
|
|
187
|
+
* The returned `key` carries the ranges in canonical sorted order and the
|
|
188
|
+
* RE-DERIVED `coveredDigest`, so a caller that supplied a stale or wrong covered
|
|
189
|
+
* digest cannot mint a key that disagrees with its own ranges. The digest itself
|
|
190
|
+
* is bare lowercase hex (it addresses an identity, not source bytes).
|
|
191
|
+
*/
|
|
192
|
+
export function encodeCrystalKey(key: CrystalKeyV1): CrystalKeyResult {
|
|
193
|
+
const codes = validateRanges(key.sourceRanges);
|
|
194
|
+
if (codes.length > 0) return { ok: false, codes };
|
|
195
|
+
|
|
196
|
+
const normalized: CrystalKeyV1 = {
|
|
197
|
+
...key,
|
|
198
|
+
sourceRanges: sortSpans(key.sourceRanges),
|
|
199
|
+
coveredDigest: computeCoveredDigest(key.sourceRanges),
|
|
200
|
+
};
|
|
201
|
+
const keyDigest = createHash("sha256")
|
|
202
|
+
.update(encodeCrystalKeyBytes(normalized), "utf8")
|
|
203
|
+
.digest("hex");
|
|
204
|
+
return { ok: true, keyDigest, key: normalized };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Whether two identities are the same crystal. Used by invalidation fixtures to
|
|
209
|
+
* state the sprint invariant directly: the key changes IFF an identity field
|
|
210
|
+
* changes — an unrelated frontier append is not an identity field, so it cannot
|
|
211
|
+
* appear here at all.
|
|
212
|
+
*/
|
|
213
|
+
export function sameCrystalKey(a: CrystalKeyV1, b: CrystalKeyV1): boolean {
|
|
214
|
+
const ea = encodeCrystalKey(a);
|
|
215
|
+
const eb = encodeCrystalKey(b);
|
|
216
|
+
return ea.ok && eb.ok && ea.keyDigest === eb.keyDigest;
|
|
217
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/cache/store.ts — content-addressed, write-once crystal store
|
|
3
|
+
* (VC7A).
|
|
4
|
+
*
|
|
5
|
+
* WRITE ONCE, NEVER OVERWRITE. A key that already holds bytes is final. Writing
|
|
6
|
+
* the SAME bytes again is accepted and idempotent (two concurrent renders raced;
|
|
7
|
+
* both are right). Writing DIFFERENT bytes under the same key returns
|
|
8
|
+
* `CRY_KEY_COLLISION` and the stored crystal is left exactly as it was.
|
|
9
|
+
*
|
|
10
|
+
* Why refuse rather than take the newer bytes? Because the key already names
|
|
11
|
+
* everything the render depended on — covered ranges, their digest, the validated
|
|
12
|
+
* dependency high-water, the renderer, the profile. If two renders of that same
|
|
13
|
+
* identity disagree, the renderer is NOT deterministic, and that is a bug to
|
|
14
|
+
* surface loudly, not to paper over by picking a winner. Last-write-wins would
|
|
15
|
+
* make the failure invisible and let a corrupted render silently displace a good
|
|
16
|
+
* one. So the store is a one-way ratchet per key.
|
|
17
|
+
*
|
|
18
|
+
* CONTENT ADDRESSED. Every crystal carries the SHA-256 of exactly its own bytes
|
|
19
|
+
* (bare lowercase hex, matching `ExactShardV1.digest`), recomputed HERE from the
|
|
20
|
+
* bytes rather than trusted from the caller — a caller-supplied digest would let
|
|
21
|
+
* a mismatched pair be stored and later "verify" against itself.
|
|
22
|
+
*
|
|
23
|
+
* ATOMIC COMMIT (the crash invariant). Writes go through a staging slot and are
|
|
24
|
+
* only published by `commit`. A write interrupted before commit leaves the
|
|
25
|
+
* staging entry orphaned and the visible map untouched, so `read` can never
|
|
26
|
+
* observe a partial crystal. On restart, `recover()` DISCARDS staged entries —
|
|
27
|
+
* it never promotes them — and a fresh write then produces exactly one valid
|
|
28
|
+
* crystal. This models the real filesystem shape (write temp file → fsync →
|
|
29
|
+
* rename) without doing any I/O here: persistence is the runtime's job, and
|
|
30
|
+
* `src/` stays storage-free and pure (PREVENT-PI-004).
|
|
31
|
+
*
|
|
32
|
+
* MODE C. `setAvailable(false)` marks the store unavailable: reads serve nothing
|
|
33
|
+
* and writes refuse with `CRY_STORE_UNAVAILABLE`. Mode C is a real triad state,
|
|
34
|
+
* not an error path — the caller must fall back to a fresh render and disclose
|
|
35
|
+
* that nothing came from cache.
|
|
36
|
+
*
|
|
37
|
+
* No console, no network (PREVENT-PI-004 / PREVENT-011).
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import { createHash } from "node:crypto";
|
|
41
|
+
|
|
42
|
+
import type {
|
|
43
|
+
CrystalMode,
|
|
44
|
+
CrystalStoreStats,
|
|
45
|
+
CrystalV1,
|
|
46
|
+
CrystalWriteResult,
|
|
47
|
+
} from "./types.js";
|
|
48
|
+
|
|
49
|
+
/** SHA-256 over bytes, BARE lowercase hex (the content address). */
|
|
50
|
+
export function contentAddress(bytes: Uint8Array): string {
|
|
51
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Byte equality without allocating — a length check first, then a scan. */
|
|
55
|
+
function bytesEqual(a: Uint8Array, b: Uint8Array): boolean {
|
|
56
|
+
if (a.length !== b.length) return false;
|
|
57
|
+
for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* An in-memory, content-addressed, write-once crystal store.
|
|
63
|
+
*
|
|
64
|
+
* Deliberately holds no filesystem handle: the process-local map IS the store as
|
|
65
|
+
* far as `src/` is concerned, and durability is layered on by the runtime. That
|
|
66
|
+
* keeps the write-once/collision arithmetic testable end-to-end with real
|
|
67
|
+
* modules and no I/O mocking.
|
|
68
|
+
*/
|
|
69
|
+
export class CrystalStore {
|
|
70
|
+
/** Published crystals, keyed by canonical key digest. */
|
|
71
|
+
private readonly committed = new Map<string, CrystalV1>();
|
|
72
|
+
/** Staged-but-uncommitted writes — invisible to `read` until committed. */
|
|
73
|
+
private readonly staged = new Map<string, CrystalV1>();
|
|
74
|
+
private available = true;
|
|
75
|
+
private hits = 0;
|
|
76
|
+
private misses = 0;
|
|
77
|
+
private hitBytes = 0;
|
|
78
|
+
private writes = 0;
|
|
79
|
+
private duplicateWrites = 0;
|
|
80
|
+
private collisions = 0;
|
|
81
|
+
|
|
82
|
+
/** Freeze a crystal object for a key/bytes pair (digest computed here). */
|
|
83
|
+
static freeze(keyDigest: string, bytes: Uint8Array, key: CrystalV1["key"]): CrystalV1 {
|
|
84
|
+
const copy = new Uint8Array(bytes);
|
|
85
|
+
return {
|
|
86
|
+
schema: "crystal-v1",
|
|
87
|
+
keyDigest,
|
|
88
|
+
bytes: copy,
|
|
89
|
+
contentDigest: contentAddress(copy),
|
|
90
|
+
byteCount: copy.length,
|
|
91
|
+
key,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Toggle store availability (mode C when false). */
|
|
96
|
+
setAvailable(value: boolean): void {
|
|
97
|
+
this.available = value;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
isAvailable(): boolean {
|
|
101
|
+
return this.available;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Stage a write without publishing it. Returns the staging handle (the key
|
|
106
|
+
* digest) so a test — or a crash — can leave it uncommitted.
|
|
107
|
+
*/
|
|
108
|
+
stage(crystal: CrystalV1): CrystalWriteResult {
|
|
109
|
+
if (!this.available) {
|
|
110
|
+
return { ok: false, code: "CRY_STORE_UNAVAILABLE", contentDigest: crystal.contentDigest };
|
|
111
|
+
}
|
|
112
|
+
this.staged.set(crystal.keyDigest, crystal);
|
|
113
|
+
return { ok: true, written: false, contentDigest: crystal.contentDigest };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Publish a staged write. Enforces write-once at the commit point: an existing
|
|
118
|
+
* key with identical bytes is idempotent, with different bytes is a collision
|
|
119
|
+
* and is NEVER overwritten.
|
|
120
|
+
*/
|
|
121
|
+
commit(keyDigest: string): CrystalWriteResult {
|
|
122
|
+
const pending = this.staged.get(keyDigest);
|
|
123
|
+
if (pending === undefined) {
|
|
124
|
+
return { ok: false, code: "CRY_STORE_UNAVAILABLE", contentDigest: "" };
|
|
125
|
+
}
|
|
126
|
+
this.staged.delete(keyDigest);
|
|
127
|
+
if (!this.available) {
|
|
128
|
+
return { ok: false, code: "CRY_STORE_UNAVAILABLE", contentDigest: pending.contentDigest };
|
|
129
|
+
}
|
|
130
|
+
const existing = this.committed.get(keyDigest);
|
|
131
|
+
if (existing !== undefined) {
|
|
132
|
+
if (bytesEqual(existing.bytes, pending.bytes)) {
|
|
133
|
+
this.duplicateWrites += 1;
|
|
134
|
+
return { ok: true, written: false, contentDigest: existing.contentDigest };
|
|
135
|
+
}
|
|
136
|
+
this.collisions += 1;
|
|
137
|
+
return { ok: false, code: "CRY_KEY_COLLISION", contentDigest: existing.contentDigest };
|
|
138
|
+
}
|
|
139
|
+
this.committed.set(keyDigest, pending);
|
|
140
|
+
this.writes += 1;
|
|
141
|
+
return { ok: true, written: true, contentDigest: pending.contentDigest };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Stage + commit in one step (the normal path). */
|
|
145
|
+
write(crystal: CrystalV1): CrystalWriteResult {
|
|
146
|
+
const staged = this.stage(crystal);
|
|
147
|
+
if (!staged.ok) return staged;
|
|
148
|
+
return this.commit(crystal.keyDigest);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Restart recovery: DISCARD every staged entry. A write interrupted before
|
|
153
|
+
* commit is never promoted — a fresh write afterwards produces exactly one
|
|
154
|
+
* valid crystal. Returns how many partial writes were dropped.
|
|
155
|
+
*/
|
|
156
|
+
recover(): number {
|
|
157
|
+
const dropped = this.staged.size;
|
|
158
|
+
this.staged.clear();
|
|
159
|
+
return dropped;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Read a committed crystal. Mode C (unavailable) serves nothing. */
|
|
163
|
+
read(keyDigest: string): CrystalV1 | undefined {
|
|
164
|
+
if (!this.available) {
|
|
165
|
+
this.misses += 1;
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
const found = this.committed.get(keyDigest);
|
|
169
|
+
if (found === undefined) {
|
|
170
|
+
this.misses += 1;
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
this.hits += 1;
|
|
174
|
+
this.hitBytes += found.byteCount;
|
|
175
|
+
return found;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Whether a key holds a committed crystal (does not count as a read). */
|
|
179
|
+
has(keyDigest: string): boolean {
|
|
180
|
+
return this.available && this.committed.has(keyDigest);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Number of writes staged but not yet committed (0 after `recover`). */
|
|
184
|
+
pendingCount(): number {
|
|
185
|
+
return this.staged.size;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The triad mode the store is currently in: C when unavailable, A once a read
|
|
190
|
+
* has been served from the store, B while every read has forced a fresh render.
|
|
191
|
+
*/
|
|
192
|
+
mode(): CrystalMode {
|
|
193
|
+
if (!this.available) return "C";
|
|
194
|
+
return this.hits > 0 ? "A" : "B";
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Reader-only aggregate for the dashboard seam — counts and bytes only. */
|
|
198
|
+
stats(): CrystalStoreStats {
|
|
199
|
+
let totalBytes = 0;
|
|
200
|
+
for (const c of this.committed.values()) totalBytes += c.byteCount;
|
|
201
|
+
return {
|
|
202
|
+
mode: this.mode(),
|
|
203
|
+
crystalCount: this.committed.size,
|
|
204
|
+
totalBytes,
|
|
205
|
+
hits: this.hits,
|
|
206
|
+
misses: this.misses,
|
|
207
|
+
hitBytes: this.hitBytes,
|
|
208
|
+
writes: this.writes,
|
|
209
|
+
duplicateWrites: this.duplicateWrites,
|
|
210
|
+
collisions: this.collisions,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,B as a,r as n}from"./index-CuLdiHRl.js";import{C as o,a as d,b as i,c as x}from"./card-BLPT2-8G.js";async function Q(){const s=await fetch("/api/vector-cortex/evaluation");if(!s.ok)throw new Error(`vector-cortex evaluation: ${s.status}`);return s.json()}async function C(){const s=await fetch("/api/vector-cortex/health");if(!s.ok)throw new Error(`vector-cortex health: ${s.status}`);return s.json()}async function W(){const s=await fetch("/api/vector-cortex/topology");if(!s.ok)throw new Error(`vector-cortex topology: ${s.status}`);return s.json()}async function Z(){const s=await fetch("/api/vector-cortex/query");if(!s.ok)throw new Error(`vector-cortex query: ${s.status}`);return s.json()}async function J(){const s=await fetch("/api/vector-cortex/shards");if(!s.ok)throw new Error(`vector-cortex shards: ${s.status}`);return s.json()}async function K(){const s=await fetch("/api/vector-cortex/reconstruct");if(!s.ok)throw new Error(`vector-cortex reconstruct: ${s.status}`);return s.json()}async function X(){const s=await fetch("/api/vector-cortex/plans");if(!s.ok)throw new Error(`vector-cortex plans: ${s.status}`);return s.json()}async function ee(){const s=await fetch("/api/vector-cortex/render");if(!s.ok)throw new Error(`vector-cortex render: ${s.status}`);return s.json()}async function se(){const s=await fetch("/api/vector-cortex/rollout");if(!s.ok)throw new Error(`vector-cortex rollout: ${s.status}`);return s.json()}async function te(){const s=await fetch("/api/vector-cortex/closure-proof");if(!s.ok)throw new Error(`vector-cortex closure-proof: ${s.status}`);return s.json()}async function re(){const s=await fetch("/api/vector-cortex/restore");if(!s.ok)throw new Error(`vector-cortex restore: ${s.status}`);return s.json()}async function ae(){const s=await fetch("/api/vector-cortex/repair");if(!s.ok)throw new Error(`vector-cortex repair: ${s.status}`);return s.json()}async function ne(s="default"){const r=await fetch(`/api/vector-cortex/ledger?session=${encodeURIComponent(s)}`);if(!r.ok)throw new Error(`vector-cortex ledger: ${r.status}`);return r.json()}async function le(s){const r=await fetch("/api/vector-cortex/breakers/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subsystem:s})});if(!r.ok)throw new Error(`vector-cortex reset: ${r.status}`);return r.json()}function t({label:s,value:r}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:s}),e.jsx("div",{className:"font-mono text-sm",children:r})]})}function ce({view:s}){return e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Validated Prompt Renderer (VC5B)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Render fixtures",value:String(s.renderCount)}),e.jsx(t,{label:"Provider profiles",value:String(s.providerCount)}),e.jsx(t,{label:"Known profiles",value:String(s.knownProfiles.length)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only render conformance route — no prompt text or session payloads exposed."})]}):e.jsx("div",{className:"vc-empty",children:"Renderer disabled (VC5B off)."})})]})}function oe({view:s}){return e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Live Graduated Rollout (VC5C)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Gate",value:`${s.gatePct}%`}),e.jsx(t,{label:"Exposed buckets",value:String(s.bucketCount)}),e.jsx(t,{label:"Total buckets",value:String(s.buckets)}),e.jsx(t,{label:"Promotion",value:s.promotionBlocked?"FROZEN":"OPEN"}),e.jsx(t,{label:"Events",value:String(s.events)}),e.jsx(t,{label:"Sessions",value:String(s.sessions)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only rollout route — no session payloads or bucket→session mappings exposed."})]}):e.jsx("div",{className:"vc-empty",children:"Rollout disabled (VC5C off)."})})]})}function de({view:s}){return e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Closure Optimization (VC6A)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Optimizations",value:String(s.optimizations)}),e.jsx(t,{label:"Proof rejections",value:String(s.proofRejections)}),e.jsx(t,{label:"Last rejection",value:s.lastRejection??"none"}),e.jsx(t,{label:"Retained edges",value:String(s.retainedEdgeTotal)}),e.jsx(t,{label:"Removed edges",value:String(s.removedEdgeTotal)}),e.jsx(t,{label:"Conservative walks",value:String(s.conservativeTraversalTotal)}),e.jsx(t,{label:"Optimized walks",value:String(s.optimizedTraversalTotal)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only closure diagnostics — aggregate counts only; per-edge proof rows, node ids, and source payloads are never exposed (SECURITY_PRIVACY)."})]}):e.jsx("div",{className:"vc-empty",children:"Closure optimization disabled (VC6A off) — conservative VC4C closure used directly (mode B)."})})]})}function ie({view:s}){return e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Exact Source Restoration (VC6B)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Restore attempts",value:String(s.restoreAttempts)}),e.jsx(t,{label:"Restored",value:String(s.restoredCount)}),e.jsx(t,{label:"Missing source",value:String(s.missingCount)}),e.jsx(t,{label:"Digest rejections",value:String(s.digestRejections)}),e.jsx(t,{label:"Last rejection",value:s.lastRejection??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only restore diagnostics — counts and HEAL_RESTORE_* codes only. There is no payload endpoint: restored bytes, span ids, node ids, and ledger text are never exposed (SECURITY_PRIVACY)."})]}):e.jsx("div",{className:"vc-empty",children:"Exact source restoration disabled (VC6B off) — no exact source is restored; omitted context is disclosed as loss (mode C)."})})]})}function xe({view:s}){return e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Self-Healing Derived State (VC6C)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Mode",value:s.mode}),e.jsx(t,{label:"Repair attempts",value:String(s.repairAttempts)}),e.jsx(t,{label:"Repairs planned",value:String(s.repairsPlanned)}),e.jsx(t,{label:"Pointers switched",value:String(s.pointersSwitched)}),e.jsx(t,{label:"Backoffs",value:String(s.backoffs)}),e.jsx(t,{label:"Last backoff",value:s.lastBackoffMs===null?"none":`${s.lastBackoffMs}ms`}),e.jsx(t,{label:"Last failure",value:s.lastFailure??"none"}),e.jsx(t,{label:"Updated",value:s.updatedAt})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only repair diagnostics — counts and HEAL_REPAIR_* codes only. There is no payload endpoint: subsystem source bytes, gap ranges, high-water marks, root digests, and ledger text are never exposed (SECURITY_PRIVACY)."})]}):e.jsx("div",{className:"vc-empty",children:"Self-healing derived state disabled (VC6C off) — no controller detects gaps or rebuilds derived state; derived state is reported disabled rather than healed (mode C)."})})]})}function ue({view:s}){return e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Dual-Tier Shards (VC4A)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Semantic shards",value:String(s.semanticCount)}),e.jsx(t,{label:"Exact shards",value:String(s.exactCount)}),e.jsx(t,{label:"Byte total",value:String(s.byteTotal)}),e.jsx(t,{label:"Protected bytes",value:String(s.protectedByteTotal)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only count/byte aggregate; staged in-memory this sprint."})]}):e.jsx("div",{className:"vc-empty",children:"Dual-tier shards disabled (VC4A off)."})})]})}function he({view:s}){return e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Reconstruction Fidelity (VC4C)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"Closure attempts",value:String(s.closureAttempts)}),e.jsx(t,{label:"Closure rejections",value:String(s.closureRejections)}),e.jsx(t,{label:"Validated",value:String(s.validatedCount)}),e.jsx(t,{label:"Invalidated",value:String(s.invalidatedCount)}),e.jsx(t,{label:"Span total",value:String(s.spanTotal)}),e.jsx(t,{label:"Byte total",value:String(s.byteTotal)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only closure/validation aggregate; staged in-memory this sprint."})]}):e.jsx("div",{className:"vc-empty",children:"Reconstruction fidelity disabled (VC4C off)."})})]})}function je({view:s}){return e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Plan Manifests (VC5A)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"DAG fixtures",value:String(s.dagCount)}),e.jsx(t,{label:"Plan fixtures",value:String(s.plannerCount)}),e.jsx(t,{label:"Plans exposed",value:String(s.plans.length)})]}),e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Reader-only plan manifests only — no session payloads or prompt text. Per-run plan outputs are staged in-memory this sprint."})]}):e.jsx("div",{className:"vc-empty",children:"PromptDagV1 + budgeted planner disabled (VC5A off)."})})]})}function me({topology:s,query:r}){return e.jsxs(e.Fragment,{children:[e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Derived Cortex Store (VC3A)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3",children:[e.jsx(t,{label:"Generation",value:s.generationId??"—"}),e.jsx(t,{label:"Ordinal",value:s.ordinal??"—"}),e.jsx(t,{label:"Records",value:String(s.recordCount)}),e.jsx(t,{label:"Frontier (HW)",value:s.sourceHighWater}),e.jsx(t,{label:"Root digest",value:s.rootDigest?s.rootDigest.slice(0,16):"—"}),s.nodes!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx(t,{label:"Nodes",value:String(s.nodes?.length??0)}),e.jsx(t,{label:"Edges",value:String(s.edges?.length??0)}),e.jsx(t,{label:"Graph digest",value:s.generationDigest?s.generationDigest.slice(0,16):"—"})]})]}),s.nodes!==void 0&&(s.edges?.length??0)>0&&e.jsxs("div",{className:"mt-4 max-h-56 overflow-y-auto",children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"Topology edges (VC3B)"}),e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 text-muted-foreground",children:[e.jsx("th",{className:"py-1 pr-2",children:"source"}),e.jsx("th",{className:"py-1 pr-2",children:"target"}),e.jsx("th",{className:"py-1 pr-2",children:"head"}),e.jsx("th",{className:"py-1 pr-2",children:"dir"}),e.jsx("th",{className:"py-1",children:"score"})]})}),e.jsx("tbody",{children:s.edges?.map((u,h)=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"py-1 pr-2 font-mono",children:u.source}),e.jsx("td",{className:"py-1 pr-2 font-mono",children:u.target}),e.jsx("td",{className:"py-1 pr-2 font-mono",children:u.head}),e.jsx("td",{className:"py-1 pr-2",children:u.direction}),e.jsx("td",{className:"py-1 font-mono",children:u.score})]},`${u.source}-${u.target}-${u.head}-${h}`))})]})]})]}):e.jsx("div",{className:"vc-empty",children:"Cortex store disabled (VC3A off)."})})]}),e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Topology Query Diagnostics (VC3C)"}),r?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:r?.enabled?e.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3",children:e.jsx(t,{label:"Router version",value:String(r.routerVersion)})}):e.jsx("div",{className:"vc-empty",children:"Query diagnostics unavailable (VC3C off)."})})]})]})}function ge({ledger:s}){return e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Occurrence Ledger (VC1B)"}),s?.enabled?e.jsx(a,{variant:"success",children:"ACTIVE"}):e.jsx(a,{variant:"danger",children:"OFF"})]})}),e.jsx(x,{children:s?.enabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 grid grid-cols-2 gap-4 md:grid-cols-3",children:[e.jsx(t,{label:"Session",value:s.session}),e.jsx(t,{label:"High-water",value:s.highWater}),e.jsx(t,{label:"Occurrences",value:String(s.count)})]}),s.occurrences.length===0?e.jsx("div",{className:"vc-empty",children:"No occurrences recorded."}):e.jsx("div",{className:"max-h-64 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50 text-muted-foreground",children:[e.jsx("th",{className:"py-1 pr-2",children:"seq"}),e.jsx("th",{className:"py-1 pr-2",children:"eventId"}),e.jsx("th",{className:"py-1 pr-2",children:"kind"}),e.jsx("th",{className:"py-1 pr-2",children:"toolCall"}),e.jsx("th",{className:"py-1",children:"digest"})]})}),e.jsx("tbody",{children:s.occurrences.map(r=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"py-1 pr-2 font-mono",children:r.seq}),e.jsx("td",{className:"py-1 pr-2 font-mono",children:r.eventId}),e.jsx("td",{className:"py-1 pr-2",children:r.kind}),e.jsx("td",{className:"py-1 pr-2 font-mono",children:r.toolCallId??"—"}),e.jsx("td",{className:"max-w-[180px] truncate font-mono text-muted-foreground",children:r.digest})]},`${r.seq}-${r.eventId}`))})]})})]}):e.jsx("div",{className:"vc-empty",children:"Ledger disabled (VC1B off)."})})]})}function m({mode:s,count:r}){return e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 py-1 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Mode ",s]}),e.jsx("span",{className:"font-mono",children:r})]})}function pe(){const[s,r]=n.useState(null),[u,h]=n.useState(null),[y,N]=n.useState(!0),[c,g]=n.useState(null),[f,v]=n.useState(null),[S,V]=n.useState(null),[R,E]=n.useState(null),[F,k]=n.useState(null),[T,A]=n.useState(null),[w,$]=n.useState(null),[I,P]=n.useState(null),[O,M]=n.useState(null),[B,L]=n.useState(null),[D,H]=n.useState(null),[z,_]=n.useState(null),[G,U]=n.useState(null),j=n.useCallback(()=>{Q().then(r).catch(l=>h(l instanceof Error?l.message:String(l))).finally(()=>N(!1)),C().then(g).catch(()=>{}),ne().then(V).catch(()=>{}),W().then(E).catch(()=>{}),Z().then(k).catch(()=>{}),J().then(A).catch(()=>{}),K().then($).catch(()=>{}),X().then(P).catch(()=>{}),ee().then(M).catch(()=>{}),se().then(L).catch(()=>{}),te().then(H).catch(()=>{}),re().then(_).catch(()=>{}),ae().then(U).catch(()=>{})},[]);n.useEffect(()=>{j();const l=setInterval(j,5e3);return()=>clearInterval(l)},[j]);const Y=()=>{le("provider").then(l=>(v(`Breaker "${l.subsystem}" ${l.state}; evidence retained: ${l.failures} failures / ${l.attempts} attempts`),C())).then(g).catch(l=>v(l instanceof Error?l.message:String(l)))};if(y&&!s)return e.jsx("div",{className:"vc-loading",children:"Loading vector-cortex evaluation…"});if(u&&!s)return e.jsxs("div",{className:"vc-error",children:["Error: ",u]});if(!s)return e.jsx("div",{className:"vc-empty",children:"No evaluation data available."});const p=Math.max(1,...s.histogram.cells,s.histogram.overflow);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Vector Cortex Evaluation"}),s.enabled?e.jsx(a,{variant:"warning",children:"OBSERVER PENDING (A)"}):e.jsx(a,{variant:"danger",children:"MODE C (OFF)"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsxs(o,{children:[e.jsx(d,{children:e.jsx(i,{children:"Samples"})}),e.jsxs(x,{children:[e.jsx("div",{className:"text-3xl font-bold",children:s.samples}),e.jsxs("div",{className:"mt-2 flex flex-col",children:[e.jsx(m,{mode:"A",count:s.byMode.A}),e.jsx(m,{mode:"B",count:s.byMode.B}),e.jsx(m,{mode:"C",count:s.byMode.C})]})]})]}),e.jsxs(o,{className:"md:col-span-2",children:[e.jsx(d,{children:e.jsx(i,{children:"Latency Histogram (ms, inclusive edges)"})}),e.jsxs(x,{children:[e.jsxs("div",{className:"flex items-end gap-2",style:{height:160},children:[s.histogram.edges.map((l,b)=>{const q=s.histogram.cells[b]/p*140;return e.jsxs("div",{className:"flex flex-1 flex-col items-center gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s.histogram.cells[b]}),e.jsx("div",{className:"w-full rounded-t",style:{height:Math.max(2,q),background:"#6366f1"}}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["≤",l]})]},l)}),e.jsxs("div",{className:"flex flex-1 flex-col items-center gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s.histogram.overflow}),e.jsx("div",{className:"w-full rounded-t",style:{height:Math.max(2,s.histogram.overflow/p*140),background:"#f87171"}}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:">250"})]})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["Total: ",s.histogram.total," · Rejects: ",s.rejects.length]})]})]})]}),e.jsxs(o,{children:[e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(i,{children:"Live Safety Envelope (VC0C)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[c?.stateSource==="ephemeral"&&e.jsx(a,{variant:"outline",children:"EPHEMERAL (non-live)"}),e.jsx("button",{onClick:Y,disabled:!c?.enabled,className:"rounded border border-border px-2 py-1 text-xs disabled:opacity-50",children:"Reset Cooldown"})]})]})}),e.jsxs(x,{children:[f&&e.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:f}),c?e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(t,{label:"State",value:c.state}),e.jsx(t,{label:"Mode",value:c.mode}),e.jsx(t,{label:"Window",value:`${c.windowMs}ms`}),e.jsx(t,{label:"Probes",value:String(c.probeCount)}),e.jsx(t,{label:"Backoff",value:`${c.backoffDelayMs}ms`}),e.jsx(t,{label:"Failures",value:`${c.failures}/${c.attempts}`}),e.jsx(t,{label:"Frontier",value:c.stateSource==="ephemeral"?"non-live":c.frontierFrozen?"FROZEN":"LIVE"}),e.jsx(t,{label:"Spool lag",value:String(c.spoolLag)}),e.jsx(t,{label:"Encoder mode",value:c.encoderMode}),e.jsx(t,{label:"Encoder asset",value:c.encoderAssetDigest?c.encoderAssetDigest.slice(0,12):"none"})]}):e.jsx("div",{className:"vc-empty",children:"Health unavailable (VC0C off)."})]})]}),e.jsx(me,{topology:R,query:F}),e.jsx(ue,{view:T}),e.jsx(he,{view:w}),e.jsx(je,{view:I}),e.jsx(ce,{view:O}),e.jsx(oe,{view:B}),e.jsx(de,{view:D}),e.jsx(ie,{view:z}),e.jsx(xe,{view:G}),e.jsx(ge,{ledger:S})]})}export{pe as default};
|
|
2
|
-
//# sourceMappingURL=VectorCortexTab-DD7vGaRS.js.map
|