pi-mega-compact 0.20.63 → 0.20.65
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/README.md +1 -1
- package/dist/config/vector-cortex-enc2a.js +35 -0
- package/dist/config/vector-cortex-enc2b.js +36 -0
- package/dist/config/vector-cortex.js +4 -0
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +2 -0
- package/dist/extensions/dashboard-server/routes-setup-enc2a.js +119 -0
- package/dist/extensions/dashboard-server/routes-setup-enc2b.js +77 -0
- package/dist/extensions/dashboard-server/routes-setup.js +65 -3
- package/dist/src/config/vector-cortex-enc2a.js +35 -0
- package/dist/src/config/vector-cortex-enc2b.js +36 -0
- package/dist/src/config/vector-cortex.js +4 -0
- package/dist/src/config.js +1 -1
- package/dist/src/vector-cortex/encoder/native-install-artifacts.js +43 -0
- package/dist/src/vector-cortex/encoder/native-qualify-retest.js +225 -0
- package/dist/vector-cortex/encoder/native-install-artifacts.js +43 -0
- package/dist/vector-cortex/encoder/native-qualify-retest.js +225 -0
- package/extensions/dashboard-client/dist/assets/{AdminTab-DrJ9VWRu.js → AdminTab-B31efZ_R.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AdminTab-DrJ9VWRu.js.map → AdminTab-B31efZ_R.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{AreaChart-B1OkLRGT.js → AreaChart-BpjHNUZm.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-B1OkLRGT.js.map → AreaChart-BpjHNUZm.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-IWwm38i0.js → BarChart-CY2FndXC.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-IWwm38i0.js.map → BarChart-CY2FndXC.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-DvNlBxzX.js → CacheTab-kMSrMD3e.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-DvNlBxzX.js.map → CacheTab-kMSrMD3e.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ConfigTab-C1t0EM2H.js → ConfigTab-BrKpv2YG.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ConfigTab-C1t0EM2H.js.map → ConfigTab-BrKpv2YG.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-CCexdJjG.js → EventsTab-DaClreCm.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-CCexdJjG.js.map → EventsTab-DaClreCm.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-BkAKwtxe.js → HealthTab-CxKQDqF3.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-BkAKwtxe.js.map → HealthTab-CxKQDqF3.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Beb59xuJ.js → MaintenanceTab-BKSlSjv0.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Beb59xuJ.js.map → MaintenanceTab-BKSlSjv0.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-P04ao17z.js → MemoryMapTab-C2goWDt8.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-P04ao17z.js.map → MemoryMapTab-C2goWDt8.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsCards-YlmnUe01.js → MetricsCards-DCPuCnrw.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsCards-YlmnUe01.js.map → MetricsCards-DCPuCnrw.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/MetricsTab-Bz0Mdyb_.js +2 -0
- package/extensions/dashboard-client/dist/assets/{MetricsTab-C2rXqvoD.js.map → MetricsTab-Bz0Mdyb_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-BBNvmR3X.js → OverviewTab-B-eZ-eDR.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-BBNvmR3X.js.map → OverviewTab-B-eZ-eDR.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-CjlumghA.js → ReposTab-W_NKRWpk.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-CjlumghA.js.map → ReposTab-W_NKRWpk.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-D1tWcUn-.js → SessionsTab-GYrtNt4_.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-D1tWcUn-.js.map → SessionsTab-GYrtNt4_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/SetupTab-_1xa6eTJ.js +3 -0
- package/extensions/dashboard-client/dist/assets/SetupTab-_1xa6eTJ.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DzBeE2y4.js → TimeSavedCard-Ciu8anVG.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DzBeE2y4.js.map → TimeSavedCard-Ciu8anVG.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnMemoryView-DKVIkjot.js → TurnMemoryView-BhXLIjWr.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnMemoryView-DKVIkjot.js.map → TurnMemoryView-BhXLIjWr.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/TurnsTab-C-f3DggL.js +2 -0
- package/extensions/dashboard-client/dist/assets/{TurnsTab-Cqyq6fVe.js.map → TurnsTab-C-f3DggL.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-CBtRo20h.js → VcStatusBadge-D97V04WE.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-CBtRo20h.js.map → VcStatusBadge-D97V04WE.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-Bk53uJZZ.js → VectorCortexTab-cyDJPAPB.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-Bk53uJZZ.js.map → VectorCortexTab-cyDJPAPB.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{WikiTab-CemxY6Lm.js → WikiTab-dQ96DyjP.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-CemxY6Lm.js.map → WikiTab-dQ96DyjP.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-BJiUJyhV.js → button-B1beLEiV.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-BJiUJyhV.js.map → button-B1beLEiV.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-Cg_LPWdl.js → card-CK9KH_ob.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-Cg_LPWdl.js.map → card-CK9KH_ob.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{client-extra-DxQFx7HY.js → client-extra-gN7xjggX.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{client-extra-DxQFx7HY.js.map → client-extra-gN7xjggX.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-sE5oI3Ee.js → generateCategoricalChart-MB2_0u55.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-sE5oI3Ee.js.map → generateCategoricalChart-MB2_0u55.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-CeBW9Vtt.js → index-CKVd_Ym_.js} +3 -3
- package/extensions/dashboard-client/dist/assets/{index-CeBW9Vtt.js.map → index-CKVd_Ym_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{switch-CmkMKtTG.js → switch-CswmYrO_.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-CmkMKtTG.js.map → switch-CswmYrO_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-CqpZacm5.js → toggle-CMepFsf0.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-CqpZacm5.js.map → toggle-CMepFsf0.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-DCKHmvXr.js → useSSE-Bl55LQFZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-DCKHmvXr.js.map → useSSE-Bl55LQFZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/tabs/SetupTab/CortexRetestCard.tsx +104 -0
- package/extensions/dashboard-client/src/tabs/SetupTab/CortexRuntimeInstallCard.tsx +103 -0
- package/extensions/dashboard-client/src/tabs/SetupTab/CortexSetup.tsx +4 -0
- package/extensions/dashboard-server/api-contracts/setup.ts +54 -0
- package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +12 -0
- package/extensions/dashboard-server/routes-setup-enc2a.ts +140 -0
- package/extensions/dashboard-server/routes-setup-enc2b.ts +82 -0
- package/extensions/dashboard-server/routes-setup.ts +65 -3
- package/package.json +1 -1
- package/src/config/vector-cortex-enc2a.ts +37 -0
- package/src/config/vector-cortex-enc2b.ts +38 -0
- package/src/config/vector-cortex.ts +4 -0
- package/src/config.ts +2 -0
- package/src/vector-cortex/encoder/native-install-artifacts.ts +60 -0
- package/src/vector-cortex/encoder/native-qualify-retest.ts +264 -0
- package/extensions/dashboard-client/dist/assets/MetricsTab-C2rXqvoD.js +0 -2
- package/extensions/dashboard-client/dist/assets/SetupTab-CgC4Rz38.js +0 -3
- package/extensions/dashboard-client/dist/assets/SetupTab-CgC4Rz38.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TurnsTab-Cqyq6fVe.js +0 -2
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ Set env vars before starting pi. Defaults are in `src/config/dedup.ts`.
|
|
|
90
90
|
| `MEGACOMPACT_WIKI_INCREMENTAL` | `true` | Incremental wiki updates (no full rebuild) |
|
|
91
91
|
| `MEGACOMPACT_AUTO_WIKI` | `true` | Auto-generate wiki from turns |
|
|
92
92
|
| `MEGACOMPACT_NEW_UI` | `true` | Use the new Tailwind/shadcn dashboard shell |
|
|
93
|
-
| `MEGACOMPACT_COST_API_ENABLED` | `false` | Opt-in: fetch model pricing from an external API (PREVENT-PI-004
|
|
93
|
+
| `MEGACOMPACT_COST_API_ENABLED` | `false` | Opt-in: fetch model pricing from an external API (PREVENT-PI-004 applies to defaults; opt-in features are exempt). Enriches dashboard cost data for models not in the local pricing table |
|
|
94
94
|
| `MEGACOMPACT_COST_API_URL` | _(unset)_ | OpenRouter-compatible model pricing endpoint (e.g. `https://openrouter.ai/api/v1/models`). Only contacted when `MEGACOMPACT_COST_API_ENABLED=true` |
|
|
95
95
|
|
|
96
96
|
Full config reference: [`docs/CONFIGURATION.md`](docs/CONFIGURATION.md)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config/vector-cortex-enc2a.ts — ENC-2a native onnxruntime install-guide flag
|
|
3
|
+
* (operator run-script assist).
|
|
4
|
+
*
|
|
5
|
+
* Sibling of vector-cortex-enc1a.ts / vector-cortex-enc1b.ts /
|
|
6
|
+
* vector-cortex-enc2budget.ts so vector-cortex.ts stays under the 300-line soft
|
|
7
|
+
* limit (soft-as-hard gate). vector-cortex.ts re-exports the flag below and
|
|
8
|
+
* root src/config.ts re-exports it, so no consumer import path changes.
|
|
9
|
+
*
|
|
10
|
+
* ENC-2a, when the operator opted into the native backend
|
|
11
|
+
* (`MEGACOMPACT_ENCODER_NATIVE=1`) but `encoderBackend` is still `"wasm"`
|
|
12
|
+
* (onnxruntime-node absent / not yet installed), surfaces an "Encoder Runtime
|
|
13
|
+
* Install" card on the Cortex sub-tab with copy-paste operator commands: the
|
|
14
|
+
* install + restart + verify steps built ONLY from the artifacts-module
|
|
15
|
+
* constants (`src/vector-cortex/encoder/native-install-artifacts.ts`) — never
|
|
16
|
+
* an inline registry URL or hash in the route (PREVENT-PI-004). The guide
|
|
17
|
+
* renders only on an installable host platform; the ENC-0e darwin-x64 demotion
|
|
18
|
+
* sentinel keeps it absent on an Intel Mac (no native binding upstream).
|
|
19
|
+
*
|
|
20
|
+
* `MEGACOMPACT_ENC_2A=0` disables: no guide fields, no install card, no absent
|
|
21
|
+
* read — byte-identical to the ENC-1b predecessor. The flag MUST also be a
|
|
22
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS
|
|
23
|
+
* — see `feedback_dashboard-flags-toggleable` memory).
|
|
24
|
+
*
|
|
25
|
+
* Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
|
|
26
|
+
*/
|
|
27
|
+
import { sprintFlag } from "./vector-cortex-flag.js";
|
|
28
|
+
/**
|
|
29
|
+
* ENC-2a — operator run-script assist (dashboard install guide for the
|
|
30
|
+
* onnxruntime-node native binding). Default ON. `MEGACOMPACT_ENC_2A=0` disables
|
|
31
|
+
* and is byte-identical to the ENC-1b predecessor: no guide/absent fields, no
|
|
32
|
+
* install card. This flag MUST also be a dashboard SETTINGS toggle (visible in
|
|
33
|
+
* config UI, never in EXCLUDED_SETTINGS).
|
|
34
|
+
*/
|
|
35
|
+
export const ENC_2A_ENABLED = () => sprintFlag("MEGACOMPACT_ENC_2A");
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config/vector-cortex-enc2b.ts — ENC-2b native onnxruntime qualification
|
|
3
|
+
* retest flag.
|
|
4
|
+
*
|
|
5
|
+
* Sibling of vector-cortex-enc2a.ts / vector-cortex-enc2budget.ts so
|
|
6
|
+
* vector-cortex.ts stays under the 300-line soft limit (soft-as-hard gate).
|
|
7
|
+
* vector-cortex.ts re-exports the flag below and root src/config.ts re-exports
|
|
8
|
+
* it, so no consumer import path changes.
|
|
9
|
+
*
|
|
10
|
+
* ENC-2b re-probes and re-qualifies the installed native onnxruntime binding
|
|
11
|
+
* (`onnxruntime-node` in `~/.pi/mega-compact/native-ort/`, operator-installed
|
|
12
|
+
* via the ENC-2a guide). When the operator installs the binding the read path
|
|
13
|
+
* does not automatically re-evaluate the qualification verdict; this sprint
|
|
14
|
+
* delivers a reader-only retest that loads the LOCAL on-disk binding, runs a
|
|
15
|
+
* bounded warmup + p95 probe against it, measures RSS, computes a fresh
|
|
16
|
+
* qualification verdict against the ENC-0f p95 budget + the operator
|
|
17
|
+
* install-budget, and surfaces it on the Setup Cortex sub-tab and the GET
|
|
18
|
+
* `/api/setup-status` response.
|
|
19
|
+
*
|
|
20
|
+
* `MEGACOMPACT_ENC_2B=0` disables: the GET omits both new retest fields, the
|
|
21
|
+
* POST ignores the retest-request key, the Cortex sub-tab renders no retest
|
|
22
|
+
* card — byte-identical to the ENC-2a predecessor. The flag MUST also be a
|
|
23
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS
|
|
24
|
+
* — see `feedback_dashboard-flags-toggleable` memory).
|
|
25
|
+
*
|
|
26
|
+
* Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
|
|
27
|
+
*/
|
|
28
|
+
import { sprintFlag } from "./vector-cortex-flag.js";
|
|
29
|
+
/**
|
|
30
|
+
* ENC-2b — native onnxruntime qualification retest (detect installed binding,
|
|
31
|
+
* re-probe p95/RSS, re-qualify). Default ON. `MEGACOMPACT_ENC_2B=0` disables and
|
|
32
|
+
* is byte-identical to the ENC-2a predecessor: no retest GET fields, no retest
|
|
33
|
+
* POST branch, no retest card. This flag MUST also be a dashboard SETTINGS
|
|
34
|
+
* toggle (visible in config UI, never in EXCLUDED_SETTINGS).
|
|
35
|
+
*/
|
|
36
|
+
export const ENC_2B_ENABLED = () => sprintFlag("MEGACOMPACT_ENC_2B");
|
|
@@ -50,5 +50,9 @@ export { DASH_0D_ENABLED } from "./vector-cortex-dash-0d.js";
|
|
|
50
50
|
export { ENC_1A_ENABLED } from "./vector-cortex-enc1a.js";
|
|
51
51
|
export { ENC_1B_ENABLED, ENC_1B_MAX_EMBEDDING_DIM, ENC_1B_EMBEDDING_DIM_ENV, ENC_1B_EMBEDDING_HEADERS_ENV, ENC_1B_ALLOW_REMOTE_EMBEDDER_ENV, ENC_1B_ENCODER_NATIVE_ENV, } from "./vector-cortex-enc1b.js";
|
|
52
52
|
export { ENC_2BUDGET_ENABLED, ENC_2BUDGET_NATIVE_ORT_BUDGET_ENV, ENC_2BUDGET_MAX_MIB, ENC_2BUDGET_DEFAULT_MIB, } from "./vector-cortex-enc2budget.js";
|
|
53
|
+
// ENC-2a native onnxruntime install-guide flag extracted to vector-cortex-enc2a.ts.
|
|
54
|
+
export { ENC_2A_ENABLED } from "./vector-cortex-enc2a.js";
|
|
55
|
+
// ENC-2b native onnxruntime qualification-retest flag extracted to vector-cortex-enc2b.ts.
|
|
56
|
+
export { ENC_2B_ENABLED } from "./vector-cortex-enc2b.js";
|
|
53
57
|
// Breaker constants (TRIAD_RESILIENCE.md §breaker) extracted to vector-cortex-breakers.ts.
|
|
54
58
|
export { BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./vector-cortex-breakers.js";
|
package/dist/config.js
CHANGED
|
@@ -114,4 +114,4 @@ export const NEW_UI = () => ragEnabled("MEGACOMPACT_NEW_UI");
|
|
|
114
114
|
// default ON, `=0`/`_DISABLED` off. Re-exported from src/config/vector-cortex.ts
|
|
115
115
|
// so root consumers share one source of truth.
|
|
116
116
|
// ---------------------------------------------------------------------------
|
|
117
|
-
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_ENABLED, ENC_0A_ENABLED, ENC_0B_ENABLED, ENC_0C_ENABLED, ENC_0D_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED, ENC_1A_ENABLED, ENC_1B_ENABLED, ENC_2BUDGET_ENABLED, ENC_2BUDGET_NATIVE_ORT_BUDGET_ENV, ENC_2BUDGET_MAX_MIB, ENC_2BUDGET_DEFAULT_MIB, COSINE_FP_BENCH_ENABLED, COSINE_FP_REAL_ENABLED, REPO_CORPUS_ENABLED, DASH_0A_ENABLED, DASH_0B_ENABLED, DASH_0C_ENABLED, DASH_0D_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
117
|
+
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_ENABLED, ENC_0A_ENABLED, ENC_0B_ENABLED, ENC_0C_ENABLED, ENC_0D_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED, ENC_1A_ENABLED, ENC_1B_ENABLED, ENC_2BUDGET_ENABLED, ENC_2BUDGET_NATIVE_ORT_BUDGET_ENV, ENC_2BUDGET_MAX_MIB, ENC_2BUDGET_DEFAULT_MIB, ENC_2A_ENABLED, ENC_2B_ENABLED, COSINE_FP_BENCH_ENABLED, COSINE_FP_REAL_ENABLED, REPO_CORPUS_ENABLED, DASH_0A_ENABLED, DASH_0B_ENABLED, DASH_0C_ENABLED, DASH_0D_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
@@ -70,6 +70,8 @@ export const VECTOR_CORTEX_SETTINGS = {
|
|
|
70
70
|
boolDirect("MEGACOMPACT_ENC_1A", "ENC-1a external embedder API key + endpoint Settings fields", "ENC-1a adds a Settings-visible field pair for the external embedder endpoint URL + optional Bearer API key, persisted by the setup-configure writer branch to the per-repo .mega-compact.env (MEGACOMPACT_EMBEDDING_URL / MEGACOMPACT_EMBEDDING_KEY). The GET status route echoes the endpoint URL and reports embeddingApiKeySet as a boolean ONLY — the raw key is never returned. OFF = no new GET fields, no writer branch, no new Settings text rows (byte-identical ENC-0g predecessor).", true),
|
|
71
71
|
boolDirect("MEGACOMPACT_ENC_1B", "ENC-1b ONNX runtime backend + embedder API settings", "ENC-1b completes the embedder API Settings surface (dim / headers / allow-remote persisted to the per-repo .mega-compact.env) and surfaces the ONNX runtime selection knob (MEGACOMPACT_ENCODER_NATIVE) as a toggle plus the current effective backend + demotion reason. OFF = no new GET fields, no writer branch, no new Settings rows or toggle (byte-identical ENC-1a predecessor).", true),
|
|
72
72
|
boolDirect("MEGACOMPACT_ENC_2BUDGET", "ENC-2a operator-configurable native install-budget knob", "ENC-2a exposes the runtime operator knob MEGACOMPACT_NATIVE_ORT_BUDGET_MIB (default 300 MiB, clamp 8192) as a dashboard Settings field. The knob gates budgetOk in the encoder runtime decision (decision.ts installBudgetMib + runtime-select.ts selectRuntimeBackend). Persisted to the per-repo .mega-compact.env via the setup-configure writer branch; the GET status route surfaces the persisted value AND the effective integer installBudgetMib() resolves to (so the dashboard shows the runtime's actual operand). OFF = no new GET fields, no writer branch, no new Settings rows (byte-identical ENC-1b predecessor).", true),
|
|
73
|
+
boolDirect("MEGACOMPACT_ENC_2A", "ENC-2a native onnxruntime install GUIDE (detect + copy-paste)", "ENC-2a surfaces the platform-matched native onnxruntime install-guide (three copy-paste steps + script path) on the Setup Cortex sub-tab when the operator opted into the native backend but the effective runtime is still wasm (onnxruntime-node absent). Pure guidance — the extension NEVER executes or fetches (PREVENT-PI-004 unchanged); the committed operator script scripts/encoder/install-native-ort.mjs runs in the USER's shell. OFF = no guide GET fields, no guide-request POST branch, no install card (byte-identical ENC-1b predecessor).", true),
|
|
74
|
+
boolDirect("MEGACOMPACT_ENC_2B", "ENC-2b native ONNX runtime qualification retest (detect + re-qualify)", "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).", true),
|
|
73
75
|
boolDirect("MEGACOMPACT_COSINE_FP_BENCH", "COS-FP-A Synthetic FP Bench", "Synthetic FP harness + L2 cosine threshold calibration (COS-FP-A): drives the deterministic synthetic-corpus grid sweep (scripts/cosine-fp/bench.mjs) that measures L2 cosine false-positive rates and emits a recommended default, and serves the reader-only GET /api/cosine-fp-report. Synthetic-corpus-only — never reads real session/ledger bytes. OFF = bench inert, endpoint 404s, no report write, L2_COSINE plain MEGACOMPACT_L2_THRESHOLD (byte-identical predecessor).", true),
|
|
74
76
|
boolDirect("MEGACOMPACT_COSINE_FP_REAL", "COS-FP-R Real-Corpus Validation", "Real-corpus L2 cosine FP validation (COS-FP-R): runs the real-corpus grid sweep (scripts/cosine-fp/real-bench.mjs) against donated, consent-approved sessions only (SECURITY_PRIVACY Lifecycle/Consent), scoring FP/FN with Wilson intervals + session-grouped bootstrap, and appends CI-backed per-content-type recommendations to the cosine-threshold report. Runs only when a valid consented corpus exists; absent corpus = no_corpus (normative pre-donation state, nothing written). OFF = script inert, nothing executes, no writes (byte-identical predecessor).", true),
|
|
75
77
|
boolDirect("MEGACOMPACT_REPO_CORPUS", "Cross-Repo Corpus (REPO-A)", "Cross-repo corpus preparation (REPO-A): the governed, consent-gated reader-only path that builds a pseudonymous corpus manifest from per-repo events.log slices and serves GET /api/repo-corpus answering which pseudonymous repos/sessions are in the corpus, what cross-repo overlap exists, and whether consent is active for each — counts + IDs + status only, never payload content. Consent is append-only (consent.mjs, CLI/ops-only); revocation freezes the builder + route. OFF = builder refuses to run, reader route 404s, single-repo recall untouched (byte-identical predecessor).", true),
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-setup-enc2a.ts — ENC-2a native onnxruntime install
|
|
3
|
+
* GUIDE (reader-only) + installed-version probe.
|
|
4
|
+
*
|
|
5
|
+
* Extracted out of routes-setup.ts (which hovers at the 300-line source soft
|
|
6
|
+
* cap, mirroring the ENC-1a/ENC-1b/ENC-2budget sibling extracts) so the
|
|
7
|
+
* ENC-2a additive GET fields — the platform-matched native install guide and
|
|
8
|
+
* the installed-version probe — live in a sibling impl file and routes-setup.ts
|
|
9
|
+
* stays a thin host.
|
|
10
|
+
*
|
|
11
|
+
* The guide's job is OPERATOR run-script assist: when the operator opted into
|
|
12
|
+
* the native backend (`MEGACOMPACT_ENCODER_NATIVE=1`) but the effective runtime
|
|
13
|
+
* is still `"wasm"` (onnxruntime-node not yet installed) AND the host platform
|
|
14
|
+
* is installable, the GET status response carries a `nativeOrtInstallGuide`
|
|
15
|
+
* object with the [install, restart, verify] copy-paste commands + the committed
|
|
16
|
+
* operator script path. The commands/URL/hash are built ONLY from the artifacts
|
|
17
|
+
* module constants (`src/vector-cortex/encoder/native-install-artifacts.ts`) —
|
|
18
|
+
* never an inline registry URL or literal hash (PREVENT-PI-004). The installed-
|
|
19
|
+
* version probe reads the local `~/.pi/mega-compact/native-ort/` package.json
|
|
20
|
+
* when present (reader-only filesystem read, zero network).
|
|
21
|
+
*
|
|
22
|
+
* The flag is off (or opt-in off / unsupported platform / non-wasm backend) ->
|
|
23
|
+
* guide `null` and installedVersion `null` -> the host omits both fields,
|
|
24
|
+
* byte-identical to the ENC-1b-era shape.
|
|
25
|
+
*
|
|
26
|
+
* Guardrails: PREVENT-PI-004 (local filesystem reads + in-memory backend
|
|
27
|
+
* selection only, zero network), PREVENT-001 (null-safe JSON), PREVENT-011
|
|
28
|
+
* (no `any`).
|
|
29
|
+
*/
|
|
30
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
31
|
+
import { join } from "node:path";
|
|
32
|
+
import { ENC_2A_ENABLED } from "../../src/config/vector-cortex.js";
|
|
33
|
+
import { readEnc1bEnv } from "./routes-setup-enc1b.js";
|
|
34
|
+
import { selectRuntimeBackend } from "../../src/vector-cortex/encoder/runtime-select.js";
|
|
35
|
+
import { detectPlatform } from "../../src/vector-cortex/encoder/asset.js";
|
|
36
|
+
import { NATIVE_ORT_VERSION, NATIVE_ORT_PACKAGE, NATIVE_ORT_INSTALLABLE_PLATFORMS, } from "../../src/vector-cortex/encoder/native-install-artifacts.js";
|
|
37
|
+
/** The committed operator script that performs the install (repo-relative). */
|
|
38
|
+
const ENC_2A_SCRIPT_PATH = "scripts/encoder/install-native-ort.mjs";
|
|
39
|
+
/** Where the operator script installs the native binding (absolute install
|
|
40
|
+
* prefix used verbatim in the guide commands + the version probe). */
|
|
41
|
+
function nativeOrtDir() {
|
|
42
|
+
return join(process.env.HOME ?? "", ".pi", "mega-compact", "native-ort");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* True when the payload carries the ENC-2a guide-request key `false`/`true`
|
|
46
|
+
* (flag-gated, additive). `false` -> 400 (operator-driven no-op); `true` -> 200
|
|
47
|
+
* + the guide echoed (still no server execution — the execute path is ENC-2c).
|
|
48
|
+
* Flag-off -> null so the key falls through unrecognized (byte-identical
|
|
49
|
+
* ENC-1b-era predecessor).
|
|
50
|
+
*/
|
|
51
|
+
export function enc2aGuideRequest(body) {
|
|
52
|
+
if (!ENC_2A_ENABLED())
|
|
53
|
+
return null;
|
|
54
|
+
if (body.nativeOrtInstallGuide === true)
|
|
55
|
+
return { status: 200 };
|
|
56
|
+
if (body.nativeOrtInstallGuide === false)
|
|
57
|
+
return { status: 400 };
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Read the ENC-2a native install GUIDE + installed-version, additive GET fields.
|
|
62
|
+
*
|
|
63
|
+
* The guide renders only when EVERY gate passes: flag on, operator opted into
|
|
64
|
+
* native, effective backend is still `"wasm"` (onnxruntime-node absent), and the
|
|
65
|
+
* host platform is installable (darwin-x64 is excluded — no native binding
|
|
66
|
+
* upstream, the ENC-0e demotion sentinel). The effective backend + demotion
|
|
67
|
+
* reason go through the EXISTING `selectRuntimeBackend` (reader-only — never a
|
|
68
|
+
* reimplemented literal). `installedVersion` probes
|
|
69
|
+
* `~/.pi/mega-compact/native-ort/node_modules/onnxruntime-node/package.json`
|
|
70
|
+
* when present; null otherwise. Returns `{ guide: null, installedVersion: null }`
|
|
71
|
+
* when the flag is off (byte-identical predecessor).
|
|
72
|
+
*/
|
|
73
|
+
export function readEnc2aGuide(stateDir) {
|
|
74
|
+
if (!ENC_2A_ENABLED())
|
|
75
|
+
return { guide: null, installedVersion: null };
|
|
76
|
+
const env = readEnc1bEnv(stateDir);
|
|
77
|
+
const platform = detectPlatform();
|
|
78
|
+
const chosen = selectRuntimeBackend({
|
|
79
|
+
platform: platform ?? "unsupported",
|
|
80
|
+
benchRecord: null,
|
|
81
|
+
nativeOptIn: env.nativeOptIn,
|
|
82
|
+
});
|
|
83
|
+
const backend = chosen.backend === "native" ? "native" : "wasm";
|
|
84
|
+
let guide = null;
|
|
85
|
+
if (env.nativeOptIn &&
|
|
86
|
+
backend === "wasm" &&
|
|
87
|
+
platform !== null &&
|
|
88
|
+
NATIVE_ORT_INSTALLABLE_PLATFORMS.includes(platform)) {
|
|
89
|
+
guide = {
|
|
90
|
+
platform,
|
|
91
|
+
commands: [
|
|
92
|
+
`npm install --prefix ${nativeOrtDir()} ${NATIVE_ORT_PACKAGE}@${NATIVE_ORT_VERSION}`,
|
|
93
|
+
"pi update --extensions && pi session-start",
|
|
94
|
+
"expect encoderBackend: native on next status poll",
|
|
95
|
+
],
|
|
96
|
+
scriptPath: ENC_2A_SCRIPT_PATH,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return { guide, installedVersion: probeInstalledVersion() };
|
|
100
|
+
}
|
|
101
|
+
/** Probe the local native-ort package.json for the installed onnxruntime-node
|
|
102
|
+
* version. Null when the package is absent/unreadable (reader-only, local). */
|
|
103
|
+
function probeInstalledVersion() {
|
|
104
|
+
try {
|
|
105
|
+
const pkgPath = join(nativeOrtDir(), "node_modules", NATIVE_ORT_PACKAGE, "package.json");
|
|
106
|
+
if (!existsSync(pkgPath))
|
|
107
|
+
return null;
|
|
108
|
+
const raw = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
109
|
+
if (typeof raw === "object" &&
|
|
110
|
+
raw !== null &&
|
|
111
|
+
typeof raw.version === "string") {
|
|
112
|
+
return raw.version;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-setup-enc2b.ts — ENC-2b native onnxruntime
|
|
3
|
+
* qualification retest (reader-only probe) + POST retest action.
|
|
4
|
+
*
|
|
5
|
+
* Extracted out of routes-setup.ts (which hovers at the 300-line source soft
|
|
6
|
+
* cap, mirroring the ENC-1b/ENC-2a sibling extracts) so the ENC-2b additive
|
|
7
|
+
* GET field — the native qualification retest result + effective backend —
|
|
8
|
+
* lives in a sibling impl file and routes-setup.ts stays a thin host.
|
|
9
|
+
*
|
|
10
|
+
* The retest's job is RE-QUALIFICATION: when the operator installed
|
|
11
|
+
* onnxruntime-node via the ENC-2a guide, the encoder read path does not
|
|
12
|
+
* automatically re-evaluate the qualification verdict. This sibling surface
|
|
13
|
+
* runs `runNativeRetest` (a bounded, reader-only, local probe) and:
|
|
14
|
+
*
|
|
15
|
+
* - surfaces `nativeOrtRetestResult` + `nativeOrtBackendEffective` on the GET
|
|
16
|
+
* when the flag is on AND a binding is installed — absent otherwise
|
|
17
|
+
* (byte-identical to the ENC-2a-era shape on flag-off/none);
|
|
18
|
+
* - handles the POST `nativeOrtRetest` key (`false` → 400
|
|
19
|
+
* `retest_rejected_false_nothing_to_do`; `true` → run + echo the fresh
|
|
20
|
+
* result; flag-off → the key is unrecognized, byte-identical predecessor).
|
|
21
|
+
*
|
|
22
|
+
* `nativeOrtBackendEffective` is `"native"` only when the retest verdict is
|
|
23
|
+
* `qualified`; any `degraded`/`failed` verdict keeps the backend `"wasm"` — the
|
|
24
|
+
* runtime never silently switches to a backend whose retest failed.
|
|
25
|
+
*
|
|
26
|
+
* Guardrails: PREVENT-PI-004 (local filesystem + in-process binding load only,
|
|
27
|
+
* zero network — the retest NEVER fetches), PREVENT-011 (no `any`).
|
|
28
|
+
*/
|
|
29
|
+
import { ENC_2B_ENABLED } from "../../src/config/vector-cortex.js";
|
|
30
|
+
import { runNativeRetest, } from "../../src/vector-cortex/encoder/native-qualify-retest.js";
|
|
31
|
+
/**
|
|
32
|
+
* Resolve the ENC-2b additive GET fields. Returns BOTH fields when the flag is
|
|
33
|
+
* on AND a native binding is installed (the retest ran); returns `{}` on
|
|
34
|
+
* flag-off AND when no binding is installed — both fields are OMITTED (absent,
|
|
35
|
+
* not null), so the GET stays byte-identical to the ENC-2a-era shape and the
|
|
36
|
+
* client hides the retest card. Flag-off omits, never nulls: the ENC-2a-era
|
|
37
|
+
* host spreads `...{}` so no new key appears. Mirror of the ENC-2a/ENC-1b
|
|
38
|
+
* sibling idiom; async because the retest loads the binding in-process.
|
|
39
|
+
*/
|
|
40
|
+
export async function readEnc2bRetest(stateDir) {
|
|
41
|
+
if (!ENC_2B_ENABLED())
|
|
42
|
+
return {};
|
|
43
|
+
const result = await runNativeRetest(stateDir);
|
|
44
|
+
if (result === null)
|
|
45
|
+
return {};
|
|
46
|
+
return {
|
|
47
|
+
nativeOrtRetestResult: result,
|
|
48
|
+
nativeOrtBackendEffective: result.verdict === "qualified" ? "native" : "wasm",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* ENC-2b POST retest-action key handling (flag-gated, additive).
|
|
53
|
+
*
|
|
54
|
+
* `true` → { action: "run" } (the host runs the retest and returns the result)
|
|
55
|
+
* `false` → { action: "reject" } (400 `retest_rejected_false_nothing_to_do`)
|
|
56
|
+
* other → null (key absent or flag off — falls through unrecognized,
|
|
57
|
+
* byte-identical ENC-2a-era predecessor).
|
|
58
|
+
*/
|
|
59
|
+
export function enc2bRetestRequest(body) {
|
|
60
|
+
if (!ENC_2B_ENABLED())
|
|
61
|
+
return null;
|
|
62
|
+
if (body.nativeOrtRetest === true)
|
|
63
|
+
return "run";
|
|
64
|
+
if (body.nativeOrtRetest === false)
|
|
65
|
+
return "reject";
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Run the ENC-2b retest now (bounded, synchronous on the request) and return
|
|
70
|
+
* the fresh result. Flag-off or no binding → null. Used by the POST "run"
|
|
71
|
+
* branch; the result is returned on the response body, never persisted.
|
|
72
|
+
*/
|
|
73
|
+
export async function runEnc2bRetest(stateDir) {
|
|
74
|
+
if (!ENC_2B_ENABLED())
|
|
75
|
+
return null;
|
|
76
|
+
return runNativeRetest(stateDir);
|
|
77
|
+
}
|
|
@@ -14,6 +14,8 @@ import { VC9D_ENABLED } from "../../src/config.js";
|
|
|
14
14
|
import { enc1aStatusFields, writeEnc1aEnv, tryEnc1aConfigure, wantsEnc1a } from "./routes-setup-enc1a.js";
|
|
15
15
|
import { enc1bStatusFields, tryEnc1bConfigure, tryEnc1bInto, enc1bValidateCombined } from "./routes-setup-enc1b.js";
|
|
16
16
|
import { enc2BudgetStatusFields, tryEnc2BudgetInto, enc2BudgetValidateCombined, } from "./routes-setup-enc2budget.js";
|
|
17
|
+
import { readEnc2aGuide, enc2aGuideRequest } from "./routes-setup-enc2a.js";
|
|
18
|
+
import { readEnc2bRetest, enc2bRetestRequest, runEnc2bRetest } from "./routes-setup-enc2b.js";
|
|
17
19
|
import { writeEmbedderEnv } from "./routes-setup-env-upsert.js";
|
|
18
20
|
import { detectOllama, detectLlamaCpp, detectOnnx, memoizedDetectOllama, memoizedDetectLlamaCpp, memoizedDetectOnnx, } from "./routes-setup-detect-cache.js";
|
|
19
21
|
// ---------------------------------------------------------------------------
|
|
@@ -60,10 +62,15 @@ export function handleSetupStatus(req, res, ctx) {
|
|
|
60
62
|
}
|
|
61
63
|
const configured = detectConfiguredEmbedder(ctx.stateDir);
|
|
62
64
|
const active = detectCurrentEmbedder();
|
|
65
|
+
// ENC-2a (flag-gated, additive): the native install-guide + installed-version
|
|
66
|
+
// fields. Optional fields are added only when present/installable; when the
|
|
67
|
+
// flag is off readEnc2aGuide returns nulls so the body stays byte-identical
|
|
68
|
+
// to the ENC-1b-era shape.
|
|
69
|
+
const enc2a = readEnc2aGuide(ctx.stateDir);
|
|
63
70
|
// ENC-1a (flag-gated, additive): echo the persisted endpoint URL and an
|
|
64
71
|
// embeddingApiKeySet boolean ONLY — the raw API key is never returned. When
|
|
65
72
|
// the flag is off (or neither is set) both fields are simply omitted.
|
|
66
|
-
const
|
|
73
|
+
const base = {
|
|
67
74
|
currentEmbedder: active,
|
|
68
75
|
configuredEmbedder: configured.embedder,
|
|
69
76
|
configuredUrl: configured.url,
|
|
@@ -73,10 +80,23 @@ export function handleSetupStatus(req, res, ctx) {
|
|
|
73
80
|
minilm: ["1", "true", "yes"].includes((process.env["MEGACOMPACT_MINILM"] ?? "").trim().toLowerCase()),
|
|
74
81
|
...enc1aStatusFields(ctx.stateDir), ...enc1bStatusFields(ctx.stateDir),
|
|
75
82
|
...enc2BudgetStatusFields(ctx.stateDir),
|
|
83
|
+
...(enc2a.guide !== null ? { nativeOrtInstallGuide: enc2a.guide } : {}),
|
|
84
|
+
...(enc2a.installedVersion !== null ? { nativeOrtInstalledVersion: enc2a.installedVersion } : {}),
|
|
76
85
|
};
|
|
86
|
+
// ENC-2b (flag-gated, additive): the native qualification retest fields. The
|
|
87
|
+
// retest loads the on-disk binding in-process (bounded, never a fetch), so
|
|
88
|
+
// readEnc2bRetest is async; the handler returns true synchronously for the
|
|
89
|
+
// dispatch and writes the response after the await. Flag-off/none mutates
|
|
90
|
+
// the body additively and stays byte-identical to the ENC-2a-era shape.
|
|
77
91
|
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
readEnc2bRetest(ctx.stateDir).then((enc2b) => {
|
|
93
|
+
const body = { ...base, ...enc2b };
|
|
94
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
95
|
+
res.end(JSON.stringify(body));
|
|
96
|
+
}).catch(() => {
|
|
97
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
98
|
+
res.end(JSON.stringify(base));
|
|
99
|
+
});
|
|
80
100
|
return true;
|
|
81
101
|
}
|
|
82
102
|
// ---------------------------------------------------------------------------
|
|
@@ -174,10 +194,52 @@ export function handleSetupConfigure(req, res, ctx) {
|
|
|
174
194
|
return;
|
|
175
195
|
}
|
|
176
196
|
const body = parsed.value;
|
|
197
|
+
// ENC-2a guide-request key (flag-gated, additive): `false` → 400 (an
|
|
198
|
+
// operator-driven no-op — this sprint conveys the GUIDE only, no server
|
|
199
|
+
// execution), `true` → 200 + the guide echoed (still no execution; the
|
|
200
|
+
// execute path is ENC-2c). Flag-off: enc2aGuideRequest returns null so the
|
|
201
|
+
// key falls through unrecognized (byte-identical ENC-1b-era predecessor).
|
|
202
|
+
const guideReq = enc2aGuideRequest(body);
|
|
203
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
204
|
+
if (guideReq !== null && guideReq.status === 400) {
|
|
205
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
206
|
+
res.end(JSON.stringify({ error: "guide_rejected_false_nothing_to_do" }));
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
177
209
|
// ENC-1a (flag-gated, additive): a pure external-embedder configure
|
|
178
210
|
// (new keys, no embedder selection) is handled by the sibling writer.
|
|
179
211
|
// Flag-off = the keys are simply not recognized, falling through to the
|
|
180
212
|
// pre-ENC-1a embedder path below (byte-identical predecessor).
|
|
213
|
+
if (guideReq !== null && guideReq.status === 200) {
|
|
214
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
215
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
216
|
+
res.end(JSON.stringify({ nativeOrtInstallGuide: readEnc2aGuide(ctx.stateDir).guide }));
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
// ENC-2b retest-action key (flag-gated, additive): `false` → 400 (an
|
|
220
|
+
// operator-driven no-op — nothing to retest), `true` → run the bounded
|
|
221
|
+
// retest synchronously and return the fresh result. Flag-off: the key
|
|
222
|
+
// falls through unrecognized (byte-identical ENC-2a-era predecessor).
|
|
223
|
+
// The retest never fetches — the binding is on disk from the ENC-2a
|
|
224
|
+
// install (PREVENT-PI-004 clean).
|
|
225
|
+
const retestReq = enc2bRetestRequest(body);
|
|
226
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
227
|
+
if (retestReq === "reject") {
|
|
228
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
229
|
+
res.end(JSON.stringify({ error: "retest_rejected_false_nothing_to_do" }));
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (retestReq === "run") {
|
|
233
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
234
|
+
runEnc2bRetest(ctx.stateDir).then((fresh) => {
|
|
235
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
236
|
+
res.end(JSON.stringify({ nativeOrtRetestResult: fresh }));
|
|
237
|
+
}).catch(() => {
|
|
238
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
239
|
+
res.end(JSON.stringify({ error: "retest_failed" }));
|
|
240
|
+
});
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
181
243
|
if (tryEnc1aConfigure(body, res, ctx))
|
|
182
244
|
return;
|
|
183
245
|
if (tryEnc1bConfigure(body, res, ctx))
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config/vector-cortex-enc2a.ts — ENC-2a native onnxruntime install-guide flag
|
|
3
|
+
* (operator run-script assist).
|
|
4
|
+
*
|
|
5
|
+
* Sibling of vector-cortex-enc1a.ts / vector-cortex-enc1b.ts /
|
|
6
|
+
* vector-cortex-enc2budget.ts so vector-cortex.ts stays under the 300-line soft
|
|
7
|
+
* limit (soft-as-hard gate). vector-cortex.ts re-exports the flag below and
|
|
8
|
+
* root src/config.ts re-exports it, so no consumer import path changes.
|
|
9
|
+
*
|
|
10
|
+
* ENC-2a, when the operator opted into the native backend
|
|
11
|
+
* (`MEGACOMPACT_ENCODER_NATIVE=1`) but `encoderBackend` is still `"wasm"`
|
|
12
|
+
* (onnxruntime-node absent / not yet installed), surfaces an "Encoder Runtime
|
|
13
|
+
* Install" card on the Cortex sub-tab with copy-paste operator commands: the
|
|
14
|
+
* install + restart + verify steps built ONLY from the artifacts-module
|
|
15
|
+
* constants (`src/vector-cortex/encoder/native-install-artifacts.ts`) — never
|
|
16
|
+
* an inline registry URL or hash in the route (PREVENT-PI-004). The guide
|
|
17
|
+
* renders only on an installable host platform; the ENC-0e darwin-x64 demotion
|
|
18
|
+
* sentinel keeps it absent on an Intel Mac (no native binding upstream).
|
|
19
|
+
*
|
|
20
|
+
* `MEGACOMPACT_ENC_2A=0` disables: no guide fields, no install card, no absent
|
|
21
|
+
* read — byte-identical to the ENC-1b predecessor. The flag MUST also be a
|
|
22
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS
|
|
23
|
+
* — see `feedback_dashboard-flags-toggleable` memory).
|
|
24
|
+
*
|
|
25
|
+
* Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
|
|
26
|
+
*/
|
|
27
|
+
import { sprintFlag } from "./vector-cortex-flag.js";
|
|
28
|
+
/**
|
|
29
|
+
* ENC-2a — operator run-script assist (dashboard install guide for the
|
|
30
|
+
* onnxruntime-node native binding). Default ON. `MEGACOMPACT_ENC_2A=0` disables
|
|
31
|
+
* and is byte-identical to the ENC-1b predecessor: no guide/absent fields, no
|
|
32
|
+
* install card. This flag MUST also be a dashboard SETTINGS toggle (visible in
|
|
33
|
+
* config UI, never in EXCLUDED_SETTINGS).
|
|
34
|
+
*/
|
|
35
|
+
export const ENC_2A_ENABLED = () => sprintFlag("MEGACOMPACT_ENC_2A");
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config/vector-cortex-enc2b.ts — ENC-2b native onnxruntime qualification
|
|
3
|
+
* retest flag.
|
|
4
|
+
*
|
|
5
|
+
* Sibling of vector-cortex-enc2a.ts / vector-cortex-enc2budget.ts so
|
|
6
|
+
* vector-cortex.ts stays under the 300-line soft limit (soft-as-hard gate).
|
|
7
|
+
* vector-cortex.ts re-exports the flag below and root src/config.ts re-exports
|
|
8
|
+
* it, so no consumer import path changes.
|
|
9
|
+
*
|
|
10
|
+
* ENC-2b re-probes and re-qualifies the installed native onnxruntime binding
|
|
11
|
+
* (`onnxruntime-node` in `~/.pi/mega-compact/native-ort/`, operator-installed
|
|
12
|
+
* via the ENC-2a guide). When the operator installs the binding the read path
|
|
13
|
+
* does not automatically re-evaluate the qualification verdict; this sprint
|
|
14
|
+
* delivers a reader-only retest that loads the LOCAL on-disk binding, runs a
|
|
15
|
+
* bounded warmup + p95 probe against it, measures RSS, computes a fresh
|
|
16
|
+
* qualification verdict against the ENC-0f p95 budget + the operator
|
|
17
|
+
* install-budget, and surfaces it on the Setup Cortex sub-tab and the GET
|
|
18
|
+
* `/api/setup-status` response.
|
|
19
|
+
*
|
|
20
|
+
* `MEGACOMPACT_ENC_2B=0` disables: the GET omits both new retest fields, the
|
|
21
|
+
* POST ignores the retest-request key, the Cortex sub-tab renders no retest
|
|
22
|
+
* card — byte-identical to the ENC-2a predecessor. The flag MUST also be a
|
|
23
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS
|
|
24
|
+
* — see `feedback_dashboard-flags-toggleable` memory).
|
|
25
|
+
*
|
|
26
|
+
* Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
|
|
27
|
+
*/
|
|
28
|
+
import { sprintFlag } from "./vector-cortex-flag.js";
|
|
29
|
+
/**
|
|
30
|
+
* ENC-2b — native onnxruntime qualification retest (detect installed binding,
|
|
31
|
+
* re-probe p95/RSS, re-qualify). Default ON. `MEGACOMPACT_ENC_2B=0` disables and
|
|
32
|
+
* is byte-identical to the ENC-2a predecessor: no retest GET fields, no retest
|
|
33
|
+
* POST branch, no retest card. This flag MUST also be a dashboard SETTINGS
|
|
34
|
+
* toggle (visible in config UI, never in EXCLUDED_SETTINGS).
|
|
35
|
+
*/
|
|
36
|
+
export const ENC_2B_ENABLED = () => sprintFlag("MEGACOMPACT_ENC_2B");
|
|
@@ -50,5 +50,9 @@ export { DASH_0D_ENABLED } from "./vector-cortex-dash-0d.js";
|
|
|
50
50
|
export { ENC_1A_ENABLED } from "./vector-cortex-enc1a.js";
|
|
51
51
|
export { ENC_1B_ENABLED, ENC_1B_MAX_EMBEDDING_DIM, ENC_1B_EMBEDDING_DIM_ENV, ENC_1B_EMBEDDING_HEADERS_ENV, ENC_1B_ALLOW_REMOTE_EMBEDDER_ENV, ENC_1B_ENCODER_NATIVE_ENV, } from "./vector-cortex-enc1b.js";
|
|
52
52
|
export { ENC_2BUDGET_ENABLED, ENC_2BUDGET_NATIVE_ORT_BUDGET_ENV, ENC_2BUDGET_MAX_MIB, ENC_2BUDGET_DEFAULT_MIB, } from "./vector-cortex-enc2budget.js";
|
|
53
|
+
// ENC-2a native onnxruntime install-guide flag extracted to vector-cortex-enc2a.ts.
|
|
54
|
+
export { ENC_2A_ENABLED } from "./vector-cortex-enc2a.js";
|
|
55
|
+
// ENC-2b native onnxruntime qualification-retest flag extracted to vector-cortex-enc2b.ts.
|
|
56
|
+
export { ENC_2B_ENABLED } from "./vector-cortex-enc2b.js";
|
|
53
57
|
// Breaker constants (TRIAD_RESILIENCE.md §breaker) extracted to vector-cortex-breakers.ts.
|
|
54
58
|
export { BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./vector-cortex-breakers.js";
|
package/dist/src/config.js
CHANGED
|
@@ -114,4 +114,4 @@ export const NEW_UI = () => ragEnabled("MEGACOMPACT_NEW_UI");
|
|
|
114
114
|
// default ON, `=0`/`_DISABLED` off. Re-exported from src/config/vector-cortex.ts
|
|
115
115
|
// so root consumers share one source of truth.
|
|
116
116
|
// ---------------------------------------------------------------------------
|
|
117
|
-
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_ENABLED, ENC_0A_ENABLED, ENC_0B_ENABLED, ENC_0C_ENABLED, ENC_0D_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED, ENC_1A_ENABLED, ENC_1B_ENABLED, ENC_2BUDGET_ENABLED, ENC_2BUDGET_NATIVE_ORT_BUDGET_ENV, ENC_2BUDGET_MAX_MIB, ENC_2BUDGET_DEFAULT_MIB, COSINE_FP_BENCH_ENABLED, COSINE_FP_REAL_ENABLED, REPO_CORPUS_ENABLED, DASH_0A_ENABLED, DASH_0B_ENABLED, DASH_0C_ENABLED, DASH_0D_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
117
|
+
export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_ENABLED, ENC_0A_ENABLED, ENC_0B_ENABLED, ENC_0C_ENABLED, ENC_0D_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED, ENC_1A_ENABLED, ENC_1B_ENABLED, ENC_2BUDGET_ENABLED, ENC_2BUDGET_NATIVE_ORT_BUDGET_ENV, ENC_2BUDGET_MAX_MIB, ENC_2BUDGET_DEFAULT_MIB, ENC_2A_ENABLED, ENC_2B_ENABLED, COSINE_FP_BENCH_ENABLED, COSINE_FP_REAL_ENABLED, REPO_CORPUS_ENABLED, DASH_0A_ENABLED, DASH_0B_ENABLED, DASH_0C_ENABLED, DASH_0D_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/encoder/native-install-artifacts.ts — ENC-2a native
|
|
3
|
+
* onnxruntime install-guide constants (PURE data module).
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for the operator's native-backend install guide
|
|
6
|
+
* (`onnxruntime-node`, the sole onnxruntime Node.js binding this extension's
|
|
7
|
+
* native path uses). The guide rendered by
|
|
8
|
+
* `extensions/dashboard-server/routes-setup-enc2a.ts` and the operator script
|
|
9
|
+
* `scripts/encoder/install-native-ort.mjs` build their commands/URLs ONLY from
|
|
10
|
+
* these scalars — never an inline registry URL or literal hash in the route or
|
|
11
|
+
* extension runtime (PREVENT-PI-004: the registry tarball URL is derived by
|
|
12
|
+
* callers from `NATIVE_ORT_PACKAGE` + "@" + `NATIVE_ORT_VERSION`, so no network
|
|
13
|
+
* path and no literal registry URL or scheme appears in src/).
|
|
14
|
+
*
|
|
15
|
+
* Package facts (verified, not invented):
|
|
16
|
+
* - onnxruntime-node publishes ONE monolithic ~100MB npm tarball — not
|
|
17
|
+
* per-platform `optionalDependencies` — so a single
|
|
18
|
+
* `NATIVE_ORT_TARBALL_SHA256` pins the whole artifact for every host.
|
|
19
|
+
* - darwin-x64 has NO native binding (arm64-only upstream since 1.17), so the
|
|
20
|
+
* guide stays absent on an Intel Mac (the ENC-0e demotion sentinel).
|
|
21
|
+
* - `NATIVE_ORT_TARBALL_SHA256` was computed from TWO independent downloads of
|
|
22
|
+
* the 1.27.0 tarball (real, cross-checked, not guessed).
|
|
23
|
+
*
|
|
24
|
+
* Pi-agnostic, dependency-free, pure data — zero I/O, zero network
|
|
25
|
+
* (PREVENT-PI-004 / PREVENT-011).
|
|
26
|
+
*/
|
|
27
|
+
/** onnxruntime-node version the guide installs (real published version). */
|
|
28
|
+
export const NATIVE_ORT_VERSION = "1.27.0";
|
|
29
|
+
/** onnxruntime-node npm package name (the native onnxruntime binding). */
|
|
30
|
+
export const NATIVE_ORT_PACKAGE = "onnxruntime-node";
|
|
31
|
+
/** SHA-256 of the onnxruntime-node@1.27.0 npm tarball (one sha for all hosts).
|
|
32
|
+
* Computed from TWO independent tarball downloads; lowercase hex, 64 chars. */
|
|
33
|
+
export const NATIVE_ORT_TARBALL_SHA256 = "c3779c01c59832f8c03e2c392ac3af10bf08579f1822e8b1c63cc451edb302a2";
|
|
34
|
+
/**
|
|
35
|
+
* Platforms for which an operator install-guide can be rendered (native
|
|
36
|
+
* binding exists upstream). darwin-x64 is excluded — it has NO native binding.
|
|
37
|
+
*/
|
|
38
|
+
export const NATIVE_ORT_INSTALLABLE_PLATFORMS = [
|
|
39
|
+
"linux-x64",
|
|
40
|
+
"linux-arm64",
|
|
41
|
+
"darwin-arm64",
|
|
42
|
+
"win32-x64",
|
|
43
|
+
];
|