pi-mega-compact 0.20.25 → 0.20.27
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-vc9a.js +29 -0
- package/dist/config/vector-cortex.js +4 -0
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/api-contracts/endpoints/registry-ext.js +7 -0
- package/dist/extensions/dashboard-server/api-contracts/setup-cortex.js +12 -0
- package/dist/extensions/dashboard-server/route-dispatch.js +3 -1
- package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -0
- package/dist/extensions/dashboard-server/routes-setup-cortex.js +143 -0
- package/dist/extensions/dashboard-server/routes.js +1 -0
- package/dist/extensions/dashboard-server/server.js +4 -2
- package/dist/extensions/dashboard-server/setup-cortex-blockers.js +53 -0
- package/dist/extensions/mega-dashboard-bounce.js +79 -0
- package/dist/extensions/mega-dashboard-cmds.js +57 -24
- package/dist/src/config/vector-cortex-vc9a.js +29 -0
- package/dist/src/config/vector-cortex.js +4 -0
- package/dist/src/config.js +1 -1
- package/extensions/dashboard-client/dist/assets/{AreaChart-DRErPez1.js → AreaChart-Bl8FQm-w.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-DRErPez1.js.map → AreaChart-Bl8FQm-w.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-Cwxel3M7.js → BarChart-BXn1a_v9.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-Cwxel3M7.js.map → BarChart-BXn1a_v9.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-D4j3vwFu.js → CacheTab-DzZpIHkZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-D4j3vwFu.js.map → CacheTab-DzZpIHkZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-BA7t_fsH.js → EventsTab-rn_Ncwk0.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-BA7t_fsH.js.map → EventsTab-rn_Ncwk0.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-Ci9gtYDP.js → HealthTab-D4d20PFh.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-Ci9gtYDP.js.map → HealthTab-D4d20PFh.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BeqWn-xu.js → MaintenanceTab-44lwue_H.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BeqWn-xu.js.map → MaintenanceTab-44lwue_H.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-BreZegCV.js → MemoryMapTab-BPCPyPqp.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-BreZegCV.js.map → MemoryMapTab-BPCPyPqp.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-DLbgfJT2.js → MetricsTab-B1is6D7F.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-DLbgfJT2.js.map → MetricsTab-B1is6D7F.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-BtcXdrnC.js → OverviewTab-DIC_cUjS.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-BtcXdrnC.js.map → OverviewTab-DIC_cUjS.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-DpDLEzV9.js → ReposTab-KhTQqt5Z.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-DpDLEzV9.js.map → ReposTab-KhTQqt5Z.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-CMe5jSrZ.js → SessionsTab-CeOUPRIM.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-CMe5jSrZ.js.map → SessionsTab-CeOUPRIM.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SetupTab-C3OY8mc7.js → SetupTab-DnN0mX0J.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SetupTab-C3OY8mc7.js.map → SetupTab-DnN0mX0J.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-BFPJUQzs.js → TimeSavedCard-CXmxE5_8.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-BFPJUQzs.js.map → TimeSavedCard-CXmxE5_8.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-Ujt29pKI.js → TurnsTab-Dbx9pZPX.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-Ujt29pKI.js.map → TurnsTab-Dbx9pZPX.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-CfxZW91A.js → VectorCortexTab-MzqdB6zI.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-CfxZW91A.js.map → VectorCortexTab-MzqdB6zI.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{WikiTab-BiKXVwGT.js → WikiTab-B1mKp1SA.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-BiKXVwGT.js.map → WikiTab-B1mKp1SA.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-DJwGcw0u.js → button-BFHPDVb1.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-DJwGcw0u.js.map → button-BFHPDVb1.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-CgjBf5LZ.js → card-XrbSJiOF.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-CgjBf5LZ.js.map → card-XrbSJiOF.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CTQIl2qs.js → generateCategoricalChart-B9Ba91Tu.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CTQIl2qs.js.map → generateCategoricalChart-B9Ba91Tu.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-Bu8CZUMX.js → index-P13AO5ni.js} +4 -4
- package/extensions/dashboard-client/dist/assets/index-P13AO5ni.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{switch-uUiS1Raq.js → switch-jnYDePmb.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-uUiS1Raq.js.map → switch-jnYDePmb.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-Dv3OEscH.js → toggle-JO-vvubb.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-Dv3OEscH.js.map → toggle-JO-vvubb.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-n6ymAic3.js → useSSE-DAkXqUOy.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-n6ymAic3.js.map → useSSE-DAkXqUOy.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-server/api-contracts/endpoints/registry-ext.ts +11 -0
- package/extensions/dashboard-server/api-contracts/setup-cortex.ts +65 -0
- package/extensions/dashboard-server/route-dispatch.ts +2 -0
- package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +6 -0
- package/extensions/dashboard-server/routes-setup-cortex.ts +167 -0
- package/extensions/dashboard-server/routes.ts +1 -0
- package/extensions/dashboard-server/server.ts +4 -2
- package/extensions/dashboard-server/setup-cortex-blockers.ts +73 -0
- package/extensions/mega-dashboard-bounce.ts +97 -0
- package/extensions/mega-dashboard-cmds.ts +63 -24
- package/package.json +1 -1
- package/src/config/vector-cortex-vc9a.ts +31 -0
- package/src/config/vector-cortex.ts +5 -0
- package/src/config.ts +1 -0
- package/extensions/dashboard-client/dist/assets/index-Bu8CZUMX.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config/vector-cortex-vc9a.ts — VC9A setup-cortex status-read-path sprint flag.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from vector-cortex.ts so that file stays under the 300-line soft
|
|
5
|
+
* limit (soft-as-hard gate), exactly as vector-cortex-vc8c.ts,
|
|
6
|
+
* vector-cortex-breakers.ts and vector-cortex-early.ts were. This is the
|
|
7
|
+
* SETUP-DASHBOARD reader flag (the dashboard Setup tab cortex status endpoint).
|
|
8
|
+
* vector-cortex.ts re-exports it below and root src/config.ts re-exports it, so
|
|
9
|
+
* no consumer import path changes.
|
|
10
|
+
*
|
|
11
|
+
* The split is purely mechanical: VC9A_ENABLED is byte-identical in name,
|
|
12
|
+
* semantics, and default to the definition it replaces, and vector-cortex.ts
|
|
13
|
+
* re-exports it so every existing `from "./config/vector-cortex.js"` import
|
|
14
|
+
* keeps resolving unchanged.
|
|
15
|
+
*
|
|
16
|
+
* Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
|
|
17
|
+
*/
|
|
18
|
+
import { sprintFlag } from "./vector-cortex-flag.js";
|
|
19
|
+
/**
|
|
20
|
+
* VC9A — Setup Cortex status read path (GET /api/setup-cortex-status).
|
|
21
|
+
* Default ON. `MEGACOMPACT_VC9A=0` disables and is byte-identical to the
|
|
22
|
+
* predecessor (VC8C-era shape): the endpoint returns `{enabled:false,
|
|
23
|
+
* mode:"C", status:"off"}` and surfaces no qualification/blocker/health detail —
|
|
24
|
+
* a pure reader-only projection, never a mutation. This flag MUST also be a
|
|
25
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS),
|
|
26
|
+
* mirroring VC4A..VC8C. The dashboard reader itself performs only local
|
|
27
|
+
* filesystem reads (no network, PREVENT-PI-004).
|
|
28
|
+
*/
|
|
29
|
+
export const VC9A_ENABLED = () => sprintFlag("MEGACOMPACT_VC9A");
|
|
@@ -244,6 +244,10 @@ export const VC8B_ENABLED = () => sprintFlag("MEGACOMPACT_VC8B");
|
|
|
244
244
|
// Re-exported here so every existing `from "./config/vector-cortex.js"`
|
|
245
245
|
// import keeps resolving unchanged.
|
|
246
246
|
export { VC8C_ENABLED } from "./vector-cortex-vc8c.js";
|
|
247
|
+
// VC9A (setup-cortex status read path) extracted to vector-cortex-vc9a.ts to
|
|
248
|
+
// keep this file under the 300-line soft limit. Re-exported here so every
|
|
249
|
+
// existing `from "./config/vector-cortex.js"` import keeps resolving unchanged.
|
|
250
|
+
export { VC9A_ENABLED } from "./vector-cortex-vc9a.js";
|
|
247
251
|
// Breaker state machine constants (TRIAD_RESILIENCE.md §breaker) extracted to
|
|
248
252
|
// vector-cortex-breakers.ts to keep this file under the 300-line soft limit.
|
|
249
253
|
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, 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, 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";
|
|
@@ -27,4 +27,11 @@ export const EXTRA_ENDPOINTS = {
|
|
|
27
27
|
path: "/api/vector-cortex/ledger",
|
|
28
28
|
description: "Reader-only occurrence-ledger identity view: seq/eventId/kind/digest + high-water (never source payloads).",
|
|
29
29
|
},
|
|
30
|
+
// ─── VC9A Setup Cortex (dashboard Setup tab cortex status) ─────────
|
|
31
|
+
/** GET /api/setup-cortex-status — reader-only vector-cortex encoder gate. */
|
|
32
|
+
setupCortexStatus: {
|
|
33
|
+
method: "GET",
|
|
34
|
+
path: "/api/setup-cortex-status",
|
|
35
|
+
description: "Reader-only vector-cortex encoder gate: mode A/B/C, qualification verdict, blockers, encoder health — for the dashboard Setup tab. Never closes the ML gate.",
|
|
36
|
+
},
|
|
30
37
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* api-contracts/setup-cortex.ts — Setup Cortex status API types (VC9A).
|
|
3
|
+
*
|
|
4
|
+
* Types for GET /api/setup-cortex-status, the reader-only aggregate that
|
|
5
|
+
* surfaces the vector-cortex encoder gate (mode A/B/C, qualification verdict,
|
|
6
|
+
* blockers, encoder health) in the dashboard Setup tab WITHOUT closing the ML
|
|
7
|
+
* gate. Reader-only: never payloads/prompts/ledger (EVAL-REDACT-002).
|
|
8
|
+
*
|
|
9
|
+
* PREVENT-PI-004: type definitions only, no network code.
|
|
10
|
+
* PREVENT-011: no `any` type — all types are explicit.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* PREVENT-PI-004: local filesystem read only, no network.
|
|
9
9
|
* PREVENT-011: no `any` type.
|
|
10
10
|
*/
|
|
11
|
-
import { handleIndex, handleRepoIndex, handleEvents, handleGameState, handleGameScores, handlePerfSamples, handlePerf, handleAchievements, handleSessions, handleTopics, handleTurns, handleMaintenance, handleProviderCache, handleMemoryStatus, handleCacheStripes, handleSetupStatus, handleSetupDetect, handleSetupConfigure, handleMemoryMap, handleRaptorTree, handleRaptorBuildHistory, handleContextHealth, handleCachePoison, handleHealthSettings, handleEmbedderHealth, handleRagSettings, handleRagMetrics, handleModelThresholds, handleWiki, handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, handleVectorCortexRender, handleVectorCortexRollout, handleVectorCortexClosureProof, handleVectorCortexRestore, } from "./routes.js";
|
|
11
|
+
import { handleIndex, handleRepoIndex, handleEvents, handleGameState, handleGameScores, handlePerfSamples, handlePerf, handleAchievements, handleSessions, handleTopics, handleTurns, handleMaintenance, handleProviderCache, handleMemoryStatus, handleCacheStripes, handleSetupStatus, handleSetupDetect, handleSetupConfigure, handleMemoryMap, handleRaptorTree, handleRaptorBuildHistory, handleContextHealth, handleCachePoison, handleHealthSettings, handleEmbedderHealth, handleRagSettings, handleRagMetrics, handleModelThresholds, handleWiki, handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, handleVectorCortexRender, handleVectorCortexRollout, handleVectorCortexClosureProof, handleVectorCortexRestore, handleSetupCortexStatus, } from "./routes.js";
|
|
12
12
|
// VC6C repair lives in its own module (routes-vector-cortex-repair.ts) so the
|
|
13
13
|
// heal route file stays well under the 400-line extension soft limit.
|
|
14
14
|
import { handleVectorCortexRepair } from "./routes-vector-cortex-repair.js";
|
|
@@ -141,5 +141,7 @@ export function dispatchRoutes(req, res, ctx) {
|
|
|
141
141
|
return true;
|
|
142
142
|
if (handleVectorCortexPlatform(req, res, ctx))
|
|
143
143
|
return true;
|
|
144
|
+
if (handleSetupCortexStatus(req, res, ctx))
|
|
145
|
+
return true;
|
|
144
146
|
return false;
|
|
145
147
|
}
|
|
@@ -48,5 +48,6 @@ export const VECTOR_CORTEX_SETTINGS = {
|
|
|
48
48
|
boolDirect("MEGACOMPACT_VC8A", "VC8A Consent-Bound Outcomes", "Consent-bound outcome ledger and offline learning dataset. Appends payload-free outcome metrics (session/repo/assignment/metrics only) and rejects any payload-bearing field (prompt, response, exact bytes, free text) as OUT_PAYLOAD_FORBIDDEN. Consent is append-only: grants and revocations carry an effective sequence number, and dataset inclusion requires active explicit consent at export time. Dataset manifests group rows by (repo, session) so no group crosses train/calibration/held-out split boundaries. Revocations disappear from future manifests. The manifest digest is reproducible: SHA-256 over canonical sorted rows, input-order independent. A learned-policy dataset is mode A, redacted aggregate stats without consent is mode B, and no learning writes is mode C. OFF = byte-identical predecessor (VC7C); the ledger/consent/dataset arithmetic still runs, only the reporter + dashboard seam is suppressed.", true),
|
|
49
49
|
boolDirect("MEGACOMPACT_VC8B", "VC8B Shadow Adaptive Policy", "Bounded shadow adaptive policy + M7 pressure-v2 migration. Policy actions are from a finite set (admit/dampen/defer/escalate/reject) chosen deterministically by the canonical pressure level; token budgets are clamped into a configured window after the pressure factor. Unknown pressure labels are rejected as POL_PRESSURE_UNKNOWN, never coerced to a neighbour. The shadow engine is structurally incapable of affecting the live path: inputs are deep-copied, the canonical prompt digest is pinned before and after to prove non-mutation, and liveMutations is always zero. M7 migrates legacy pressure labels to the v2 canonical five by copy/validate/switch; an unknown label blocks the switch and keeps the legacy pointer (M7_PRESSURE_UNKNOWN). A shadow decision is mode A, static calibrated policy is mode B (forced by invalid A), and fixed legacy thresholds is mode C (forced by M7 or B failure). OFF = byte-identical predecessor (VC8A); the policy/shadow/migration arithmetic still runs, only the reporter + dashboard seam is suppressed.", true),
|
|
50
50
|
boolDirect("MEGACOMPACT_VC8C", "VC8C Canary Platform + Rust Parity", "Canary selection and external Rust parity. The selector admits a qualified external Rust artifact only when ABI version, URL metadata, commit, Cargo.lock digest, and platform all match evidence; a Cargo.lock digest mismatch rejects the artifact (RUST_CARGO_DIGEST_MISMATCH). The cross-conformance runner exchanges length-framed neutral records over a local stdin/stdout channel — a subprocess, never a URL (PREVENT-PI-004). A parity mismatch selects TS mode B. A qualified external artifact is mode A, TS reference is mode B, legacy path is mode C. OFF = byte-identical predecessor (VC8B); the selector and cross-conformance arithmetic still run, only the reporter + dashboard seam is suppressed.", true),
|
|
51
|
+
boolDirect("MEGACOMPACT_VC9A", "VC9A Setup Cortex Status", "Reader-only Setup Cortex status read path (GET /api/setup-cortex-status): surfaces the vector-cortex encoder gate — mode A/B/C, qualification verdict, open blockers, encoder health — to the dashboard Setup tab without closing the ML gate. OFF = byte-identical predecessor (VC8C-era): returns enabled:false / mode:C / status:off.", true),
|
|
51
52
|
],
|
|
52
53
|
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-setup-cortex.ts — VC9A Setup Cortex status route.
|
|
3
|
+
*
|
|
4
|
+
* GET /api/setup-cortex-status — reader-only aggregate surfacing the
|
|
5
|
+
* vector-cortex encoder gate (mode A/B/C, qualification verdict,
|
|
6
|
+
* blockers, encoder health) for the dashboard Setup tab. Does NOT close
|
|
7
|
+
* the ML gate: the hard-gate blockers are read-only and stay open.
|
|
8
|
+
*
|
|
9
|
+
* Reuses readEncoderManifest / verifyEncoderAsset / detectPlatform
|
|
10
|
+
* (src/vector-cortex/encoder/asset.ts) and deriveVcStatus (vc-status.ts),
|
|
11
|
+
* plus the memoized encoder-facts pattern from routes-vector-cortex-health.ts
|
|
12
|
+
* (manifest bytes + file size/mtime + platform cache key) so the expensive
|
|
13
|
+
* full-asset hashing is skipped on repeat polls.
|
|
14
|
+
*
|
|
15
|
+
* The blocker rows carry NO string literals here — they come from the static
|
|
16
|
+
* manifest module setup-cortex-blockers.ts (single canonical source).
|
|
17
|
+
*
|
|
18
|
+
* Guardrails: PREVENT-PI-004 (local filesystem read only), PREVENT-011 (no
|
|
19
|
+
* `any`), reader-only aggregate (never payloads/prompts/ledger — EVAL-REDACT-002).
|
|
20
|
+
*/
|
|
21
|
+
import { createHash } from "node:crypto";
|
|
22
|
+
import { readFileSync, statSync } from "node:fs";
|
|
23
|
+
import { join, dirname } from "node:path";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
import { VC9A_ENABLED } from "../../src/config.js";
|
|
26
|
+
import { readEncoderManifest, verifyEncoderAsset, detectPlatform } from "../../src/vector-cortex/encoder/asset.js";
|
|
27
|
+
import { sendJson } from "./routes-vector-cortex-shared.js";
|
|
28
|
+
import { deriveVcStatus } from "./vc-status.js";
|
|
29
|
+
import { SETUP_CORTEX_BLOCKERS } from "./setup-cortex-blockers.js";
|
|
30
|
+
/** Resolve the committed encoder-v1 asset dir by walking up to the repo root. */
|
|
31
|
+
function encoderAssetDir() {
|
|
32
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
33
|
+
const rel = join("assets", "vector-cortex", "encoder-v1");
|
|
34
|
+
for (let i = 0; i < 8; i++) {
|
|
35
|
+
const candidate = join(dir, rel);
|
|
36
|
+
try {
|
|
37
|
+
// guardrails-allow PREVENT-PI-004: local asset filesystem read (loopback)
|
|
38
|
+
readFileSync(join(candidate, "manifest.json"));
|
|
39
|
+
return candidate;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
/* keep walking */
|
|
43
|
+
}
|
|
44
|
+
const next = dirname(dir);
|
|
45
|
+
if (next === dir)
|
|
46
|
+
break;
|
|
47
|
+
dir = next;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
let factCache = null;
|
|
52
|
+
/** Stable cache key: manifest bytes + (size,mtime) of the asset files + platform. */
|
|
53
|
+
function factCacheKey(dir, manifestPath) {
|
|
54
|
+
const platform = detectPlatform();
|
|
55
|
+
if (!platform)
|
|
56
|
+
return null;
|
|
57
|
+
const parts = [platform];
|
|
58
|
+
try {
|
|
59
|
+
for (const p of [manifestPath, join(dir, "model.onnx"), join(dir, "tokenizer.json")]) {
|
|
60
|
+
const s = statSync(p);
|
|
61
|
+
parts.push(`${s.size}:${s.mtimeMs}`);
|
|
62
|
+
}
|
|
63
|
+
// guardrails-allow PREVENT-PI-004: local manifest filesystem read (loopback)
|
|
64
|
+
parts.push(createHash("sha256").update(readFileSync(manifestPath)).digest("hex"));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return parts.join("|");
|
|
70
|
+
}
|
|
71
|
+
function computeSetupCortexFacts(dir) {
|
|
72
|
+
const manifest = readEncoderManifest(dir);
|
|
73
|
+
if (manifest === null) {
|
|
74
|
+
return { mode: "C", assetDigestPrefix: null, verdict: "unavailable", thresholdFailures: [] };
|
|
75
|
+
}
|
|
76
|
+
const manifestPath = join(dir, "manifest.json");
|
|
77
|
+
const key = factCacheKey(dir, manifestPath);
|
|
78
|
+
if (key === null)
|
|
79
|
+
return null;
|
|
80
|
+
if (factCache !== null && factCache.key === key)
|
|
81
|
+
return factCache.facts;
|
|
82
|
+
let digest;
|
|
83
|
+
try {
|
|
84
|
+
// guardrails-allow PREVENT-PI-004: local manifest filesystem read (loopback)
|
|
85
|
+
digest = createHash("sha256").update(readFileSync(manifestPath)).digest("hex");
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
const facts = { mode: "B", assetDigestPrefix: null, verdict: "demoted", thresholdFailures: ["ENC_ASSET_UNREADABLE"] };
|
|
89
|
+
factCache = { key, facts };
|
|
90
|
+
return facts;
|
|
91
|
+
}
|
|
92
|
+
const verify = verifyEncoderAsset(dir, manifest, detectPlatform());
|
|
93
|
+
const prefix = digest.slice(0, 12);
|
|
94
|
+
const facts = verify.ok
|
|
95
|
+
? { mode: "A", assetDigestPrefix: prefix, verdict: "qualified", thresholdFailures: [] }
|
|
96
|
+
: { mode: "B", assetDigestPrefix: prefix, verdict: "demoted", thresholdFailures: [verify.code] };
|
|
97
|
+
factCache = { key, facts };
|
|
98
|
+
return facts;
|
|
99
|
+
}
|
|
100
|
+
function setupCortexFacts() {
|
|
101
|
+
const dir = encoderAssetDir();
|
|
102
|
+
if (dir === null) {
|
|
103
|
+
return { mode: "C", assetDigestPrefix: null, verdict: "unavailable", thresholdFailures: [] };
|
|
104
|
+
}
|
|
105
|
+
const facts = computeSetupCortexFacts(dir);
|
|
106
|
+
return facts ?? { mode: "C", assetDigestPrefix: null, verdict: "unavailable", thresholdFailures: [] };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Reader-only GET /api/setup-cortex-status (VC9A).
|
|
110
|
+
*
|
|
111
|
+
* Purely read: no mutation, never payloads/prompts/ledger. Flag-off returns the
|
|
112
|
+
* byte-identical VC8C-era shape `{enabled:false, mode:"C", status:"off"}` with
|
|
113
|
+
* the encoder-health mode C and no qualification/blocker detail leaked.
|
|
114
|
+
*/
|
|
115
|
+
export function handleSetupCortexStatus(req, res, _ctx) {
|
|
116
|
+
const url = req.url ?? "";
|
|
117
|
+
if (url !== "/api/setup-cortex-status")
|
|
118
|
+
return false;
|
|
119
|
+
if (req.method !== "GET") {
|
|
120
|
+
sendJson(res, 405, { error: "method_not_allowed" });
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
const enabled = VC9A_ENABLED();
|
|
124
|
+
const facts = enabled ? setupCortexFacts() : null;
|
|
125
|
+
const blocks = enabled ? [...SETUP_CORTEX_BLOCKERS] : [];
|
|
126
|
+
const body = {
|
|
127
|
+
enabled,
|
|
128
|
+
flag: "MEGACOMPACT_VC9A",
|
|
129
|
+
mode: facts ? facts.mode : "C",
|
|
130
|
+
assetDigestPrefix: facts ? facts.assetDigestPrefix : null,
|
|
131
|
+
qualification: facts
|
|
132
|
+
? { verdict: facts.verdict, thresholdFailures: facts.thresholdFailures }
|
|
133
|
+
: { verdict: "unavailable", thresholdFailures: [] },
|
|
134
|
+
blockers: blocks,
|
|
135
|
+
encoderHealth: facts
|
|
136
|
+
? { assetDigestPrefix: facts.assetDigestPrefix, mode: facts.mode }
|
|
137
|
+
: { assetDigestPrefix: null, mode: "C" },
|
|
138
|
+
updatedAt: new Date().toISOString(),
|
|
139
|
+
status: deriveVcStatus({ enabled, hasData: !!facts && facts.verdict !== "unavailable", structuralOnly: true }),
|
|
140
|
+
};
|
|
141
|
+
sendJson(res, 200, body);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
@@ -24,3 +24,4 @@ export { handleRagMetrics } from "./routes-rag-metrics.js";
|
|
|
24
24
|
export { handleModelThresholds } from "./routes-model-thresholds.js";
|
|
25
25
|
export { handleWiki } from "./routes-wiki.js";
|
|
26
26
|
export { handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, handleVectorCortexRender, handleVectorCortexRollout, handleVectorCortexClosureProof, handleVectorCortexRestore, } from "./routes-vector-cortex.js";
|
|
27
|
+
export { handleSetupCortexStatus } from "./routes-setup-cortex.js";
|
|
@@ -254,9 +254,11 @@ export async function launchDashboardServer(stateDir) {
|
|
|
254
254
|
}));
|
|
255
255
|
v6.listen(port, "::1", () => log("ipv6 loopback bound", { port })); // guardrails-allow PREVENT-PI-004: IPv6 loopback (::1) mirror of the dashboard server
|
|
256
256
|
}
|
|
257
|
-
// Write port.pid
|
|
257
|
+
// Write port.pid (VC0F B2: stamp `version` so the launcher can detect
|
|
258
|
+
// a stale runner by comparing the marker against its own version
|
|
259
|
+
// without an HTTP probe — closes the orphan case for pre-B2 servers).
|
|
258
260
|
try {
|
|
259
|
-
writeFileSync(portFile, JSON.stringify({ port, pid: process.pid }));
|
|
261
|
+
writeFileSync(portFile, JSON.stringify({ port, pid: process.pid, version: SERVER_VERSION }));
|
|
260
262
|
}
|
|
261
263
|
catch (e) {
|
|
262
264
|
log("could not write port.pid", { error: String(e) });
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/setup-cortex-blockers.ts — canonical blocker manifest for the
|
|
3
|
+
* dashboard Setup Cortex status read path (VC9A).
|
|
4
|
+
*
|
|
5
|
+
* The hard-gate items enumerated in docs/vector-cortex/vc2-model-prep.md §6
|
|
6
|
+
* (per the 2026-08-05 research update: the opset-14→17 re-export blocker is
|
|
7
|
+
* REMOVED because onnx-community exports are now opset 21). This module is the
|
|
8
|
+
* SINGLE canonical source of those blockers — the route file
|
|
9
|
+
* (routes-setup-cortex.ts) carries NO string literals for them; it reads this
|
|
10
|
+
* static manifest so the UI rows and the spec stay in one place.
|
|
11
|
+
*
|
|
12
|
+
* Reader-only, static: zero network, no writes (PREVENT-PI-004), no `any`
|
|
13
|
+
* (PREVENT-011).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The four blockers VC9A reports. Enumerates the vc2-model-prep §6 items that
|
|
17
|
+
* remain per the 2026-08-05 research. The opset re-export blocker (formerly
|
|
18
|
+
* §6 #2) is NOT listed: onnx-community exports are opset 21, so it is removed.
|
|
19
|
+
*/
|
|
20
|
+
export const SETUP_CORTEX_BLOCKERS = [
|
|
21
|
+
{
|
|
22
|
+
id: "HG-1",
|
|
23
|
+
title: "Five projection heads do not exist",
|
|
24
|
+
severity: "blocker",
|
|
25
|
+
status: "open",
|
|
26
|
+
resolution: "Supervision transfer onto a frozen bge-small-en-v1.5 trunk (contradiction distilled from cross-encoder/nli-deberta-v3-small; dependency NLI-assisted; cache-stability deterministic; payload-routing small MLP) — VC2B training + export.",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "HG-3",
|
|
30
|
+
title: "onnxruntime-node install exceeds the 80 MiB asset budget",
|
|
31
|
+
severity: "blocker",
|
|
32
|
+
status: "open",
|
|
33
|
+
resolution: "onnxruntime-node bundles ~258 MiB across all platforms. Candidate: transformers.js v4.2.0 (9.5 MiB shell, pure-Node via onnxruntime-web WASM) measured against budget + p95 gate before committing.",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "HG-4",
|
|
37
|
+
title: "No darwin-x64 binary in onnxruntime-node",
|
|
38
|
+
severity: "high",
|
|
39
|
+
status: "open",
|
|
40
|
+
resolution: "Intel-Mac mode-A users demote to the WASM path (if HG-3 resolves that way) or mode B.",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "HG-5",
|
|
44
|
+
title: "RSS margin at 512 tokens is ~0.5%",
|
|
45
|
+
severity: "medium",
|
|
46
|
+
status: "open",
|
|
47
|
+
resolution: "149.2 MiB vs 150 MiB cap with run-to-run variance 119-149 MiB; considers capping mode A at 384 tokens or using the marginal-footprint accounting runtime.ts already implements.",
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
/** Look up one blocker by id; undefined when unknown (defensive). */
|
|
51
|
+
export function setupCortexBlocker(id) {
|
|
52
|
+
return SETUP_CORTEX_BLOCKERS.find((b) => b.id === id);
|
|
53
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mega-dashboard-bounce.ts — VC0F stale-runner detection + bounce.
|
|
3
|
+
*
|
|
4
|
+
* Delegate of `mega-dashboard-cmds.ts` (kept under the extensions/ soft limit):
|
|
5
|
+
* owns the once-per-process staleness gate and the pure
|
|
6
|
+
* `bounceStaleRunnerIfAny` decision, which is the durable restart-on-upgrade
|
|
7
|
+
* seam — after `pi update --extensions` replaces the on-disk package, the next
|
|
8
|
+
* `session_start` probes the running dashboard, sees the version mismatch, and
|
|
9
|
+
* kills + respawns the stale runner so it serves the current code.
|
|
10
|
+
*
|
|
11
|
+
* The function is dependency-injected so unit tests (VC0F C1–C3) can stub every
|
|
12
|
+
* primitive; the production wiring (live discovery / version / kill) lives in
|
|
13
|
+
* `mega-dashboard-cmds.ts` and is passed in. No network here — the localhost
|
|
14
|
+
* HTTP probes live behind the injected `isServerRunning`/`serverVersion` deps
|
|
15
|
+
* (already audited PREVENT-PI-004 in the parent file).
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Once-per-process staleness gate (VC0F A2). After the FIRST successful probe
|
|
19
|
+
* we skip re-probing on later /mega-dashboard invocations or session-start
|
|
20
|
+
* events within the same extension process — the probe is cheap but the
|
|
21
|
+
* kill+respawn it triggers is disruptive. Set regardless of outcome.
|
|
22
|
+
*/
|
|
23
|
+
let stalenessCheckedThisProcess = false;
|
|
24
|
+
/** Test-only seam: clear the once-per-process gate between unit tests. */
|
|
25
|
+
export function resetStalenessGateForTests() {
|
|
26
|
+
stalenessCheckedThisProcess = false;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Detect + replace a STALE dashboard runner for the current repo (VC0F A1).
|
|
30
|
+
*
|
|
31
|
+
* A runner is stale when it is an orphan (live but missing its port.pid
|
|
32
|
+
* marker), when its marker's stamped `version` differs from this extension's
|
|
33
|
+
* own version (VC0F B2 — avoids the HTTP probe), or when the version it
|
|
34
|
+
* reports over HTTP differs from our own (fallback for pre-B2 servers whose
|
|
35
|
+
* marker has no `version` field). A stale runner is killed so the next launch
|
|
36
|
+
* serves the current on-disk code.
|
|
37
|
+
*
|
|
38
|
+
* Best-effort and non-fatal (Goal 4): any failure returns `{bounced:false}`
|
|
39
|
+
* and never throws. Runs at most once per extension process (A2).
|
|
40
|
+
*/
|
|
41
|
+
export async function bounceStaleRunnerIfAny(deps) {
|
|
42
|
+
if (stalenessCheckedThisProcess)
|
|
43
|
+
return { bounced: false };
|
|
44
|
+
try {
|
|
45
|
+
stalenessCheckedThisProcess = true; // once per process, regardless of outcome
|
|
46
|
+
const info = await deps.isServerRunning();
|
|
47
|
+
if (!info)
|
|
48
|
+
return { bounced: false };
|
|
49
|
+
const orphan = !info.hasPidFile;
|
|
50
|
+
const want = deps.ownVersion();
|
|
51
|
+
const marker = deps.markerVersion();
|
|
52
|
+
let stale;
|
|
53
|
+
let from = null;
|
|
54
|
+
if (orphan) {
|
|
55
|
+
stale = true; // live server with no marker → orphan by definition
|
|
56
|
+
}
|
|
57
|
+
else if (want != null && marker != null) {
|
|
58
|
+
stale = marker !== want; // B2: compare the stamped marker, skip the HTTP probe
|
|
59
|
+
from = marker;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const running = await deps.serverVersion(info.port);
|
|
63
|
+
from = running;
|
|
64
|
+
stale = want != null && running != null && running !== want;
|
|
65
|
+
}
|
|
66
|
+
if (stale) {
|
|
67
|
+
deps.notify(orphan
|
|
68
|
+
? "[mega-compact] replacing orphaned dashboard server…"
|
|
69
|
+
: `[mega-compact] replacing stale dashboard (${from ?? "?"} → ${want ?? "?"})…`);
|
|
70
|
+
deps.killServerOnPort(info.port);
|
|
71
|
+
return { bounced: true };
|
|
72
|
+
}
|
|
73
|
+
return { bounced: false };
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Best-effort, non-fatal — a failed probe/kill never breaks the caller.
|
|
77
|
+
return { bounced: false };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -9,6 +9,11 @@ import { join, dirname, sep } from "node:path";
|
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import { existsSync, writeFileSync, readFileSync, unlinkSync, openSync, closeSync } from "node:fs";
|
|
11
11
|
import { spawn, execSync } from "node:child_process"; // guardrails-allow PREVENT-PI-004: spawns the optional, user-triggered localhost dashboard server only
|
|
12
|
+
import { bounceStaleRunnerIfAny, } from "./mega-dashboard-bounce.js";
|
|
13
|
+
// Re-export the VC0F bounce seam for the unit tests, which import the parent
|
|
14
|
+
// module. The implementation + once-per-process gate live in the sibling
|
|
15
|
+
// delegate file to keep this module under the extensions/ soft limit (400).
|
|
16
|
+
export { bounceStaleRunnerIfAny, resetStalenessGateForTests } from "./mega-dashboard-bounce.js";
|
|
12
17
|
/** Register the dashboard server lifecycle commands. */
|
|
13
18
|
export function registerDashboardCommands(pi, runtime) {
|
|
14
19
|
// H3 fix: read currentStateDir at CALL time, not registration time. The
|
|
@@ -118,6 +123,27 @@ export function registerDashboardCommands(pi, runtime) {
|
|
|
118
123
|
}
|
|
119
124
|
catch { /* ignore */ }
|
|
120
125
|
}
|
|
126
|
+
/** Version stamped in the current repo's port.pid marker (VC0F B2), or null
|
|
127
|
+
* when the marker is absent or predates the stamped `version` field. */
|
|
128
|
+
function markerVersion() {
|
|
129
|
+
try {
|
|
130
|
+
const info = JSON.parse(readFileSync(portFile(), "utf-8"));
|
|
131
|
+
return typeof info.version === "string" ? info.version : null;
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Build the dependency set `bounceStaleRunnerIfAny` needs for the CURRENT
|
|
139
|
+
* repo's dashboard lifecycle (port.pid / runner / launch-log all resolve via
|
|
140
|
+
* `runtime.currentStateDir`, so a repo switch re-targets the bounce).
|
|
141
|
+
* `notify` is threaded here so the interactive /mega-dashboard path surfaces
|
|
142
|
+
* the replace messages while the silent session-start path is a no-op.
|
|
143
|
+
*/
|
|
144
|
+
function staleBounceDeps(notify) {
|
|
145
|
+
return { isServerRunning, serverVersion, markerVersion, ownVersion, killServerOnPort, notify };
|
|
146
|
+
}
|
|
121
147
|
/**
|
|
122
148
|
* Resolve the launchable dashboard-server module.
|
|
123
149
|
*
|
|
@@ -157,9 +183,14 @@ export function registerDashboardCommands(pi, runtime) {
|
|
|
157
183
|
if (!resolved)
|
|
158
184
|
return false;
|
|
159
185
|
dashboardNeedsStrip = resolved.needsStripTypes;
|
|
186
|
+
// VC0F B1: stamp the extension version in the generated script at WRITE time
|
|
187
|
+
// so a future probe can compare it against ownVersion() without a live HTTP
|
|
188
|
+
// round-trip (useful when the server is hung and /api/version times out).
|
|
189
|
+
const stampedVersion = ownVersion() ?? "0.0.0";
|
|
160
190
|
const script = [
|
|
161
191
|
`import { appendFileSync } from "node:fs";`,
|
|
162
192
|
`const __log = ${JSON.stringify(launchLog())};`,
|
|
193
|
+
`const __VERSION = ${JSON.stringify(stampedVersion)}; // mega-compact bundle version stamped at write time (VC0F B1)`,
|
|
163
194
|
`function __fail(err) {`,
|
|
164
195
|
` const msg = "[mega-compact] dashboard failed: " + (err && err.stack ? err.stack : String(err));`,
|
|
165
196
|
` try { appendFileSync(__log, msg + "\\n"); } catch { /* ignore */ }`,
|
|
@@ -188,31 +219,18 @@ export function registerDashboardCommands(pi, runtime) {
|
|
|
188
219
|
description: "Start the local web dashboard and optionally open it in the default browser.",
|
|
189
220
|
handler: async (_args, ctx) => {
|
|
190
221
|
runtime.bindRepo(ctx.cwd);
|
|
191
|
-
|
|
222
|
+
// VC0F A1: lift the stale-replace decision out of the handler. Interactive
|
|
223
|
+
// path is unchanged — the user is still notified before a stale runner is
|
|
224
|
+
// killed. When a stale server is bounced, we fall straight through to a
|
|
225
|
+
// fresh spawn; otherwise reuse the live current server if there is one.
|
|
226
|
+
const { bounced } = await bounceStaleRunnerIfAny(staleBounceDeps((msg) => ctx.ui.notify(msg)));
|
|
227
|
+
const info = bounced ? null : await isServerRunning();
|
|
192
228
|
if (info) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const orphan = !info.hasPidFile;
|
|
199
|
-
const running = await serverVersion(info.port);
|
|
200
|
-
const want = ownVersion();
|
|
201
|
-
const stale = orphan || (want != null && running != null && running !== want);
|
|
202
|
-
if (stale) {
|
|
203
|
-
ctx.ui.notify(orphan
|
|
204
|
-
? "[mega-compact] replacing orphaned dashboard server…"
|
|
205
|
-
: `[mega-compact] replacing stale dashboard (${running} → ${want})…`);
|
|
206
|
-
killServerOnPort(info.port);
|
|
207
|
-
info = null;
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
ctx.ui.notify(`[mega-compact] dashboard already running at ${info.url}`);
|
|
211
|
-
const open = await ctx.ui.confirm("mega-compact dashboard", `Open ${info.url} in browser?`);
|
|
212
|
-
if (open)
|
|
213
|
-
openBrowser(info.url);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
229
|
+
ctx.ui.notify(`[mega-compact] dashboard already running at ${info.url}`);
|
|
230
|
+
const open = await ctx.ui.confirm("mega-compact dashboard", `Open ${info.url} in browser?`);
|
|
231
|
+
if (open)
|
|
232
|
+
openBrowser(info.url);
|
|
233
|
+
return;
|
|
216
234
|
}
|
|
217
235
|
// Start the server
|
|
218
236
|
ctx.ui.notify("[mega-compact] starting dashboard server…");
|
|
@@ -332,4 +350,19 @@ export function registerDashboardCommands(pi, runtime) {
|
|
|
332
350
|
}
|
|
333
351
|
},
|
|
334
352
|
});
|
|
353
|
+
// VC0F A3 — durable restart-on-upgrade: after `pi update --extensions`
|
|
354
|
+
// replaces the on-disk package, the next pi session probes the running
|
|
355
|
+
// dashboard, sees the version mismatch, and kills + respawns the stale runner
|
|
356
|
+
// automatically. SILENT — no ctx.ui.notify on this session-start path (unlike
|
|
357
|
+
// the explicit /mega-dashboard path). Best-effort and non-fatal: a probe or
|
|
358
|
+
// kill failure here never breaks session startup.
|
|
359
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
360
|
+
runtime.bindRepo(ctx.cwd);
|
|
361
|
+
try {
|
|
362
|
+
await bounceStaleRunnerIfAny(staleBounceDeps(() => { }));
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
/* best-effort — never break the session */
|
|
366
|
+
}
|
|
367
|
+
});
|
|
335
368
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config/vector-cortex-vc9a.ts — VC9A setup-cortex status-read-path sprint flag.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from vector-cortex.ts so that file stays under the 300-line soft
|
|
5
|
+
* limit (soft-as-hard gate), exactly as vector-cortex-vc8c.ts,
|
|
6
|
+
* vector-cortex-breakers.ts and vector-cortex-early.ts were. This is the
|
|
7
|
+
* SETUP-DASHBOARD reader flag (the dashboard Setup tab cortex status endpoint).
|
|
8
|
+
* vector-cortex.ts re-exports it below and root src/config.ts re-exports it, so
|
|
9
|
+
* no consumer import path changes.
|
|
10
|
+
*
|
|
11
|
+
* The split is purely mechanical: VC9A_ENABLED is byte-identical in name,
|
|
12
|
+
* semantics, and default to the definition it replaces, and vector-cortex.ts
|
|
13
|
+
* re-exports it so every existing `from "./config/vector-cortex.js"` import
|
|
14
|
+
* keeps resolving unchanged.
|
|
15
|
+
*
|
|
16
|
+
* Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
|
|
17
|
+
*/
|
|
18
|
+
import { sprintFlag } from "./vector-cortex-flag.js";
|
|
19
|
+
/**
|
|
20
|
+
* VC9A — Setup Cortex status read path (GET /api/setup-cortex-status).
|
|
21
|
+
* Default ON. `MEGACOMPACT_VC9A=0` disables and is byte-identical to the
|
|
22
|
+
* predecessor (VC8C-era shape): the endpoint returns `{enabled:false,
|
|
23
|
+
* mode:"C", status:"off"}` and surfaces no qualification/blocker/health detail —
|
|
24
|
+
* a pure reader-only projection, never a mutation. This flag MUST also be a
|
|
25
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS),
|
|
26
|
+
* mirroring VC4A..VC8C. The dashboard reader itself performs only local
|
|
27
|
+
* filesystem reads (no network, PREVENT-PI-004).
|
|
28
|
+
*/
|
|
29
|
+
export const VC9A_ENABLED = () => sprintFlag("MEGACOMPACT_VC9A");
|
|
@@ -244,6 +244,10 @@ export const VC8B_ENABLED = () => sprintFlag("MEGACOMPACT_VC8B");
|
|
|
244
244
|
// Re-exported here so every existing `from "./config/vector-cortex.js"`
|
|
245
245
|
// import keeps resolving unchanged.
|
|
246
246
|
export { VC8C_ENABLED } from "./vector-cortex-vc8c.js";
|
|
247
|
+
// VC9A (setup-cortex status read path) extracted to vector-cortex-vc9a.ts to
|
|
248
|
+
// keep this file under the 300-line soft limit. Re-exported here so every
|
|
249
|
+
// existing `from "./config/vector-cortex.js"` import keeps resolving unchanged.
|
|
250
|
+
export { VC9A_ENABLED } from "./vector-cortex-vc9a.js";
|
|
247
251
|
// Breaker state machine constants (TRIAD_RESILIENCE.md §breaker) extracted to
|
|
248
252
|
// vector-cortex-breakers.ts to keep this file under the 300-line soft limit.
|
|
249
253
|
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, 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, 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";
|