pi-mega-compact 0.20.69 → 0.20.71
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-enc2c.js +38 -0
- package/dist/config/vector-cortex.js +2 -0
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/api-contracts/setup-cortex-native-ort.js +22 -0
- package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -0
- package/dist/extensions/dashboard-server/routes-setup-cortex-actions.js +17 -11
- package/dist/extensions/dashboard-server/routes-vector-cortex-crystals.js +45 -30
- package/dist/extensions/dashboard-server/routes-vector-cortex-diagnostics.js +50 -29
- package/dist/extensions/dashboard-server/routes-vector-cortex-economics.js +33 -20
- package/dist/extensions/dashboard-server/routes-vector-cortex-helpers.js +54 -0
- package/dist/extensions/dashboard-server/routes-vector-cortex-policy.js +33 -16
- package/dist/extensions/dashboard-server/setup-cortex-actions-native-ort.js +107 -0
- package/dist/extensions/dashboard-server/setup-cortex-actions.js +9 -2
- package/dist/src/config/vector-cortex-enc2c.js +38 -0
- package/dist/src/config/vector-cortex.js +2 -0
- package/dist/src/config.js +1 -1
- package/dist/src/vector-cortex/cache/store.js +25 -2
- package/dist/src/vector-cortex/encoder/asset.js +34 -2
- package/dist/src/vector-cortex/encoder/router.js +31 -3
- package/dist/src/vector-cortex/livewire/livewire-live.js +163 -0
- package/dist/src/vector-cortex/livewire/livewire-registry.js +73 -0
- package/dist/src/vector-cortex/livewire/livewire-runtime.js +107 -0
- package/dist/src/vector-cortex/livewire/livewire-snapshot.js +101 -0
- package/dist/src/vector-cortex/livewire/livewire-types.js +19 -0
- package/dist/src/vector-cortex/provider/registry.js +44 -12
- package/dist/src/vector-cortex/setup-cortex-blockers-compute.js +3 -0
- package/dist/vector-cortex/cache/store.js +25 -2
- package/dist/vector-cortex/encoder/asset.js +34 -2
- package/dist/vector-cortex/encoder/router.js +31 -3
- package/dist/vector-cortex/provider/registry.js +44 -12
- package/dist/vector-cortex/setup-cortex-blockers-compute.js +3 -0
- package/extensions/dashboard-client/dist/assets/{AdminTab-BUl1fyQ-.js → AdminTab-ZyVtgYrZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AdminTab-BUl1fyQ-.js.map → AdminTab-ZyVtgYrZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{AreaChart-CumzbAON.js → AreaChart-7ms8Hk1m.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-CumzbAON.js.map → AreaChart-7ms8Hk1m.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-MvUf2UYv.js → BarChart-DeTE0NXA.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-MvUf2UYv.js.map → BarChart-DeTE0NXA.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-CqpJZ5Ok.js → CacheTab-CpIrpr_X.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-CqpJZ5Ok.js.map → CacheTab-CpIrpr_X.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cr0pKYGK.js → ConfigTab-BNMrO7uz.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cr0pKYGK.js.map → ConfigTab-BNMrO7uz.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-FTQ4nJae.js → EventsTab-j42vDTjs.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-FTQ4nJae.js.map → EventsTab-j42vDTjs.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-D7s5lCB0.js → HealthTab-D0Tf8XM_.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-D7s5lCB0.js.map → HealthTab-D0Tf8XM_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DW5c0ngt.js → MaintenanceTab-CleWX_RM.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DW5c0ngt.js.map → MaintenanceTab-CleWX_RM.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-ocR07fD7.js → MemoryMapTab-LUpPJzNP.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-ocR07fD7.js.map → MemoryMapTab-LUpPJzNP.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsCards-CNBlWLoU.js → MetricsCards-G4_uynTE.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsCards-CNBlWLoU.js.map → MetricsCards-G4_uynTE.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/MetricsTab-yypKMQXf.js +2 -0
- package/extensions/dashboard-client/dist/assets/{MetricsTab-sks9wzZr.js.map → MetricsTab-yypKMQXf.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-Duu9zseZ.js → OverviewTab-M47NMRaT.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-Duu9zseZ.js.map → OverviewTab-M47NMRaT.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-CMd5NYjk.js → ReposTab-BX3ZxrAI.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-CMd5NYjk.js.map → ReposTab-BX3ZxrAI.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-Ht-k4LKk.js → SessionsTab-CSUmsNeZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-Ht-k4LKk.js.map → SessionsTab-CSUmsNeZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SetupTab-BCfBdL-1.js → SetupTab-jF9BsQjw.js} +3 -3
- package/extensions/dashboard-client/dist/assets/SetupTab-jF9BsQjw.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-B3CAK2FZ.js → TimeSavedCard-qfwO1WJ3.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-B3CAK2FZ.js.map → TimeSavedCard-qfwO1WJ3.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnMemoryView-7SRtcvZF.js → TurnMemoryView-C7NQo_xi.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnMemoryView-7SRtcvZF.js.map → TurnMemoryView-C7NQo_xi.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/TurnsTab-D-19giqQ.js +2 -0
- package/extensions/dashboard-client/dist/assets/{TurnsTab-Djd-nzlT.js.map → TurnsTab-D-19giqQ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-BzvdQnVq.js → VcStatusBadge-DTHlwuUJ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-BzvdQnVq.js.map → VcStatusBadge-DTHlwuUJ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-qmY0a0E-.js → VectorCortexTab-Dvgdcwvs.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-qmY0a0E-.js.map → VectorCortexTab-Dvgdcwvs.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{WikiTab-DMmc36Xi.js → WikiTab-CYUEAQmZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-DMmc36Xi.js.map → WikiTab-CYUEAQmZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-DcRndiuf.js → button-DPOwTRN8.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-DcRndiuf.js.map → button-DPOwTRN8.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-CwWLYigw.js → card-CUipkgi9.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-CwWLYigw.js.map → card-CUipkgi9.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{client-extra-NQXJNKNj.js → client-extra-9lcKX-iO.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{client-extra-NQXJNKNj.js.map → client-extra-9lcKX-iO.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-BX9n_-am.js → generateCategoricalChart-_WpiJebf.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-BX9n_-am.js.map → generateCategoricalChart-_WpiJebf.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-DgKI8jwx.js → index-DlHJ7LBL.js} +3 -3
- package/extensions/dashboard-client/dist/assets/{index-DgKI8jwx.js.map → index-DlHJ7LBL.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{switch-C_xzN77s.js → switch-Cx6-1wnT.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-C_xzN77s.js.map → switch-Cx6-1wnT.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-807R1-Th.js → toggle-Y3vbE0NG.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-807R1-Th.js.map → toggle-Y3vbE0NG.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-BNG39O7p.js → useSSE-CnJdk56R.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-BNG39O7p.js.map → useSSE-CnJdk56R.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/tabs/SetupTab/CortexActionsCard.tsx +89 -5
- package/extensions/dashboard-client/src/types/setup-cortex.ts +22 -1
- package/extensions/dashboard-server/api-contracts/setup-cortex-native-ort.ts +52 -0
- package/extensions/dashboard-server/api-contracts/setup-cortex.ts +8 -2
- package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +6 -0
- package/extensions/dashboard-server/routes-setup-cortex-actions.ts +22 -11
- package/extensions/dashboard-server/routes-vector-cortex-crystals.ts +46 -30
- package/extensions/dashboard-server/routes-vector-cortex-diagnostics.ts +52 -29
- package/extensions/dashboard-server/routes-vector-cortex-economics.ts +35 -20
- package/extensions/dashboard-server/routes-vector-cortex-helpers.ts +84 -0
- package/extensions/dashboard-server/routes-vector-cortex-policy.ts +35 -16
- package/extensions/dashboard-server/setup-cortex-actions-native-ort.ts +121 -0
- package/extensions/dashboard-server/setup-cortex-actions.ts +9 -3
- package/package.json +1 -1
- package/src/config/vector-cortex-enc2c.ts +40 -0
- package/src/config/vector-cortex.ts +2 -0
- package/src/config.ts +1 -0
- package/src/vector-cortex/cache/store.ts +26 -2
- package/src/vector-cortex/encoder/asset.ts +46 -3
- package/src/vector-cortex/encoder/router.ts +56 -2
- package/src/vector-cortex/encoder/types.ts +3 -0
- package/src/vector-cortex/livewire/livewire-live.ts +223 -0
- package/src/vector-cortex/livewire/livewire-registry.ts +91 -0
- package/src/vector-cortex/livewire/livewire-runtime.ts +117 -0
- package/src/vector-cortex/livewire/livewire-snapshot.ts +108 -0
- package/src/vector-cortex/livewire/livewire-types.ts +84 -0
- package/src/vector-cortex/provider/economics.ts +9 -31
- package/src/vector-cortex/provider/registry.ts +82 -11
- package/src/vector-cortex/provider/types.ts +37 -0
- package/src/vector-cortex/setup-cortex-blockers-compute.ts +8 -1
- package/extensions/dashboard-client/dist/assets/MetricsTab-sks9wzZr.js +0 -2
- package/extensions/dashboard-client/dist/assets/SetupTab-BCfBdL-1.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TurnsTab-Djd-nzlT.js +0 -2
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/livewire/livewire-runtime.ts — LIVEWIRE runtime accumulation seam.
|
|
3
|
+
*
|
|
4
|
+
* The WRITE side of LIVEWIRE: the runtime calls these methods wherever the
|
|
5
|
+
* corresponding subsystem path actually runs, and each call accumulates into the
|
|
6
|
+
* per-stateDir live state and persists a reduced count-only snapshot (best-effort,
|
|
7
|
+
* non-fatal). This is the seam that turns the pure VC7A/VC7B/VC7C/VC8B arithmetic
|
|
8
|
+
* into LIVE dashboard state.
|
|
9
|
+
*
|
|
10
|
+
* FLAG SEMANTICS (mirrors every other VC writer): these methods run REGARDLESS of
|
|
11
|
+
* the corresponding `MEGACOMPACT_VC*` flag — the arithmetic is never skipped, and
|
|
12
|
+
* a miss is still classified / a write still stored exactly as before. Only the
|
|
13
|
+
* dashboard REPORT seam (`routes-vector-cortex-*.ts`) is flag-gated: with the
|
|
14
|
+
* flag off a route returns the legacy `deferredReason` (byte-identical to the
|
|
15
|
+
* predecessor). The reporter emit seams in `cache/*-emit.ts` / `controller/
|
|
16
|
+
* policy-emit.ts` remain the event-announcement gate.
|
|
17
|
+
*
|
|
18
|
+
* PREVENT-PI-004: no network. PREVENT-011: no `any`. Every write is best-effort.
|
|
19
|
+
*/
|
|
20
|
+
import { classifyMiss } from "../cache/diagnostics.js";
|
|
21
|
+
import { shouldBlockServe } from "../cache/breaker.js";
|
|
22
|
+
import { livewireOf, persistLivewire } from "./livewire-registry.js";
|
|
23
|
+
/**
|
|
24
|
+
* Record a VC7A crystal WRITE attempt (write-once + collision arithmetic). The
|
|
25
|
+
* caller passes the fully-formed `CrystalV1`; the store returns the write result
|
|
26
|
+
* (first-write / idempotent / collision). The dashboard's `stats()` reflects it.
|
|
27
|
+
*
|
|
28
|
+
* @returns the store's write verdict, forwarded so the runtime can act on a
|
|
29
|
+
* collision without re-deriving it.
|
|
30
|
+
*/
|
|
31
|
+
export function recordCrystalWrite(stateDir, crystal) {
|
|
32
|
+
const state = livewireOf(stateDir);
|
|
33
|
+
const result = state.crystalStore.write(crystal);
|
|
34
|
+
persistLivewire(state, stateDir);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Record a VC7A crystal READ attempt. Returns the stored crystal (or undefined
|
|
39
|
+
* on a miss / mode C), mirroring `CrystalStore.read` so the cache-serve path can
|
|
40
|
+
* use this seam entirely.
|
|
41
|
+
*/
|
|
42
|
+
export function readCrystal(stateDir, keyDigest) {
|
|
43
|
+
const state = livewireOf(stateDir);
|
|
44
|
+
const found = state.crystalStore.read(keyDigest);
|
|
45
|
+
persistLivewire(state, stateDir);
|
|
46
|
+
return found;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Record a VC7C miss observation: classify it into its exclusive class and tally
|
|
50
|
+
* it. When the class demands the cache serve be demoted BEFORE answering, the
|
|
51
|
+
* `serveBlocked` counter is also incremented. The live breaker state itself is
|
|
52
|
+
* driven by the real cache-serve path (through `breaker.execute`), not here; this
|
|
53
|
+
* seam only observes and tallies.
|
|
54
|
+
*
|
|
55
|
+
* @returns the exclusive class the observation was tallied under.
|
|
56
|
+
*/
|
|
57
|
+
export function observeCacheMiss(stateDir, observation) {
|
|
58
|
+
const state = livewireOf(stateDir);
|
|
59
|
+
const missClass = classifyMiss(observation).missClass;
|
|
60
|
+
state.diagnostics.tallies[missClass] += 1;
|
|
61
|
+
if (shouldBlockServe(missClass))
|
|
62
|
+
state.diagnostics.serveBlocked += 1;
|
|
63
|
+
persistLivewire(state, stateDir);
|
|
64
|
+
return missClass;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Record a VC7C cache serve that the breaker demoted BEFORE answering. Talls the
|
|
68
|
+
* `serveBlocked` counter the diagnostics card surfaces.
|
|
69
|
+
*/
|
|
70
|
+
export function recordServeBlocked(stateDir) {
|
|
71
|
+
const state = livewireOf(stateDir);
|
|
72
|
+
state.diagnostics.serveBlocked += 1;
|
|
73
|
+
persistLivewire(state, stateDir);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Record a VC8B shadow evaluation run: accumulate its decision metrics so the
|
|
77
|
+
* policy card reports how many shadow decisions were evaluated / clamped /
|
|
78
|
+
* rejected and how many live mutations the shadow proved (structurally 0).
|
|
79
|
+
*/
|
|
80
|
+
export function recordShadowRun(stateDir, result) {
|
|
81
|
+
const state = livewireOf(stateDir);
|
|
82
|
+
state.shadow.shadowDecisions += result.metrics.evaluated;
|
|
83
|
+
state.shadow.clampedDecisions += result.metrics.clamped;
|
|
84
|
+
state.shadow.rejectedInputs += result.metrics.rejected;
|
|
85
|
+
state.shadow.liveMutations += result.metrics.liveMutations;
|
|
86
|
+
persistLivewire(state, stateDir);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Set the active M7 pressure version (1 = legacy, 2 = migrated). The runtime
|
|
90
|
+
* calls this after a successful `migratePressureV2` so the policy card reflects
|
|
91
|
+
* the live migration state rather than a hardcoded 1.
|
|
92
|
+
*/
|
|
93
|
+
export function setPressureVersion(stateDir, version) {
|
|
94
|
+
const state = livewireOf(stateDir);
|
|
95
|
+
state.shadow.pressureVersion = version;
|
|
96
|
+
persistLivewire(state, stateDir);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Mark that VC7B cache economics have actually been computed at runtime (the
|
|
100
|
+
* `computed` bit drives the economics card's `hasData`). The runtime calls this
|
|
101
|
+
* after the first real `computeEconomics` over observed usage.
|
|
102
|
+
*/
|
|
103
|
+
export function markEconomicsComputed(stateDir) {
|
|
104
|
+
const state = livewireOf(stateDir);
|
|
105
|
+
state.economics.computed = true;
|
|
106
|
+
persistLivewire(state, stateDir);
|
|
107
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/livewire/livewire-snapshot.ts — LIVEWIRE aggregate persistence.
|
|
3
|
+
*
|
|
4
|
+
* The four LV subsytems are in-process live objects, but the dashboard server may
|
|
5
|
+
* run in a SEPARATE process from the runtime that accumulates the counts. To keep
|
|
6
|
+
* the reader-only routes honest when they run in their own process, this module
|
|
7
|
+
* persists a COUNT-ONLY aggregate snapshot (`vector-cortex-livewire.json`) to the
|
|
8
|
+
* per-repo `stateDir`, and `openLivewire` rehydrates a fresh process from it on
|
|
9
|
+
* first access. This is the same DR-snapshot philosophy as the legacy JSON
|
|
10
|
+
* checkpoints, but reduced to counts + codes (SECURITY_PRIVACY — see these types).
|
|
11
|
+
*
|
|
12
|
+
* BEST-EFFORT + NON-FATAL. A failed write is logged as a structured event and
|
|
13
|
+
* never breaks the agent loop; a missing/unreadable snapshot reads as null and
|
|
14
|
+
* the process starts from zero (matches the non-fatal-stores invariant). Every
|
|
15
|
+
* write is atomic-ish: the JSON is fully serialized to a temp name then renamed
|
|
16
|
+
* so a reader never observes a partial snapshot.
|
|
17
|
+
*
|
|
18
|
+
* PREVENT-PI-004: local filesystem read/write only, no network. PREVENT-011: no
|
|
19
|
+
* `any`.
|
|
20
|
+
*/
|
|
21
|
+
import { readFileSync, writeFileSync, renameSync, existsSync, mkdirSync } from "node:fs";
|
|
22
|
+
import { join } from "node:path";
|
|
23
|
+
/** The snapshot filename in the per-repo stateDir (counts + codes only). */
|
|
24
|
+
export const LIVEWIRE_SNAPSHOT_FILE = "vector-cortex-livewire.json";
|
|
25
|
+
/** Resolve the snapshot path for a stateDir. */
|
|
26
|
+
export function livewireSnapshotPath(stateDir) {
|
|
27
|
+
return join(stateDir, LIVEWIRE_SNAPSHOT_FILE);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Best-effort type guard over a parsed snapshot. Rejects anything that is not
|
|
31
|
+
* the exact aggregate shape so a corrupted or stale file cannot poison the
|
|
32
|
+
* rehydrated counters.
|
|
33
|
+
*/
|
|
34
|
+
function isSnapshot(value) {
|
|
35
|
+
if (typeof value !== "object" || value === null)
|
|
36
|
+
return false;
|
|
37
|
+
const s = value;
|
|
38
|
+
return (s.schema === "vector-cortex-livewire-v1" &&
|
|
39
|
+
typeof s.crystals === "object" &&
|
|
40
|
+
s.crystals !== null &&
|
|
41
|
+
typeof s.diagnostics === "object" &&
|
|
42
|
+
s.diagnostics !== null &&
|
|
43
|
+
typeof s.economics === "object" &&
|
|
44
|
+
s.economics !== null &&
|
|
45
|
+
typeof s.policy === "object" &&
|
|
46
|
+
s.policy !== null);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Read the persisted aggregate for a stateDir, or null when absent/unreadable/
|
|
50
|
+
* malformed. Best-effort and non-fatal by construction.
|
|
51
|
+
*/
|
|
52
|
+
export function loadLivewireSnapshot(stateDir) {
|
|
53
|
+
const path = livewireSnapshotPath(stateDir);
|
|
54
|
+
let raw;
|
|
55
|
+
try {
|
|
56
|
+
raw = readFileSync(path, "utf-8");
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const parsed = JSON.parse(raw);
|
|
63
|
+
return isSnapshot(parsed) ? parsed : null;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Best-effort write of the aggregate snapshot (atomic rename). Never throws to
|
|
71
|
+
* the caller: a persistence failure logs a structured event and is swallowed.
|
|
72
|
+
*
|
|
73
|
+
* @param logger optional structured logger `(line: unknown) => void`; when
|
|
74
|
+
* omitted no event is emitted (tests pass `undefined`).
|
|
75
|
+
*/
|
|
76
|
+
export function saveLivewireSnapshot(stateDir, snapshot, logger) {
|
|
77
|
+
const dir = stateDir;
|
|
78
|
+
try {
|
|
79
|
+
if (!existsSync(dir))
|
|
80
|
+
mkdirSync(dir, { recursive: true });
|
|
81
|
+
const path = livewireSnapshotPath(dir);
|
|
82
|
+
const tmp = `${path}.tmp`;
|
|
83
|
+
writeFileSync(tmp, JSON.stringify(snapshot), "utf-8");
|
|
84
|
+
renameSync(tmp, path);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (logger !== undefined) {
|
|
88
|
+
try {
|
|
89
|
+
logger({
|
|
90
|
+
ts: new Date().toISOString(),
|
|
91
|
+
event: "vector_cortex_livewire_snapshot_write_failed",
|
|
92
|
+
stateDir,
|
|
93
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// A failing logger must not recurse into another failure.
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/livewire/livewire-types.ts — LIVEWIRE aggregate snapshot types.
|
|
3
|
+
*
|
|
4
|
+
* LIVEWIRE wires the four complete-but-unwired Vector Cortex subsystems into the
|
|
5
|
+
* runtime so their dashboard routes report LIVE state instead of hardcoded
|
|
6
|
+
* "deferred" zeros. This module is the SINGLE SOURCE OF TRUTH for the persisted
|
|
7
|
+
* aggregate snapshot shape (counts + codes ONLY) and for the per-stateDir
|
|
8
|
+
* live-state records the routes read.
|
|
9
|
+
*
|
|
10
|
+
* SECURITY_PRIVACY: every field here is a count, a code, or a finite triad mode.
|
|
11
|
+
* There is deliberately NO string slot for a session id, a request/crystal
|
|
12
|
+
* digest, a covered range, frozen bytes, a profile id, or ledger content — a
|
|
13
|
+
* crystal IS a frozen rendered prompt, so the card that reports on it must never
|
|
14
|
+
* be able to carry one. The snapshot is the SAME reduced shape, so nothing secret
|
|
15
|
+
* reaches disk either.
|
|
16
|
+
*
|
|
17
|
+
* PREVENT-PI-004: type definitions only, no network code. PREVENT-011: no `any`.
|
|
18
|
+
*/
|
|
19
|
+
export {};
|
|
@@ -45,48 +45,80 @@ function baseCache(stableFields) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
/** Build a contract-profile shape pinned as a conformance fixture too. */
|
|
48
|
-
function profile(id, version, excludedJsonPointers) {
|
|
48
|
+
function profile(id, version, excludedJsonPointers, economics) {
|
|
49
49
|
return {
|
|
50
50
|
schema: "provider-profile-v1",
|
|
51
51
|
id,
|
|
52
52
|
version,
|
|
53
53
|
hashMode: "entire-canonical-request",
|
|
54
54
|
excludedJsonPointers,
|
|
55
|
+
economics,
|
|
55
56
|
};
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Build integer micro-unit economics for a base profile (VC7B). A cache WRITE
|
|
60
|
+
* costs more than an uncached token, a cache READ costs less — the standard
|
|
61
|
+
* provider-prompt-cache shape. `exclusionFixtureId` mirrors the profile's own
|
|
62
|
+
* exclusion fixture (or null when the profile has none to prove).
|
|
63
|
+
*/
|
|
64
|
+
function econ(id, version, exclusionFixtureId, values) {
|
|
65
|
+
return {
|
|
66
|
+
schema: "provider-economics-v1",
|
|
67
|
+
profileId: id,
|
|
68
|
+
profileVersion: version,
|
|
69
|
+
basePrice: values.basePrice,
|
|
70
|
+
readPrice: values.readPrice,
|
|
71
|
+
writePrice: values.writePrice,
|
|
72
|
+
ttlMs: values.ttlMs,
|
|
73
|
+
minPrefix: values.minPrefix,
|
|
74
|
+
exclusionFixtureId,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Representative integer micro-unit economics for the Anthropic opus base tier. */
|
|
78
|
+
const OPUS_ECON = econ("anthropic-claude-opus", "v1", null, { basePrice: 15, readPrice: 2, writePrice: 19, ttlMs: 300_000, minPrefix: 1024 });
|
|
79
|
+
/** Representative integer micro-unit economics for the Anthropic sonnet base tier. */
|
|
80
|
+
const SONNET_ECON = econ("anthropic-claude-sonnet", "v1", null, { basePrice: 3, readPrice: 0, writePrice: 4, ttlMs: 300_000, minPrefix: 1024 });
|
|
81
|
+
/** Representative integer micro-unit economics for the OpenAI gpt base tier. */
|
|
82
|
+
const GPT_ECON = econ("openai-gpt", "v1", null, { basePrice: 5, readPrice: 1, writePrice: 6, ttlMs: 300_000, minPrefix: 1024 });
|
|
83
|
+
/** The gemini profile's versioned, fixture-proven exclusion. */
|
|
84
|
+
const GEMINI_EXCLUSIONS = [
|
|
85
|
+
{
|
|
86
|
+
pointer: "/requestId",
|
|
87
|
+
fixtureId: "PRO-EXCLUDE-010",
|
|
88
|
+
proofDigest: "sha256:excluded-request-id-proof",
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
/** Representative integer micro-unit economics for the gemini base tier. */
|
|
92
|
+
const GEMINI_ECON = econ("google-gemini", "v1", "PRO-EXCLUDE-010", { basePrice: 3, readPrice: 1, writePrice: 4, ttlMs: 300_000, minPrefix: 1024 });
|
|
57
93
|
/**
|
|
58
94
|
* The fixture-backed base profiles. Each entry is the REAL bundle the renderer
|
|
59
95
|
* resolves; the parallel conformance fixtures prove the cache-identity behavior.
|
|
60
96
|
*/
|
|
61
97
|
const BASE_PROFILES = [
|
|
62
98
|
{
|
|
63
|
-
profile: profile("anthropic-claude-opus", "v1", []),
|
|
99
|
+
profile: profile("anthropic-claude-opus", "v1", [], OPUS_ECON),
|
|
64
100
|
role: BASE_ROLE,
|
|
65
101
|
tool: BASE_TOOL,
|
|
66
102
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
67
103
|
},
|
|
68
104
|
{
|
|
69
|
-
profile: profile("anthropic-claude-sonnet", "v1", []),
|
|
105
|
+
profile: profile("anthropic-claude-sonnet", "v1", [], SONNET_ECON),
|
|
70
106
|
role: BASE_ROLE,
|
|
71
107
|
tool: BASE_TOOL,
|
|
72
108
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
73
109
|
},
|
|
74
110
|
{
|
|
75
|
-
profile: profile("openai-gpt", "v1", []),
|
|
111
|
+
profile: profile("openai-gpt", "v1", [], GPT_ECON),
|
|
76
112
|
role: BASE_ROLE,
|
|
77
113
|
tool: BASE_TOOL,
|
|
78
114
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
79
115
|
},
|
|
80
116
|
{
|
|
81
117
|
// A profile that proves a fixture-excluded pointer: a provider whose
|
|
82
|
-
// request-id header cannot affect cache identity. Excluded + versioned
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
fixtureId: "PRO-EXCLUDE-010",
|
|
87
|
-
proofDigest: "sha256:excluded-request-id-proof",
|
|
88
|
-
},
|
|
89
|
-
]),
|
|
118
|
+
// request-id header cannot affect cache identity. Excluded + versioned, and
|
|
119
|
+
// the exclusion fixture id is carried into economics so the proof is
|
|
120
|
+
// honored (an unproven exclusion would fail economics validation).
|
|
121
|
+
profile: profile("google-gemini", "v1", GEMINI_EXCLUSIONS, GEMINI_ECON),
|
|
90
122
|
role: BASE_ROLE,
|
|
91
123
|
tool: BASE_TOOL,
|
|
92
124
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
@@ -164,6 +164,9 @@ const ACTION_GATE_CANDIDATES = {
|
|
|
164
164
|
// behavior change. HG-7 is training work (no action in this set).
|
|
165
165
|
bench: ["HG-1", "HG-3", "HG-6"],
|
|
166
166
|
"verify-asset": [],
|
|
167
|
+
// ENC-2c: installing the lazy-download native binding is gated by HG-3 (the
|
|
168
|
+
// open install-budget hard gate) — a closed HG-3 no longer blocks the install.
|
|
169
|
+
"install-native-ort": ["HG-3"],
|
|
167
170
|
};
|
|
168
171
|
/**
|
|
169
172
|
* Re-derived VC9B action gating from the LIVE computed blockers. An action is
|
|
@@ -70,6 +70,11 @@ export class CrystalStore {
|
|
|
70
70
|
writes = 0;
|
|
71
71
|
duplicateWrites = 0;
|
|
72
72
|
collisions = 0;
|
|
73
|
+
/** Restart-survival crystal count/bytes (LIVEWIRE rehydrate). The `committed`
|
|
74
|
+
* map is empty in a fresh process; these offsets carry the persisted totals
|
|
75
|
+
* so the dashboard does not reset to zero on restart. */
|
|
76
|
+
rehydratedCrystalCount = 0;
|
|
77
|
+
rehydratedTotalBytes = 0;
|
|
73
78
|
/** Freeze a crystal object for a key/bytes pair (digest computed here). */
|
|
74
79
|
static freeze(keyDigest, bytes, key) {
|
|
75
80
|
const copy = new Uint8Array(bytes);
|
|
@@ -178,12 +183,12 @@ export class CrystalStore {
|
|
|
178
183
|
}
|
|
179
184
|
/** Reader-only aggregate for the dashboard seam — counts and bytes only. */
|
|
180
185
|
stats() {
|
|
181
|
-
let totalBytes =
|
|
186
|
+
let totalBytes = this.rehydratedTotalBytes;
|
|
182
187
|
for (const c of this.committed.values())
|
|
183
188
|
totalBytes += c.byteCount;
|
|
184
189
|
return {
|
|
185
190
|
mode: this.mode(),
|
|
186
|
-
crystalCount: this.committed.size,
|
|
191
|
+
crystalCount: this.rehydratedCrystalCount + this.committed.size,
|
|
187
192
|
totalBytes,
|
|
188
193
|
hits: this.hits,
|
|
189
194
|
misses: this.misses,
|
|
@@ -193,4 +198,22 @@ export class CrystalStore {
|
|
|
193
198
|
collisions: this.collisions,
|
|
194
199
|
};
|
|
195
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Restart survival: seed the CUMULATIVE counters from a previously-persisted
|
|
203
|
+
* aggregate (LIVEWIRE). The in-memory `committed` map is naturally empty in a
|
|
204
|
+
* fresh process — this only restores the running totals the dashboard reports,
|
|
205
|
+
* so a process restart does not reset the dashboard to zero. It deliberately
|
|
206
|
+
* does NOT reconstruct crystals: frozen bytes are never persisted to the
|
|
207
|
+
* reader aggregate, only the counts.
|
|
208
|
+
*/
|
|
209
|
+
rehydrate(stats) {
|
|
210
|
+
this.rehydratedCrystalCount = stats.crystalCount;
|
|
211
|
+
this.rehydratedTotalBytes = stats.totalBytes;
|
|
212
|
+
this.hits = stats.hits;
|
|
213
|
+
this.misses = stats.misses;
|
|
214
|
+
this.hitBytes = stats.hitBytes;
|
|
215
|
+
this.writes = stats.writes;
|
|
216
|
+
this.duplicateWrites = stats.duplicateWrites;
|
|
217
|
+
this.collisions = stats.collisions;
|
|
218
|
+
}
|
|
196
219
|
}
|
|
@@ -67,7 +67,14 @@ function isManifest(m) {
|
|
|
67
67
|
typeof o.onnx.path === "string" &&
|
|
68
68
|
typeof o.onnx.sha256 === "string" &&
|
|
69
69
|
typeof o.tokenizer.path === "string" &&
|
|
70
|
-
typeof o.tokenizer.sha256 === "string"
|
|
70
|
+
typeof o.tokenizer.sha256 === "string" &&
|
|
71
|
+
// ML5-A (VC2B-2): optional headWeights must, when present, be a valid
|
|
72
|
+
// ManifestAssetFile (path basename + sha256 + bytes).
|
|
73
|
+
(o.headWeights === undefined ||
|
|
74
|
+
(!!o.headWeights &&
|
|
75
|
+
typeof o.headWeights.path === "string" &&
|
|
76
|
+
typeof o.headWeights.sha256 === "string" &&
|
|
77
|
+
typeof o.headWeights.bytes === "number")));
|
|
71
78
|
}
|
|
72
79
|
/**
|
|
73
80
|
* Verify the asset manifest + digest + constraints BEFORE allocation.
|
|
@@ -107,6 +114,11 @@ export function verifyEncoderAsset(assetDir, manifest, platform = detectPlatform
|
|
|
107
114
|
if (!isBasename(manifest.onnx.path) || !isBasename(manifest.tokenizer.path)) {
|
|
108
115
|
return { ok: false, code: ENC_FAIL.MANIFEST_INVALID };
|
|
109
116
|
}
|
|
117
|
+
// ML5-A (VC2B-2): a manifest-declared headWeights path must also be a bare
|
|
118
|
+
// basename (no traversal into arbitrary paths off the asset dir).
|
|
119
|
+
if (manifest.headWeights !== undefined && !isBasename(manifest.headWeights.path)) {
|
|
120
|
+
return { ok: false, code: ENC_FAIL.MANIFEST_INVALID };
|
|
121
|
+
}
|
|
110
122
|
const onnxPath = join(assetDir, manifest.onnx.path);
|
|
111
123
|
const onnxDigest = digestFile(onnxPath);
|
|
112
124
|
if (onnxDigest === null)
|
|
@@ -119,6 +131,19 @@ export function verifyEncoderAsset(assetDir, manifest, platform = detectPlatform
|
|
|
119
131
|
return { ok: false, code: ENC_FAIL.ASSET_UNREADABLE };
|
|
120
132
|
if (tokDigest !== manifest.tokenizer.sha256)
|
|
121
133
|
return { ok: false, code: ENC_FAIL.DIGEST_MISMATCH };
|
|
134
|
+
// ML5-A (VC2B-2): verify the manifest-pinned trained-heads sibling when the
|
|
135
|
+
// manifest declares it. Absent declaration -> headWeightsDigest: null and no
|
|
136
|
+
// failure (committed placeholder bundle ships no trained weights).
|
|
137
|
+
let headWeightsDigest = null;
|
|
138
|
+
if (manifest.headWeights !== undefined) {
|
|
139
|
+
const hwPath = join(assetDir, manifest.headWeights.path);
|
|
140
|
+
const hwDigest = digestFile(hwPath);
|
|
141
|
+
if (hwDigest === null)
|
|
142
|
+
return { ok: false, code: ENC_FAIL.ASSET_UNREADABLE };
|
|
143
|
+
if (hwDigest !== manifest.headWeights.sha256)
|
|
144
|
+
return { ok: false, code: ENC_FAIL.DIGEST_MISMATCH };
|
|
145
|
+
headWeightsDigest = hwDigest;
|
|
146
|
+
}
|
|
122
147
|
let embeddedBytes = 0;
|
|
123
148
|
try {
|
|
124
149
|
embeddedBytes = statSync(onnxPath).size + statSync(tokPath).size;
|
|
@@ -126,7 +151,14 @@ export function verifyEncoderAsset(assetDir, manifest, platform = detectPlatform
|
|
|
126
151
|
catch {
|
|
127
152
|
return { ok: false, code: ENC_FAIL.ASSET_UNREADABLE };
|
|
128
153
|
}
|
|
129
|
-
return {
|
|
154
|
+
return {
|
|
155
|
+
ok: true,
|
|
156
|
+
embeddedBytes,
|
|
157
|
+
maxTokens: manifest.maxTokens,
|
|
158
|
+
onnxDigest,
|
|
159
|
+
tokenizerDigest: tokDigest,
|
|
160
|
+
headWeightsDigest,
|
|
161
|
+
};
|
|
130
162
|
}
|
|
131
163
|
/**
|
|
132
164
|
* Read + shape-check a committed ModelManifestV1 from an asset directory.
|
|
@@ -25,11 +25,12 @@
|
|
|
25
25
|
* Pi-agnostic, zero network (PREVENT-PI-004), no `any` (PREVENT-011).
|
|
26
26
|
*/
|
|
27
27
|
import { createEncoderRuntime } from "./runtime.js";
|
|
28
|
-
import { encodeVectorSet } from "./heads.js";
|
|
28
|
+
import { encodeVectorSet, loadHeadProjections, projectHeadFromTrunk, } from "./heads.js";
|
|
29
29
|
import { embedTrigram512, selectTrigramBFallback } from "./trigram.js";
|
|
30
30
|
import { embedLexical, selectLexicalC } from "./lexical.js";
|
|
31
31
|
import { createEncoderHeadsReporter } from "./emit-vc2b.js";
|
|
32
|
-
import {
|
|
32
|
+
import { ML5A_ENABLED } from "../../config/vector-cortex.js";
|
|
33
|
+
import { ENC_FAIL, ENCODER_HEAD_ORDER, } from "./types.js";
|
|
33
34
|
/** Deterministic text derived from an int token sequence so the asset-free
|
|
34
35
|
* fallback producers operate on the same authority the learned path encoded. */
|
|
35
36
|
function textFromTokens(tokens) {
|
|
@@ -92,9 +93,36 @@ export function encodeOrFallback(input, assetDir, options = {}) {
|
|
|
92
93
|
if (!inferred.ok) {
|
|
93
94
|
return fallbackFromLoad({ ok: false, mode: "B", code: inferred.code }, reporter, tokens);
|
|
94
95
|
}
|
|
95
|
-
const vectorSet =
|
|
96
|
+
const vectorSet = produceVectorSet(inferred.semantic, tokens, options, reporter);
|
|
96
97
|
return { ok: true, mode: "A", vectorSet, code: null };
|
|
97
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Produce a mode-A `VectorSetV1` from the [1,384] trunk embedding (the
|
|
101
|
+
* `runtime.infer` result). VC2B-2 ML5-A: when real trained heads are loaded
|
|
102
|
+
* (`MEGACOMPACT_ML5_A` on + a `trainedHeadsPath` that loads), the multi-head
|
|
103
|
+
* output is projected through the real trained projection matrices via
|
|
104
|
+
* `projectHeadFromTrunk`. Otherwise (flag-off / absent / unloadable artifact)
|
|
105
|
+
* the deterministic LCG placeholder `encodeVectorSet` serves mode A —
|
|
106
|
+
* byte-identical to the VC2B predecessor. Non-fatal: an unloadable artifact
|
|
107
|
+
* degrades to the placeholder, never a throw.
|
|
108
|
+
*/
|
|
109
|
+
function produceVectorSet(trunkEmbedding, tokens, options, reporter) {
|
|
110
|
+
const table = ML5A_ENABLED() && options.trainedHeadsPath !== undefined
|
|
111
|
+
? loadHeadProjections(options.trainedHeadsPath)
|
|
112
|
+
: null;
|
|
113
|
+
if (table !== null) {
|
|
114
|
+
const heads = ENCODER_HEAD_ORDER.map((h) => projectHeadFromTrunk(h, trunkEmbedding, table));
|
|
115
|
+
reporter.headsEmitted({
|
|
116
|
+
heads: heads.length,
|
|
117
|
+
dims: heads.map((h) => h.dim).join("/"),
|
|
118
|
+
normalized: true,
|
|
119
|
+
tokens: tokens.length,
|
|
120
|
+
});
|
|
121
|
+
return { schema: "vector-set-v1", inputTokens: [...tokens], heads, normalized: true };
|
|
122
|
+
}
|
|
123
|
+
// ML5-A placeholder fallback (byte-identical predecessor).
|
|
124
|
+
return encodeVectorSet(tokens, { reporter, seed: options.seed });
|
|
125
|
+
}
|
|
98
126
|
/**
|
|
99
127
|
* Catch a (real or forced) A load failure (ok === false only) and select the
|
|
100
128
|
* B/C fallback that emits `vector_cortex_encoder_fallback_selected` from the
|
|
@@ -45,48 +45,80 @@ function baseCache(stableFields) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
/** Build a contract-profile shape pinned as a conformance fixture too. */
|
|
48
|
-
function profile(id, version, excludedJsonPointers) {
|
|
48
|
+
function profile(id, version, excludedJsonPointers, economics) {
|
|
49
49
|
return {
|
|
50
50
|
schema: "provider-profile-v1",
|
|
51
51
|
id,
|
|
52
52
|
version,
|
|
53
53
|
hashMode: "entire-canonical-request",
|
|
54
54
|
excludedJsonPointers,
|
|
55
|
+
economics,
|
|
55
56
|
};
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Build integer micro-unit economics for a base profile (VC7B). A cache WRITE
|
|
60
|
+
* costs more than an uncached token, a cache READ costs less — the standard
|
|
61
|
+
* provider-prompt-cache shape. `exclusionFixtureId` mirrors the profile's own
|
|
62
|
+
* exclusion fixture (or null when the profile has none to prove).
|
|
63
|
+
*/
|
|
64
|
+
function econ(id, version, exclusionFixtureId, values) {
|
|
65
|
+
return {
|
|
66
|
+
schema: "provider-economics-v1",
|
|
67
|
+
profileId: id,
|
|
68
|
+
profileVersion: version,
|
|
69
|
+
basePrice: values.basePrice,
|
|
70
|
+
readPrice: values.readPrice,
|
|
71
|
+
writePrice: values.writePrice,
|
|
72
|
+
ttlMs: values.ttlMs,
|
|
73
|
+
minPrefix: values.minPrefix,
|
|
74
|
+
exclusionFixtureId,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Representative integer micro-unit economics for the Anthropic opus base tier. */
|
|
78
|
+
const OPUS_ECON = econ("anthropic-claude-opus", "v1", null, { basePrice: 15, readPrice: 2, writePrice: 19, ttlMs: 300_000, minPrefix: 1024 });
|
|
79
|
+
/** Representative integer micro-unit economics for the Anthropic sonnet base tier. */
|
|
80
|
+
const SONNET_ECON = econ("anthropic-claude-sonnet", "v1", null, { basePrice: 3, readPrice: 0, writePrice: 4, ttlMs: 300_000, minPrefix: 1024 });
|
|
81
|
+
/** Representative integer micro-unit economics for the OpenAI gpt base tier. */
|
|
82
|
+
const GPT_ECON = econ("openai-gpt", "v1", null, { basePrice: 5, readPrice: 1, writePrice: 6, ttlMs: 300_000, minPrefix: 1024 });
|
|
83
|
+
/** The gemini profile's versioned, fixture-proven exclusion. */
|
|
84
|
+
const GEMINI_EXCLUSIONS = [
|
|
85
|
+
{
|
|
86
|
+
pointer: "/requestId",
|
|
87
|
+
fixtureId: "PRO-EXCLUDE-010",
|
|
88
|
+
proofDigest: "sha256:excluded-request-id-proof",
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
/** Representative integer micro-unit economics for the gemini base tier. */
|
|
92
|
+
const GEMINI_ECON = econ("google-gemini", "v1", "PRO-EXCLUDE-010", { basePrice: 3, readPrice: 1, writePrice: 4, ttlMs: 300_000, minPrefix: 1024 });
|
|
57
93
|
/**
|
|
58
94
|
* The fixture-backed base profiles. Each entry is the REAL bundle the renderer
|
|
59
95
|
* resolves; the parallel conformance fixtures prove the cache-identity behavior.
|
|
60
96
|
*/
|
|
61
97
|
const BASE_PROFILES = [
|
|
62
98
|
{
|
|
63
|
-
profile: profile("anthropic-claude-opus", "v1", []),
|
|
99
|
+
profile: profile("anthropic-claude-opus", "v1", [], OPUS_ECON),
|
|
64
100
|
role: BASE_ROLE,
|
|
65
101
|
tool: BASE_TOOL,
|
|
66
102
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
67
103
|
},
|
|
68
104
|
{
|
|
69
|
-
profile: profile("anthropic-claude-sonnet", "v1", []),
|
|
105
|
+
profile: profile("anthropic-claude-sonnet", "v1", [], SONNET_ECON),
|
|
70
106
|
role: BASE_ROLE,
|
|
71
107
|
tool: BASE_TOOL,
|
|
72
108
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
73
109
|
},
|
|
74
110
|
{
|
|
75
|
-
profile: profile("openai-gpt", "v1", []),
|
|
111
|
+
profile: profile("openai-gpt", "v1", [], GPT_ECON),
|
|
76
112
|
role: BASE_ROLE,
|
|
77
113
|
tool: BASE_TOOL,
|
|
78
114
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
79
115
|
},
|
|
80
116
|
{
|
|
81
117
|
// A profile that proves a fixture-excluded pointer: a provider whose
|
|
82
|
-
// request-id header cannot affect cache identity. Excluded + versioned
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
fixtureId: "PRO-EXCLUDE-010",
|
|
87
|
-
proofDigest: "sha256:excluded-request-id-proof",
|
|
88
|
-
},
|
|
89
|
-
]),
|
|
118
|
+
// request-id header cannot affect cache identity. Excluded + versioned, and
|
|
119
|
+
// the exclusion fixture id is carried into economics so the proof is
|
|
120
|
+
// honored (an unproven exclusion would fail economics validation).
|
|
121
|
+
profile: profile("google-gemini", "v1", GEMINI_EXCLUSIONS, GEMINI_ECON),
|
|
90
122
|
role: BASE_ROLE,
|
|
91
123
|
tool: BASE_TOOL,
|
|
92
124
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
@@ -164,6 +164,9 @@ const ACTION_GATE_CANDIDATES = {
|
|
|
164
164
|
// behavior change. HG-7 is training work (no action in this set).
|
|
165
165
|
bench: ["HG-1", "HG-3", "HG-6"],
|
|
166
166
|
"verify-asset": [],
|
|
167
|
+
// ENC-2c: installing the lazy-download native binding is gated by HG-3 (the
|
|
168
|
+
// open install-budget hard gate) — a closed HG-3 no longer blocks the install.
|
|
169
|
+
"install-native-ort": ["HG-3"],
|
|
167
170
|
};
|
|
168
171
|
/**
|
|
169
172
|
* Re-derived VC9B action gating from the LIVE computed blockers. An action is
|
package/extensions/dashboard-client/dist/assets/{AdminTab-BUl1fyQ-.js → AdminTab-ZyVtgYrZ.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as s,u as o,e as c,j as e}from"./index-
|
|
2
|
-
//# sourceMappingURL=AdminTab-
|
|
1
|
+
import{r as s,u as o,e as c,j as e}from"./index-DlHJ7LBL.js";import{T as i}from"./toggle-Y3vbE0NG.js";import r from"./MaintenanceTab-CleWX_RM.js";import{C as l}from"./ConfigTab-BNMrO7uz.js";import"./card-CUipkgi9.js";import"./button-DPOwTRN8.js";import"./switch-Cx6-1wnT.js";const f="MEGACOMPACT_DASH_0C";function m(n){if(!n)return!1;for(const t of n.categories)for(const a of t.settings)if(a.key===f&&a.type==="boolean")return a.value===!0;return!1}function h(){const[n,t]=s.useState("maintenance"),{data:a}=o(s.useCallback(()=>c(),[]),{pollInterval:0,maxRetries:0});return m(a)?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",role:"tablist","aria-label":"Admin views",children:[e.jsx(i,{pressed:n==="maintenance",onClick:()=>t("maintenance"),children:"Maintenance"}),e.jsx(i,{pressed:n==="config",onClick:()=>t("config"),children:"Config"})]}),n==="maintenance"?e.jsx(r,{}):e.jsx(l,{})]}):e.jsx(r,{})}export{h as default};
|
|
2
|
+
//# sourceMappingURL=AdminTab-ZyVtgYrZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminTab-
|
|
1
|
+
{"version":3,"file":"AdminTab-ZyVtgYrZ.js","sources":["../../src/tabs/AdminTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/tabs/AdminTab.tsx — Admin tab (DASH-0c delegate-shell).\n *\n * DASH-0c: the Admin surface combines the maintenance actions with the config\n * editor. A `AdminViews` toggle (\"maintenance\" / \"config\") switches between\n * `MaintenanceTab` (the maintenance shell over MaintenanceTab/*) and `ConfigTab`\n * (the config editor). Both bodies are UNCHANGED — only their hosting changes to\n * this new delegate-shell. `MaintenanceTab.tsx` and `ConfigTab.tsx` stay importable\n * from their original hosts (`ConfigTab` also stays wired into SetupTab per the\n * dual-host note). Flag-ON renders the toggle + both views; flag-OFF renders only\n * the maintenance view (the predecessor's `admin → MaintenanceTab` mapping),\n * and App.tsx keeps its current TabId routing this sprint (DASH-0d rewires).\n *\n * Flag: `MEGACOMPACT_DASH_0C` default ON. The dashboard client is a browser\n * bundle with NO `process` global, so the positive sprint flag cannot be read\n * server-side-style (`process.env`) inside the client. Instead the flag is read\n * from the server-authoritative `/api/rag-settings` state: the server resolves\n * `process.env[\"MEGACOMPACT_DASH_0C\"] ?? default` into the `SettingState.value`\n * boolean.\n */\n\nimport type React from \"react\";\nimport { useCallback, useState } from \"react\";\nimport type { SettingsResponse } from \"@contracts\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchSettings } from \"../api/client\";\nimport { Toggle } from \"../components/ui/toggle\";\nimport MaintenanceTab from \"./MaintenanceTab\";\nimport ConfigTab from \"./ConfigTab\";\n\nconst DASH_0C_KEY = \"MEGACOMPACT_DASH_0C\";\n\n/** Resolve the DASH-0c consolidation flag from the server settings state.\n * Absent/not-yet-loaded => false (flag-off posture), so flag-off users never\n * see the toggle flash; the toggle appears only once settings confirm it is ON. */\nfunction dash0cEnabled(settings: SettingsResponse | null): boolean {\n\tif (!settings) return false;\n\tfor (const cat of settings.categories) {\n\t\tfor (const s of cat.settings) {\n\t\t\tif (s.key === DASH_0C_KEY && s.type === \"boolean\") return s.value === true;\n\t\t}\n\t}\n\treturn false;\n}\n\ntype AdminViews = \"maintenance\" | \"config\";\n\nexport default function AdminTab(): React.ReactElement {\n\tconst [view, setView] = useState<AdminViews>(\"maintenance\");\n\n\tconst { data: settingsData } = useApi<SettingsResponse>(\n\t\tuseCallback(() => fetchSettings(), []),\n\t\t{ pollInterval: 0, maxRetries: 0 },\n\t);\n\tconst dash0cOn = dash0cEnabled(settingsData);\n\n\tif (!dash0cOn) {\n\t\treturn <MaintenanceTab />;\n\t}\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t<div\n\t\t\t\tclassName=\"flex items-center gap-2\"\n\t\t\t\trole=\"tablist\"\n\t\t\t\taria-label=\"Admin views\"\n\t\t\t>\n\t\t\t\t<Toggle\n\t\t\t\t\tpressed={view === \"maintenance\"}\n\t\t\t\t\tonClick={() => setView(\"maintenance\")}\n\t\t\t\t>\n\t\t\t\t\tMaintenance\n\t\t\t\t</Toggle>\n\t\t\t\t<Toggle pressed={view === \"config\"} onClick={() => setView(\"config\")}>\n\t\t\t\t\tConfig\n\t\t\t\t</Toggle>\n\t\t\t</div>\n\t\t\t{view === \"maintenance\" ? <MaintenanceTab /> : <ConfigTab />}\n\t\t</div>\n\t);\n}\n"],"names":["DASH_0C_KEY","dash0cEnabled","settings","cat","s","AdminTab","view","setView","useState","settingsData","useApi","useCallback","fetchSettings","jsxs","jsx","Toggle","MaintenanceTab","ConfigTab"],"mappings":"mRA8BA,MAAMA,EAAc,sBAKpB,SAASC,EAAcC,EAA4C,CAClE,GAAI,CAACA,EAAU,MAAO,GACtB,UAAWC,KAAOD,EAAS,WAC1B,UAAWE,KAAKD,EAAI,SACnB,GAAIC,EAAE,MAAQJ,GAAeI,EAAE,OAAS,UAAW,OAAOA,EAAE,QAAU,GAGxE,MAAO,EACR,CAIA,SAAwBC,GAA+B,CACtD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAqB,aAAa,EAEpD,CAAE,KAAMC,CAAA,EAAiBC,EAC9BC,cAAY,IAAMC,EAAA,EAAiB,EAAE,EACrC,CAAE,aAAc,EAAG,WAAY,CAAA,CAAE,EAIlC,OAFiBX,EAAcQ,CAAY,EAO1CI,EAAAA,KAAC,MAAA,CAAI,UAAU,sBACd,SAAA,CAAAA,EAAAA,KAAC,MAAA,CACA,UAAU,0BACV,KAAK,UACL,aAAW,cAEX,SAAA,CAAAC,EAAAA,IAACC,EAAA,CACA,QAAST,IAAS,cAClB,QAAS,IAAMC,EAAQ,aAAa,EACpC,SAAA,aAAA,CAAA,EAGDO,EAAAA,IAACC,EAAA,CAAO,QAAST,IAAS,SAAU,QAAS,IAAMC,EAAQ,QAAQ,EAAG,SAAA,QAAA,CAEtE,CAAA,CAAA,CAAA,EAEAD,IAAS,cAAgBQ,MAACE,EAAA,CAAA,CAAe,QAAMC,EAAA,CAAA,CAAU,CAAA,EAC3D,QArBQD,EAAA,EAAe,CAuBzB"}
|