pi-mega-compact 0.20.6 → 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 (117) 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-helpers.js +3 -32
  6. package/dist/extensions/dashboard-server/routes-rag-settings-types.js +11 -0
  7. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +44 -0
  8. package/dist/extensions/dashboard-server/routes-vector-cortex-heal.js +47 -0
  9. package/dist/extensions/dashboard-server/routes-vector-cortex.js +1 -0
  10. package/dist/extensions/dashboard-server/routes.js +1 -1
  11. package/dist/extensions/dashboard-server/server.js +3 -82
  12. package/dist/src/config/dedup.js +1 -0
  13. package/dist/src/config/vector-cortex.js +12 -0
  14. package/dist/src/config.js +1 -1
  15. package/dist/src/dedup-audit.test-helpers.js +43 -0
  16. package/dist/src/monitoring.js +9 -0
  17. package/dist/src/vector-cortex/heal/_acceptance-fixture.js +56 -0
  18. package/dist/src/vector-cortex/heal/closure-metrics.js +66 -0
  19. package/dist/src/vector-cortex/heal/closure-opt.js +242 -0
  20. package/dist/src/vector-cortex/heal/emit.js +69 -0
  21. package/dist/src/vector-cortex/heal/proof.js +210 -0
  22. package/dist/src/vector-cortex/heal/types.js +42 -0
  23. package/dist/src/vectorStore/add-l0.js +108 -0
  24. package/dist/src/vectorStore/add-l1.js +35 -0
  25. package/dist/src/vectorStore/add.js +229 -0
  26. package/dist/src/vectorStore/class.js +15 -291
  27. package/dist/src/vectorStore/dedup-audit.js +104 -0
  28. package/dist/src/vectorStore.js +1 -0
  29. package/dist/vector-cortex/heal/_acceptance-fixture.js +56 -0
  30. package/dist/vector-cortex/heal/closure-metrics.js +66 -0
  31. package/dist/vector-cortex/heal/closure-opt.js +242 -0
  32. package/dist/vector-cortex/heal/emit.js +69 -0
  33. package/dist/vector-cortex/heal/proof.js +210 -0
  34. package/dist/vector-cortex/heal/types.js +42 -0
  35. package/extensions/dashboard-client/dist/assets/{AreaChart-DqTbaSRA.js → AreaChart-5yxaI8IO.js} +2 -2
  36. package/extensions/dashboard-client/dist/assets/{AreaChart-DqTbaSRA.js.map → AreaChart-5yxaI8IO.js.map} +1 -1
  37. package/extensions/dashboard-client/dist/assets/{BarChart-BfNBeOvF.js → BarChart-BoHhCqH-.js} +2 -2
  38. package/extensions/dashboard-client/dist/assets/{BarChart-BfNBeOvF.js.map → BarChart-BoHhCqH-.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/{CacheTab-C9SOMYB5.js → CacheTab-Di6L3CsF.js} +2 -2
  40. package/extensions/dashboard-client/dist/assets/{CacheTab-C9SOMYB5.js.map → CacheTab-Di6L3CsF.js.map} +1 -1
  41. package/extensions/dashboard-client/dist/assets/{EventsTab-GsMKP10_.js → EventsTab-Cdff3h6s.js} +2 -2
  42. package/extensions/dashboard-client/dist/assets/{EventsTab-GsMKP10_.js.map → EventsTab-Cdff3h6s.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/{HealthTab-DAOCXwRP.js → HealthTab-MthYYVLw.js} +2 -2
  44. package/extensions/dashboard-client/dist/assets/{HealthTab-DAOCXwRP.js.map → HealthTab-MthYYVLw.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BtBeMkB5.js → MaintenanceTab-D9G4ntsG.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BtBeMkB5.js.map → MaintenanceTab-D9G4ntsG.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DzndtgkZ.js → MemoryMapTab-CN8Lr5Qf.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DzndtgkZ.js.map → MemoryMapTab-CN8Lr5Qf.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{MetricsTab-DyxJ4eb8.js → MetricsTab-CgO32kSo.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{MetricsTab-DyxJ4eb8.js.map → MetricsTab-CgO32kSo.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/{OverviewTab-DCiEdVWR.js → OverviewTab-Cb4kR0h1.js} +2 -2
  52. package/extensions/dashboard-client/dist/assets/{OverviewTab-DCiEdVWR.js.map → OverviewTab-Cb4kR0h1.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/{ReposTab-B5SIqVHA.js → ReposTab-Dt1FGnMR.js} +2 -2
  54. package/extensions/dashboard-client/dist/assets/{ReposTab-B5SIqVHA.js.map → ReposTab-Dt1FGnMR.js.map} +1 -1
  55. package/extensions/dashboard-client/dist/assets/{SessionsTab-DLWFJ9xI.js → SessionsTab-D7D2RW6U.js} +2 -2
  56. package/extensions/dashboard-client/dist/assets/{SessionsTab-DLWFJ9xI.js.map → SessionsTab-D7D2RW6U.js.map} +1 -1
  57. package/extensions/dashboard-client/dist/assets/{SetupTab-CvGXZyej.js → SetupTab-CgV5xCzz.js} +2 -2
  58. package/extensions/dashboard-client/dist/assets/{SetupTab-CvGXZyej.js.map → SetupTab-CgV5xCzz.js.map} +1 -1
  59. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-wZuQGxLS.js → TimeSavedCard-CCNuJjyO.js} +2 -2
  60. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-wZuQGxLS.js.map → TimeSavedCard-CCNuJjyO.js.map} +1 -1
  61. package/extensions/dashboard-client/dist/assets/{TurnsTab-B7aOejch.js → TurnsTab-Cv1OCttJ.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{TurnsTab-B7aOejch.js.map → TurnsTab-Cv1OCttJ.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DTabQo6h.js +2 -0
  64. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DTabQo6h.js.map +1 -0
  65. package/extensions/dashboard-client/dist/assets/{WikiTab-DhWHjAtt.js → WikiTab-B48QnQrK.js} +2 -2
  66. package/extensions/dashboard-client/dist/assets/{WikiTab-DhWHjAtt.js.map → WikiTab-B48QnQrK.js.map} +1 -1
  67. package/extensions/dashboard-client/dist/assets/{button-BrC-W87h.js → button-BBQl2MiF.js} +2 -2
  68. package/extensions/dashboard-client/dist/assets/{button-BrC-W87h.js.map → button-BBQl2MiF.js.map} +1 -1
  69. package/extensions/dashboard-client/dist/assets/{card-0rgfRgr3.js → card-BYbefUur.js} +2 -2
  70. package/extensions/dashboard-client/dist/assets/{card-0rgfRgr3.js.map → card-BYbefUur.js.map} +1 -1
  71. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DRresOQF.js → generateCategoricalChart-swm0YZe0.js} +2 -2
  72. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DRresOQF.js.map → generateCategoricalChart-swm0YZe0.js.map} +1 -1
  73. package/extensions/dashboard-client/dist/assets/{index-DohmtZWL.js → index-DeIky7xm.js} +3 -3
  74. package/extensions/dashboard-client/dist/assets/{index-DohmtZWL.js.map → index-DeIky7xm.js.map} +1 -1
  75. package/extensions/dashboard-client/dist/assets/{switch-Bs8g_zB5.js → switch-CctU78ww.js} +2 -2
  76. package/extensions/dashboard-client/dist/assets/{switch-Bs8g_zB5.js.map → switch-CctU78ww.js.map} +1 -1
  77. package/extensions/dashboard-client/dist/assets/{toggle-DVVauIo8.js → toggle-BRCNCoiI.js} +2 -2
  78. package/extensions/dashboard-client/dist/assets/{toggle-DVVauIo8.js.map → toggle-BRCNCoiI.js.map} +1 -1
  79. package/extensions/dashboard-client/dist/assets/{useSSE-DxH1PTAR.js → useSSE-WfOiWDH_.js} +2 -2
  80. package/extensions/dashboard-client/dist/assets/{useSSE-DxH1PTAR.js.map → useSSE-WfOiWDH_.js.map} +1 -1
  81. package/extensions/dashboard-client/dist/index.html +1 -1
  82. package/extensions/dashboard-client/src/api/vector-cortex.ts +9 -0
  83. package/extensions/dashboard-client/src/tabs/VectorCortexClosureCard.tsx +46 -0
  84. package/extensions/dashboard-client/src/tabs/VectorCortexLedgerCard.tsx +80 -0
  85. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +12 -164
  86. package/extensions/dashboard-client/src/tabs/VectorCortexTopologyCard.tsx +131 -0
  87. package/extensions/dashboard-client/src/types/vector-cortex.ts +14 -0
  88. package/extensions/dashboard-server/api-contracts/vector-cortex-heal.ts +43 -0
  89. package/extensions/dashboard-server/api-contracts/vector-cortex.ts +2 -0
  90. package/extensions/dashboard-server/route-dispatch.ts +112 -0
  91. package/extensions/dashboard-server/routes-rag-settings-helpers.ts +11 -135
  92. package/extensions/dashboard-server/routes-rag-settings-types.ts +34 -0
  93. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +148 -0
  94. package/extensions/dashboard-server/routes-vector-cortex-heal.ts +56 -0
  95. package/extensions/dashboard-server/routes-vector-cortex.ts +1 -0
  96. package/extensions/dashboard-server/routes.ts +1 -0
  97. package/extensions/dashboard-server/server.ts +3 -86
  98. package/package.json +1 -1
  99. package/src/config/dedup.ts +9 -0
  100. package/src/config/vector-cortex.ts +13 -0
  101. package/src/config.ts +1 -0
  102. package/src/dedup-audit.test-helpers.ts +49 -0
  103. package/src/monitoring.ts +10 -0
  104. package/src/vector-cortex/heal/_acceptance-fixture.ts +108 -0
  105. package/src/vector-cortex/heal/closure-metrics.ts +73 -0
  106. package/src/vector-cortex/heal/closure-opt.ts +266 -0
  107. package/src/vector-cortex/heal/emit.ts +93 -0
  108. package/src/vector-cortex/heal/proof.ts +234 -0
  109. package/src/vector-cortex/heal/types.ts +226 -0
  110. package/src/vectorStore/add-l0.ts +152 -0
  111. package/src/vectorStore/add-l1.ts +57 -0
  112. package/src/vectorStore/add.ts +269 -0
  113. package/src/vectorStore/class.ts +17 -327
  114. package/src/vectorStore/dedup-audit.ts +199 -0
  115. package/src/vectorStore.ts +1 -0
  116. package/extensions/dashboard-client/dist/assets/VectorCortexTab-eHVt9yDx.js +0 -2
  117. 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
+ }
@@ -1,12 +1,4 @@
1
- /**
2
- * dashboard-server/routes-rag-settings-helpers.ts — SETTINGS inventory.
3
- *
4
- * The full catalog of user-adjustable MEGACOMPACT_* settings surfaced by the
5
- * dashboard Setup panel, grouped by category. Kept separate from the route
6
- * handler so the inventory can grow without bloating the handler file.
7
- *
8
- * PREVENT-011: no `any` type.
9
- */
1
+ import { VECTOR_CORTEX_SETTINGS } from "./routes-rag-settings-vector-cortex.js";
10
2
  // Shorthand builders to keep the inventory terse and unambiguous.
11
3
  const boolFlag = (key, label, description, def, requiresLlm = false) => ({
12
4
  key,
@@ -90,6 +82,7 @@ export const SETTINGS = [
90
82
  boolDirect("MEGACOMPACT_MARK_ONLY_L1", "Mark Only L1", "L1 runs but does not collapse", false),
91
83
  boolDirect("MEGACOMPACT_MARK_ONLY_L2", "Mark Only L2", "L2 runs but does not collapse", false),
92
84
  boolDirect("MEGACOMPACT_MINILM", "MiniLM Embedder", "Use MiniLM instead of trigram", false),
85
+ boolDirect("MEGACOMPACT_DEDUP_AUDIT", "Dedup Audit Trail", "Append one events.log line per tier decision (which layer collapsed a region, onto what, at what similarity) to tune the thresholds below. Pure instrumentation — dedup behavior is identical either way.", true),
93
86
  ],
94
87
  },
95
88
  {
@@ -131,29 +124,7 @@ export const SETTINGS = [
131
124
  num("MEGACOMPACT_EMBEDDING_CHARS_PER_TOKEN", "Embedding Chars per Token", "Estimated characters per token used for embedder chunking size", 4, 1, 32),
132
125
  ],
133
126
  },
134
- {
135
- name: "Vector Cortex",
136
- settings: [
137
- boolDirect("MEGACOMPACT_VC0A", "VC0A Baseline Observability", "Structured evaluation observer (MetricEventV1 + latency histogram). OFF = mode C, byte-identical to predecessor.", true),
138
- boolDirect("MEGACOMPACT_VC0B", "VC0B Replay Correctness", "ReplayCutV2 effective-cut (min of boundary-safe/commit/capture high-water + pair retreat + anchor floor) and M3 effective-cut-v2 migration. OFF = legacy capped replay, byte-identical.", true),
139
- boolDirect("MEGACOMPACT_VC1A", "VC1A Canonical Byte Events", "EventV2 byte-authority ledger codec (original bytes + SHA-256, strict UTF-8, derived NFC) and canonical validator (EVT_DIGEST_MISMATCH / EVT_UTF8_TAG_INVALID / EVT_DUPLICATE_ID). OFF = mode C, transcript codec unchanged, byte-identical.", true),
140
- boolDirect("MEGACOMPACT_VC1B", "VC1B Occurrence Ledger + Tool Identity", "Neutral occurrence ledger (LedgerReader/Writer/Admin + CompatJournalV1): per-session monotonic seq, tool result references one earlier call, uniqueness by (eventId,digest) only, and the M2 copy-validate-switch downgrade journal. OFF = mode C, ledger unwritten, byte-identical.", true),
141
- boolDirect("MEGACOMPACT_VC0C", "VC0C Live Safety Envelope", "TriadResult/Breaker live circuit breaker (60s window, 20 attempts, 30s cooldown, 3 probes, 5min healthy residence) + durable spool before provider invocation; manual reset clears cooldown but never evidence. OFF = mode C, unchanged transcript, byte-identical.", true),
142
- boolDirect("MEGACOMPACT_VC1C", "VC1C Cross-Language Conformance v2", "FixtureManifestV2 canonical manifest validator + DowngradeReport deterministic downgrade export + MinHashV2 exact big-integer signatures and the M4 copy/validate/switch minhash-v2 migration (seed table frozen, cross-language byte-exact). OFF = mode C, v1 sync dedup scan unchanged, byte-identical.", true),
143
- boolDirect("MEGACOMPACT_VC2A", "VC2A Offline Model Runtime", "ModelManifestV1 digest-before-load ONNX runtime (opset17/batch1/max512) + asset-free trigram demotion. Asset path assets/vector-cortex/encoder-v1 is immutable/digest-pinned. OFF = mode C, byte-identical to predecessor.", true),
144
- boolDirect("MEGACOMPACT_VC2B", "VC2B Multi-Head Encoder", "VectorSetV1 five L2-normalized heads (384/128/128/64/32) with head-calibration draft + asset-free trigram B (512d) and lexical C fallbacks, plus the per-head emit seam. OFF = mode C, no per-head vectors emitted, byte-identical predecessor.", true),
145
- boolDirect("MEGACOMPACT_VC2C", "VC2C Encoder Qualification + Calibration", "QualifiedEncoderV1/CalibrationV1: calibration fit on the calibration split only (held-out labels prohibited) + atomic selection across MODEL_ASSET and per-head EVALUATION thresholds (any field failure demotes all of A). OFF = mode C, no qualification/calibration selection, byte-identical predecessor.", true),
146
- boolDirect("MEGACOMPACT_VC3A", "VC3A Cortex Store", "Capability-gated derived cortex store (CortexReader/Writer/Admin + CortexRecordV1): additive, keyed (sourceHighWater, algorithmVersion, id), immutable records, deterministic generation rebuild + one root digest. OFF = mode C, no cortex records written, byte-identical predecessor.", true),
147
- boolDirect("MEGACOMPACT_VC3B", "VC3B Deterministic Topology", "Deterministic cortical topology (TopologyV1/EdgeV1): per-(source,head) top-k=16/head calibrated-threshold edges, stable score-desc/then-target-ID sort, dependency directed + contradiction symmetric paired records, one stable generation digest. OFF = mode C, no topology graph built/emitted, predecessor-precise topology view, byte-identical predecessor.", true),
148
- boolDirect("MEGACOMPACT_VC3C", "VC3C Topology Query + Router Invalidation", "TopologyQueryV1/RouterKeyV2 structured keys (length-delimited, unsigned-byte order, no prefix ambiguity), exact (session,generation) invalidation, stale-generation rejection (TOP_GENERATION_STALE), and the M6 router-generation-v2 copy/validate/switch migration. OFF = mode C, no structured router key / generation invalidation, byte-identical predecessor.", true),
149
- boolDirect("MEGACOMPACT_VC4A", "VC4A Dual-Tier Shards", "SemanticShardV1/ExactShardV1/ShardManifestV1: partition a session ONLY at complete EventV2 boundaries; exact shards preserve every tool call/result pair, anchor and invalid UTF-8 event as original bytes (pairs never split across exact shards); manifest enforces disjoint sorted ranges + complete protected-span coverage. OFF = mode C, exact anchors/current transcript only, byte-identical predecessor.", true),
150
- boolDirect("MEGACOMPACT_VC4B", "VC4B Residual Basis Parity", "Residual codec: orthonormal DCT-II basis + int16 block quantization + block-scoped exact correction stream + (9,6) Reed-Solomon parity shards with SHA-256 corruption detection; admission gates on encodedSize <= 95% of exact-compressed size. OFF = mode C, no residual artifact produced, byte-identical predecessor.", true),
151
- boolDirect("MEGACOMPACT_VC4C", "VC4C Reconstruction Fidelity", "Conservative closure + source-order assembly + reconstruction validator: recursively closes dependencies and whole tool pairs to a fixed point, resolves contradictions by retaining the later exact source resolution, assembles spans solely by source range, and rejects missing anchors / split pairs / digest mismatch / unresolved contradiction. Mandatory token estimate is content-only and handed unchanged to VC5A. OFF = mode C, no closure/validator, byte-identical predecessor (VC4B).", true),
152
- 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),
153
- 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),
154
- 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),
155
- ],
156
- },
127
+ VECTOR_CORTEX_SETTINGS,
157
128
  {
158
129
  name: "Cost API",
159
130
  settings: [
@@ -0,0 +1,11 @@
1
+ /**
2
+ * dashboard-server/routes-rag-settings-types.ts — SETTINGS inventory contract.
3
+ *
4
+ * The shared shapes the settings inventory is built from. Extracted so the
5
+ * inventory can be split across sibling files (helpers.ts + the per-area groups)
6
+ * without either side importing the other's data — contract-first, per
7
+ * docs/ENGINEERING_PRACTICES.md.
8
+ *
9
+ * PREVENT-011: no `any` type.
10
+ */
11
+ export {};
@@ -0,0 +1,44 @@
1
+ /**
2
+ * dashboard-server/routes-rag-settings-vector-cortex.ts — Vector Cortex SETTINGS.
3
+ *
4
+ * The VC0A..VC5C chain flag inventory, split out of routes-rag-settings-helpers.ts
5
+ * to keep that file under the 400-line extensions/ soft limit. Every VC flag is a
6
+ * user-visible dashboard toggle (never in EXCLUDED_SETTINGS) per the chain spec,
7
+ * and each carries the long description the Setup panel renders as help text.
8
+ *
9
+ * PREVENT-011: no `any` type.
10
+ */
11
+ const boolDirect = (key, label, description, def) => ({
12
+ key,
13
+ label,
14
+ description,
15
+ type: "boolean",
16
+ default: def,
17
+ disabledConvention: false,
18
+ requiresLlm: false,
19
+ });
20
+ /** The Vector Cortex chain flags, as one SETTINGS category. */
21
+ export const VECTOR_CORTEX_SETTINGS = {
22
+ name: "Vector Cortex",
23
+ settings: [
24
+ boolDirect("MEGACOMPACT_VC0A", "VC0A Baseline Observability", "Structured evaluation observer (MetricEventV1 + latency histogram). OFF = mode C, byte-identical to predecessor.", true),
25
+ boolDirect("MEGACOMPACT_VC0B", "VC0B Replay Correctness", "ReplayCutV2 effective-cut (min of boundary-safe/commit/capture high-water + pair retreat + anchor floor) and M3 effective-cut-v2 migration. OFF = legacy capped replay, byte-identical.", true),
26
+ boolDirect("MEGACOMPACT_VC1A", "VC1A Canonical Byte Events", "EventV2 byte-authority ledger codec (original bytes + SHA-256, strict UTF-8, derived NFC) and canonical validator (EVT_DIGEST_MISMATCH / EVT_UTF8_TAG_INVALID / EVT_DUPLICATE_ID). OFF = mode C, transcript codec unchanged, byte-identical.", true),
27
+ boolDirect("MEGACOMPACT_VC1B", "VC1B Occurrence Ledger + Tool Identity", "Neutral occurrence ledger (LedgerReader/Writer/Admin + CompatJournalV1): per-session monotonic seq, tool result references one earlier call, uniqueness by (eventId,digest) only, and the M2 copy-validate-switch downgrade journal. OFF = mode C, ledger unwritten, byte-identical.", true),
28
+ boolDirect("MEGACOMPACT_VC0C", "VC0C Live Safety Envelope", "TriadResult/Breaker live circuit breaker (60s window, 20 attempts, 30s cooldown, 3 probes, 5min healthy residence) + durable spool before provider invocation; manual reset clears cooldown but never evidence. OFF = mode C, unchanged transcript, byte-identical.", true),
29
+ boolDirect("MEGACOMPACT_VC1C", "VC1C Cross-Language Conformance v2", "FixtureManifestV2 canonical manifest validator + DowngradeReport deterministic downgrade export + MinHashV2 exact big-integer signatures and the M4 copy/validate/switch minhash-v2 migration (seed table frozen, cross-language byte-exact). OFF = mode C, v1 sync dedup scan unchanged, byte-identical.", true),
30
+ boolDirect("MEGACOMPACT_VC2A", "VC2A Offline Model Runtime", "ModelManifestV1 digest-before-load ONNX runtime (opset17/batch1/max512) + asset-free trigram demotion. Asset path assets/vector-cortex/encoder-v1 is immutable/digest-pinned. OFF = mode C, byte-identical to predecessor.", true),
31
+ boolDirect("MEGACOMPACT_VC2B", "VC2B Multi-Head Encoder", "VectorSetV1 five L2-normalized heads (384/128/128/64/32) with head-calibration draft + asset-free trigram B (512d) and lexical C fallbacks, plus the per-head emit seam. OFF = mode C, no per-head vectors emitted, byte-identical predecessor.", true),
32
+ boolDirect("MEGACOMPACT_VC2C", "VC2C Encoder Qualification + Calibration", "QualifiedEncoderV1/CalibrationV1: calibration fit on the calibration split only (held-out labels prohibited) + atomic selection across MODEL_ASSET and per-head EVALUATION thresholds (any field failure demotes all of A). OFF = mode C, no qualification/calibration selection, byte-identical predecessor.", true),
33
+ boolDirect("MEGACOMPACT_VC3A", "VC3A Cortex Store", "Capability-gated derived cortex store (CortexReader/Writer/Admin + CortexRecordV1): additive, keyed (sourceHighWater, algorithmVersion, id), immutable records, deterministic generation rebuild + one root digest. OFF = mode C, no cortex records written, byte-identical predecessor.", true),
34
+ boolDirect("MEGACOMPACT_VC3B", "VC3B Deterministic Topology", "Deterministic cortical topology (TopologyV1/EdgeV1): per-(source,head) top-k=16/head calibrated-threshold edges, stable score-desc/then-target-ID sort, dependency directed + contradiction symmetric paired records, one stable generation digest. OFF = mode C, no topology graph built/emitted, predecessor-precise topology view, byte-identical predecessor.", true),
35
+ boolDirect("MEGACOMPACT_VC3C", "VC3C Topology Query + Router Invalidation", "TopologyQueryV1/RouterKeyV2 structured keys (length-delimited, unsigned-byte order, no prefix ambiguity), exact (session,generation) invalidation, stale-generation rejection (TOP_GENERATION_STALE), and the M6 router-generation-v2 copy/validate/switch migration. OFF = mode C, no structured router key / generation invalidation, byte-identical predecessor.", true),
36
+ boolDirect("MEGACOMPACT_VC4A", "VC4A Dual-Tier Shards", "SemanticShardV1/ExactShardV1/ShardManifestV1: partition a session ONLY at complete EventV2 boundaries; exact shards preserve every tool call/result pair, anchor and invalid UTF-8 event as original bytes (pairs never split across exact shards); manifest enforces disjoint sorted ranges + complete protected-span coverage. OFF = mode C, exact anchors/current transcript only, byte-identical predecessor.", true),
37
+ boolDirect("MEGACOMPACT_VC4B", "VC4B Residual Basis Parity", "Residual codec: orthonormal DCT-II basis + int16 block quantization + block-scoped exact correction stream + (9,6) Reed-Solomon parity shards with SHA-256 corruption detection; admission gates on encodedSize <= 95% of exact-compressed size. OFF = mode C, no residual artifact produced, byte-identical predecessor.", true),
38
+ boolDirect("MEGACOMPACT_VC4C", "VC4C Reconstruction Fidelity", "Conservative closure + source-order assembly + reconstruction validator: recursively closes dependencies and whole tool pairs to a fixed point, resolves contradictions by retaining the later exact source resolution, assembles spans solely by source range, and rejects missing anchors / split pairs / digest mismatch / unresolved contradiction. Mandatory token estimate is content-only and handed unchanged to VC5A. OFF = mode C, no closure/validator, byte-identical predecessor (VC4B).", true),
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
+ 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
+ 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),
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
  });
@@ -69,6 +69,7 @@ export function loadDedupConfig() {
69
69
  RAPTOR_MAX_LEAF_EXPANSION: envNum("MEGACOMPACT_RAPTOR_MAX_LEAF_EXP", 10),
70
70
  RAPTOR_FRESHNESS_HOURS: envNum("MEGACOMPACT_RAPTOR_FRESHNESS_HOURS", 4),
71
71
  RAPTOR_INJECT_SUMMARIES: envBool("MEGACOMPACT_RAPTOR_INJECT_SUMMARIES", true),
72
+ DEDUP_AUDIT: envBool("MEGACOMPACT_DEDUP_AUDIT", true),
72
73
  FP_RATE_L0: envNum("MEGACOMPACT_FP_RATE_L0", 0.01),
73
74
  FP_RATE_L1L2: envNum("MEGACOMPACT_FP_RATE_L1L2", 0.05),
74
75
  ALERT_WINDOW_MS: envNum("MEGACOMPACT_ALERT_WINDOW_MS", 600_000),
@@ -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,43 @@
1
+ /**
2
+ * dedup-audit.test-helpers.ts — shared harness for the dedup audit trail tests.
3
+ *
4
+ * Extracted so dedup-audit.test.ts and dedup-audit-gating.test.ts share one
5
+ * temp-dir lifecycle and one events.log reader instead of duplicating them, and
6
+ * so each test file stays under the 300-line src/ soft limit.
7
+ *
8
+ * Hermetic: every store gets its own temp state dir, so no test can observe
9
+ * another's audit lines. No network (PREVENT-PI-004).
10
+ */
11
+ import { mkdtempSync, readFileSync, writeFileSync, existsSync } from "node:fs";
12
+ import { tmpdir } from "node:os";
13
+ import { join } from "node:path";
14
+ import { loadDedupConfig } from "./config/dedup.js";
15
+ import { defaultEventsPath } from "./monitoring.js";
16
+ /** Root temp dir shared by both audit test files (each run gets a subdir). */
17
+ export const baseTmp = mkdtempSync(join(tmpdir(), "mc-dedup-audit-"));
18
+ /** The live config with per-test overrides applied. */
19
+ export function cfg(over = {}) {
20
+ return { ...loadDedupConfig(), ...over };
21
+ }
22
+ let seq = 0;
23
+ /** A never-before-used state dir under `baseTmp`. */
24
+ export function freshDir() {
25
+ return join(baseTmp, `run-${seq++}-${Math.floor(performance.now() * 1000)}`);
26
+ }
27
+ /** Read every dedup_audit line from a store's default events.log. */
28
+ export function auditLines(stateDir) {
29
+ const path = defaultEventsPath(stateDir);
30
+ if (!existsSync(path))
31
+ return [];
32
+ return readFileSync(path, "utf-8")
33
+ .split("\n")
34
+ .filter((l) => l.trim())
35
+ .map((l) => JSON.parse(l))
36
+ .filter((e) => e.type === "dedup_audit");
37
+ }
38
+ /** A path whose parent directory can never be created: it sits under a FILE. */
39
+ export function unwritablePath() {
40
+ const blocker = join(baseTmp, `blocker-${seq++}`);
41
+ writeFileSync(blocker, "not a directory");
42
+ return join(blocker, "sub", "events.log");
43
+ }
@@ -142,3 +142,12 @@ export function logRecallQuality(path, ev) {
142
142
  /* best-effort — never break the extension */
143
143
  }
144
144
  }
145
+ // ---------------------------------------------------------------------------
146
+ // Dedup audit trail (external-audit item #2)
147
+ // ---------------------------------------------------------------------------
148
+ // The event shape and its append helper are DEFINED in vectorStore/dedup-audit.ts,
149
+ // co-located with the only recorder that emits them (this file already carries
150
+ // decision events + the metrics snapshot + FP alerting and must stay under its
151
+ // 300-line soft limit). Re-exported here so callers that treat monitoring.ts as
152
+ // the events.log barrel — including the dashboard SSE tail — keep one import.
153
+ export { logDedupAudit } from "./vectorStore/dedup-audit.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
+ }