pi-mega-compact 0.20.23 → 0.20.25

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 (138) hide show
  1. package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +2 -0
  2. package/dist/extensions/dashboard-server/routes-vector-cortex-crystals.js +6 -0
  3. package/dist/extensions/dashboard-server/routes-vector-cortex-diagnostics.js +6 -0
  4. package/dist/extensions/dashboard-server/routes-vector-cortex-economics.js +6 -0
  5. package/dist/extensions/dashboard-server/routes-vector-cortex-eval.js +2 -0
  6. package/dist/extensions/dashboard-server/routes-vector-cortex-heal.js +9 -0
  7. package/dist/extensions/dashboard-server/routes-vector-cortex-health.js +4 -0
  8. package/dist/extensions/dashboard-server/routes-vector-cortex-ledger.js +2 -0
  9. package/dist/extensions/dashboard-server/routes-vector-cortex-outcomes.js +10 -2
  10. package/dist/extensions/dashboard-server/routes-vector-cortex-plans.js +2 -0
  11. package/dist/extensions/dashboard-server/routes-vector-cortex-platform.js +13 -2
  12. package/dist/extensions/dashboard-server/routes-vector-cortex-policy.js +6 -0
  13. package/dist/extensions/dashboard-server/routes-vector-cortex-query.js +2 -0
  14. package/dist/extensions/dashboard-server/routes-vector-cortex-reconstruct.js +5 -0
  15. package/dist/extensions/dashboard-server/routes-vector-cortex-render.js +2 -0
  16. package/dist/extensions/dashboard-server/routes-vector-cortex-repair.js +5 -0
  17. package/dist/extensions/dashboard-server/routes-vector-cortex-residual.js +2 -0
  18. package/dist/extensions/dashboard-server/routes-vector-cortex-rollout.js +56 -3
  19. package/dist/extensions/dashboard-server/routes-vector-cortex-shards.js +5 -0
  20. package/dist/extensions/dashboard-server/routes-vector-cortex-topology.js +2 -0
  21. package/dist/extensions/dashboard-server/vc-status.js +17 -0
  22. package/dist/extensions/mega-events/agent-handlers/turnEndHandler/cacheStripe.js +15 -4
  23. package/dist/extensions/mega-events/context-handler/afterCompact.js +25 -6
  24. package/dist/extensions/mega-events/context-handler/dbMirrorAppend.js +35 -7
  25. package/dist/extensions/mega-events/context-handler/pipelineRun.js +17 -2
  26. package/dist/extensions/mega-events/context-handler/tailResult.js +45 -12
  27. package/dist/extensions/mega-events/register.js +17 -0
  28. package/dist/extensions/mega-pipeline/recall.js +11 -0
  29. package/dist/src/cache-stripe-impl.js +52 -214
  30. package/dist/src/cache-stripe-score.js +115 -0
  31. package/extensions/dashboard-client/dist/assets/{AreaChart-BzEedilo.js → AreaChart-DRErPez1.js} +2 -2
  32. package/extensions/dashboard-client/dist/assets/{AreaChart-BzEedilo.js.map → AreaChart-DRErPez1.js.map} +1 -1
  33. package/extensions/dashboard-client/dist/assets/{BarChart-CzAVg1_J.js → BarChart-Cwxel3M7.js} +2 -2
  34. package/extensions/dashboard-client/dist/assets/{BarChart-CzAVg1_J.js.map → BarChart-Cwxel3M7.js.map} +1 -1
  35. package/extensions/dashboard-client/dist/assets/{CacheTab-D2-rzTuX.js → CacheTab-D4j3vwFu.js} +2 -2
  36. package/extensions/dashboard-client/dist/assets/{CacheTab-D2-rzTuX.js.map → CacheTab-D4j3vwFu.js.map} +1 -1
  37. package/extensions/dashboard-client/dist/assets/{EventsTab-DB7g1Szy.js → EventsTab-BA7t_fsH.js} +2 -2
  38. package/extensions/dashboard-client/dist/assets/{EventsTab-DB7g1Szy.js.map → EventsTab-BA7t_fsH.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/{HealthTab-Cvkmi-R3.js → HealthTab-Ci9gtYDP.js} +2 -2
  40. package/extensions/dashboard-client/dist/assets/{HealthTab-Cvkmi-R3.js.map → HealthTab-Ci9gtYDP.js.map} +1 -1
  41. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-g_udcOO7.js → MaintenanceTab-BeqWn-xu.js} +2 -2
  42. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-g_udcOO7.js.map → MaintenanceTab-BeqWn-xu.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DAjBaf8P.js → MemoryMapTab-BreZegCV.js} +2 -2
  44. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DAjBaf8P.js.map → MemoryMapTab-BreZegCV.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{MetricsTab-13dYYocB.js → MetricsTab-DLbgfJT2.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{MetricsTab-13dYYocB.js.map → MetricsTab-DLbgfJT2.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{OverviewTab-CLpCyLvx.js → OverviewTab-BtcXdrnC.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{OverviewTab-CLpCyLvx.js.map → OverviewTab-BtcXdrnC.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{ReposTab-EdAqUrwG.js → ReposTab-DpDLEzV9.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{ReposTab-EdAqUrwG.js.map → ReposTab-DpDLEzV9.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/{SessionsTab-C21ZuOL_.js → SessionsTab-CMe5jSrZ.js} +2 -2
  52. package/extensions/dashboard-client/dist/assets/{SessionsTab-C21ZuOL_.js.map → SessionsTab-CMe5jSrZ.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/{SetupTab-CP7lE3L_.js → SetupTab-C3OY8mc7.js} +2 -2
  54. package/extensions/dashboard-client/dist/assets/{SetupTab-CP7lE3L_.js.map → SetupTab-C3OY8mc7.js.map} +1 -1
  55. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DZ3QR8qt.js → TimeSavedCard-BFPJUQzs.js} +2 -2
  56. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DZ3QR8qt.js.map → TimeSavedCard-BFPJUQzs.js.map} +1 -1
  57. package/extensions/dashboard-client/dist/assets/{TurnsTab-CNchE5rD.js → TurnsTab-Ujt29pKI.js} +2 -2
  58. package/extensions/dashboard-client/dist/assets/{TurnsTab-CNchE5rD.js.map → TurnsTab-Ujt29pKI.js.map} +1 -1
  59. package/extensions/dashboard-client/dist/assets/VectorCortexTab-CfxZW91A.js +2 -0
  60. package/extensions/dashboard-client/dist/assets/VectorCortexTab-CfxZW91A.js.map +1 -0
  61. package/extensions/dashboard-client/dist/assets/{WikiTab-BIe5Z9Nc.js → WikiTab-BiKXVwGT.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{WikiTab-BIe5Z9Nc.js.map → WikiTab-BiKXVwGT.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/assets/{button-BrVreSt5.js → button-DJwGcw0u.js} +2 -2
  64. package/extensions/dashboard-client/dist/assets/{button-BrVreSt5.js.map → button-DJwGcw0u.js.map} +1 -1
  65. package/extensions/dashboard-client/dist/assets/{card-D9F4wbqs.js → card-CgjBf5LZ.js} +2 -2
  66. package/extensions/dashboard-client/dist/assets/{card-D9F4wbqs.js.map → card-CgjBf5LZ.js.map} +1 -1
  67. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-mkdzCnMP.js → generateCategoricalChart-CTQIl2qs.js} +2 -2
  68. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-mkdzCnMP.js.map → generateCategoricalChart-CTQIl2qs.js.map} +1 -1
  69. package/extensions/dashboard-client/dist/assets/{index-CtlmOlj1.js → index-Bu8CZUMX.js} +3 -3
  70. package/extensions/dashboard-client/dist/assets/{index-CtlmOlj1.js.map → index-Bu8CZUMX.js.map} +1 -1
  71. package/extensions/dashboard-client/dist/assets/{switch-BXmp5iwA.js → switch-uUiS1Raq.js} +2 -2
  72. package/extensions/dashboard-client/dist/assets/{switch-BXmp5iwA.js.map → switch-uUiS1Raq.js.map} +1 -1
  73. package/extensions/dashboard-client/dist/assets/{toggle-BgawNwW9.js → toggle-Dv3OEscH.js} +2 -2
  74. package/extensions/dashboard-client/dist/assets/{toggle-BgawNwW9.js.map → toggle-Dv3OEscH.js.map} +1 -1
  75. package/extensions/dashboard-client/dist/assets/{useSSE-DZKX73Ea.js → useSSE-n6ymAic3.js} +2 -2
  76. package/extensions/dashboard-client/dist/assets/{useSSE-DZKX73Ea.js.map → useSSE-n6ymAic3.js.map} +1 -1
  77. package/extensions/dashboard-client/dist/index.html +1 -1
  78. package/extensions/dashboard-client/src/tabs/VcStatusBadge.tsx +24 -0
  79. package/extensions/dashboard-client/src/tabs/VectorCortexClosureCard.tsx +12 -6
  80. package/extensions/dashboard-client/src/tabs/VectorCortexCrystalsCard.tsx +12 -6
  81. package/extensions/dashboard-client/src/tabs/VectorCortexDiagnosticsCard.tsx +12 -6
  82. package/extensions/dashboard-client/src/tabs/VectorCortexEconomicsCard.tsx +12 -6
  83. package/extensions/dashboard-client/src/tabs/VectorCortexLedgerCard.tsx +12 -6
  84. package/extensions/dashboard-client/src/tabs/VectorCortexOutcomesCard.tsx +12 -6
  85. package/extensions/dashboard-client/src/tabs/VectorCortexPlansCard.tsx +12 -6
  86. package/extensions/dashboard-client/src/tabs/VectorCortexPlatformCard.tsx +12 -6
  87. package/extensions/dashboard-client/src/tabs/VectorCortexPolicyCard.tsx +12 -6
  88. package/extensions/dashboard-client/src/tabs/VectorCortexRenderCard.tsx +12 -6
  89. package/extensions/dashboard-client/src/tabs/VectorCortexRepairCard.tsx +12 -6
  90. package/extensions/dashboard-client/src/tabs/VectorCortexRestoreCard.tsx +12 -6
  91. package/extensions/dashboard-client/src/tabs/VectorCortexRolloutCard.tsx +12 -6
  92. package/extensions/dashboard-client/src/tabs/VectorCortexShardsCard.tsx +23 -11
  93. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +5 -7
  94. package/extensions/dashboard-client/src/tabs/VectorCortexTopologyCard.tsx +28 -14
  95. package/extensions/dashboard-client/src/types/vector-cortex-vc7.ts +6 -0
  96. package/extensions/dashboard-client/src/types/vector-cortex-vc8.ts +6 -0
  97. package/extensions/dashboard-client/src/types/vector-cortex.ts +26 -0
  98. package/extensions/dashboard-server/api-contracts/vector-cortex-cache.ts +2 -0
  99. package/extensions/dashboard-server/api-contracts/vector-cortex-diagnostics.ts +2 -0
  100. package/extensions/dashboard-server/api-contracts/vector-cortex-economics.ts +2 -0
  101. package/extensions/dashboard-server/api-contracts/vector-cortex-heal.ts +6 -0
  102. package/extensions/dashboard-server/api-contracts/vector-cortex-outcomes.ts +2 -0
  103. package/extensions/dashboard-server/api-contracts/vector-cortex-platform.ts +2 -0
  104. package/extensions/dashboard-server/api-contracts/vector-cortex-policy.ts +2 -0
  105. package/extensions/dashboard-server/api-contracts/vector-cortex.ts +19 -0
  106. package/extensions/dashboard-server/routes-rag-settings-helpers.ts +12 -0
  107. package/extensions/dashboard-server/routes-vector-cortex-crystals.ts +6 -0
  108. package/extensions/dashboard-server/routes-vector-cortex-diagnostics.ts +6 -0
  109. package/extensions/dashboard-server/routes-vector-cortex-economics.ts +6 -0
  110. package/extensions/dashboard-server/routes-vector-cortex-eval.ts +2 -0
  111. package/extensions/dashboard-server/routes-vector-cortex-heal.ts +9 -0
  112. package/extensions/dashboard-server/routes-vector-cortex-health.ts +4 -0
  113. package/extensions/dashboard-server/routes-vector-cortex-ledger.ts +2 -0
  114. package/extensions/dashboard-server/routes-vector-cortex-outcomes.ts +11 -2
  115. package/extensions/dashboard-server/routes-vector-cortex-plans.ts +2 -0
  116. package/extensions/dashboard-server/routes-vector-cortex-platform.ts +14 -2
  117. package/extensions/dashboard-server/routes-vector-cortex-policy.ts +6 -0
  118. package/extensions/dashboard-server/routes-vector-cortex-query.ts +2 -0
  119. package/extensions/dashboard-server/routes-vector-cortex-reconstruct.ts +5 -0
  120. package/extensions/dashboard-server/routes-vector-cortex-render.ts +2 -0
  121. package/extensions/dashboard-server/routes-vector-cortex-repair.ts +5 -0
  122. package/extensions/dashboard-server/routes-vector-cortex-residual.ts +2 -0
  123. package/extensions/dashboard-server/routes-vector-cortex-rollout.ts +58 -3
  124. package/extensions/dashboard-server/routes-vector-cortex-shards.ts +5 -0
  125. package/extensions/dashboard-server/routes-vector-cortex-topology.ts +2 -0
  126. package/extensions/dashboard-server/vc-status.ts +22 -0
  127. package/extensions/mega-events/agent-handlers/turnEndHandler/cacheStripe.ts +13 -4
  128. package/extensions/mega-events/context-handler/afterCompact.ts +25 -6
  129. package/extensions/mega-events/context-handler/dbMirrorAppend.ts +39 -7
  130. package/extensions/mega-events/context-handler/pipelineRun.ts +18 -3
  131. package/extensions/mega-events/context-handler/tailResult.ts +56 -15
  132. package/extensions/mega-events/register.ts +14 -1
  133. package/extensions/mega-pipeline/recall.ts +10 -0
  134. package/package.json +1 -1
  135. package/src/cache-stripe-impl.ts +73 -277
  136. package/src/cache-stripe-score.ts +170 -0
  137. package/extensions/dashboard-client/dist/assets/VectorCortexTab-B3WuPeyn.js +0 -2
  138. package/extensions/dashboard-client/dist/assets/VectorCortexTab-B3WuPeyn.js.map +0 -1
@@ -50,6 +50,8 @@ export const SETTINGS = [
50
50
  boolFlag("MEGACOMPACT_MEMORY_GRAPH", "Memory Graph", "Dashboard-oriented memory graph traversal", true),
51
51
  boolFlag("MEGACOMPACT_HYDE", "HyDE", "Generate hypothetical answer via LLM, embed it, RRF-fuse", true, true),
52
52
  boolFlag("MEGACOMPACT_NEW_UI", "New Dashboard UI", "Tailwind + shadcn visual design (sidebar, glass panels)", true),
53
+ boolDirect("MEGACOMPACT_MESSAGE_SEPARATION", "Message Separation (P2)", "PLAN_V2: split conversation thread from tool results to grow stable cache prefix", false),
54
+ boolDirect("MEGACOMPACT_CACHE_STRIPING", "Cache Striping (P3)", "PLAN_V2: order stable context by stability score so durable chunks lead the prompt", false),
53
55
  ],
54
56
  },
55
57
  {
@@ -26,6 +26,7 @@
26
26
  import { VC7A_ENABLED } from "../../src/config.js";
27
27
  import { sendJson } from "./routes-vector-cortex-shared.js";
28
28
  import { countVcEvents, vcCount } from "./vc-event-counts.js";
29
+ import { deriveVcStatus } from "./vc-status.js";
29
30
  // Actual events emitted by src/vector-cortex/cache/crystal-emit.ts.
30
31
  const CRYSTAL_EVENTS = [
31
32
  "vector_cortex_crystal_written",
@@ -67,6 +68,11 @@ export function handleVectorCortexCrystals(req, res, ctx) {
67
68
  lastFailure: null,
68
69
  updatedAt: new Date().toISOString(),
69
70
  deferredReason: "crystal_store_not_instantiated_v0_20_23",
71
+ status: deriveVcStatus({
72
+ enabled,
73
+ deferredReason: "crystal_store_not_instantiated_v0_20_23",
74
+ hasData: vcCount(counts, "vector_cortex_crystal_written") > 0,
75
+ }),
70
76
  };
71
77
  sendJson(res, 200, body);
72
78
  return true;
@@ -28,6 +28,7 @@
28
28
  import { VC7C_ENABLED } from "../../src/config.js";
29
29
  import { sendJson } from "./routes-vector-cortex-shared.js";
30
30
  import { countVcEvents, vcCount } from "./vc-event-counts.js";
31
+ import { deriveVcStatus } from "./vc-status.js";
31
32
  // Actual events emitted by src/vector-cortex/cache/diagnostics-emit.ts.
32
33
  const DIAGNOSTICS_EVENTS = ["vector_cortex_cache_serve_blocked"];
33
34
  /**
@@ -67,6 +68,11 @@ export function handleVectorCortexDiagnostics(req, res, ctx) {
67
68
  lastFailure: null,
68
69
  updatedAt: new Date().toISOString(),
69
70
  deferredReason: "cache_classifier_not_wired_v0_20_23",
71
+ status: deriveVcStatus({
72
+ enabled,
73
+ deferredReason: "cache_classifier_not_wired_v0_20_23",
74
+ hasData: vcCount(counts, "vector_cortex_cache_serve_blocked") > 0,
75
+ }),
70
76
  };
71
77
  sendJson(res, 200, body);
72
78
  return true;
@@ -24,6 +24,7 @@
24
24
  */
25
25
  import { VC7B_ENABLED } from "../../src/config.js";
26
26
  import { sendJson } from "./routes-vector-cortex-shared.js";
27
+ import { deriveVcStatus } from "./vc-status.js";
27
28
  /**
28
29
  * Reader-only GET /api/vector-cortex/cache-economics (VC7B).
29
30
  *
@@ -54,6 +55,11 @@ export function handleVectorCortexEconomics(req, res, _ctx) {
54
55
  lastFailure: null,
55
56
  updatedAt: new Date().toISOString(),
56
57
  deferredReason: "economics_not_computed_v0_20_23",
58
+ status: deriveVcStatus({
59
+ enabled,
60
+ deferredReason: "economics_not_computed_v0_20_23",
61
+ hasData: false,
62
+ }),
57
63
  };
58
64
  sendJson(res, 200, body);
59
65
  return true;
@@ -13,6 +13,7 @@ import { VC0A_ENABLED } from "../../src/config.js";
13
13
  import { readEvalRows } from "../../src/vector-cortex/eval/persist.js";
14
14
  import { summarizeEvalRows } from "../../src/vector-cortex/eval/reader.js";
15
15
  import { sendJson } from "./routes-vector-cortex-shared.js";
16
+ import { deriveVcStatus } from "./vc-status.js";
16
17
  /** Reader-only aggregate GET /api/vector-cortex/evaluation. */
17
18
  export function handleVectorCortexEvaluation(req, res, ctx) {
18
19
  const url = req.url ?? "";
@@ -43,6 +44,7 @@ export function handleVectorCortexEvaluation(req, res, ctx) {
43
44
  },
44
45
  rejects: [], // VC0C wires live breaker/reject telemetry here
45
46
  updatedAt: new Date().toISOString(),
47
+ status: deriveVcStatus({ enabled, hasData: summary.samples > 0 }),
46
48
  };
47
49
  sendJson(res, 200, body);
48
50
  return true;
@@ -22,6 +22,7 @@
22
22
  import { VC6A_ENABLED, VC6B_ENABLED } from "../../src/config.js";
23
23
  import { sendJson } from "./routes-vector-cortex-shared.js";
24
24
  import { countVcEvents, vcCount } from "./vc-event-counts.js";
25
+ import { deriveVcStatus } from "./vc-status.js";
25
26
  // Actual event names emitted by src/vector-cortex/heal/emit.ts + restore-emit.ts.
26
27
  const CLOSURE_EVENTS = [
27
28
  "vector_cortex_closure_optimized",
@@ -56,6 +57,10 @@ export function handleVectorCortexClosureProof(req, res, ctx) {
56
57
  optimizedTraversalTotal: 0,
57
58
  lastRejection: null,
58
59
  updatedAt: new Date().toISOString(),
60
+ status: deriveVcStatus({
61
+ enabled,
62
+ hasData: vcCount(counts, "vector_cortex_closure_optimized") > 0,
63
+ }),
59
64
  };
60
65
  sendJson(res, 200, body);
61
66
  return true;
@@ -92,6 +97,10 @@ export function handleVectorCortexRestore(req, res, ctx) {
92
97
  digestRejections: vcCount(counts, "vector_cortex_restore_digest_rejected"),
93
98
  lastRejection: null,
94
99
  updatedAt: new Date().toISOString(),
100
+ status: deriveVcStatus({
101
+ enabled,
102
+ hasData: vcCount(counts, "vector_cortex_source_restored") > 0,
103
+ }),
95
104
  };
96
105
  sendJson(res, 200, body);
97
106
  return true;
@@ -16,6 +16,7 @@ import { VC0C_ENABLED, VC2C_ENABLED } from "../../src/config.js";
16
16
  import { createVectorCortexSafety } from "../mega-runtime/vector-cortex-safety.js";
17
17
  import { readEncoderManifest, verifyEncoderAsset, detectPlatform } from "../../src/vector-cortex/encoder/asset.js";
18
18
  import { sendJson, readJsonBody } from "./routes-vector-cortex-shared.js";
19
+ import { deriveVcStatus } from "./vc-status.js";
19
20
  /** Resolve the committed encoder-v1 asset dir by walking up to the repo root. */
20
21
  function encoderAssetDir() {
21
22
  let dir = dirname(fileURLToPath(import.meta.url));
@@ -137,6 +138,7 @@ export function handleVectorCortexHealth(req, res, ctx) {
137
138
  stateSource: "ephemeral",
138
139
  encoderAssetDigest: enc.assetDigest,
139
140
  encoderMode: enc.mode,
141
+ status: deriveVcStatus({ enabled: false, hasData: false }),
140
142
  };
141
143
  if (!card) {
142
144
  sendJson(res, 200, fallback);
@@ -174,6 +176,7 @@ export function handleVectorCortexHealth(req, res, ctx) {
174
176
  stateSource: card.stateSource,
175
177
  encoderAssetDigest: enc.assetDigest,
176
178
  encoderMode: enc.mode,
179
+ status: deriveVcStatus({ enabled, hasData: true, structuralOnly: true }),
177
180
  };
178
181
  sendJson(res, 200, body);
179
182
  return true;
@@ -222,6 +225,7 @@ export function handleVectorCortexBreakersReset(req, res, ctx) {
222
225
  probeCount: rec.probeCount,
223
226
  manualReason: rec.manualReason,
224
227
  updatedAt: rec.updatedAt,
228
+ status: deriveVcStatus({ enabled: true, hasData: true }),
225
229
  };
226
230
  sendJson(res, 200, body);
227
231
  }
@@ -14,6 +14,7 @@
14
14
  import { VC1B_ENABLED } from "../../src/config.js";
15
15
  import { createLedgerStore } from "../../src/vector-cortex/ledger/store.js";
16
16
  import { sendJson } from "./routes-vector-cortex-shared.js";
17
+ import { deriveVcStatus } from "./vc-status.js";
17
18
  /**
18
19
  * Reader-only GET /api/vector-cortex/ledger (VC1B).
19
20
  */
@@ -76,6 +77,7 @@ export function handleVectorCortexLedger(req, res, ctx) {
76
77
  count,
77
78
  occurrences,
78
79
  updatedAt: new Date().toISOString(),
80
+ status: deriveVcStatus({ enabled: active, hasData: count > 0 }),
79
81
  };
80
82
  sendJson(res, 200, body);
81
83
  return true;
@@ -18,11 +18,16 @@
18
18
  */
19
19
  import { VC8A_ENABLED } from "../../src/config.js";
20
20
  import { sendJson, readJsonBody } from "./routes-vector-cortex-shared.js";
21
+ import { countVcEvents, vcCount } from "./vc-event-counts.js";
22
+ import { deriveVcStatus } from "./vc-status.js";
23
+ // Actual events emitted by src/vector-cortex/outcomes/* — the outcome append is
24
+ // the sole aggregate signal (consent grants/revokes are not emitted as events).
25
+ const OUTCOME_EVENTS = ["vector_cortex_outcome_appended"];
21
26
  /**
22
27
  * GET /api/vector-cortex/outcomes — reader-only outcomes aggregate (VC8A).
23
28
  * POST /api/vector-cortex/outcomes/consent — audited consent admin API.
24
29
  */
25
- export function handleVectorCortexOutcomes(req, res, _ctx) {
30
+ export function handleVectorCortexOutcomes(req, res, ctx) {
26
31
  const url = req.url ?? "";
27
32
  const path = url.split("?")[0] ?? url;
28
33
  if (path === "/api/vector-cortex/outcomes/consent") {
@@ -62,17 +67,20 @@ export function handleVectorCortexOutcomes(req, res, _ctx) {
62
67
  return true;
63
68
  }
64
69
  const enabled = VC8A_ENABLED();
70
+ const counts = countVcEvents(ctx.stateDir, OUTCOME_EVENTS);
71
+ const outcomeCount = vcCount(counts, "vector_cortex_outcome_appended");
65
72
  const mode = enabled ? "A" : "C";
66
73
  const body = {
67
74
  enabled,
68
75
  mode,
69
- outcomeCount: 0,
76
+ outcomeCount,
70
77
  consentedSessions: 0,
71
78
  revokedSessions: 0,
72
79
  manifestCount: 0,
73
80
  excludedCount: 0,
74
81
  lastFailure: null,
75
82
  updatedAt: new Date().toISOString(),
83
+ status: deriveVcStatus({ enabled, hasData: outcomeCount > 0 }),
76
84
  };
77
85
  sendJson(res, 200, body);
78
86
  return true;
@@ -23,6 +23,7 @@ import { VC5A_ENABLED } from "../../src/config.js";
23
23
  import { DAG_IDS } from "../../src/vector-cortex/prompt-dag/types.js";
24
24
  import { PLN_IDS } from "../../src/vector-cortex/planner/types.js";
25
25
  import { sendJson } from "./routes-vector-cortex-shared.js";
26
+ import { deriveVcStatus } from "./vc-status.js";
26
27
  /**
27
28
  * Reader-only GET /api/vector-cortex/plans (VC5A).
28
29
  */
@@ -43,6 +44,7 @@ export function handleVectorCortexPlans(req, res, _ctx) {
43
44
  plannerCount: enabled ? PLN_IDS.length : 0,
44
45
  plans: [],
45
46
  updatedAt: new Date().toISOString(),
47
+ status: deriveVcStatus({ enabled, hasData: true, structuralOnly: true }),
46
48
  };
47
49
  sendJson(res, 200, body);
48
50
  return true;
@@ -15,8 +15,16 @@
15
15
  */
16
16
  import { VC8C_ENABLED } from "../../src/config.js";
17
17
  import { sendJson } from "./routes-vector-cortex-shared.js";
18
+ import { countVcEvents, vcCount } from "./vc-event-counts.js";
19
+ import { deriveVcStatus } from "./vc-status.js";
20
+ // Actual events emitted by src/vector-cortex/platform/* — a parity run checks
21
+ // fixtures and a demotion records an engine-selection downgrade.
22
+ const PLATFORM_EVENTS = [
23
+ "vector_cortex_engine_parity_checked",
24
+ "vector_cortex_engine_selection_demoted",
25
+ ];
18
26
  /** GET /api/vector-cortex/platform — reader-only engine parity/selection aggregate (VC8C). */
19
- export function handleVectorCortexPlatform(req, res, _ctx) {
27
+ export function handleVectorCortexPlatform(req, res, ctx) {
20
28
  const url = req.url ?? "";
21
29
  const path = url.split("?")[0] ?? url;
22
30
  if (path !== "/api/vector-cortex/platform")
@@ -26,16 +34,19 @@ export function handleVectorCortexPlatform(req, res, _ctx) {
26
34
  return true;
27
35
  }
28
36
  const enabled = VC8C_ENABLED();
37
+ const counts = countVcEvents(ctx.stateDir, PLATFORM_EVENTS);
29
38
  const mode = enabled ? "A" : "C";
39
+ const fixtureCount = vcCount(counts, "vector_cortex_engine_parity_checked");
30
40
  const body = {
31
41
  enabled,
32
42
  mode,
33
- fixtureCount: 0,
43
+ fixtureCount,
34
44
  passed: 0,
35
45
  failed: 0,
36
46
  externalRunnerConfigured: process.env.MEGACOMPACT_RUST_RUNNER !== undefined,
37
47
  lastFailure: null,
38
48
  updatedAt: new Date().toISOString(),
49
+ status: deriveVcStatus({ enabled, hasData: fixtureCount > 0 }),
39
50
  };
40
51
  sendJson(res, 200, body);
41
52
  return true;
@@ -17,6 +17,7 @@
17
17
  */
18
18
  import { VC8B_ENABLED } from "../../src/config.js";
19
19
  import { sendJson } from "./routes-vector-cortex-shared.js";
20
+ import { deriveVcStatus } from "./vc-status.js";
20
21
  /** GET /api/vector-cortex/policy — reader-only policy + shadow aggregate (VC8B). */
21
22
  export function handleVectorCortexPolicy(req, res, _ctx) {
22
23
  const url = req.url ?? "";
@@ -40,6 +41,11 @@ export function handleVectorCortexPolicy(req, res, _ctx) {
40
41
  lastFailure: null,
41
42
  updatedAt: new Date().toISOString(),
42
43
  deferredReason: "shadow_controller_not_instantiated_v0_20_23",
44
+ status: deriveVcStatus({
45
+ enabled,
46
+ deferredReason: "shadow_controller_not_instantiated_v0_20_23",
47
+ hasData: false,
48
+ }),
43
49
  };
44
50
  sendJson(res, 200, body);
45
51
  return true;
@@ -15,6 +15,7 @@
15
15
  import { VC3C_ENABLED } from "../../src/config.js";
16
16
  import { ROUTER_KEY_VERSION } from "../../src/vector-cortex/topology/query.js";
17
17
  import { sendJson } from "./routes-vector-cortex-shared.js";
18
+ import { deriveVcStatus } from "./vc-status.js";
18
19
  /**
19
20
  * Reader-only GET /api/vector-cortex/query (VC3C query-layer diagnostics).
20
21
  */
@@ -40,6 +41,7 @@ export function handleVectorCortexQuery(req, res, _ctx) {
40
41
  enabled,
41
42
  routerVersion: ROUTER_KEY_VERSION,
42
43
  updatedAt: new Date().toISOString(),
44
+ status: deriveVcStatus({ enabled, hasData: true, structuralOnly: true }),
43
45
  };
44
46
  sendJson(res, 200, body);
45
47
  return true;
@@ -9,6 +9,7 @@
9
9
  import { VC4C_ENABLED } from "../../src/config.js";
10
10
  import { sendJson } from "./routes-vector-cortex-shared.js";
11
11
  import { countVcEvents, vcCount } from "./vc-event-counts.js";
12
+ import { deriveVcStatus } from "./vc-status.js";
12
13
  // Closure attempt/rejection events emitted by src/vector-cortex/heal/emit.ts.
13
14
  const RECONSTRUCT_EVENTS = [
14
15
  "vector_cortex_closure_optimized",
@@ -34,6 +35,10 @@ export function handleVectorCortexReconstruct(req, res, ctx) {
34
35
  spanTotal: 0,
35
36
  byteTotal: 0,
36
37
  updatedAt: new Date().toISOString(),
38
+ status: deriveVcStatus({
39
+ enabled,
40
+ hasData: vcCount(counts, "vector_cortex_closure_optimized") > 0,
41
+ }),
37
42
  };
38
43
  sendJson(res, 200, body);
39
44
  return true;
@@ -17,6 +17,7 @@ import { REN_IDS } from "../../src/vector-cortex/render/types.js";
17
17
  import { PRO_IDS } from "../../src/vector-cortex/provider/types.js";
18
18
  import { KNOWN_PROVIDER_KEYS } from "../../src/vector-cortex/provider/registry.js";
19
19
  import { sendJson } from "./routes-vector-cortex-shared.js";
20
+ import { deriveVcStatus } from "./vc-status.js";
20
21
  /** Reader-only GET /api/vector-cortex/render (VC5B). */
21
22
  export function handleVectorCortexRender(req, res, _ctx) {
22
23
  const url = req.url ?? "";
@@ -34,6 +35,7 @@ export function handleVectorCortexRender(req, res, _ctx) {
34
35
  providerCount: enabled ? PRO_IDS.length : 0,
35
36
  knownProfiles: enabled ? KNOWN_PROVIDER_KEYS : [],
36
37
  updatedAt: new Date().toISOString(),
38
+ status: deriveVcStatus({ enabled, hasData: true, structuralOnly: true }),
37
39
  };
38
40
  sendJson(res, 200, body);
39
41
  return true;
@@ -23,6 +23,7 @@
23
23
  import { VC6C_ENABLED } from "../../src/config.js";
24
24
  import { sendJson } from "./routes-vector-cortex-shared.js";
25
25
  import { countVcEvents, vcCount } from "./vc-event-counts.js";
26
+ import { deriveVcStatus } from "./vc-status.js";
26
27
  // Actual event names emitted by src/vector-cortex/heal/repair-emit.ts.
27
28
  const REPAIR_EVENTS = [
28
29
  "vector_cortex_repair_planned",
@@ -65,6 +66,10 @@ export function handleVectorCortexRepair(req, res, ctx) {
65
66
  lastBackoffMs: null,
66
67
  lastFailure: null,
67
68
  updatedAt: new Date().toISOString(),
69
+ status: deriveVcStatus({
70
+ enabled,
71
+ hasData: vcCount(counts, "vector_cortex_repair_planned") > 0,
72
+ }),
68
73
  };
69
74
  sendJson(res, 200, body);
70
75
  return true;
@@ -20,6 +20,7 @@
20
20
  */
21
21
  import { VC4B_ENABLED } from "../../src/config.js";
22
22
  import { sendJson } from "./routes-vector-cortex-shared.js";
23
+ import { deriveVcStatus } from "./vc-status.js";
23
24
  /**
24
25
  * Reader-only GET /api/vector-cortex/residual (VC4B).
25
26
  */
@@ -45,6 +46,7 @@ export function handleVectorCortexResidual(req, res, _ctx) {
45
46
  encodedByteTotal: 0,
46
47
  exactByteTotal: 0,
47
48
  updatedAt: new Date().toISOString(),
49
+ status: deriveVcStatus({ enabled, hasData: false, structuralOnly: true }),
48
50
  };
49
51
  sendJson(res, 200, body);
50
52
  return true;
@@ -11,11 +11,22 @@
11
11
  * Guardrails: PREVENT-PI-004 (local in-process state only), PREVENT-011 (no
12
12
  * `any`), reader-only aggregate (counts + gate state only).
13
13
  */
14
+ import { readFileSync } from "node:fs";
15
+ import { join } from "node:path";
14
16
  import { VC5C_ENABLED } from "../../src/config.js";
15
17
  import { ROLLOUT_GATES, ROLLOUT_BUCKETS } from "../../src/vector-cortex/rollout/types.js";
16
18
  import { sendJson } from "./routes-vector-cortex-shared.js";
19
+ import { countVcEvents, vcCount } from "./vc-event-counts.js";
20
+ import { deriveVcStatus } from "./vc-status.js";
21
+ // Rollout events: assigned/promotion-blocked from rollout/emit.ts, plus the
22
+ // explicit decision event appended by pipelineRun.ts:79 after decideLivePath.
23
+ const ROLLOUT_EVENTS = [
24
+ "vector_cortex_rollout_assigned",
25
+ "vector_cortex_rollout_promotion_blocked",
26
+ "vector_cortex_rollout_decision",
27
+ ];
17
28
  /** Reader-only GET /api/vector-cortex/rollout (VC5C). */
18
- export function handleVectorCortexRollout(req, res, _ctx) {
29
+ export function handleVectorCortexRollout(req, res, ctx) {
19
30
  const url = req.url ?? "";
20
31
  const path = url.split("?")[0] ?? url;
21
32
  if (path !== "/api/vector-cortex/rollout")
@@ -25,6 +36,11 @@ export function handleVectorCortexRollout(req, res, _ctx) {
25
36
  return true;
26
37
  }
27
38
  const enabled = VC5C_ENABLED();
39
+ const counts = countVcEvents(ctx.stateDir, ROLLOUT_EVENTS);
40
+ const eventCount = vcCount(counts, "vector_cortex_rollout_assigned") +
41
+ vcCount(counts, "vector_cortex_rollout_promotion_blocked") +
42
+ vcCount(counts, "vector_cortex_rollout_decision");
43
+ const sessionCount = enabled ? distinctRolloutSessions(ctx.stateDir) : 0;
28
44
  const gateIndex = 0; // Ephemeral rollout state: no durable gate in this sprint.
29
45
  const gatePct = ROLLOUT_GATES[gateIndex];
30
46
  const body = {
@@ -33,11 +49,48 @@ export function handleVectorCortexRollout(req, res, _ctx) {
33
49
  gatePct: enabled ? gatePct : 0,
34
50
  buckets: ROLLOUT_BUCKETS,
35
51
  bucketCount: enabled ? gatePct * 100 : 0,
36
- events: 0,
37
- sessions: 0,
52
+ events: enabled ? eventCount : 0,
53
+ sessions: enabled ? sessionCount : 0,
38
54
  promotionBlocked: false,
39
55
  updatedAt: new Date().toISOString(),
56
+ status: deriveVcStatus({ enabled, hasData: eventCount > 0 }),
40
57
  };
41
58
  sendJson(res, 200, body);
42
59
  return true;
43
60
  }
61
+ /**
62
+ * Count distinct session ids among rollout_assigned events in the tail of
63
+ * events.log. Best-effort: a missing/unreadable log or malformed lines yield 0.
64
+ * Only the `sessionId` field of rollout_assigned lines is inspected (aggregate
65
+ * only, never session payloads/prompts).
66
+ */
67
+ function distinctRolloutSessions(stateDir) {
68
+ const seen = new Set();
69
+ let raw;
70
+ try {
71
+ raw = readFileSync(join(stateDir, "events.log"), "utf-8");
72
+ }
73
+ catch {
74
+ return 0;
75
+ }
76
+ const lines = raw.split("\n");
77
+ const start = Math.max(0, lines.length - 10000);
78
+ for (let i = start; i < lines.length; i++) {
79
+ const line = lines[i];
80
+ if (line.length === 0)
81
+ continue;
82
+ let ev = null;
83
+ try {
84
+ ev = JSON.parse(line);
85
+ }
86
+ catch {
87
+ continue;
88
+ }
89
+ if (ev?.event === "vector_cortex_rollout_assigned" &&
90
+ typeof ev.sessionId === "string" &&
91
+ ev.sessionId.length > 0) {
92
+ seen.add(ev.sessionId);
93
+ }
94
+ }
95
+ return seen.size;
96
+ }
@@ -20,6 +20,7 @@
20
20
  import { VC4A_ENABLED } from "../../src/config.js";
21
21
  import { sendJson } from "./routes-vector-cortex-shared.js";
22
22
  import { countVcEvents, vcCount } from "./vc-event-counts.js";
23
+ import { deriveVcStatus } from "./vc-status.js";
23
24
  // Actual events emitted by src/vector-cortex/shards/manifest.ts. VC4A has no
24
25
  // per-tier (semantic/exact) write event — the manifest build is the single
25
26
  // shard-write signal — so semanticCount is wired to it and exactCount stays 0
@@ -50,6 +51,10 @@ export function handleVectorCortexShards(req, res, ctx) {
50
51
  byteTotal: 0,
51
52
  protectedByteTotal: 0,
52
53
  updatedAt: new Date().toISOString(),
54
+ status: deriveVcStatus({
55
+ enabled,
56
+ hasData: vcCount(counts, "vector_cortex_shard_manifest_built") > 0,
57
+ }),
53
58
  };
54
59
  sendJson(res, 200, body);
55
60
  return true;
@@ -26,6 +26,7 @@ import { Logger } from "../../src/log.js";
26
26
  import { createCortexStore } from "../../src/vector-cortex/cortex/store.js";
27
27
  import { buildTopologyGraph } from "../../src/vector-cortex/topology/index.js";
28
28
  import { sendJson } from "./routes-vector-cortex-shared.js";
29
+ import { deriveVcStatus } from "./vc-status.js";
29
30
  /** Well-known cortex record kind that carries a canonical candidate payload. */
30
31
  const TOPOLOGY_RECORD_KIND = "topology";
31
32
  /**
@@ -88,6 +89,7 @@ export function handleVectorCortexTopology(req, res, ctx) {
88
89
  ? { nodes, edges, generationDigest }
89
90
  : {}),
90
91
  updatedAt: new Date().toISOString(),
92
+ status: deriveVcStatus({ enabled: active, hasData: summary.recordCount > 0 }),
91
93
  };
92
94
  sendJson(res, 200, body);
93
95
  return true;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * dashboard-server/vc-status.ts — shared status derivation for Vector Cortex
3
+ * dashboard routes. Every VC route computes a status field so the client can
4
+ * show meaningful state (live / awaiting data / deferred / structural) instead
5
+ * of bare zeros.
6
+ *
7
+ * Guardrails: PREVENT-011 (no `any`).
8
+ */
9
+ export function deriveVcStatus(opts) {
10
+ if (!opts.enabled)
11
+ return "off";
12
+ if (opts.deferredReason)
13
+ return "deferred";
14
+ if (opts.structuralOnly)
15
+ return "structural";
16
+ return opts.hasData ? "live" : "awaiting_data";
17
+ }
@@ -10,12 +10,23 @@ export function cacheStripe(event, runtime, config) {
10
10
  const currentTurn = event.turnIndex;
11
11
  const embedder = defaultEmbedder();
12
12
  // (a) Extract text from the assistant's response for topic embedding.
13
+ // pi's assistant content may be a plain string OR an array of parts.
14
+ // Discriminate by type and only reach into `.text` after confirming the
15
+ // part is an object carrying a string `.text` — never assume shape.
13
16
  let textToEmbed = "";
14
17
  const msg = event.message;
15
- if (msg.role === "assistant" && Array.isArray(msg.content)) {
16
- for (const part of msg.content) {
17
- if ("text" in part && typeof part.text === "string") {
18
- textToEmbed += part.text + " ";
18
+ if (msg.role === "assistant") {
19
+ const c = msg.content;
20
+ if (typeof c === "string") {
21
+ textToEmbed = c;
22
+ }
23
+ else if (Array.isArray(c)) {
24
+ for (const part of c) {
25
+ if (part && typeof part === "object" && "text" in part) {
26
+ const t = part.text;
27
+ if (typeof t === "string")
28
+ textToEmbed += t + " ";
29
+ }
19
30
  }
20
31
  }
21
32
  }
@@ -23,9 +23,12 @@ import { VC6A_ENABLED, VC6C_ENABLED } from "../../../src/config/vector-cortex.js
23
23
  * topic model, and dedup — gated on dbMirror. Non-fatal end-to-end.
24
24
  */
25
25
  export async function persistEpochAndMaintain(runtime, config, ran) {
26
- // S27 DB-mirror: write checkpoint_epoch with deterministic nonce.
27
- // This makes the cache key stable across identical compactions.
28
- if (config.dbMirror) {
26
+ // PLAN_V2 cache-striping epoch row. buildCacheOptimizedPrompt's stripe
27
+ // lookup reads the most-recent checkpoint_epochs row, so emit it whenever
28
+ // PLAN_V2 flags are live. Separate from the legacy dbMirror block below so
29
+ // PLAN_V2 can run with dbMirror OFF (flag-on is a genuine additive; flag-OFF
30
+ // = byte-identical to the predecessor, since this block no-ops then).
31
+ if (config.dbMirror || config.messageSeparation || config.cacheStriping) {
29
32
  try {
30
33
  const db = openStore(runtime.currentStateDir);
31
34
  const cpId = ran.result.checkpointId ?? `epoch-${Date.now()}`;
@@ -40,11 +43,27 @@ export async function persistEpochAndMaintain(runtime, config, ran) {
40
43
  createdAt: Date.now(),
41
44
  };
42
45
  writeCheckpointEpoch(db, epoch);
46
+ }
47
+ catch (e) {
48
+ runtime.logger.warn("planv2-epoch-fail", { error: String(e) });
49
+ }
50
+ }
51
+ // S27 DB-mirror downstream: stamp turns, rebuild wiki, seed topics, dedup.
52
+ // Remains on `config.dbMirror` only — these are DB-mirror maintenance and
53
+ // must NOT run for PLAN_V2-only configurations.
54
+ if (config.dbMirror) {
55
+ try {
56
+ const db = openStore(runtime.currentStateDir);
57
+ const cpId = ran.result.checkpointId ?? `epoch-${Date.now()}`;
58
+ // epoch + writeCheckpointEpoch moved to the PLAN_V2 block above (it
59
+ // gates the wider set of flags); reuse epochIdFor(cpId) here so the
60
+ // stamps below land in the same epoch row.
61
+ const epochId = epochIdFor(cpId);
43
62
  // S50B: link this session's turns to the epoch that just compacted
44
63
  // them (compression-by-conversation-epoch metrics). Isolated-store
45
64
  // only; best-effort + non-fatal.
46
65
  try {
47
- stampTurnsEpochFor(config, runtime.rt.sessionId, epoch.epochId, runtime.currentStateDir);
66
+ stampTurnsEpochFor(config, runtime.rt.sessionId, epochId, runtime.currentStateDir);
48
67
  }
49
68
  catch {
50
69
  /* non-fatal: epoch stamping never breaks compaction */
@@ -218,9 +237,9 @@ export async function persistEpochAndMaintain(runtime, config, ran) {
218
237
  try {
219
238
  reportRepairPlanned((name, payload) => runtime.appendEvent(name, payload), {
220
239
  subsystem: "post_compact",
221
- generation: 1,
240
+ generation: runtime.rt.compactCount,
222
241
  backoffMs: 0,
223
- gapSize: 0,
242
+ gapSize: ran.result.compactedFrom,
224
243
  });
225
244
  }
226
245
  catch {