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
|
@@ -73,7 +73,11 @@ export interface SetupCortexStatusResponse {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/** The set of developer actions the Setup Cortex action drivers can run. */
|
|
76
|
-
export type SetupCortexActionKind =
|
|
76
|
+
export type SetupCortexActionKind =
|
|
77
|
+
| "fetch-model"
|
|
78
|
+
| "bench"
|
|
79
|
+
| "verify-asset"
|
|
80
|
+
| "install-native-ort";
|
|
77
81
|
|
|
78
82
|
/** Request body for POST /api/setup-cortex-action. confirm:true required. */
|
|
79
83
|
export interface SetupCortexActionRequest {
|
|
@@ -81,6 +85,17 @@ export interface SetupCortexActionRequest {
|
|
|
81
85
|
readonly confirm: boolean;
|
|
82
86
|
}
|
|
83
87
|
|
|
88
|
+
/** ENC-2b/ENC-2c: the native onnxruntime qualification retest result (server
|
|
89
|
+
* shape mirror from api-contracts/setup-cortex-native-ort.ts). */
|
|
90
|
+
export interface NativeOrtRetestResult {
|
|
91
|
+
readonly platform: string;
|
|
92
|
+
readonly version: string;
|
|
93
|
+
readonly verdict: "qualified" | "degraded" | "failed";
|
|
94
|
+
readonly p95Ms: number;
|
|
95
|
+
readonly rssMiB: number;
|
|
96
|
+
readonly testedAt: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
84
99
|
/** Outcome of running one Setup Cortex action. */
|
|
85
100
|
export interface SetupCortexActionResult {
|
|
86
101
|
readonly action: SetupCortexActionKind;
|
|
@@ -89,6 +104,12 @@ export interface SetupCortexActionResult {
|
|
|
89
104
|
readonly logPath: string;
|
|
90
105
|
readonly logName: string;
|
|
91
106
|
readonly spawned: boolean;
|
|
107
|
+
/** ENC-2c: fresh retest result for install-native-ort (null when retest
|
|
108
|
+
* could not run / no binding). Present ONLY for install-native-ort. */
|
|
109
|
+
readonly nativeOrtRetestResult?: NativeOrtRetestResult | null;
|
|
110
|
+
/** ENC-2c: effective backend after install retest — "native" when verdict is
|
|
111
|
+
* "qualified", else "wasm". Present ONLY for install-native-ort. */
|
|
112
|
+
readonly nativeOrtBackendEffective?: "native" | "wasm";
|
|
92
113
|
}
|
|
93
114
|
|
|
94
115
|
/** Error body used when a hard gate blocks the requested action. */
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* api-contracts/setup-cortex-native-ort.ts — ENC-2c native onnxruntime
|
|
3
|
+
* lazy-download INSTALL action contract types.
|
|
4
|
+
*
|
|
5
|
+
* Sibling additive types for the VC9B action driver: POST /api/setup-cortex-action
|
|
6
|
+
* gains the `install-native-ort` action that, when confirmed, runs the committed
|
|
7
|
+
* scripts/encoder/install-native-ort.mjs subprocess locally (npm-delegated,
|
|
8
|
+
* sha256-verified) and then re-qualifies the binding via the ENC-2b retest path.
|
|
9
|
+
*
|
|
10
|
+
* The retest result shape mirrors `RetestResult` from
|
|
11
|
+
* extensions/dashboard-server/api-contracts/setup.ts (and
|
|
12
|
+
* src/vector-cortex/encoder/native-qualify-retest.ts): { platform, version,
|
|
13
|
+
* verdict, p95Ms, rssMiB, testedAt }. It is declared here rather than imported
|
|
14
|
+
* from src/ so the contract lives wholly in the extensions layer (PREVENT-PI —
|
|
15
|
+
* extensions never import impl internals) and stays self-contained.
|
|
16
|
+
*
|
|
17
|
+
* PREVENT-PI-004: type definitions only, no network code. The install action is
|
|
18
|
+
* a confirm-gated, npm-delegated local subprocess with NO URL literals (registry
|
|
19
|
+
* URL + sha256 live only in native-install-artifacts.ts).
|
|
20
|
+
* PREVENT-011: no `any` type — all types explicit.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type { SetupCortexActionResult } from "./setup-cortex.js";
|
|
24
|
+
|
|
25
|
+
/** ENC-2b/ENC-2c: the native onnxruntime qualification retest result (shape
|
|
26
|
+
* mirror of api-contracts/setup.ts `RetestResult`). Surfaces only platform,
|
|
27
|
+
* version, verdict, p95/RSS, testedAt — never binding binary contents or model
|
|
28
|
+
* weights (SECURITY_PRIVACY). */
|
|
29
|
+
export interface NativeOrtRetestResult {
|
|
30
|
+
readonly platform: string;
|
|
31
|
+
readonly version: string;
|
|
32
|
+
readonly verdict: "qualified" | "degraded" | "failed";
|
|
33
|
+
readonly p95Ms: number;
|
|
34
|
+
readonly rssMiB: number;
|
|
35
|
+
readonly testedAt: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The action kind union, which now includes the ENC-2c lazy-download install
|
|
39
|
+
* action (widen source: setup-cortex.ts). */
|
|
40
|
+
export type SetupCortexActionKindWithInstall = SetupCortexActionResult["action"];
|
|
41
|
+
|
|
42
|
+
/** ENC-2c additive fields appended to the setup-cortex action result once the
|
|
43
|
+
* install subprocess completes (retest ran regardless of install exit code). */
|
|
44
|
+
export interface SetupCortexActionResultWithNativeOrt
|
|
45
|
+
extends SetupCortexActionResult {
|
|
46
|
+
/** Fresh ENC-2b qualification retest result after install (null when the
|
|
47
|
+
* retest could not run / no binding). Present ONLY for install-native-ort. */
|
|
48
|
+
readonly nativeOrtRetestResult?: NativeOrtRetestResult | null;
|
|
49
|
+
/** Effective backend after the retest: "native" when verdict is `qualified`,
|
|
50
|
+
* otherwise "wasm". Present ONLY for install-native-ort. */
|
|
51
|
+
readonly nativeOrtBackendEffective?: "native" | "wasm";
|
|
52
|
+
}
|
|
@@ -82,8 +82,14 @@ export interface SetupCortexStatusResponse {
|
|
|
82
82
|
|
|
83
83
|
// ─── VC9B action drivers ────────────────────────────────────────────────────
|
|
84
84
|
|
|
85
|
-
/** The set of developer actions the Setup Cortex action drivers can run.
|
|
86
|
-
|
|
85
|
+
/** The set of developer actions the Setup Cortex action drivers can run.
|
|
86
|
+
* ENC-2c adds `install-native-ort` (confirm-gated lazy-download native install
|
|
87
|
+
* + re-qualification), surfaced additively via setup-cortex-native-ort.ts. */
|
|
88
|
+
export type SetupCortexActionKind =
|
|
89
|
+
| "fetch-model"
|
|
90
|
+
| "bench"
|
|
91
|
+
| "verify-asset"
|
|
92
|
+
| "install-native-ort";
|
|
87
93
|
|
|
88
94
|
/**
|
|
89
95
|
* Request body for POST /api/setup-cortex-action. `confirm:true` is the
|
|
@@ -326,6 +326,12 @@ export const VECTOR_CORTEX_SETTINGS: SettingGroup = {
|
|
|
326
326
|
"ENC-2b re-probes and re-qualifies the installed native onnxruntime binding (onnxruntime-node in ~/.pi/mega-compact/native-ort/, operator-installed via the ENC-2a guide): loads the LOCAL on-disk binding, runs a bounded warmup + p95 probe, measures RSS, and computes a fresh qualification verdict against the ENC-0f p95 budget + the operator install-budget. Never downloads or trains (PREVENT-PI-004 / HG-1 unchanged); surfaces nativeOrtRetestResult + nativeOrtBackendEffective on the GET /api/setup-status. OFF = no retest GET fields, no retest POST branch, no retest card (byte-identical ENC-2a predecessor).",
|
|
327
327
|
true,
|
|
328
328
|
),
|
|
329
|
+
boolDirect(
|
|
330
|
+
"MEGACOMPACT_ENC_2C",
|
|
331
|
+
"ENC-2c native ONNX runtime lazy-download INSTALL action (dashboard-triggered)",
|
|
332
|
+
"ENC-2c turns ENC-2a's operator run-script assist into a confirm-gated dashboard action: the Setup Cortex sub-tab gains an Install Native ORT button that, when the operator confirms, runs the committed scripts/encoder/install-native-ort.mjs subprocess locally (npm-delegated, sha256-verified) and then re-qualifies the binding via the ENC-2b retest path, exposing nativeOrtRetestResult / nativeOrtBackendEffective on the completion. PREVENT-PI-004 opt-in exemption: confirm-gated, npm-delegated, no URL literals (registry URL + sha256 live only in native-install-artifacts.ts). OFF = no install action POST branch, no UI button, no install result fields (byte-identical ENC-2b predecessor).",
|
|
333
|
+
true,
|
|
334
|
+
),
|
|
329
335
|
boolDirect(
|
|
330
336
|
"MEGACOMPACT_COSINE_FP_BENCH",
|
|
331
337
|
"COS-FP-A Synthetic FP Bench",
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
* GET /api/setup-cortex-action-log — bounded, redacted log tail
|
|
6
6
|
*
|
|
7
7
|
* Reader/actor-only: NEVER exposes payload bytes, prompts, or ledger. Actions
|
|
8
|
-
* only spawn the committed local vc2-model-prep scripts
|
|
9
|
-
* encoder assets (verify-asset) —
|
|
10
|
-
* (
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* only spawn the committed local vc2-model-prep scripts, re-read the committed
|
|
9
|
+
* encoder assets (verify-asset), or — ENC-2c — run the confirm-gated npm-delegated
|
|
10
|
+
* native onnxruntime install (install-native-ort) + re-qualify — no network in
|
|
11
|
+
* this layer (PREVENT-PI-004). A hard gate (HG-1/HG-3) blocking the requested
|
|
12
|
+
* action yields 423 action_blocked_by_open_item with the blocker ids and NO
|
|
13
|
+
* subprocess is spawned. Missing confirm:true yields 400 confirmation_required.
|
|
14
|
+
* Flag-off (MEGACOMPACT_VC9B=0) is byte-identical to the VC9A-era predecessor:
|
|
15
|
+
* the routes are absent, so they return the 404 disabled shape and no action runs.
|
|
15
16
|
*
|
|
16
17
|
* Guardrails: PREVENT-011 (no `any`), PREVENT-001 (guarded JSON.parse via
|
|
17
18
|
* readJsonBody), no string literals for scripts/blockers (delegated to
|
|
@@ -24,7 +25,12 @@ import { join, dirname } from "node:path";
|
|
|
24
25
|
import { fileURLToPath } from "node:url";
|
|
25
26
|
import type { RouteContext } from "./routes-core.js";
|
|
26
27
|
import { sendJson, readJsonBody } from "./routes-vector-cortex-shared.js";
|
|
27
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
VC9B_ENABLED,
|
|
30
|
+
ENC_0G_ENABLED,
|
|
31
|
+
ENC_0F_ENABLED,
|
|
32
|
+
ENC_2C_ENABLED,
|
|
33
|
+
} from "../../src/config.js";
|
|
28
34
|
import { setupCortexActionBlockers, computeSetupCortexBlockers } from "./setup-cortex-blockers.js";
|
|
29
35
|
import { readEncoderManifest, detectPlatform } from "../../src/vector-cortex/encoder/asset.js";
|
|
30
36
|
import {
|
|
@@ -41,6 +47,7 @@ const ACTION_KINDS = new Set<SetupCortexActionKind>([
|
|
|
41
47
|
"fetch-model",
|
|
42
48
|
"bench",
|
|
43
49
|
"verify-asset",
|
|
50
|
+
"install-native-ort",
|
|
44
51
|
]);
|
|
45
52
|
|
|
46
53
|
function isActionKind(v: unknown): v is SetupCortexActionKind {
|
|
@@ -113,7 +120,9 @@ export function handleSetupCortexAction(
|
|
|
113
120
|
}
|
|
114
121
|
const value = parsed.value;
|
|
115
122
|
const action = value.action;
|
|
116
|
-
|
|
123
|
+
// ENC-2c: install-native-ort is recognized ONLY while ENC_2C is on —
|
|
124
|
+
// flag-off is byte-identical to the ENC-2b predecessor (invalid_action).
|
|
125
|
+
if (!isActionKind(action) || (action === "install-native-ort" && !ENC_2C_ENABLED())) {
|
|
117
126
|
sendJson(res, 400, { error: "invalid_action" });
|
|
118
127
|
return;
|
|
119
128
|
}
|
|
@@ -134,8 +143,10 @@ export function handleSetupCortexAction(
|
|
|
134
143
|
});
|
|
135
144
|
return;
|
|
136
145
|
}
|
|
137
|
-
|
|
138
|
-
|
|
146
|
+
void (async () => {
|
|
147
|
+
const result = await runSetupCortexAction(action, ctx.stateDir);
|
|
148
|
+
sendJson(res, result.ok ? 200 : 500, result);
|
|
149
|
+
})();
|
|
139
150
|
});
|
|
140
151
|
return true;
|
|
141
152
|
}
|
|
@@ -28,21 +28,21 @@ import type { IncomingMessage, ServerResponse } from "node:http";
|
|
|
28
28
|
import type { RouteContext } from "./routes-core.js";
|
|
29
29
|
import { VC7A_ENABLED } from "../../src/config.js";
|
|
30
30
|
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
31
|
-
import { countVcEvents, vcCount } from "./vc-event-counts.js";
|
|
32
31
|
import { deriveVcStatus } from "./vc-status.js";
|
|
32
|
+
import { readLivewireSnapshot } from "../../src/vector-cortex/livewire/livewire-registry.js";
|
|
33
33
|
import type { VectorCortexCrystalsView } from "./api-contracts/vector-cortex-cache.js";
|
|
34
34
|
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"vector_cortex_crystal_collision",
|
|
39
|
-
] as const;
|
|
35
|
+
// The flag-off deferred reason, kept byte-identical to the pre-LIVEWIRE
|
|
36
|
+
// predecessor (VC7A: `crystal_store_not_instantiated_v0_20_23`).
|
|
37
|
+
const DEFERRED_REASON = "crystal_store_not_instantiated_v0_20_23";
|
|
40
38
|
|
|
41
39
|
/**
|
|
42
40
|
* Reader-only GET /api/vector-cortex/cache-crystals (VC7A).
|
|
43
41
|
*
|
|
44
|
-
* Counts, byte volumes, and CRY_* codes only
|
|
45
|
-
*
|
|
42
|
+
* Counts, byte volumes, and CRY_* codes only. With the flag ON it surfaces the
|
|
43
|
+
* LIVEWIRE `CrystalStore` aggregate (live reads/writes/collisions accumulated at
|
|
44
|
+
* runtime); with the flag OFF it returns the byte-identical legacy deferred view
|
|
45
|
+
* (mode C, deferredReason present) so flag-off parity holds.
|
|
46
46
|
*/
|
|
47
47
|
export function handleVectorCortexCrystals(
|
|
48
48
|
req: IncomingMessage,
|
|
@@ -58,31 +58,47 @@ export function handleVectorCortexCrystals(
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const enabled = VC7A_ENABLED();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
if (!enabled) {
|
|
62
|
+
// Flag-off parity: byte-identical to the predecessor (mode C + deferred).
|
|
63
|
+
const body: VectorCortexCrystalsView = {
|
|
64
|
+
enabled: false,
|
|
65
|
+
mode: "C",
|
|
66
|
+
crystalCount: 0,
|
|
67
|
+
totalBytes: 0,
|
|
68
|
+
hits: 0,
|
|
69
|
+
misses: 0,
|
|
70
|
+
hitBytes: 0,
|
|
71
|
+
writes: 0,
|
|
72
|
+
duplicateWrites: 0,
|
|
73
|
+
collisions: 0,
|
|
74
|
+
lastFailure: null,
|
|
75
|
+
updatedAt: new Date().toISOString(),
|
|
76
|
+
deferredReason: DEFERRED_REASON,
|
|
77
|
+
status: deriveVcStatus({ enabled: false, hasData: false }),
|
|
78
|
+
};
|
|
79
|
+
sendJson(res, 200, body);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const snap = readLivewireSnapshot(ctx.stateDir);
|
|
84
|
+
const crystal = snap.crystals;
|
|
85
|
+
const hasData = crystal.crystalCount > 0;
|
|
67
86
|
const body: VectorCortexCrystalsView = {
|
|
68
|
-
enabled,
|
|
69
|
-
mode,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
enabled: true,
|
|
88
|
+
// Surface the store's honest triad mode (B until a hit, A after, C when the
|
|
89
|
+
// store was set unavailable) rather than a hardcoded A.
|
|
90
|
+
mode: crystal.mode,
|
|
91
|
+
crystalCount: crystal.crystalCount,
|
|
92
|
+
totalBytes: crystal.totalBytes,
|
|
93
|
+
hits: crystal.hits,
|
|
94
|
+
misses: crystal.misses,
|
|
95
|
+
hitBytes: crystal.hitBytes,
|
|
96
|
+
writes: crystal.writes,
|
|
97
|
+
duplicateWrites: crystal.duplicateWrites,
|
|
98
|
+
collisions: crystal.collisions,
|
|
78
99
|
lastFailure: null,
|
|
79
100
|
updatedAt: new Date().toISOString(),
|
|
80
|
-
|
|
81
|
-
status: deriveVcStatus({
|
|
82
|
-
enabled,
|
|
83
|
-
deferredReason: "crystal_store_not_instantiated_v0_20_23",
|
|
84
|
-
hasData: vcCount(counts, "vector_cortex_crystal_written") > 0,
|
|
85
|
-
}),
|
|
101
|
+
status: deriveVcStatus({ enabled: true, hasData }),
|
|
86
102
|
};
|
|
87
103
|
sendJson(res, 200, body);
|
|
88
104
|
return true;
|
|
@@ -30,18 +30,21 @@ import type { IncomingMessage, ServerResponse } from "node:http";
|
|
|
30
30
|
import type { RouteContext } from "./routes-core.js";
|
|
31
31
|
import { VC7C_ENABLED } from "../../src/config.js";
|
|
32
32
|
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
33
|
-
import { countVcEvents, vcCount } from "./vc-event-counts.js";
|
|
34
33
|
import { deriveVcStatus } from "./vc-status.js";
|
|
34
|
+
import { readLivewireSnapshot } from "../../src/vector-cortex/livewire/livewire-registry.js";
|
|
35
35
|
import type { VectorCortexDiagnosticsView } from "./api-contracts/vector-cortex-diagnostics.js";
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
|
|
37
|
+
// The flag-off deferred reason, kept byte-identical to the pre-LIVEWIRE
|
|
38
|
+
// predecessor (VC7C: `cache_classifier_not_wired_v0_20_23`).
|
|
39
|
+
const DEFERRED_REASON = "cache_classifier_not_wired_v0_20_23";
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* Reader-only GET /api/vector-cortex/cache-diagnostics (VC7C).
|
|
42
43
|
*
|
|
43
|
-
* Per-miss-class counts, breaker state, and CACHE
|
|
44
|
-
*
|
|
44
|
+
* Per-miss-class counts, serveBlocked, breaker state, and CACHE/M5 codes only.
|
|
45
|
+
* With the flag ON it surfaces the LIVEWIRE classifier/breaker tallies
|
|
46
|
+
* accumulated at runtime; with the flag OFF it returns the byte-identical legacy
|
|
47
|
+
* deferred view (mode C, deferredReason present).
|
|
45
48
|
*/
|
|
46
49
|
export function handleVectorCortexDiagnostics(
|
|
47
50
|
req: IncomingMessage,
|
|
@@ -57,32 +60,52 @@ export function handleVectorCortexDiagnostics(
|
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
const enabled = VC7C_ENABLED();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
if (!enabled) {
|
|
64
|
+
// Flag-off parity: byte-identical to the predecessor (mode C + deferred).
|
|
65
|
+
const body: VectorCortexDiagnosticsView = {
|
|
66
|
+
enabled: false,
|
|
67
|
+
mode: "C",
|
|
68
|
+
profileMisses: 0,
|
|
69
|
+
rangeMisses: 0,
|
|
70
|
+
dependencyMisses: 0,
|
|
71
|
+
requestMisses: 0,
|
|
72
|
+
generationMisses: 0,
|
|
73
|
+
unknownMisses: 0,
|
|
74
|
+
serveBlocked: 0,
|
|
75
|
+
breakerState: "closed",
|
|
76
|
+
lastFailure: null,
|
|
77
|
+
updatedAt: new Date().toISOString(),
|
|
78
|
+
deferredReason: DEFERRED_REASON,
|
|
79
|
+
status: deriveVcStatus({ enabled: false, hasData: false }),
|
|
80
|
+
};
|
|
81
|
+
sendJson(res, 200, body);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const diag = readLivewireSnapshot(ctx.stateDir).diagnostics;
|
|
86
|
+
const hasData =
|
|
87
|
+
diag.profileMisses +
|
|
88
|
+
diag.rangeMisses +
|
|
89
|
+
diag.dependencyMisses +
|
|
90
|
+
diag.requestMisses +
|
|
91
|
+
diag.generationMisses +
|
|
92
|
+
diag.unknownMisses +
|
|
93
|
+
diag.serveBlocked >
|
|
94
|
+
0;
|
|
67
95
|
const body: VectorCortexDiagnosticsView = {
|
|
68
|
-
enabled,
|
|
69
|
-
mode,
|
|
70
|
-
profileMisses:
|
|
71
|
-
rangeMisses:
|
|
72
|
-
dependencyMisses:
|
|
73
|
-
requestMisses:
|
|
74
|
-
generationMisses:
|
|
75
|
-
unknownMisses:
|
|
76
|
-
serveBlocked:
|
|
77
|
-
breakerState:
|
|
78
|
-
lastFailure:
|
|
96
|
+
enabled: true,
|
|
97
|
+
mode: "A",
|
|
98
|
+
profileMisses: diag.profileMisses,
|
|
99
|
+
rangeMisses: diag.rangeMisses,
|
|
100
|
+
dependencyMisses: diag.dependencyMisses,
|
|
101
|
+
requestMisses: diag.requestMisses,
|
|
102
|
+
generationMisses: diag.generationMisses,
|
|
103
|
+
unknownMisses: diag.unknownMisses,
|
|
104
|
+
serveBlocked: diag.serveBlocked,
|
|
105
|
+
breakerState: diag.breakerState,
|
|
106
|
+
lastFailure: diag.lastFailure,
|
|
79
107
|
updatedAt: new Date().toISOString(),
|
|
80
|
-
|
|
81
|
-
status: deriveVcStatus({
|
|
82
|
-
enabled,
|
|
83
|
-
deferredReason: "cache_classifier_not_wired_v0_20_23",
|
|
84
|
-
hasData: vcCount(counts, "vector_cortex_cache_serve_blocked") > 0,
|
|
85
|
-
}),
|
|
108
|
+
status: deriveVcStatus({ enabled: true, hasData }),
|
|
86
109
|
};
|
|
87
110
|
sendJson(res, 200, body);
|
|
88
111
|
return true;
|
|
@@ -28,18 +28,25 @@ import type { RouteContext } from "./routes-core.js";
|
|
|
28
28
|
import { VC7B_ENABLED } from "../../src/config.js";
|
|
29
29
|
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
30
30
|
import { deriveVcStatus } from "./vc-status.js";
|
|
31
|
+
import { readLivewireSnapshot } from "../../src/vector-cortex/livewire/livewire-registry.js";
|
|
31
32
|
import type { VectorCortexEconomicsView } from "./api-contracts/vector-cortex-economics.js";
|
|
32
33
|
|
|
34
|
+
// The flag-off deferred reason, kept byte-identical to the pre-LIVEWIRE
|
|
35
|
+
// predecessor (VC7B: `economics_not_computed_v0_20_23`).
|
|
36
|
+
const DEFERRED_REASON = "economics_not_computed_v0_20_23";
|
|
37
|
+
|
|
33
38
|
/**
|
|
34
39
|
* Reader-only GET /api/vector-cortex/cache-economics (VC7B).
|
|
35
40
|
*
|
|
36
|
-
* Counts, profile tallies, and ECON_* codes only
|
|
37
|
-
*
|
|
41
|
+
* Counts, profile tallies, and ECON_* codes only. With the flag ON it surfaces
|
|
42
|
+
* the LIVEWIRE-provided profile economics tallies + the runtime `computed` bit;
|
|
43
|
+
* with the flag OFF it returns the byte-identical legacy deferred view (mode C,
|
|
44
|
+
* deferredReason present).
|
|
38
45
|
*/
|
|
39
46
|
export function handleVectorCortexEconomics(
|
|
40
47
|
req: IncomingMessage,
|
|
41
48
|
res: ServerResponse,
|
|
42
|
-
|
|
49
|
+
ctx: RouteContext,
|
|
43
50
|
): boolean {
|
|
44
51
|
const url = req.url ?? "";
|
|
45
52
|
const path = url.split("?")[0] ?? url;
|
|
@@ -50,25 +57,33 @@ export function handleVectorCortexEconomics(
|
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
const enabled = VC7B_ENABLED();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
if (!enabled) {
|
|
61
|
+
// Flag-off parity: byte-identical to the predecessor (mode C + deferred).
|
|
62
|
+
const body: VectorCortexEconomicsView = {
|
|
63
|
+
enabled: false,
|
|
64
|
+
mode: "C",
|
|
65
|
+
profileCount: 0,
|
|
66
|
+
provenExclusions: 0,
|
|
67
|
+
unprovenExclusions: 0,
|
|
68
|
+
lastFailure: null,
|
|
69
|
+
updatedAt: new Date().toISOString(),
|
|
70
|
+
deferredReason: DEFERRED_REASON,
|
|
71
|
+
status: deriveVcStatus({ enabled: false, hasData: false }),
|
|
72
|
+
};
|
|
73
|
+
sendJson(res, 200, body);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const econ = readLivewireSnapshot(ctx.stateDir).economics;
|
|
58
78
|
const body: VectorCortexEconomicsView = {
|
|
59
|
-
enabled,
|
|
60
|
-
mode,
|
|
61
|
-
profileCount:
|
|
62
|
-
provenExclusions:
|
|
63
|
-
unprovenExclusions:
|
|
64
|
-
lastFailure:
|
|
79
|
+
enabled: true,
|
|
80
|
+
mode: "A",
|
|
81
|
+
profileCount: econ.profileCount,
|
|
82
|
+
provenExclusions: econ.provenExclusions,
|
|
83
|
+
unprovenExclusions: econ.unprovenExclusions,
|
|
84
|
+
lastFailure: econ.lastFailure,
|
|
65
85
|
updatedAt: new Date().toISOString(),
|
|
66
|
-
|
|
67
|
-
status: deriveVcStatus({
|
|
68
|
-
enabled,
|
|
69
|
-
deferredReason: "economics_not_computed_v0_20_23",
|
|
70
|
-
hasData: false,
|
|
71
|
-
}),
|
|
86
|
+
status: deriveVcStatus({ enabled: true, hasData: econ.computed }),
|
|
72
87
|
};
|
|
73
88
|
sendJson(res, 200, body);
|
|
74
89
|
return true;
|
|
@@ -108,3 +108,87 @@ export async function seedEval(dir: string): Promise<void> {
|
|
|
108
108
|
{ session: "s1", seq: 4, event: "encode", value: 12, unit: "ms", mode: "A" },
|
|
109
109
|
]);
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Seed a LIVEWIRE aggregate snapshot directly on disk so the spawned dashboard
|
|
114
|
+
* server (a separate process) rehydrates real subsystem counts and its reader-only
|
|
115
|
+
* routes report LIVE (non-deferred) data. This is how the LIVEWIRE route tests
|
|
116
|
+
* prove the wiring: the runtimes' persisted counts are exactly what a reader
|
|
117
|
+
* process reconstructs. Counts + codes + triad mode only (SECURITY_PRIVACY).
|
|
118
|
+
*/
|
|
119
|
+
export async function seedLivewireSnapshot(
|
|
120
|
+
dir: string,
|
|
121
|
+
overrides?: {
|
|
122
|
+
crystals?: Partial<Record<
|
|
123
|
+
"crystalCount" | "totalBytes" | "hits" | "misses" | "hitBytes" |
|
|
124
|
+
"writes" | "duplicateWrites" | "collisions",
|
|
125
|
+
number
|
|
126
|
+
>>;
|
|
127
|
+
diagnostics?: Partial<Record<
|
|
128
|
+
"profileMisses" | "rangeMisses" | "dependencyMisses" | "requestMisses" |
|
|
129
|
+
"generationMisses" | "unknownMisses" | "serveBlocked",
|
|
130
|
+
number
|
|
131
|
+
>> & { breakerState?: string };
|
|
132
|
+
economics?: {
|
|
133
|
+
computed?: boolean;
|
|
134
|
+
profileCount?: number;
|
|
135
|
+
provenExclusions?: number;
|
|
136
|
+
unprovenExclusions?: number;
|
|
137
|
+
};
|
|
138
|
+
policy?: {
|
|
139
|
+
shadowDecisions?: number;
|
|
140
|
+
clampedDecisions?: number;
|
|
141
|
+
rejectedInputs?: number;
|
|
142
|
+
pressureVersion?: number;
|
|
143
|
+
liveMutations?: number;
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
): Promise<void> {
|
|
147
|
+
const { saveLivewireSnapshot } = await import(
|
|
148
|
+
"../../src/vector-cortex/livewire/livewire-snapshot.js"
|
|
149
|
+
);
|
|
150
|
+
const c = overrides?.crystals ?? {};
|
|
151
|
+
const d = overrides?.diagnostics ?? {};
|
|
152
|
+
const e = overrides?.economics ?? {};
|
|
153
|
+
const p = overrides?.policy ?? {};
|
|
154
|
+
saveLivewireSnapshot(dir, {
|
|
155
|
+
schema: "vector-cortex-livewire-v1",
|
|
156
|
+
crystals: {
|
|
157
|
+
mode: "A",
|
|
158
|
+
crystalCount: c.crystalCount ?? 3,
|
|
159
|
+
totalBytes: c.totalBytes ?? 1024,
|
|
160
|
+
hits: c.hits ?? 0,
|
|
161
|
+
misses: c.misses ?? 0,
|
|
162
|
+
hitBytes: c.hitBytes ?? 0,
|
|
163
|
+
writes: c.writes ?? 0,
|
|
164
|
+
duplicateWrites: c.duplicateWrites ?? 0,
|
|
165
|
+
collisions: c.collisions ?? 0,
|
|
166
|
+
},
|
|
167
|
+
diagnostics: {
|
|
168
|
+
profileMisses: d.profileMisses ?? 0,
|
|
169
|
+
rangeMisses: d.rangeMisses ?? 0,
|
|
170
|
+
dependencyMisses: d.dependencyMisses ?? 0,
|
|
171
|
+
requestMisses: d.requestMisses ?? 0,
|
|
172
|
+
generationMisses: d.generationMisses ?? 0,
|
|
173
|
+
unknownMisses: d.unknownMisses ?? 0,
|
|
174
|
+
serveBlocked: d.serveBlocked ?? 0,
|
|
175
|
+
breakerState: d.breakerState ?? "CLOSED_A",
|
|
176
|
+
lastFailure: null,
|
|
177
|
+
},
|
|
178
|
+
economics: {
|
|
179
|
+
profileCount: e.profileCount ?? 4,
|
|
180
|
+
provenExclusions: e.provenExclusions ?? 1,
|
|
181
|
+
unprovenExclusions: e.unprovenExclusions ?? 0,
|
|
182
|
+
computed: e.computed ?? true,
|
|
183
|
+
lastFailure: null,
|
|
184
|
+
},
|
|
185
|
+
policy: {
|
|
186
|
+
shadowDecisions: p.shadowDecisions ?? 0,
|
|
187
|
+
clampedDecisions: p.clampedDecisions ?? 0,
|
|
188
|
+
rejectedInputs: p.rejectedInputs ?? 0,
|
|
189
|
+
liveMutations: p.liveMutations ?? 0,
|
|
190
|
+
pressureVersion: (p.pressureVersion ?? 1) as 1 | 2,
|
|
191
|
+
lastFailure: null,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
}
|
|
@@ -21,13 +21,18 @@ import type { RouteContext } from "./routes-core.js";
|
|
|
21
21
|
import { VC8B_ENABLED } from "../../src/config.js";
|
|
22
22
|
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
23
23
|
import { deriveVcStatus } from "./vc-status.js";
|
|
24
|
+
import { readLivewireSnapshot } from "../../src/vector-cortex/livewire/livewire-registry.js";
|
|
24
25
|
import type { VectorCortexPolicyView } from "./api-contracts/vector-cortex-policy.js";
|
|
25
26
|
|
|
27
|
+
// The flag-off deferred reason, kept byte-identical to the pre-LIVEWIRE
|
|
28
|
+
// predecessor (VC8B: `shadow_controller_not_instantiated_v0_20_23`).
|
|
29
|
+
const DEFERRED_REASON = "shadow_controller_not_instantiated_v0_20_23";
|
|
30
|
+
|
|
26
31
|
/** GET /api/vector-cortex/policy — reader-only policy + shadow aggregate (VC8B). */
|
|
27
32
|
export function handleVectorCortexPolicy(
|
|
28
33
|
req: IncomingMessage,
|
|
29
34
|
res: ServerResponse,
|
|
30
|
-
|
|
35
|
+
ctx: RouteContext,
|
|
31
36
|
): boolean {
|
|
32
37
|
const url = req.url ?? "";
|
|
33
38
|
const path = url.split("?")[0] ?? url;
|
|
@@ -39,23 +44,37 @@ export function handleVectorCortexPolicy(
|
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
const enabled = VC8B_ENABLED();
|
|
42
|
-
|
|
47
|
+
if (!enabled) {
|
|
48
|
+
// Flag-off parity: byte-identical to the predecessor (mode C + deferred).
|
|
49
|
+
const body: VectorCortexPolicyView = {
|
|
50
|
+
enabled: false,
|
|
51
|
+
mode: "C",
|
|
52
|
+
shadowDecisions: 0,
|
|
53
|
+
clampedDecisions: 0,
|
|
54
|
+
rejectedInputs: 0,
|
|
55
|
+
liveMutations: 0,
|
|
56
|
+
pressureVersion: 1,
|
|
57
|
+
lastFailure: null,
|
|
58
|
+
updatedAt: new Date().toISOString(),
|
|
59
|
+
deferredReason: DEFERRED_REASON,
|
|
60
|
+
status: deriveVcStatus({ enabled: false, hasData: false }),
|
|
61
|
+
};
|
|
62
|
+
sendJson(res, 200, body);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const policy = readLivewireSnapshot(ctx.stateDir).policy;
|
|
43
67
|
const body: VectorCortexPolicyView = {
|
|
44
|
-
enabled,
|
|
45
|
-
mode,
|
|
46
|
-
shadowDecisions:
|
|
47
|
-
clampedDecisions:
|
|
48
|
-
rejectedInputs:
|
|
49
|
-
liveMutations:
|
|
50
|
-
pressureVersion:
|
|
51
|
-
lastFailure:
|
|
68
|
+
enabled: true,
|
|
69
|
+
mode: "A",
|
|
70
|
+
shadowDecisions: policy.shadowDecisions,
|
|
71
|
+
clampedDecisions: policy.clampedDecisions,
|
|
72
|
+
rejectedInputs: policy.rejectedInputs,
|
|
73
|
+
liveMutations: policy.liveMutations,
|
|
74
|
+
pressureVersion: policy.pressureVersion,
|
|
75
|
+
lastFailure: policy.lastFailure,
|
|
52
76
|
updatedAt: new Date().toISOString(),
|
|
53
|
-
|
|
54
|
-
status: deriveVcStatus({
|
|
55
|
-
enabled,
|
|
56
|
-
deferredReason: "shadow_controller_not_instantiated_v0_20_23",
|
|
57
|
-
hasData: false,
|
|
58
|
-
}),
|
|
77
|
+
status: deriveVcStatus({ enabled: true, hasData: policy.shadowDecisions > 0 }),
|
|
59
78
|
};
|
|
60
79
|
sendJson(res, 200, body);
|
|
61
80
|
return true;
|