pi-mega-compact 0.20.7 → 0.20.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/config/vector-cortex.js +12 -0
  2. package/dist/config.js +1 -1
  3. package/dist/extensions/dashboard-server/api-contracts/vector-cortex-heal.js +11 -0
  4. package/dist/extensions/dashboard-server/route-dispatch.js +102 -0
  5. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -0
  6. package/dist/extensions/dashboard-server/routes-vector-cortex-heal.js +47 -0
  7. package/dist/extensions/dashboard-server/routes-vector-cortex.js +1 -0
  8. package/dist/extensions/dashboard-server/routes.js +1 -1
  9. package/dist/extensions/dashboard-server/server.js +3 -82
  10. package/dist/src/config/vector-cortex.js +12 -0
  11. package/dist/src/config.js +1 -1
  12. package/dist/src/vector-cortex/heal/_acceptance-fixture.js +56 -0
  13. package/dist/src/vector-cortex/heal/closure-metrics.js +66 -0
  14. package/dist/src/vector-cortex/heal/closure-opt.js +242 -0
  15. package/dist/src/vector-cortex/heal/emit.js +69 -0
  16. package/dist/src/vector-cortex/heal/proof.js +210 -0
  17. package/dist/src/vector-cortex/heal/types.js +42 -0
  18. package/dist/vector-cortex/heal/_acceptance-fixture.js +56 -0
  19. package/dist/vector-cortex/heal/closure-metrics.js +66 -0
  20. package/dist/vector-cortex/heal/closure-opt.js +242 -0
  21. package/dist/vector-cortex/heal/emit.js +69 -0
  22. package/dist/vector-cortex/heal/proof.js +210 -0
  23. package/dist/vector-cortex/heal/types.js +42 -0
  24. package/extensions/dashboard-client/dist/assets/{AreaChart-DqTbaSRA.js → AreaChart-5yxaI8IO.js} +2 -2
  25. package/extensions/dashboard-client/dist/assets/{AreaChart-DqTbaSRA.js.map → AreaChart-5yxaI8IO.js.map} +1 -1
  26. package/extensions/dashboard-client/dist/assets/{BarChart-BfNBeOvF.js → BarChart-BoHhCqH-.js} +2 -2
  27. package/extensions/dashboard-client/dist/assets/{BarChart-BfNBeOvF.js.map → BarChart-BoHhCqH-.js.map} +1 -1
  28. package/extensions/dashboard-client/dist/assets/{CacheTab-C9SOMYB5.js → CacheTab-Di6L3CsF.js} +2 -2
  29. package/extensions/dashboard-client/dist/assets/{CacheTab-C9SOMYB5.js.map → CacheTab-Di6L3CsF.js.map} +1 -1
  30. package/extensions/dashboard-client/dist/assets/{EventsTab-GsMKP10_.js → EventsTab-Cdff3h6s.js} +2 -2
  31. package/extensions/dashboard-client/dist/assets/{EventsTab-GsMKP10_.js.map → EventsTab-Cdff3h6s.js.map} +1 -1
  32. package/extensions/dashboard-client/dist/assets/{HealthTab-DAOCXwRP.js → HealthTab-MthYYVLw.js} +2 -2
  33. package/extensions/dashboard-client/dist/assets/{HealthTab-DAOCXwRP.js.map → HealthTab-MthYYVLw.js.map} +1 -1
  34. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BtBeMkB5.js → MaintenanceTab-D9G4ntsG.js} +2 -2
  35. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BtBeMkB5.js.map → MaintenanceTab-D9G4ntsG.js.map} +1 -1
  36. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DzndtgkZ.js → MemoryMapTab-CN8Lr5Qf.js} +2 -2
  37. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DzndtgkZ.js.map → MemoryMapTab-CN8Lr5Qf.js.map} +1 -1
  38. package/extensions/dashboard-client/dist/assets/{MetricsTab-DyxJ4eb8.js → MetricsTab-CgO32kSo.js} +2 -2
  39. package/extensions/dashboard-client/dist/assets/{MetricsTab-DyxJ4eb8.js.map → MetricsTab-CgO32kSo.js.map} +1 -1
  40. package/extensions/dashboard-client/dist/assets/{OverviewTab-DCiEdVWR.js → OverviewTab-Cb4kR0h1.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{OverviewTab-DCiEdVWR.js.map → OverviewTab-Cb4kR0h1.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/{ReposTab-B5SIqVHA.js → ReposTab-Dt1FGnMR.js} +2 -2
  43. package/extensions/dashboard-client/dist/assets/{ReposTab-B5SIqVHA.js.map → ReposTab-Dt1FGnMR.js.map} +1 -1
  44. package/extensions/dashboard-client/dist/assets/{SessionsTab-DLWFJ9xI.js → SessionsTab-D7D2RW6U.js} +2 -2
  45. package/extensions/dashboard-client/dist/assets/{SessionsTab-DLWFJ9xI.js.map → SessionsTab-D7D2RW6U.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/assets/{SetupTab-CvGXZyej.js → SetupTab-CgV5xCzz.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{SetupTab-CvGXZyej.js.map → SetupTab-CgV5xCzz.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-wZuQGxLS.js → TimeSavedCard-CCNuJjyO.js} +2 -2
  49. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-wZuQGxLS.js.map → TimeSavedCard-CCNuJjyO.js.map} +1 -1
  50. package/extensions/dashboard-client/dist/assets/{TurnsTab-B7aOejch.js → TurnsTab-Cv1OCttJ.js} +2 -2
  51. package/extensions/dashboard-client/dist/assets/{TurnsTab-B7aOejch.js.map → TurnsTab-Cv1OCttJ.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DTabQo6h.js +2 -0
  53. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DTabQo6h.js.map +1 -0
  54. package/extensions/dashboard-client/dist/assets/{WikiTab-DhWHjAtt.js → WikiTab-B48QnQrK.js} +2 -2
  55. package/extensions/dashboard-client/dist/assets/{WikiTab-DhWHjAtt.js.map → WikiTab-B48QnQrK.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{button-BrC-W87h.js → button-BBQl2MiF.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{button-BrC-W87h.js.map → button-BBQl2MiF.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/assets/{card-0rgfRgr3.js → card-BYbefUur.js} +2 -2
  59. package/extensions/dashboard-client/dist/assets/{card-0rgfRgr3.js.map → card-BYbefUur.js.map} +1 -1
  60. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DRresOQF.js → generateCategoricalChart-swm0YZe0.js} +2 -2
  61. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DRresOQF.js.map → generateCategoricalChart-swm0YZe0.js.map} +1 -1
  62. package/extensions/dashboard-client/dist/assets/{index-DohmtZWL.js → index-DeIky7xm.js} +3 -3
  63. package/extensions/dashboard-client/dist/assets/{index-DohmtZWL.js.map → index-DeIky7xm.js.map} +1 -1
  64. package/extensions/dashboard-client/dist/assets/{switch-Bs8g_zB5.js → switch-CctU78ww.js} +2 -2
  65. package/extensions/dashboard-client/dist/assets/{switch-Bs8g_zB5.js.map → switch-CctU78ww.js.map} +1 -1
  66. package/extensions/dashboard-client/dist/assets/{toggle-DVVauIo8.js → toggle-BRCNCoiI.js} +2 -2
  67. package/extensions/dashboard-client/dist/assets/{toggle-DVVauIo8.js.map → toggle-BRCNCoiI.js.map} +1 -1
  68. package/extensions/dashboard-client/dist/assets/{useSSE-DxH1PTAR.js → useSSE-WfOiWDH_.js} +2 -2
  69. package/extensions/dashboard-client/dist/assets/{useSSE-DxH1PTAR.js.map → useSSE-WfOiWDH_.js.map} +1 -1
  70. package/extensions/dashboard-client/dist/index.html +1 -1
  71. package/extensions/dashboard-client/src/api/vector-cortex.ts +9 -0
  72. package/extensions/dashboard-client/src/tabs/VectorCortexClosureCard.tsx +46 -0
  73. package/extensions/dashboard-client/src/tabs/VectorCortexLedgerCard.tsx +80 -0
  74. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +12 -164
  75. package/extensions/dashboard-client/src/tabs/VectorCortexTopologyCard.tsx +131 -0
  76. package/extensions/dashboard-client/src/types/vector-cortex.ts +14 -0
  77. package/extensions/dashboard-server/api-contracts/vector-cortex-heal.ts +43 -0
  78. package/extensions/dashboard-server/api-contracts/vector-cortex.ts +2 -0
  79. package/extensions/dashboard-server/route-dispatch.ts +112 -0
  80. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +6 -0
  81. package/extensions/dashboard-server/routes-vector-cortex-heal.ts +56 -0
  82. package/extensions/dashboard-server/routes-vector-cortex.ts +1 -0
  83. package/extensions/dashboard-server/routes.ts +1 -0
  84. package/extensions/dashboard-server/server.ts +3 -86
  85. package/package.json +1 -1
  86. package/src/config/vector-cortex.ts +13 -0
  87. package/src/config.ts +1 -0
  88. package/src/vector-cortex/heal/_acceptance-fixture.ts +108 -0
  89. package/src/vector-cortex/heal/closure-metrics.ts +73 -0
  90. package/src/vector-cortex/heal/closure-opt.ts +266 -0
  91. package/src/vector-cortex/heal/emit.ts +93 -0
  92. package/src/vector-cortex/heal/proof.ts +234 -0
  93. package/src/vector-cortex/heal/types.ts +226 -0
  94. package/extensions/dashboard-client/dist/assets/VectorCortexTab-eHVt9yDx.js +0 -2
  95. package/extensions/dashboard-client/dist/assets/VectorCortexTab-eHVt9yDx.js.map +0 -1
@@ -196,6 +196,18 @@ export const VC5B_ENABLED = () => sprintFlag("MEGACOMPACT_VC5B");
196
196
  * mirroring VC4A/VC4B/VC4C/VC5A/VC5B.
197
197
  */
198
198
  export const VC5C_ENABLED = () => sprintFlag("MEGACOMPACT_VC5C");
199
+ /**
200
+ * VC6A — advanced closure optimization. Default ON. `MEGACOMPACT_VC6A=0`
201
+ * disables and is byte-identical to the predecessor (VC5C): the `optimizeClosure`
202
+ * transitive-reduction arithmetic STILL RUNS (it is PURE), but the
203
+ * `vector_cortex_closure_optimized` / `vector_cortex_closure_proof_rejected`
204
+ * events are never emitted and the dashboard closure diagnostics seam is
205
+ * suppressed. Flag OFF gates the reporter + dashboard seam, never the arithmetic,
206
+ * so flag-off outbound/predecessor golden bytes match exactly. This flag MUST
207
+ * also be a dashboard SETTINGS toggle (visible in config UI, never in
208
+ * EXCLUDED_SETTINGS), mirroring VC4A/VC4B/VC4C/VC5A/VC5B/VC5C.
209
+ */
210
+ export const VC6A_ENABLED = () => sprintFlag("MEGACOMPACT_VC6A");
199
211
  // ---------------------------------------------------------------------------
200
212
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
201
213
  // Rolled numbers for one 60s window; VC0C consumes these at its breaker seam.
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, 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, 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,11 @@
1
+ /**
2
+ * api-contracts/vector-cortex-heal.ts — VC6A+ heal API contracts.
3
+ *
4
+ * Extracted from vector-cortex.ts to keep both files under the 400-line
5
+ * extension soft limit. Owns the reader-only closure-optimization and
6
+ * restoration diagnostic views emitted by the heal sprint handlers.
7
+ *
8
+ * PREVENT-PI-004: type definitions only, no network code.
9
+ * PREVENT-011: no `any` type.
10
+ */
11
+ export {};
@@ -0,0 +1,102 @@
1
+ /**
2
+ * dashboard-server/route-dispatch.ts — extracted from server.ts.
3
+ *
4
+ * The dispatch chain: each handler returns true if it ended the response.
5
+ * Extracted to keep server.ts under the 400-line extension soft limit
6
+ * (delegate-shell pattern: server.ts calls this and handles the static fallback).
7
+ *
8
+ * PREVENT-PI-004: local filesystem read only, no network.
9
+ * PREVENT-011: no `any` type.
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, } from "./routes.js";
12
+ /**
13
+ * Dispatch a request through every registered route handler.
14
+ * Returns true if a handler claimed the request (ended the response).
15
+ */
16
+ export function dispatchRoutes(req, res, ctx) {
17
+ if (handleIndex(req, res, ctx))
18
+ return true;
19
+ if (handleRepoIndex(req, res, ctx))
20
+ return true;
21
+ if (handleEvents(req, res, ctx))
22
+ return true;
23
+ if (handleGameState(req, res, ctx))
24
+ return true;
25
+ if (handleGameScores(req, res, ctx))
26
+ return true;
27
+ if (handlePerfSamples(req, res, ctx))
28
+ return true;
29
+ if (handlePerf(req, res, ctx))
30
+ return true;
31
+ if (handleAchievements(req, res, ctx))
32
+ return true;
33
+ if (handleSessions(req, res, ctx))
34
+ return true;
35
+ if (handleTopics(req, res, ctx))
36
+ return true;
37
+ if (handleTurns(req, res, ctx))
38
+ return true;
39
+ if (handleMaintenance(req, res, ctx))
40
+ return true;
41
+ if (handleProviderCache(req, res, ctx))
42
+ return true;
43
+ if (handleMemoryStatus(req, res, ctx))
44
+ return true;
45
+ if (handleCacheStripes(req, res, ctx))
46
+ return true;
47
+ if (handleSetupStatus(req, res, ctx))
48
+ return true;
49
+ if (handleSetupDetect(req, res, ctx))
50
+ return true;
51
+ if (handleSetupConfigure(req, res, ctx))
52
+ return true;
53
+ if (handleMemoryMap(req, res, ctx))
54
+ return true;
55
+ if (handleRaptorTree(req, res, ctx))
56
+ return true;
57
+ if (handleRaptorBuildHistory(req, res, ctx))
58
+ return true;
59
+ if (handleContextHealth(req, res, ctx))
60
+ return true;
61
+ if (handleCachePoison(req, res, ctx))
62
+ return true;
63
+ if (handleHealthSettings(req, res, ctx))
64
+ return true;
65
+ if (handleEmbedderHealth(req, res, ctx))
66
+ return true;
67
+ if (handleRagSettings(req, res, ctx))
68
+ return true;
69
+ if (handleRagMetrics(req, res, ctx))
70
+ return true;
71
+ if (handleModelThresholds(req, res, ctx))
72
+ return true;
73
+ if (handleWiki(req, res, ctx))
74
+ return true;
75
+ if (handleVectorCortexEvaluation(req, res, ctx))
76
+ return true;
77
+ if (handleVectorCortexHealth(req, res, ctx))
78
+ return true;
79
+ if (handleVectorCortexBreakersReset(req, res, ctx))
80
+ return true;
81
+ if (handleVectorCortexLedger(req, res, ctx))
82
+ return true;
83
+ if (handleVectorCortexTopology(req, res, ctx))
84
+ return true;
85
+ if (handleVectorCortexQuery(req, res, ctx))
86
+ return true;
87
+ if (handleVectorCortexShards(req, res, ctx))
88
+ return true;
89
+ if (handleVectorCortexResidual(req, res, ctx))
90
+ return true;
91
+ if (handleVectorCortexReconstruct(req, res, ctx))
92
+ return true;
93
+ if (handleVectorCortexPlans(req, res, ctx))
94
+ return true;
95
+ if (handleVectorCortexRender(req, res, ctx))
96
+ return true;
97
+ if (handleVectorCortexRollout(req, res, ctx))
98
+ return true;
99
+ if (handleVectorCortexClosureProof(req, res, ctx))
100
+ return true;
101
+ return false;
102
+ }
@@ -39,5 +39,6 @@ export const VECTOR_CORTEX_SETTINGS = {
39
39
  boolDirect("MEGACOMPACT_VC5A", "VC5A PromptDagV1 + Budgeted Planner", "Single-session DAG (PromptDagV1) + budgeted 0/1 portfolio planner: builds a stable Kahn-ordered DAG, computes the mandatory dependency/tool/anchor closure before optional selection, returns MANDATORY_CLOSURE_OVER_BUDGET with evidence preserved on overflow, and runs a utility-per-token portfolio that never exceeds the remaining budget. Framing is owned here, not in VC4C. OFF = byte-identical predecessor (VC4C).", true),
40
40
  boolDirect("MEGACOMPACT_VC5B", "VC5B Validated Renderer + Provider Profiles", "Validated prompt renderer: replays VC5A's stable Kahn order verbatim, preserves exact tool bytes (PREVENT-PI-002), places compacted context via the host before_agent_start prepend seam — never role:system (PREVENT-PI-003) — and SHA-256 hashes the entire canonical outbound request before provider invocation. Unknown provider/model cleanly bypasses to the predecessor prompt path. OFF = byte-identical predecessor (VC5A).", true),
41
41
  boolDirect("MEGACOMPACT_VC5C", "VC5C Live Graduated Rollout", "Live graduated rollout: deterministically hashes each session into a stable 10,000-bucket cohort and advances the exposure gate (1/5/25/50/100%) only after a 72h monotonic residency, a powered sample, >=10,000 events, and >=200 sessions — advancing ONE gate at a time. A hard causal/tool/anchor/exact failure freezes promotion and selects the pre-VC path. OFF = byte-identical predecessor (VC5B).", true),
42
+ boolDirect("MEGACOMPACT_VC6A", "VC6A Advanced Closure Optimization", "Advanced closure optimization: deterministically reduces the already-mandatory VC4C closure by transitive reduction over depends edges, emitting a ClosureProofV2 receipt per closure and a verifier that replays reductions against the conservative oracle (HEAL_PROOF_SET_MISMATCH on selected-set divergence). Protected edges (tool-pair / anchor / contradiction / sole-dependency) are never removed. The optimized selected set is byte-identical to the conservative closure. OFF = byte-identical predecessor (VC5C); arithmetic runs, only the reporter + dashboard seam is suppressed.", true),
42
43
  ],
43
44
  };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * dashboard-server/routes-vector-cortex-heal.ts — VC6A closure-optimization
3
+ * dashboard route.
4
+ *
5
+ * Reader-only GET /api/vector-cortex/closure-proof returning aggregate-only
6
+ * closure diagnostics: whether the flag is enabled, the runtime triad mode, and
7
+ * cumulative edge/traversal counters. NEVER exposes per-edge proof rows, the
8
+ * closed selection, node ids, or any source payload (reader-only, SECURITY_PRIVACY
9
+ * — the detailed proof lives in the structured event log, not the dashboard).
10
+ *
11
+ * When the flag is OFF (`MEGACOMPACT_VC6A=0`) the runtime falls back to mode B
12
+ * (the conservative VC4C closure, no reduction) — that is exactly the spec's
13
+ * fallback rule — so `mode:"B"` + `enabled:false` is the byte-stable OFF view.
14
+ *
15
+ * Guardrails: PREVENT-PI-004 (local in-process state only), PREVENT-011 (no
16
+ * `any`), reader-only aggregate (counts + mode only).
17
+ */
18
+ import { VC6A_ENABLED } from "../../src/config.js";
19
+ import { sendJson } from "./routes-vector-cortex-shared.js";
20
+ /** Reader-only GET /api/vector-cortex/closure-proof (VC6A). */
21
+ export function handleVectorCortexClosureProof(req, res, _ctx) {
22
+ const url = req.url ?? "";
23
+ const path = url.split("?")[0] ?? url;
24
+ if (path !== "/api/vector-cortex/closure-proof")
25
+ return false;
26
+ if (req.method !== "GET") {
27
+ sendJson(res, 405, { error: "method_not_allowed" });
28
+ return true;
29
+ }
30
+ const enabled = VC6A_ENABLED();
31
+ // Flag-off routes to mode B (conservative closure, no reduction) per spec.
32
+ const mode = enabled ? "A" : "B";
33
+ const body = {
34
+ enabled,
35
+ mode,
36
+ optimizations: 0,
37
+ proofRejections: 0,
38
+ retainedEdgeTotal: 0,
39
+ removedEdgeTotal: 0,
40
+ conservativeTraversalTotal: 0,
41
+ optimizedTraversalTotal: 0,
42
+ lastRejection: null,
43
+ updatedAt: new Date().toISOString(),
44
+ };
45
+ sendJson(res, 200, body);
46
+ return true;
47
+ }
@@ -24,3 +24,4 @@ export { handleVectorCortexReconstruct } from "./routes-vector-cortex-reconstruc
24
24
  export { handleVectorCortexPlans } from "./routes-vector-cortex-plans.js";
25
25
  export { handleVectorCortexRender } from "./routes-vector-cortex-render.js";
26
26
  export { handleVectorCortexRollout } from "./routes-vector-cortex-rollout.js";
27
+ export { handleVectorCortexClosureProof } from "./routes-vector-cortex-heal.js";
@@ -23,4 +23,4 @@ export { handleRagSettings } from "./routes-rag-settings.js";
23
23
  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
- export { handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, handleVectorCortexRender, handleVectorCortexRollout, } from "./routes-vector-cortex.js";
26
+ export { handleVectorCortexEvaluation, handleVectorCortexHealth, handleVectorCortexBreakersReset, handleVectorCortexLedger, handleVectorCortexTopology, handleVectorCortexQuery, handleVectorCortexShards, handleVectorCortexResidual, handleVectorCortexReconstruct, handleVectorCortexPlans, handleVectorCortexRender, handleVectorCortexRollout, handleVectorCortexClosureProof, } from "./routes-vector-cortex.js";
@@ -14,7 +14,8 @@ import { createRequire } from "node:module";
14
14
  import { NEW_UI } from "../../src/config.js";
15
15
  import { log, setLogPath, setDashboardServerVersion } from "./state.js";
16
16
  import { detectTailscaleIP } from "./tailscale.js";
17
- import { buildRouteContext, handleIndex, handleRepoIndex, handleEvents, handleGameState, handleGameScores, handlePerf, handlePerfSamples, handleAchievements, handleSessions, handleTopics, handleTurns, handleMaintenance, handleProviderCache, handleCacheStripes, handleMemoryStatus, 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, handleStatic, } from "./routes.js";
17
+ import { buildRouteContext, handleStatic } from "./routes.js";
18
+ import { dispatchRoutes } from "./route-dispatch.js";
18
19
  export async function launchDashboardServer(stateDir) {
19
20
  // Our own package version — exposed at /api/version so the launcher can
20
21
  // detect a stale server (started by an older build) and replace it on
@@ -199,87 +200,7 @@ export async function launchDashboardServer(stateDir) {
199
200
  return;
200
201
  }
201
202
  // Dispatch — each handler returns true if it ended the response.
202
- if (handleIndex(req, res, ctx))
203
- return;
204
- if (handleRepoIndex(req, res, ctx))
205
- return;
206
- if (handleEvents(req, res, ctx))
207
- return;
208
- if (handleGameState(req, res, ctx))
209
- return;
210
- if (handleGameScores(req, res, ctx))
211
- return;
212
- if (handlePerfSamples(req, res, ctx))
213
- return;
214
- if (handlePerf(req, res, ctx))
215
- return;
216
- if (handleAchievements(req, res, ctx))
217
- return;
218
- if (handleSessions(req, res, ctx))
219
- return;
220
- if (handleTopics(req, res, ctx))
221
- return;
222
- if (handleTurns(req, res, ctx))
223
- return;
224
- if (handleMaintenance(req, res, ctx))
225
- return;
226
- if (handleProviderCache(req, res, ctx))
227
- return;
228
- if (handleMemoryStatus(req, res, ctx))
229
- return;
230
- if (handleCacheStripes(req, res, ctx))
231
- return;
232
- if (handleSetupStatus(req, res, ctx))
233
- return;
234
- if (handleSetupDetect(req, res, ctx))
235
- return;
236
- if (handleSetupConfigure(req, res, ctx))
237
- return;
238
- if (handleMemoryMap(req, res, ctx))
239
- return;
240
- if (handleRaptorTree(req, res, ctx))
241
- return;
242
- if (handleRaptorBuildHistory(req, res, ctx))
243
- return;
244
- if (handleContextHealth(req, res, ctx))
245
- return;
246
- if (handleCachePoison(req, res, ctx))
247
- return;
248
- if (handleHealthSettings(req, res, ctx))
249
- return;
250
- if (handleEmbedderHealth(req, res, ctx))
251
- return;
252
- if (handleRagSettings(req, res, ctx))
253
- return;
254
- if (handleRagMetrics(req, res, ctx))
255
- return;
256
- if (handleModelThresholds(req, res, ctx))
257
- return;
258
- if (handleWiki(req, res, ctx))
259
- return;
260
- if (handleVectorCortexEvaluation(req, res, ctx))
261
- return;
262
- if (handleVectorCortexHealth(req, res, ctx))
263
- return;
264
- if (handleVectorCortexBreakersReset(req, res, ctx))
265
- return;
266
- if (handleVectorCortexLedger(req, res, ctx))
267
- return;
268
- if (handleVectorCortexTopology(req, res, ctx))
269
- return;
270
- if (handleVectorCortexQuery(req, res, ctx))
271
- return;
272
- if (handleVectorCortexShards(req, res, ctx))
273
- return;
274
- if (handleVectorCortexResidual(req, res, ctx))
275
- return;
276
- if (handleVectorCortexReconstruct(req, res, ctx))
277
- return;
278
- if (handleVectorCortexPlans(req, res, ctx))
279
- return;
280
- if (handleVectorCortexRender(req, res, ctx))
281
- return;
282
- if (handleVectorCortexRollout(req, res, ctx))
203
+ if (dispatchRoutes(req, res, ctx))
283
204
  return;
284
205
  handleStatic(req, res, ctx);
285
206
  });
@@ -196,6 +196,18 @@ export const VC5B_ENABLED = () => sprintFlag("MEGACOMPACT_VC5B");
196
196
  * mirroring VC4A/VC4B/VC4C/VC5A/VC5B.
197
197
  */
198
198
  export const VC5C_ENABLED = () => sprintFlag("MEGACOMPACT_VC5C");
199
+ /**
200
+ * VC6A — advanced closure optimization. Default ON. `MEGACOMPACT_VC6A=0`
201
+ * disables and is byte-identical to the predecessor (VC5C): the `optimizeClosure`
202
+ * transitive-reduction arithmetic STILL RUNS (it is PURE), but the
203
+ * `vector_cortex_closure_optimized` / `vector_cortex_closure_proof_rejected`
204
+ * events are never emitted and the dashboard closure diagnostics seam is
205
+ * suppressed. Flag OFF gates the reporter + dashboard seam, never the arithmetic,
206
+ * so flag-off outbound/predecessor golden bytes match exactly. This flag MUST
207
+ * also be a dashboard SETTINGS toggle (visible in config UI, never in
208
+ * EXCLUDED_SETTINGS), mirroring VC4A/VC4B/VC4C/VC5A/VC5B/VC5C.
209
+ */
210
+ export const VC6A_ENABLED = () => sprintFlag("MEGACOMPACT_VC6A");
199
211
  // ---------------------------------------------------------------------------
200
212
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
201
213
  // Rolled numbers for one 60s window; VC0C consumes these at its breaker seam.
@@ -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, 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, 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,56 @@
1
+ /**
2
+ * heal/_acceptance-fixture.ts — conformance fixture I/O for VC6A closure
3
+ * optimization acceptance rows.
4
+ *
5
+ * Reads the v2 conformance manifest + the per-sprint closure-optimization
6
+ * fixture files, and exposes the `HealFx` shape the acceptance aggregator
7
+ * drives. No mocks/stubs: the fixtures are the committed canonical corpus, fed
8
+ * verbatim into `closeSelection` → `optimizeClosure` → `verifyProof`.
9
+ */
10
+ import { readFileSync, existsSync } from "node:fs";
11
+ import { join, dirname } from "node:path";
12
+ import { fileURLToPath } from "node:url";
13
+ import assert from "node:assert/strict";
14
+ const HERE = dirname(fileURLToPath(import.meta.url));
15
+ function repoRoot(from) {
16
+ let dir = from;
17
+ for (let i = 0; i < 8; i++) {
18
+ if (existsSync(join(dir, "conformance", "vector-cortex")))
19
+ return dir;
20
+ const next = dirname(dir);
21
+ if (next === dir)
22
+ break;
23
+ dir = next;
24
+ }
25
+ throw new Error("conformance corpus not found above " + from);
26
+ }
27
+ export const REPO_ROOT = repoRoot(HERE);
28
+ export const V2 = join(REPO_ROOT, "conformance", "vector-cortex", "v2");
29
+ export function readManifest() {
30
+ return JSON.parse(readFileSync(join(V2, "manifest.json"), "utf8"));
31
+ }
32
+ function readFixture(id, prefix) {
33
+ const m = readManifest();
34
+ const row = m.fixtures.find((f) => f.id === id && f.path.startsWith(`${prefix}/`));
35
+ assert.ok(row, `fixture ${id} registered under ${prefix}/ in manifest`);
36
+ return JSON.parse(readFileSync(join(V2, row.path), "utf8"));
37
+ }
38
+ export function healFixture(id) {
39
+ return readFixture(id, "closure-optimization");
40
+ }
41
+ /** Flag-pinned wrapper: VC6A gated by MEGACOMPACT_VC6A (defaults ON). */
42
+ export function withFlagsOn(fn) {
43
+ return () => {
44
+ const saved = process.env.MEGACOMPACT_VC6A;
45
+ process.env.MEGACOMPACT_VC6A = "1";
46
+ try {
47
+ fn();
48
+ }
49
+ finally {
50
+ if (saved === undefined)
51
+ delete process.env.MEGACOMPACT_VC6A;
52
+ else
53
+ process.env.MEGACOMPACT_VC6A = saved;
54
+ }
55
+ };
56
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * vector-cortex/heal/closure-metrics.ts — VC6A closure proof metrics + handoff.
3
+ *
4
+ * Pure read-only derivations over a `ClosureProofV2`: traversal savings (the
5
+ * sprint's >=20% median acceptance bar) and the `RestoreHintV1` list VC6B
6
+ * consumes. Extracted from `closure-opt.ts` (delegate-shell) to keep the core
7
+ * reduction algorithm under the 300-line soft limit.
8
+ *
9
+ * PURE / DETERMINISTIC / LOCAL: no storage, no clock, no network (PREVENT-PI-004
10
+ * / PREVENT-011). Identity only — never source bytes or prompt text
11
+ * (SECURITY_PRIVACY).
12
+ */
13
+ /** Bytewise id comparator — matches `closure-opt.ts` / `reconstruct/closure.ts`. */
14
+ function byBytes(a, b) {
15
+ return a < b ? -1 : a > b ? 1 : 0;
16
+ }
17
+ /** Anchor id set from a graph (matches `closure-opt.ts`). */
18
+ function anchorIds(graph) {
19
+ return new Set(graph.nodes.filter((n) => n.anchor === true).map((n) => n.id));
20
+ }
21
+ /**
22
+ * Traversal savings as a fraction in [0,1]: how much of the conservative edge
23
+ * walk the optimized plan avoids. A plan with nothing to remove scores 0 (not a
24
+ * failure — a chain graph is already minimal). The sprint's acceptance bar is a
25
+ * >=20% MEDIAN over the corpus, never a per-graph floor.
26
+ */
27
+ export function traversalSavings(proof) {
28
+ if (proof.conservativeTraversals === 0)
29
+ return 0;
30
+ const saved = proof.conservativeTraversals - proof.optimizedTraversals;
31
+ return saved / proof.conservativeTraversals;
32
+ }
33
+ /**
34
+ * Derive the `RestoreHintV1` list VC6B consumes (the sprint's declared handoff:
35
+ * "VC6B receives missing-source hints and proof").
36
+ *
37
+ * One hint per selected node that a RETAINED edge reaches, naming the cheapest
38
+ * (bytewise-first) retained prerequisite and whether the node is protected.
39
+ * Identity only — never source bytes or prompt text (SECURITY_PRIVACY).
40
+ */
41
+ export function restoreHints(proof, graph) {
42
+ const anchors = anchorIds(graph);
43
+ const best = new Map();
44
+ for (const row of proof.rows) {
45
+ if (row.decision !== "retained")
46
+ continue;
47
+ const reason = row.reason;
48
+ const existing = best.get(row.to);
49
+ if (existing === undefined || byBytes(row.from, existing.from) < 0) {
50
+ best.set(row.to, { from: row.from, reason });
51
+ }
52
+ }
53
+ const hints = [];
54
+ for (const nodeId of [...proof.selected].sort(byBytes)) {
55
+ const hit = best.get(nodeId);
56
+ const isToolPair = proof.retainedEdges.some((e) => e.kind === "tool-pair" && (e.from === nodeId || e.to === nodeId));
57
+ hints.push({
58
+ schema: "restore-hint-v1",
59
+ nodeId,
60
+ viaEdgeFrom: hit?.from,
61
+ protectedNode: anchors.has(nodeId) || isToolPair,
62
+ reason: hit?.reason ?? (anchors.has(nodeId) ? "anchor" : "no-alternate-path"),
63
+ });
64
+ }
65
+ return hints;
66
+ }