pi-mega-compact 0.20.69 → 0.20.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/config/vector-cortex-enc2c.js +38 -0
  2. package/dist/config/vector-cortex.js +2 -0
  3. package/dist/config.js +1 -1
  4. package/dist/extensions/dashboard-server/api-contracts/setup-cortex-native-ort.js +22 -0
  5. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -0
  6. package/dist/extensions/dashboard-server/routes-setup-cortex-actions.js +17 -11
  7. package/dist/extensions/dashboard-server/setup-cortex-actions-native-ort.js +107 -0
  8. package/dist/extensions/dashboard-server/setup-cortex-actions.js +9 -2
  9. package/dist/src/config/vector-cortex-enc2c.js +38 -0
  10. package/dist/src/config/vector-cortex.js +2 -0
  11. package/dist/src/config.js +1 -1
  12. package/dist/src/vector-cortex/setup-cortex-blockers-compute.js +3 -0
  13. package/dist/vector-cortex/setup-cortex-blockers-compute.js +3 -0
  14. package/extensions/dashboard-client/dist/assets/{AdminTab-BUl1fyQ-.js → AdminTab-ZyVtgYrZ.js} +2 -2
  15. package/extensions/dashboard-client/dist/assets/{AdminTab-BUl1fyQ-.js.map → AdminTab-ZyVtgYrZ.js.map} +1 -1
  16. package/extensions/dashboard-client/dist/assets/{AreaChart-CumzbAON.js → AreaChart-7ms8Hk1m.js} +2 -2
  17. package/extensions/dashboard-client/dist/assets/{AreaChart-CumzbAON.js.map → AreaChart-7ms8Hk1m.js.map} +1 -1
  18. package/extensions/dashboard-client/dist/assets/{BarChart-MvUf2UYv.js → BarChart-DeTE0NXA.js} +2 -2
  19. package/extensions/dashboard-client/dist/assets/{BarChart-MvUf2UYv.js.map → BarChart-DeTE0NXA.js.map} +1 -1
  20. package/extensions/dashboard-client/dist/assets/{CacheTab-CqpJZ5Ok.js → CacheTab-CpIrpr_X.js} +2 -2
  21. package/extensions/dashboard-client/dist/assets/{CacheTab-CqpJZ5Ok.js.map → CacheTab-CpIrpr_X.js.map} +1 -1
  22. package/extensions/dashboard-client/dist/assets/{ConfigTab-Cr0pKYGK.js → ConfigTab-BNMrO7uz.js} +2 -2
  23. package/extensions/dashboard-client/dist/assets/{ConfigTab-Cr0pKYGK.js.map → ConfigTab-BNMrO7uz.js.map} +1 -1
  24. package/extensions/dashboard-client/dist/assets/{EventsTab-FTQ4nJae.js → EventsTab-j42vDTjs.js} +2 -2
  25. package/extensions/dashboard-client/dist/assets/{EventsTab-FTQ4nJae.js.map → EventsTab-j42vDTjs.js.map} +1 -1
  26. package/extensions/dashboard-client/dist/assets/{HealthTab-D7s5lCB0.js → HealthTab-D0Tf8XM_.js} +2 -2
  27. package/extensions/dashboard-client/dist/assets/{HealthTab-D7s5lCB0.js.map → HealthTab-D0Tf8XM_.js.map} +1 -1
  28. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DW5c0ngt.js → MaintenanceTab-CleWX_RM.js} +2 -2
  29. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DW5c0ngt.js.map → MaintenanceTab-CleWX_RM.js.map} +1 -1
  30. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-ocR07fD7.js → MemoryMapTab-LUpPJzNP.js} +2 -2
  31. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-ocR07fD7.js.map → MemoryMapTab-LUpPJzNP.js.map} +1 -1
  32. package/extensions/dashboard-client/dist/assets/{MetricsCards-CNBlWLoU.js → MetricsCards-G4_uynTE.js} +2 -2
  33. package/extensions/dashboard-client/dist/assets/{MetricsCards-CNBlWLoU.js.map → MetricsCards-G4_uynTE.js.map} +1 -1
  34. package/extensions/dashboard-client/dist/assets/MetricsTab-yypKMQXf.js +2 -0
  35. package/extensions/dashboard-client/dist/assets/{MetricsTab-sks9wzZr.js.map → MetricsTab-yypKMQXf.js.map} +1 -1
  36. package/extensions/dashboard-client/dist/assets/{OverviewTab-Duu9zseZ.js → OverviewTab-M47NMRaT.js} +2 -2
  37. package/extensions/dashboard-client/dist/assets/{OverviewTab-Duu9zseZ.js.map → OverviewTab-M47NMRaT.js.map} +1 -1
  38. package/extensions/dashboard-client/dist/assets/{ReposTab-CMd5NYjk.js → ReposTab-BX3ZxrAI.js} +2 -2
  39. package/extensions/dashboard-client/dist/assets/{ReposTab-CMd5NYjk.js.map → ReposTab-BX3ZxrAI.js.map} +1 -1
  40. package/extensions/dashboard-client/dist/assets/{SessionsTab-Ht-k4LKk.js → SessionsTab-CSUmsNeZ.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{SessionsTab-Ht-k4LKk.js.map → SessionsTab-CSUmsNeZ.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/{SetupTab-BCfBdL-1.js → SetupTab-jF9BsQjw.js} +3 -3
  43. package/extensions/dashboard-client/dist/assets/SetupTab-jF9BsQjw.js.map +1 -0
  44. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-B3CAK2FZ.js → TimeSavedCard-qfwO1WJ3.js} +2 -2
  45. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-B3CAK2FZ.js.map → TimeSavedCard-qfwO1WJ3.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-7SRtcvZF.js → TurnMemoryView-C7NQo_xi.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-7SRtcvZF.js.map → TurnMemoryView-C7NQo_xi.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/TurnsTab-D-19giqQ.js +2 -0
  49. package/extensions/dashboard-client/dist/assets/{TurnsTab-Djd-nzlT.js.map → TurnsTab-D-19giqQ.js.map} +1 -1
  50. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-BzvdQnVq.js → VcStatusBadge-DTHlwuUJ.js} +2 -2
  51. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-BzvdQnVq.js.map → VcStatusBadge-DTHlwuUJ.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-qmY0a0E-.js → VectorCortexTab-Dvgdcwvs.js} +2 -2
  53. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-qmY0a0E-.js.map → VectorCortexTab-Dvgdcwvs.js.map} +1 -1
  54. package/extensions/dashboard-client/dist/assets/{WikiTab-DMmc36Xi.js → WikiTab-CYUEAQmZ.js} +2 -2
  55. package/extensions/dashboard-client/dist/assets/{WikiTab-DMmc36Xi.js.map → WikiTab-CYUEAQmZ.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{button-DcRndiuf.js → button-DPOwTRN8.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{button-DcRndiuf.js.map → button-DPOwTRN8.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/assets/{card-CwWLYigw.js → card-CUipkgi9.js} +2 -2
  59. package/extensions/dashboard-client/dist/assets/{card-CwWLYigw.js.map → card-CUipkgi9.js.map} +1 -1
  60. package/extensions/dashboard-client/dist/assets/{client-extra-NQXJNKNj.js → client-extra-9lcKX-iO.js} +2 -2
  61. package/extensions/dashboard-client/dist/assets/{client-extra-NQXJNKNj.js.map → client-extra-9lcKX-iO.js.map} +1 -1
  62. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-BX9n_-am.js → generateCategoricalChart-_WpiJebf.js} +2 -2
  63. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-BX9n_-am.js.map → generateCategoricalChart-_WpiJebf.js.map} +1 -1
  64. package/extensions/dashboard-client/dist/assets/{index-DgKI8jwx.js → index-DlHJ7LBL.js} +3 -3
  65. package/extensions/dashboard-client/dist/assets/{index-DgKI8jwx.js.map → index-DlHJ7LBL.js.map} +1 -1
  66. package/extensions/dashboard-client/dist/assets/{switch-C_xzN77s.js → switch-Cx6-1wnT.js} +2 -2
  67. package/extensions/dashboard-client/dist/assets/{switch-C_xzN77s.js.map → switch-Cx6-1wnT.js.map} +1 -1
  68. package/extensions/dashboard-client/dist/assets/{toggle-807R1-Th.js → toggle-Y3vbE0NG.js} +2 -2
  69. package/extensions/dashboard-client/dist/assets/{toggle-807R1-Th.js.map → toggle-Y3vbE0NG.js.map} +1 -1
  70. package/extensions/dashboard-client/dist/assets/{useSSE-BNG39O7p.js → useSSE-CnJdk56R.js} +2 -2
  71. package/extensions/dashboard-client/dist/assets/{useSSE-BNG39O7p.js.map → useSSE-CnJdk56R.js.map} +1 -1
  72. package/extensions/dashboard-client/dist/index.html +1 -1
  73. package/extensions/dashboard-client/src/tabs/SetupTab/CortexActionsCard.tsx +89 -5
  74. package/extensions/dashboard-client/src/types/setup-cortex.ts +22 -1
  75. package/extensions/dashboard-server/api-contracts/setup-cortex-native-ort.ts +52 -0
  76. package/extensions/dashboard-server/api-contracts/setup-cortex.ts +8 -2
  77. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +6 -0
  78. package/extensions/dashboard-server/routes-setup-cortex-actions.ts +22 -11
  79. package/extensions/dashboard-server/setup-cortex-actions-native-ort.ts +121 -0
  80. package/extensions/dashboard-server/setup-cortex-actions.ts +9 -3
  81. package/package.json +1 -1
  82. package/src/config/vector-cortex-enc2c.ts +40 -0
  83. package/src/config/vector-cortex.ts +2 -0
  84. package/src/config.ts +1 -0
  85. package/src/vector-cortex/setup-cortex-blockers-compute.ts +8 -1
  86. package/extensions/dashboard-client/dist/assets/MetricsTab-sks9wzZr.js +0 -2
  87. package/extensions/dashboard-client/dist/assets/SetupTab-BCfBdL-1.js.map +0 -1
  88. 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 = "fetch-model" | "bench" | "verify-asset";
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
- export type SetupCortexActionKind = "fetch-model" | "bench" | "verify-asset";
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 or re-read the committed
9
- * encoder assets (verify-asset) — no network (PREVENT-PI-004). A hard gate
10
- * (HG-1/HG-3) blocking the requested action yields 423 action_blocked_by_open_item
11
- * with the blocker ids and NO subprocess is spawned. Missing confirm:true yields
12
- * 400 confirmation_required. Flag-off (MEGACOMPACT_VC9B=0) is byte-identical to
13
- * the VC9A-era predecessor: the routes are absent, so they return the 404
14
- * disabled shape and no action runs.
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 { VC9B_ENABLED, ENC_0G_ENABLED, ENC_0F_ENABLED } from "../../src/config.js";
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
- if (!isActionKind(action)) {
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
- const result = runSetupCortexAction(action, ctx.stateDir);
138
- sendJson(res, result.ok ? 200 : 500, result);
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
  }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * dashboard-server/setup-cortex-actions-native-ort.ts — ENC-2c native onnxruntime
3
+ * lazy-download INSTALL action driver (actor surface for install-native-ort).
4
+ *
5
+ * Sibling of setup-cortex-actions.ts (which stays under the 300-line source soft
6
+ * cap). Implements the mechanics behind the VC9B `install-native-ort` action:
7
+ *
8
+ * 1. locate the committed scripts/encoder/install-native-ort.mjs by walking up
9
+ * to the repo root (mirroring setup-cortex-actions.ts vc2ScriptDir);
10
+ * 2. spawn `node <script>` locally with a 60s timeout (npm-delegated,
11
+ * sha256-verified install — the registry URL + sha256 live ONLY in
12
+ * src/vector-cortex/encoder/native-install-artifacts.ts, never here);
13
+ * 3. capture output to <stateDir>/logs/vc9b/install-native-ort-<ts>.log;
14
+ * 4. REGARDLESS of the install exit code, re-qualify the binding via the ENC-2b
15
+ * retest path (`runNativeRetest`) and surface the fresh result +
16
+ * effective backend.
17
+ *
18
+ * PREVENT-PI-004 banner: this is an OPT-IN, confirm-gated, npm-delegated local
19
+ * subprocess of a committed repo script. It performs no network I/O in this
20
+ * module and carries NO URL literals (the codebase-wide no-URL-literal scan
21
+ * covers src/ + extensions/).
22
+ *
23
+ * Guardrails: PREVENT-011 (no `any`); the subprocess is a committed local script,
24
+ * never fetched (PREVENT-PI-004, guardrails-allow below).
25
+ */
26
+
27
+ import { spawnSync } from "node:child_process"; // guardrails-allow PREVENT-PI-004: opt-in, confirm-gated, npm-delegated install subprocess (local spawn of committed repo script; no URL literals)
28
+ import { mkdirSync, writeFileSync, existsSync } from "node:fs";
29
+ import { join, dirname } from "node:path";
30
+ import { fileURLToPath } from "node:url";
31
+ import { runNativeRetest } from "../../src/vector-cortex/encoder/native-qualify-retest.js";
32
+ import type {
33
+ SetupCortexActionResultWithNativeOrt,
34
+ NativeOrtRetestResult,
35
+ } from "./api-contracts/setup-cortex-native-ort.js";
36
+
37
+ /** Locate scripts/encoder/install-native-ort.mjs by walking up to the repo root. */
38
+ export function installScriptPath(): string | null {
39
+ let dir = dirname(fileURLToPath(import.meta.url));
40
+ const rel = join("scripts", "encoder", "install-native-ort.mjs");
41
+ for (let i = 0; i < 8; i++) {
42
+ const candidate = join(dir, rel);
43
+ // guardrails-allow PREVENT-PI-004: local repo filesystem read (loopback)
44
+ if (existsSync(candidate)) return candidate;
45
+ const next = dirname(dir);
46
+ if (next === dir) break;
47
+ dir = next;
48
+ }
49
+ return null;
50
+ }
51
+
52
+ /** Ensure the vc9b log dir exists (mirrors setup-cortex-actions.ts). */
53
+ function ensureLogDir(stateDir: string): string {
54
+ const dir = join(stateDir, "logs", "vc9b");
55
+ // guardrails-allow PREVENT-PI-004: local state-dir filesystem write (loopback)
56
+ mkdirSync(dir, { recursive: true });
57
+ return dir;
58
+ }
59
+
60
+ function writeLog(logPath: string, body: string): void {
61
+ // guardrails-allow PREVENT-PI-004: local state-dir filesystem write (loopback)
62
+ writeFileSync(logPath, body, "utf8");
63
+ }
64
+
65
+ /**
66
+ * Run the ENC-2c lazy-download native onnxruntime INSTALL action. Locates and
67
+ * spawns the committed install script (npm-delegated, sha256-verified), logs the
68
+ * captured output, then ALWAYS runs the ENC-2b retest to re-qualify the binding
69
+ * (regardless of install exit code) and surfaces the fresh result.
70
+ *
71
+ * Never throws: a missing script or non-zero exit is surfaced as ok=false on the
72
+ * result; the retest runs even on install failure so the operator sees the
73
+ * post-install qualification state. Returns a combined SetupCortexActionResult
74
+ * with the ENC-2c additive fields (present only for pendant actions).
75
+ */
76
+ // guardrails-allow PREVENT-PI-004: opt-in, confirm-gated, npm-delegated install action (subprocess of committed repo script; no URL literals)
77
+ export async function runInstallNativeOrt(
78
+ stateDir: string,
79
+ ): Promise<SetupCortexActionResultWithNativeOrt> {
80
+ const ts = Date.now();
81
+ const logName = `install-native-ort-${ts}.log`;
82
+ const logPath = join(ensureLogDir(stateDir), logName);
83
+
84
+ const scriptPath = installScriptPath();
85
+ if (scriptPath === null) {
86
+ writeLog(logPath, "install-native-ort.mjs not found in this checkout\n");
87
+ return {
88
+ action: "install-native-ort",
89
+ ok: false,
90
+ exitCode: null,
91
+ logPath,
92
+ logName,
93
+ spawned: true,
94
+ };
95
+ }
96
+
97
+ // guardrails-allow PREVENT-PI-004: opt-in, confirm-gated, npm-delegated
98
+ // install subprocess (local spawn of committed repo script; no URL literals)
99
+ const result = spawnSync(process.execPath, [scriptPath], {
100
+ encoding: "utf8",
101
+ timeout: 60_000,
102
+ });
103
+
104
+ const out = `${result.stdout ?? ""}${result.stderr ?? ""}`;
105
+ writeLog(logPath, out || "(no output)\n");
106
+
107
+ // Re-qualify AFTER install regardless of exit code (the retest is the source of
108
+ // truth for whether the binding is actually usable).
109
+ const retest: NativeOrtRetestResult | null = await runNativeRetest(stateDir);
110
+
111
+ return {
112
+ action: "install-native-ort",
113
+ ok: result.status === 0,
114
+ exitCode: result.status === null ? null : result.status,
115
+ logPath,
116
+ logName,
117
+ spawned: true,
118
+ nativeOrtRetestResult: retest,
119
+ nativeOrtBackendEffective: retest !== null && retest.verdict === "qualified" ? "native" : "wasm",
120
+ };
121
+ }
@@ -6,7 +6,9 @@
6
6
  * vc2-model-prep scripts (fetch-model.sh, bench-onnx.mjs), capturing their
7
7
  * output to <stateDir>/logs/vc9b/<action>-<ts>.log, re-running the committed
8
8
  * encoder asset verification seam for verify-asset (NO subprocess), and serving
9
- * a bounded + redacted log tail.
9
+ * a bounded + redacted log tail. ENC-2c adds the `install-native-ort` action,
10
+ * delegated to the sibling setup-cortex-actions-native-ort.ts (the confirm-gated,
11
+ * npm-delegated local install + ENC-2b re-qualification).
10
12
  *
11
13
  * This module is the ONLY place that touches the filesystem for VC9B actions.
12
14
  * The route file (routes-setup-cortex-actions.ts) carries NO path/script/blocker
@@ -41,6 +43,7 @@ import {
41
43
  readQualificationRecord,
42
44
  encoderStateDir,
43
45
  } from "./qualification-record.js";
46
+ import { runInstallNativeOrt } from "./setup-cortex-actions-native-ort.js";
44
47
 
45
48
  /** Cap applied to every log tail served by the action-log route. */
46
49
  export const ACTION_LOG_TAIL_BYTES = 8192;
@@ -251,11 +254,14 @@ function writeLog(logPath: string, body: string): void {
251
254
  * result on success; throws nothing — every failure is surfaced as a result with
252
255
  * ok=false so the route can shape the HTTP response. Never touches the network;
253
256
  * the subprocesses it may spawn are the committed local vc2-model-prep scripts.
257
+ * Async (ENC-2c): install-native-ort runs the npm-delegated local install then
258
+ * re-qualifies via the ENC-2b retest path.
254
259
  */
255
- export function runSetupCortexAction(
260
+ export async function runSetupCortexAction(
256
261
  action: SetupCortexActionKind,
257
262
  stateDir: string,
258
- ): SetupCortexActionResult {
263
+ ): Promise<SetupCortexActionResult> {
259
264
  if (action === "verify-asset") return runVerifyAsset(stateDir);
265
+ if (action === "install-native-ort") return runInstallNativeOrt(stateDir);
260
266
  return runSpawnedAction(action, stateDir);
261
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.20.69",
3
+ "version": "0.20.70",
4
4
  "description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
@@ -0,0 +1,40 @@
1
+ /**
2
+ * config/vector-cortex-enc2c.ts — ENC-2c native onnxruntime lazy-download
3
+ * install-action flag (dashboard-triggered install).
4
+ *
5
+ * Sibling of vector-cortex-enc2a.ts / vector-cortex-enc2b.ts so vector-cortex.ts
6
+ * stays under the 300-line soft limit (soft-as-hard gate). vector-cortex.ts
7
+ * re-exports the flag below and root src/config.ts re-exports it, so no consumer
8
+ * import path changes.
9
+ *
10
+ * ENC-2c turns ENC-2a's operator run-script assist into a dashboard action: the
11
+ * Setup Cortex sub-tab gains an "Install Native ORT" button that, when confirmed
12
+ * by the operator, runs the committed `scripts/encoder/install-native-ort.mjs`
13
+ * subprocess locally (npm-delegated, sha256-verified) and then re-qualifies the
14
+ * binding via the ENC-2b retest path. This is a PREVENT-PI-004 opt-in exemption:
15
+ * it is confirm-gated (never automatic), delegated to a local subprocess of a
16
+ * committed repo script, and carries NO URL literals in src/ or extensions/
17
+ * (the registry URL + sha256 live only in the artifacts-module constants).
18
+ *
19
+ * `MEGACOMPACT_ENC_2C=0` disables: no install action branch, no UI button, no
20
+ * install-related result fields — byte-identical to the ENC-2b predecessor. The
21
+ * flag MUST also be a dashboard SETTINGS toggle (visible in config UI, never in
22
+ * EXCLUDED_SETTINGS — see `feedback_dashboard-flags-toggleable` memory).
23
+ *
24
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
25
+ *
26
+ * guardrails-allow PREVENT-PI-004: opt-in confirm-gated install action;
27
+ * delegates to local npm install subprocess, no URL literals (registry URL +
28
+ * sha256 live only in native-install-artifacts.ts)
29
+ */
30
+
31
+ import { sprintFlag } from "./vector-cortex-flag.js";
32
+
33
+ /**
34
+ * ENC-2c — lazy-download native onnxruntime install action (dashboard-triggered,
35
+ * npm-delegated, confirm-gated). Default ON. `MEGACOMPACT_ENC_2C=0` disables and
36
+ * is byte-identical to the ENC-2b predecessor: no install action POST branch, no
37
+ * UI button, no install result fields. This flag MUST also be a dashboard SETTINGS
38
+ * toggle (visible in config UI, never in EXCLUDED_SETTINGS).
39
+ */
40
+ export const ENC_2C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_ENC_2C");
@@ -96,6 +96,8 @@ export {
96
96
  export { ENC_2A_ENABLED } from "./vector-cortex-enc2a.js";
97
97
  // ENC-2b native onnxruntime qualification-retest flag extracted to vector-cortex-enc2b.ts.
98
98
  export { ENC_2B_ENABLED } from "./vector-cortex-enc2b.js";
99
+ // ENC-2c native onnxruntime lazy-download install-action flag extracted to vector-cortex-enc2c.ts.
100
+ export { ENC_2C_ENABLED } from "./vector-cortex-enc2c.js";
99
101
  // Breaker constants (TRIAD_RESILIENCE.md §breaker) extracted to vector-cortex-breakers.ts.
100
102
  export {
101
103
  BREAKER_WINDOW_MS,
package/src/config.ts CHANGED
@@ -204,6 +204,7 @@ export {
204
204
  ENC_2BUDGET_DEFAULT_MIB,
205
205
  ENC_2A_ENABLED,
206
206
  ENC_2B_ENABLED,
207
+ ENC_2C_ENABLED,
207
208
  COSINE_FP_BENCH_ENABLED,
208
209
  COSINE_FP_REAL_ENABLED,
209
210
  REPO_CORPUS_ENABLED,
@@ -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 = "fetch-model" | "bench" | "verify-asset";
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