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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/livewire/livewire-registry.ts — per-stateDir LIWIRE registry.
|
|
3
|
+
*
|
|
4
|
+
* The single seam the runtime and the reader-only dashboard routes BOTH access.
|
|
5
|
+
* It owns a `Map<stateDir, LivewireLiveState>` (one live subsystem cluster per
|
|
6
|
+
* repo) and lazily opens a state on first access, rehydrating its cumulative
|
|
7
|
+
* counters from the persisted aggregate snapshot (`livewire-snapshot.ts`) so a
|
|
8
|
+
* freshly-spawned process — e.g. the dashboard server — reports the same counts
|
|
9
|
+
* the runtime has already accumulated.
|
|
10
|
+
*
|
|
11
|
+
* The runtime WRITES through this registry (see `livewire-runtime.ts`): each
|
|
12
|
+
* mutation persists a reduced, count-only snapshot. The routes READ through
|
|
13
|
+
* `livewireOf(stateDir)` and call the pure `snapshotOf`. There is no other path.
|
|
14
|
+
*
|
|
15
|
+
* BEST-EFFORT + NON-FATAL. `openLivewire` never throws: persistence failures are
|
|
16
|
+
* swallowed by the snapshot layer and state is always returned. PREVENT-PI-004
|
|
17
|
+
* (local in-process Map + filesystem only), PREVENT-011 (no `any`).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { LivewireSnapshot } from "./livewire-types.js";
|
|
21
|
+
import {
|
|
22
|
+
createLiveState,
|
|
23
|
+
rehydrateLive,
|
|
24
|
+
snapshotOf,
|
|
25
|
+
type LivewireLiveState,
|
|
26
|
+
} from "./livewire-live.js";
|
|
27
|
+
import {
|
|
28
|
+
loadLivewireSnapshot,
|
|
29
|
+
saveLivewireSnapshot,
|
|
30
|
+
} from "./livewire-snapshot.js";
|
|
31
|
+
|
|
32
|
+
/** The per-stateDir registry (process-local; a fresh process starts empty). */
|
|
33
|
+
const REGISTRY = new Map<string, LivewireLiveState>();
|
|
34
|
+
|
|
35
|
+
/** Optional structured logger for best-effort failure events. */
|
|
36
|
+
export type LivewireLogger = (line: unknown) => void;
|
|
37
|
+
|
|
38
|
+
let activeLogger: LivewireLogger | undefined;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Bind the structured logger the snapshot layer uses for its non-fatal write
|
|
42
|
+
* failures. The runtime calls this once at startup with its JSON logger.
|
|
43
|
+
*/
|
|
44
|
+
export function setLivewireLogger(logger: LivewireLogger | undefined): void {
|
|
45
|
+
activeLogger = logger;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Open (or return the cached) live state for a stateDir. Lazy: on first access
|
|
50
|
+
* it rehydrates from the persisted aggregate so a separate dashboard process
|
|
51
|
+
* reflects prior runtime work. Never throws.
|
|
52
|
+
*/
|
|
53
|
+
export function livewireOf(stateDir: string): LivewireLiveState {
|
|
54
|
+
const cached = REGISTRY.get(stateDir);
|
|
55
|
+
if (cached !== undefined) return cached;
|
|
56
|
+
const state = createLiveState();
|
|
57
|
+
const snap = loadLivewireSnapshot(stateDir);
|
|
58
|
+
if (snap !== null) rehydrateLive(state, snap);
|
|
59
|
+
REGISTRY.set(stateDir, state);
|
|
60
|
+
return state;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Persist a state's reduced aggregate (counts + codes only). Best-effort and
|
|
65
|
+
* non-fatal. Called by the runtime after every mutation so the snapshot stays
|
|
66
|
+
* fresh for any reader process.
|
|
67
|
+
*/
|
|
68
|
+
export function persistLivewire(state: LivewireLiveState, stateDir: string): void {
|
|
69
|
+
saveLivewireSnapshot(stateDir, snapshotOf(state), activeLogger);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Persist the live state for a stateDir (convenience over open + persist). */
|
|
73
|
+
export function flushLivewire(stateDir: string): void {
|
|
74
|
+
const state = REGISTRY.get(stateDir);
|
|
75
|
+
if (state === undefined) return;
|
|
76
|
+
persistLivewire(state, stateDir);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Build the reader aggregate for one stateDir WITHOUT persisting — the reader
|
|
81
|
+
* seam the dashboard routes call. Reads the live state (rehydrated from disk on
|
|
82
|
+
* first access) and projects it to the count-only snapshot.
|
|
83
|
+
*/
|
|
84
|
+
export function readLivewireSnapshot(stateDir: string): LivewireSnapshot {
|
|
85
|
+
return snapshotOf(livewireOf(stateDir));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** For tests: drop the registry so a fresh stateDir is fully rehydrated. */
|
|
89
|
+
export function _resetLivewireRegistryForTests(): void {
|
|
90
|
+
REGISTRY.clear();
|
|
91
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
|
|
21
|
+
import type { MissClass, MissObservation } from "../cache/diagnostics-types.js";
|
|
22
|
+
import { classifyMiss } from "../cache/diagnostics.js";
|
|
23
|
+
import { shouldBlockServe } from "../cache/breaker.js";
|
|
24
|
+
import type { CrystalV1, CrystalWriteResult } from "../cache/types.js";
|
|
25
|
+
import type { ShadowResult } from "../controller/types.js";
|
|
26
|
+
import { livewireOf, persistLivewire } from "./livewire-registry.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Record a VC7A crystal WRITE attempt (write-once + collision arithmetic). The
|
|
30
|
+
* caller passes the fully-formed `CrystalV1`; the store returns the write result
|
|
31
|
+
* (first-write / idempotent / collision). The dashboard's `stats()` reflects it.
|
|
32
|
+
*
|
|
33
|
+
* @returns the store's write verdict, forwarded so the runtime can act on a
|
|
34
|
+
* collision without re-deriving it.
|
|
35
|
+
*/
|
|
36
|
+
export function recordCrystalWrite(stateDir: string, crystal: CrystalV1): CrystalWriteResult {
|
|
37
|
+
const state = livewireOf(stateDir);
|
|
38
|
+
const result = state.crystalStore.write(crystal);
|
|
39
|
+
persistLivewire(state, stateDir);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Record a VC7A crystal READ attempt. Returns the stored crystal (or undefined
|
|
45
|
+
* on a miss / mode C), mirroring `CrystalStore.read` so the cache-serve path can
|
|
46
|
+
* use this seam entirely.
|
|
47
|
+
*/
|
|
48
|
+
export function readCrystal(stateDir: string, keyDigest: string): CrystalV1 | undefined {
|
|
49
|
+
const state = livewireOf(stateDir);
|
|
50
|
+
const found = state.crystalStore.read(keyDigest);
|
|
51
|
+
persistLivewire(state, stateDir);
|
|
52
|
+
return found;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Record a VC7C miss observation: classify it into its exclusive class and tally
|
|
57
|
+
* it. When the class demands the cache serve be demoted BEFORE answering, the
|
|
58
|
+
* `serveBlocked` counter is also incremented. The live breaker state itself is
|
|
59
|
+
* driven by the real cache-serve path (through `breaker.execute`), not here; this
|
|
60
|
+
* seam only observes and tallies.
|
|
61
|
+
*
|
|
62
|
+
* @returns the exclusive class the observation was tallied under.
|
|
63
|
+
*/
|
|
64
|
+
export function observeCacheMiss(stateDir: string, observation: MissObservation): MissClass {
|
|
65
|
+
const state = livewireOf(stateDir);
|
|
66
|
+
const missClass = classifyMiss(observation).missClass;
|
|
67
|
+
state.diagnostics.tallies[missClass] += 1;
|
|
68
|
+
if (shouldBlockServe(missClass)) state.diagnostics.serveBlocked += 1;
|
|
69
|
+
persistLivewire(state, stateDir);
|
|
70
|
+
return missClass;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Record a VC7C cache serve that the breaker demoted BEFORE answering. Talls the
|
|
75
|
+
* `serveBlocked` counter the diagnostics card surfaces.
|
|
76
|
+
*/
|
|
77
|
+
export function recordServeBlocked(stateDir: string): void {
|
|
78
|
+
const state = livewireOf(stateDir);
|
|
79
|
+
state.diagnostics.serveBlocked += 1;
|
|
80
|
+
persistLivewire(state, stateDir);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Record a VC8B shadow evaluation run: accumulate its decision metrics so the
|
|
85
|
+
* policy card reports how many shadow decisions were evaluated / clamped /
|
|
86
|
+
* rejected and how many live mutations the shadow proved (structurally 0).
|
|
87
|
+
*/
|
|
88
|
+
export function recordShadowRun(stateDir: string, result: ShadowResult): void {
|
|
89
|
+
const state = livewireOf(stateDir);
|
|
90
|
+
state.shadow.shadowDecisions += result.metrics.evaluated;
|
|
91
|
+
state.shadow.clampedDecisions += result.metrics.clamped;
|
|
92
|
+
state.shadow.rejectedInputs += result.metrics.rejected;
|
|
93
|
+
state.shadow.liveMutations += result.metrics.liveMutations;
|
|
94
|
+
persistLivewire(state, stateDir);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Set the active M7 pressure version (1 = legacy, 2 = migrated). The runtime
|
|
99
|
+
* calls this after a successful `migratePressureV2` so the policy card reflects
|
|
100
|
+
* the live migration state rather than a hardcoded 1.
|
|
101
|
+
*/
|
|
102
|
+
export function setPressureVersion(stateDir: string, version: 1 | 2): void {
|
|
103
|
+
const state = livewireOf(stateDir);
|
|
104
|
+
state.shadow.pressureVersion = version;
|
|
105
|
+
persistLivewire(state, stateDir);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Mark that VC7B cache economics have actually been computed at runtime (the
|
|
110
|
+
* `computed` bit drives the economics card's `hasData`). The runtime calls this
|
|
111
|
+
* after the first real `computeEconomics` over observed usage.
|
|
112
|
+
*/
|
|
113
|
+
export function markEconomicsComputed(stateDir: string): void {
|
|
114
|
+
const state = livewireOf(stateDir);
|
|
115
|
+
state.economics.computed = true;
|
|
116
|
+
persistLivewire(state, stateDir);
|
|
117
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
|
|
22
|
+
import { readFileSync, writeFileSync, renameSync, existsSync, mkdirSync } from "node:fs";
|
|
23
|
+
import { join } from "node:path";
|
|
24
|
+
import type { LivewireSnapshot } from "./livewire-types.js";
|
|
25
|
+
|
|
26
|
+
/** The snapshot filename in the per-repo stateDir (counts + codes only). */
|
|
27
|
+
export const LIVEWIRE_SNAPSHOT_FILE = "vector-cortex-livewire.json";
|
|
28
|
+
|
|
29
|
+
/** Resolve the snapshot path for a stateDir. */
|
|
30
|
+
export function livewireSnapshotPath(stateDir: string): string {
|
|
31
|
+
return join(stateDir, LIVEWIRE_SNAPSHOT_FILE);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Best-effort type guard over a parsed snapshot. Rejects anything that is not
|
|
36
|
+
* the exact aggregate shape so a corrupted or stale file cannot poison the
|
|
37
|
+
* rehydrated counters.
|
|
38
|
+
*/
|
|
39
|
+
function isSnapshot(value: unknown): value is LivewireSnapshot {
|
|
40
|
+
if (typeof value !== "object" || value === null) return false;
|
|
41
|
+
const s = value as Record<string, unknown>;
|
|
42
|
+
return (
|
|
43
|
+
s.schema === "vector-cortex-livewire-v1" &&
|
|
44
|
+
typeof s.crystals === "object" &&
|
|
45
|
+
s.crystals !== null &&
|
|
46
|
+
typeof s.diagnostics === "object" &&
|
|
47
|
+
s.diagnostics !== null &&
|
|
48
|
+
typeof s.economics === "object" &&
|
|
49
|
+
s.economics !== null &&
|
|
50
|
+
typeof s.policy === "object" &&
|
|
51
|
+
s.policy !== null
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Read the persisted aggregate for a stateDir, or null when absent/unreadable/
|
|
57
|
+
* malformed. Best-effort and non-fatal by construction.
|
|
58
|
+
*/
|
|
59
|
+
export function loadLivewireSnapshot(stateDir: string): LivewireSnapshot | null {
|
|
60
|
+
const path = livewireSnapshotPath(stateDir);
|
|
61
|
+
let raw: string;
|
|
62
|
+
try {
|
|
63
|
+
raw = readFileSync(path, "utf-8");
|
|
64
|
+
} catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const parsed: unknown = JSON.parse(raw);
|
|
69
|
+
return isSnapshot(parsed) ? parsed : null;
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Best-effort write of the aggregate snapshot (atomic rename). Never throws to
|
|
77
|
+
* the caller: a persistence failure logs a structured event and is swallowed.
|
|
78
|
+
*
|
|
79
|
+
* @param logger optional structured logger `(line: unknown) => void`; when
|
|
80
|
+
* omitted no event is emitted (tests pass `undefined`).
|
|
81
|
+
*/
|
|
82
|
+
export function saveLivewireSnapshot(
|
|
83
|
+
stateDir: string,
|
|
84
|
+
snapshot: LivewireSnapshot,
|
|
85
|
+
logger?: (line: unknown) => void,
|
|
86
|
+
): void {
|
|
87
|
+
const dir = stateDir;
|
|
88
|
+
try {
|
|
89
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
90
|
+
const path = livewireSnapshotPath(dir);
|
|
91
|
+
const tmp = `${path}.tmp`;
|
|
92
|
+
writeFileSync(tmp, JSON.stringify(snapshot), "utf-8");
|
|
93
|
+
renameSync(tmp, path);
|
|
94
|
+
} catch (err) {
|
|
95
|
+
if (logger !== undefined) {
|
|
96
|
+
try {
|
|
97
|
+
logger({
|
|
98
|
+
ts: new Date().toISOString(),
|
|
99
|
+
event: "vector_cortex_livewire_snapshot_write_failed",
|
|
100
|
+
stateDir,
|
|
101
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
102
|
+
});
|
|
103
|
+
} catch {
|
|
104
|
+
// A failing logger must not recurse into another failure.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
|
|
20
|
+
/** Triad mode shared by the crystals / diagnostics / economics cards. */
|
|
21
|
+
export type LivewireMode = "A" | "B" | "C";
|
|
22
|
+
|
|
23
|
+
/** VC7A crystal aggregate — mirrors `CrystalStoreStats` one-for-one. */
|
|
24
|
+
export interface LivewireCrystalAggregate {
|
|
25
|
+
readonly mode: LivewireMode;
|
|
26
|
+
readonly crystalCount: number;
|
|
27
|
+
readonly totalBytes: number;
|
|
28
|
+
readonly hits: number;
|
|
29
|
+
readonly misses: number;
|
|
30
|
+
readonly hitBytes: number;
|
|
31
|
+
readonly writes: number;
|
|
32
|
+
readonly duplicateWrites: number;
|
|
33
|
+
readonly collisions: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** VC7C per-miss-class tallies + breaker observable state. */
|
|
37
|
+
export interface LivewireDiagnosticsAggregate {
|
|
38
|
+
readonly profileMisses: number;
|
|
39
|
+
readonly rangeMisses: number;
|
|
40
|
+
readonly dependencyMisses: number;
|
|
41
|
+
readonly requestMisses: number;
|
|
42
|
+
readonly generationMisses: number;
|
|
43
|
+
readonly unknownMisses: number;
|
|
44
|
+
readonly serveBlocked: number;
|
|
45
|
+
/** Breaker observable state name (CLOSED_A / OPEN_B / ... / MANUAL_HALT). */
|
|
46
|
+
readonly breakerState: string;
|
|
47
|
+
/** Last CACHE/M5 code, or null. */
|
|
48
|
+
readonly lastFailure: string | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** VC7B economics aggregate — static profile tallies + computed bit. */
|
|
52
|
+
export interface LivewireEconomicsAggregate {
|
|
53
|
+
/** Provider profiles that declare cache economics. */
|
|
54
|
+
readonly profileCount: number;
|
|
55
|
+
/** Exclusions that carry a proving fixture id. */
|
|
56
|
+
readonly provenExclusions: number;
|
|
57
|
+
/** Exclusions rejected for lacking a fixture id. */
|
|
58
|
+
readonly unprovenExclusions: number;
|
|
59
|
+
/** True once the runtime has actually run `computeEconomics` at least once. */
|
|
60
|
+
readonly computed: boolean;
|
|
61
|
+
/** Last ECON_* code, or null. */
|
|
62
|
+
readonly lastFailure: string | null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** VC8B shadow-policy aggregate — maps 1:1 to the policy card fields. */
|
|
66
|
+
export interface LivewirePolicyAggregate {
|
|
67
|
+
readonly shadowDecisions: number;
|
|
68
|
+
readonly clampedDecisions: number;
|
|
69
|
+
readonly rejectedInputs: number;
|
|
70
|
+
readonly liveMutations: number;
|
|
71
|
+
/** Active pressure version (1 legacy / 2 migrated). */
|
|
72
|
+
readonly pressureVersion: 1 | 2;
|
|
73
|
+
/** Last POL_ or M7_ code, or null. */
|
|
74
|
+
readonly lastFailure: string | null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The persisted, restart-surviving aggregate for one stateDir. */
|
|
78
|
+
export interface LivewireSnapshot {
|
|
79
|
+
readonly schema: "vector-cortex-livewire-v1";
|
|
80
|
+
readonly crystals: LivewireCrystalAggregate;
|
|
81
|
+
readonly diagnostics: LivewireDiagnosticsAggregate;
|
|
82
|
+
readonly economics: LivewireEconomicsAggregate;
|
|
83
|
+
readonly policy: LivewirePolicyAggregate;
|
|
84
|
+
}
|
|
@@ -47,38 +47,16 @@
|
|
|
47
47
|
* gates only the reporter/dashboard seam in `../cache/economics-emit.ts`.
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
-
import type {
|
|
50
|
+
import type {
|
|
51
|
+
ProviderEconomicsV1,
|
|
52
|
+
ProviderProfileExclusion,
|
|
53
|
+
ProviderProfileV1,
|
|
54
|
+
} from "./types.js";
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* charging $3.00 per million input tokens has `basePrice: 3`. Integers keep the
|
|
57
|
-
* money path exact; see the file header for why floats are refused.
|
|
58
|
-
*/
|
|
59
|
-
export interface ProviderEconomicsV1 {
|
|
60
|
-
readonly schema: "provider-economics-v1";
|
|
61
|
-
/** The `ProviderProfileV1.id` these economics belong to. */
|
|
62
|
-
readonly profileId: string;
|
|
63
|
-
/** Profile version — economics are versioned WITH the profile they price. */
|
|
64
|
-
readonly profileVersion: string;
|
|
65
|
-
/** Uncached price per token, integer micro-units. The savings baseline. */
|
|
66
|
-
readonly basePrice: number;
|
|
67
|
-
/** Cache-READ price per token, integer micro-units. Normally < basePrice. */
|
|
68
|
-
readonly readPrice: number;
|
|
69
|
-
/** Cache-WRITE price per token, integer micro-units. Normally > basePrice. */
|
|
70
|
-
readonly writePrice: number;
|
|
71
|
-
/** Cache entry lifetime in ms. A prefix older than this cannot be read back. */
|
|
72
|
-
readonly ttlMs: number;
|
|
73
|
-
/** Minimum cacheable prefix in tokens; a shorter prefix is never cached. */
|
|
74
|
-
readonly minPrefix: number;
|
|
75
|
-
/**
|
|
76
|
-
* Conformance fixture ID proving this profile's exclusion set is safe, or
|
|
77
|
-
* `null` when the profile declares NO exclusions (nothing to prove). A profile
|
|
78
|
-
* WITH exclusions and a null/blank id is rejected — see `validateEconomics`.
|
|
79
|
-
*/
|
|
80
|
-
readonly exclusionFixtureId: string | null;
|
|
81
|
-
}
|
|
56
|
+
// `ProviderEconomicsV1` is defined in `./types.js` so it can ride on
|
|
57
|
+
// `ProviderProfileV1` without a type-only module cycle. Re-exported forward here
|
|
58
|
+
// so every existing consumer import path (`from "./economics.js"`) is unchanged.
|
|
59
|
+
export type { ProviderEconomicsV1 } from "./types.js";
|
|
82
60
|
|
|
83
61
|
/** Observed (or shadow) cache traffic for one economics computation. */
|
|
84
62
|
export interface CacheUsageV1 {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
20
|
PRO_PROFILE_UNKNOWN,
|
|
21
|
+
type ProviderEconomicsV1,
|
|
21
22
|
type ProviderProfileBundle,
|
|
22
23
|
type ProviderProfileResult,
|
|
23
24
|
type ProviderProfileV1,
|
|
@@ -60,6 +61,7 @@ function profile(
|
|
|
60
61
|
id: string,
|
|
61
62
|
version: string,
|
|
62
63
|
excludedJsonPointers: ProviderProfileV1["excludedJsonPointers"],
|
|
64
|
+
economics: ProviderProfileV1["economics"],
|
|
63
65
|
): ProviderProfileV1 {
|
|
64
66
|
return {
|
|
65
67
|
schema: "provider-profile-v1",
|
|
@@ -67,42 +69,111 @@ function profile(
|
|
|
67
69
|
version,
|
|
68
70
|
hashMode: "entire-canonical-request",
|
|
69
71
|
excludedJsonPointers,
|
|
72
|
+
economics,
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Build integer micro-unit economics for a base profile (VC7B). A cache WRITE
|
|
78
|
+
* costs more than an uncached token, a cache READ costs less — the standard
|
|
79
|
+
* provider-prompt-cache shape. `exclusionFixtureId` mirrors the profile's own
|
|
80
|
+
* exclusion fixture (or null when the profile has none to prove).
|
|
81
|
+
*/
|
|
82
|
+
function econ(
|
|
83
|
+
id: string,
|
|
84
|
+
version: string,
|
|
85
|
+
exclusionFixtureId: string | null,
|
|
86
|
+
values: {
|
|
87
|
+
basePrice: number;
|
|
88
|
+
readPrice: number;
|
|
89
|
+
writePrice: number;
|
|
90
|
+
ttlMs: number;
|
|
91
|
+
minPrefix: number;
|
|
92
|
+
},
|
|
93
|
+
): ProviderEconomicsV1 {
|
|
94
|
+
return {
|
|
95
|
+
schema: "provider-economics-v1",
|
|
96
|
+
profileId: id,
|
|
97
|
+
profileVersion: version,
|
|
98
|
+
basePrice: values.basePrice,
|
|
99
|
+
readPrice: values.readPrice,
|
|
100
|
+
writePrice: values.writePrice,
|
|
101
|
+
ttlMs: values.ttlMs,
|
|
102
|
+
minPrefix: values.minPrefix,
|
|
103
|
+
exclusionFixtureId,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Representative integer micro-unit economics for the Anthropic opus base tier. */
|
|
108
|
+
const OPUS_ECON: ProviderEconomicsV1 = econ(
|
|
109
|
+
"anthropic-claude-opus",
|
|
110
|
+
"v1",
|
|
111
|
+
null,
|
|
112
|
+
{ basePrice: 15, readPrice: 2, writePrice: 19, ttlMs: 300_000, minPrefix: 1024 },
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
/** Representative integer micro-unit economics for the Anthropic sonnet base tier. */
|
|
116
|
+
const SONNET_ECON: ProviderEconomicsV1 = econ(
|
|
117
|
+
"anthropic-claude-sonnet",
|
|
118
|
+
"v1",
|
|
119
|
+
null,
|
|
120
|
+
{ basePrice: 3, readPrice: 0, writePrice: 4, ttlMs: 300_000, minPrefix: 1024 },
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
/** Representative integer micro-unit economics for the OpenAI gpt base tier. */
|
|
124
|
+
const GPT_ECON: ProviderEconomicsV1 = econ(
|
|
125
|
+
"openai-gpt",
|
|
126
|
+
"v1",
|
|
127
|
+
null,
|
|
128
|
+
{ basePrice: 5, readPrice: 1, writePrice: 6, ttlMs: 300_000, minPrefix: 1024 },
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
/** The gemini profile's versioned, fixture-proven exclusion. */
|
|
132
|
+
const GEMINI_EXCLUSIONS: ProviderProfileV1["excludedJsonPointers"] = [
|
|
133
|
+
{
|
|
134
|
+
pointer: "/requestId",
|
|
135
|
+
fixtureId: "PRO-EXCLUDE-010",
|
|
136
|
+
proofDigest: "sha256:excluded-request-id-proof",
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
/** Representative integer micro-unit economics for the gemini base tier. */
|
|
141
|
+
const GEMINI_ECON: ProviderEconomicsV1 = econ(
|
|
142
|
+
"google-gemini",
|
|
143
|
+
"v1",
|
|
144
|
+
"PRO-EXCLUDE-010",
|
|
145
|
+
{ basePrice: 3, readPrice: 1, writePrice: 4, ttlMs: 300_000, minPrefix: 1024 },
|
|
146
|
+
);
|
|
147
|
+
|
|
73
148
|
/**
|
|
74
149
|
* The fixture-backed base profiles. Each entry is the REAL bundle the renderer
|
|
75
150
|
* resolves; the parallel conformance fixtures prove the cache-identity behavior.
|
|
76
151
|
*/
|
|
77
152
|
const BASE_PROFILES: readonly ProviderProfileBundle[] = [
|
|
78
153
|
{
|
|
79
|
-
profile: profile("anthropic-claude-opus", "v1", []),
|
|
154
|
+
profile: profile("anthropic-claude-opus", "v1", [], OPUS_ECON),
|
|
80
155
|
role: BASE_ROLE,
|
|
81
156
|
tool: BASE_TOOL,
|
|
82
157
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
83
158
|
},
|
|
84
159
|
{
|
|
85
|
-
profile: profile("anthropic-claude-sonnet", "v1", []),
|
|
160
|
+
profile: profile("anthropic-claude-sonnet", "v1", [], SONNET_ECON),
|
|
86
161
|
role: BASE_ROLE,
|
|
87
162
|
tool: BASE_TOOL,
|
|
88
163
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
89
164
|
},
|
|
90
165
|
{
|
|
91
|
-
profile: profile("openai-gpt", "v1", []),
|
|
166
|
+
profile: profile("openai-gpt", "v1", [], GPT_ECON),
|
|
92
167
|
role: BASE_ROLE,
|
|
93
168
|
tool: BASE_TOOL,
|
|
94
169
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
95
170
|
},
|
|
96
171
|
{
|
|
97
172
|
// A profile that proves a fixture-excluded pointer: a provider whose
|
|
98
|
-
// request-id header cannot affect cache identity. Excluded + versioned
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
fixtureId: "PRO-EXCLUDE-010",
|
|
103
|
-
proofDigest: "sha256:excluded-request-id-proof",
|
|
104
|
-
},
|
|
105
|
-
]),
|
|
173
|
+
// request-id header cannot affect cache identity. Excluded + versioned, and
|
|
174
|
+
// the exclusion fixture id is carried into economics so the proof is
|
|
175
|
+
// honored (an unproven exclusion would fail economics validation).
|
|
176
|
+
profile: profile("google-gemini", "v1", GEMINI_EXCLUSIONS, GEMINI_ECON),
|
|
106
177
|
role: BASE_ROLE,
|
|
107
178
|
tool: BASE_TOOL,
|
|
108
179
|
cache: baseCache(["systemPromptPrepend", "tools", "nodes"]),
|
|
@@ -35,6 +35,37 @@ export interface ProviderProfileExclusion {
|
|
|
35
35
|
readonly proofDigest: string;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Cache economics attached to a provider profile (VC7B).
|
|
40
|
+
*
|
|
41
|
+
* Prices are integer MICRO-UNITS PER TOKEN (1e-6 currency units), so a provider
|
|
42
|
+
* charging $3.00 per million input tokens has `basePrice: 3`. Integers keep the
|
|
43
|
+
* money path exact (see `economics.ts` for why floats are refused).
|
|
44
|
+
*/
|
|
45
|
+
export interface ProviderEconomicsV1 {
|
|
46
|
+
readonly schema: "provider-economics-v1";
|
|
47
|
+
/** The `ProviderProfileV1.id` these economics belong to. */
|
|
48
|
+
readonly profileId: string;
|
|
49
|
+
/** Profile version — economics are versioned WITH the profile they price. */
|
|
50
|
+
readonly profileVersion: string;
|
|
51
|
+
/** Uncached price per token, integer micro-units. The savings baseline. */
|
|
52
|
+
readonly basePrice: number;
|
|
53
|
+
/** Cache-READ price per token, integer micro-units. Normally < basePrice. */
|
|
54
|
+
readonly readPrice: number;
|
|
55
|
+
/** Cache-WRITE price per token, integer micro-units. Normally > basePrice. */
|
|
56
|
+
readonly writePrice: number;
|
|
57
|
+
/** Cache entry lifetime in ms. A prefix older than this cannot be read back. */
|
|
58
|
+
readonly ttlMs: number;
|
|
59
|
+
/** Minimum cacheable prefix in tokens; a shorter prefix is never cached. */
|
|
60
|
+
readonly minPrefix: number;
|
|
61
|
+
/**
|
|
62
|
+
* Conformance fixture ID proving this profile's exclusion set is safe, or
|
|
63
|
+
* `null` when the profile declares NO exclusions (nothing to prove). A profile
|
|
64
|
+
* WITH exclusions and a null/blank id is rejected — see `validateEconomics`.
|
|
65
|
+
*/
|
|
66
|
+
readonly exclusionFixtureId: string | null;
|
|
67
|
+
}
|
|
68
|
+
|
|
38
69
|
/**
|
|
39
70
|
* The provider-profile contract. A renderer consumes a profile to decide how the
|
|
40
71
|
* rendered prompt is serialized into the canonical outbound request without
|
|
@@ -47,6 +78,12 @@ export interface ProviderProfileV1 {
|
|
|
47
78
|
readonly hashMode: ProviderHashMode;
|
|
48
79
|
/** Versioned, fixture-proven exclusions (empty = hash the whole request). */
|
|
49
80
|
readonly excludedJsonPointers: readonly ProviderProfileExclusion[];
|
|
81
|
+
/**
|
|
82
|
+
* VC7B cache economics pricing this profile's frozen-render reuse. Every base
|
|
83
|
+
* profile carries economics so the cache-economics aggregate is computable
|
|
84
|
+
* without a side table; a profile WITHOUT economics is simply never cached.
|
|
85
|
+
*/
|
|
86
|
+
readonly economics: ProviderEconomicsV1 | null;
|
|
50
87
|
}
|
|
51
88
|
|
|
52
89
|
/**
|
|
@@ -198,7 +198,11 @@ export function computeSetupCortexBlockers(input: {
|
|
|
198
198
|
// ─── VC9B action gating ─────────────────────────────────────────────────────
|
|
199
199
|
|
|
200
200
|
/** The VC9B action kinds the drivers know how to run. */
|
|
201
|
-
export type SetupCortexActionKind =
|
|
201
|
+
export type SetupCortexActionKind =
|
|
202
|
+
| "fetch-model"
|
|
203
|
+
| "bench"
|
|
204
|
+
| "verify-asset"
|
|
205
|
+
| "install-native-ort";
|
|
202
206
|
|
|
203
207
|
/**
|
|
204
208
|
* The static PER-ACTION CANDIDATE gate ids — this is POLICY, NOT the derived
|
|
@@ -216,6 +220,9 @@ const ACTION_GATE_CANDIDATES: Readonly<Record<SetupCortexActionKind, readonly st
|
|
|
216
220
|
// behavior change. HG-7 is training work (no action in this set).
|
|
217
221
|
bench: ["HG-1", "HG-3", "HG-6"],
|
|
218
222
|
"verify-asset": [],
|
|
223
|
+
// ENC-2c: installing the lazy-download native binding is gated by HG-3 (the
|
|
224
|
+
// open install-budget hard gate) — a closed HG-3 no longer blocks the install.
|
|
225
|
+
"install-native-ort": ["HG-3"],
|
|
219
226
|
};
|
|
220
227
|
|
|
221
228
|
/**
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as r}from"./index-DgKI8jwx.js";import{M as t}from"./MetricsCards-CNBlWLoU.js";import"./card-CwWLYigw.js";import"./generateCategoricalChart-BX9n_-am.js";import"./BarChart-MvUf2UYv.js";import"./AreaChart-CumzbAON.js";function e(){return r.jsx(t,{})}export{e as default};
|
|
2
|
-
//# sourceMappingURL=MetricsTab-sks9wzZr.js.map
|