pi-mega-compact 0.20.4 → 0.20.6

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 (130) hide show
  1. package/dist/config/vector-cortex.js +24 -0
  2. package/dist/config.js +1 -1
  3. package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +2 -0
  4. package/dist/extensions/dashboard-server/routes-vector-cortex-render.js +40 -0
  5. package/dist/extensions/dashboard-server/routes-vector-cortex-rollout.js +43 -0
  6. package/dist/extensions/dashboard-server/routes-vector-cortex.js +2 -0
  7. package/dist/extensions/dashboard-server/routes.js +1 -1
  8. package/dist/extensions/dashboard-server/server.js +5 -1
  9. package/dist/extensions/mega-context/vector-cortex.js +128 -0
  10. package/dist/extensions/mega-runtime/vector-cortex-live.js +105 -0
  11. package/dist/src/config/vector-cortex.js +24 -0
  12. package/dist/src/config.js +1 -1
  13. package/dist/src/store/sqlite/global-sessions.js +16 -4
  14. package/dist/src/vector-cortex/provider/registry.js +112 -0
  15. package/dist/src/vector-cortex/provider/types.js +30 -0
  16. package/dist/src/vector-cortex/render/_acceptance-fixture.js +58 -0
  17. package/dist/src/vector-cortex/render/_acceptance-helpers.js +17 -0
  18. package/dist/src/vector-cortex/render/_acceptance-provider.js +29 -0
  19. package/dist/src/vector-cortex/render/_acceptance-scenario.js +259 -0
  20. package/dist/src/vector-cortex/render/renderer.js +119 -0
  21. package/dist/src/vector-cortex/render/types.js +29 -0
  22. package/dist/src/vector-cortex/render/validator.js +90 -0
  23. package/dist/src/vector-cortex/rollout/_acceptance-fixture.js +55 -0
  24. package/dist/src/vector-cortex/rollout/_acceptance-helpers.js +8 -0
  25. package/dist/src/vector-cortex/rollout/_acceptance-scenario.js +70 -0
  26. package/dist/src/vector-cortex/rollout/assign.js +56 -0
  27. package/dist/src/vector-cortex/rollout/emit.js +50 -0
  28. package/dist/src/vector-cortex/rollout/gate.js +75 -0
  29. package/dist/src/vector-cortex/rollout/types.js +39 -0
  30. package/dist/vector-cortex/provider/registry.js +112 -0
  31. package/dist/vector-cortex/provider/types.js +30 -0
  32. package/dist/vector-cortex/render/_acceptance-fixture.js +58 -0
  33. package/dist/vector-cortex/render/_acceptance-helpers.js +17 -0
  34. package/dist/vector-cortex/render/_acceptance-provider.js +29 -0
  35. package/dist/vector-cortex/render/_acceptance-scenario.js +259 -0
  36. package/dist/vector-cortex/render/renderer.js +119 -0
  37. package/dist/vector-cortex/render/types.js +29 -0
  38. package/dist/vector-cortex/render/validator.js +90 -0
  39. package/dist/vector-cortex/rollout/_acceptance-fixture.js +55 -0
  40. package/dist/vector-cortex/rollout/_acceptance-helpers.js +8 -0
  41. package/dist/vector-cortex/rollout/_acceptance-scenario.js +70 -0
  42. package/dist/vector-cortex/rollout/assign.js +56 -0
  43. package/dist/vector-cortex/rollout/emit.js +50 -0
  44. package/dist/vector-cortex/rollout/gate.js +75 -0
  45. package/dist/vector-cortex/rollout/types.js +39 -0
  46. package/extensions/dashboard-client/dist/assets/{AreaChart-Cam9-nhT.js → AreaChart-DqTbaSRA.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{AreaChart-Cam9-nhT.js.map → AreaChart-DqTbaSRA.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/{BarChart-DzIY8aM1.js → BarChart-BfNBeOvF.js} +2 -2
  49. package/extensions/dashboard-client/dist/assets/{BarChart-DzIY8aM1.js.map → BarChart-BfNBeOvF.js.map} +1 -1
  50. package/extensions/dashboard-client/dist/assets/{CacheTab-CKIiYsG_.js → CacheTab-C9SOMYB5.js} +2 -2
  51. package/extensions/dashboard-client/dist/assets/{CacheTab-CKIiYsG_.js.map → CacheTab-C9SOMYB5.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/{EventsTab-xaaBJLiK.js → EventsTab-GsMKP10_.js} +2 -2
  53. package/extensions/dashboard-client/dist/assets/{EventsTab-xaaBJLiK.js.map → EventsTab-GsMKP10_.js.map} +1 -1
  54. package/extensions/dashboard-client/dist/assets/{HealthTab-BGtUKOqG.js → HealthTab-DAOCXwRP.js} +2 -2
  55. package/extensions/dashboard-client/dist/assets/{HealthTab-BGtUKOqG.js.map → HealthTab-DAOCXwRP.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-ABgQnTZ9.js → MaintenanceTab-BtBeMkB5.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-ABgQnTZ9.js.map → MaintenanceTab-BtBeMkB5.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-ChR2GAN-.js → MemoryMapTab-DzndtgkZ.js} +2 -2
  59. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-ChR2GAN-.js.map → MemoryMapTab-DzndtgkZ.js.map} +1 -1
  60. package/extensions/dashboard-client/dist/assets/{MetricsTab-DdCLAgcR.js → MetricsTab-DyxJ4eb8.js} +2 -2
  61. package/extensions/dashboard-client/dist/assets/{MetricsTab-DdCLAgcR.js.map → MetricsTab-DyxJ4eb8.js.map} +1 -1
  62. package/extensions/dashboard-client/dist/assets/{OverviewTab-DtemzJt6.js → OverviewTab-DCiEdVWR.js} +2 -2
  63. package/extensions/dashboard-client/dist/assets/{OverviewTab-DtemzJt6.js.map → OverviewTab-DCiEdVWR.js.map} +1 -1
  64. package/extensions/dashboard-client/dist/assets/{ReposTab-B9mvD9Ep.js → ReposTab-B5SIqVHA.js} +2 -2
  65. package/extensions/dashboard-client/dist/assets/{ReposTab-B9mvD9Ep.js.map → ReposTab-B5SIqVHA.js.map} +1 -1
  66. package/extensions/dashboard-client/dist/assets/{SessionsTab-BcO38XLS.js → SessionsTab-DLWFJ9xI.js} +2 -2
  67. package/extensions/dashboard-client/dist/assets/{SessionsTab-BcO38XLS.js.map → SessionsTab-DLWFJ9xI.js.map} +1 -1
  68. package/extensions/dashboard-client/dist/assets/{SetupTab-D_TBNP09.js → SetupTab-CvGXZyej.js} +2 -2
  69. package/extensions/dashboard-client/dist/assets/{SetupTab-D_TBNP09.js.map → SetupTab-CvGXZyej.js.map} +1 -1
  70. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-TjHpbUOo.js → TimeSavedCard-wZuQGxLS.js} +2 -2
  71. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-TjHpbUOo.js.map → TimeSavedCard-wZuQGxLS.js.map} +1 -1
  72. package/extensions/dashboard-client/dist/assets/{TurnsTab-DprxndCF.js → TurnsTab-B7aOejch.js} +2 -2
  73. package/extensions/dashboard-client/dist/assets/{TurnsTab-DprxndCF.js.map → TurnsTab-B7aOejch.js.map} +1 -1
  74. package/extensions/dashboard-client/dist/assets/VectorCortexTab-eHVt9yDx.js +2 -0
  75. package/extensions/dashboard-client/dist/assets/VectorCortexTab-eHVt9yDx.js.map +1 -0
  76. package/extensions/dashboard-client/dist/assets/{WikiTab-OKgSo15G.js → WikiTab-DhWHjAtt.js} +2 -2
  77. package/extensions/dashboard-client/dist/assets/{WikiTab-OKgSo15G.js.map → WikiTab-DhWHjAtt.js.map} +1 -1
  78. package/extensions/dashboard-client/dist/assets/{button-D_Qz4q7L.js → button-BrC-W87h.js} +2 -2
  79. package/extensions/dashboard-client/dist/assets/{button-D_Qz4q7L.js.map → button-BrC-W87h.js.map} +1 -1
  80. package/extensions/dashboard-client/dist/assets/{card-CsI6Jm3p.js → card-0rgfRgr3.js} +2 -2
  81. package/extensions/dashboard-client/dist/assets/{card-CsI6Jm3p.js.map → card-0rgfRgr3.js.map} +1 -1
  82. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CvHKUdhX.js → generateCategoricalChart-DRresOQF.js} +2 -2
  83. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-CvHKUdhX.js.map → generateCategoricalChart-DRresOQF.js.map} +1 -1
  84. package/extensions/dashboard-client/dist/assets/{index-0Ye_un22.js → index-DohmtZWL.js} +3 -3
  85. package/extensions/dashboard-client/dist/assets/{index-0Ye_un22.js.map → index-DohmtZWL.js.map} +1 -1
  86. package/extensions/dashboard-client/dist/assets/{switch-VQEoJl8Q.js → switch-Bs8g_zB5.js} +2 -2
  87. package/extensions/dashboard-client/dist/assets/{switch-VQEoJl8Q.js.map → switch-Bs8g_zB5.js.map} +1 -1
  88. package/extensions/dashboard-client/dist/assets/{toggle-CAPm4HJo.js → toggle-DVVauIo8.js} +2 -2
  89. package/extensions/dashboard-client/dist/assets/{toggle-CAPm4HJo.js.map → toggle-DVVauIo8.js.map} +1 -1
  90. package/extensions/dashboard-client/dist/assets/{useSSE-pxsNTVkh.js → useSSE-DxH1PTAR.js} +2 -2
  91. package/extensions/dashboard-client/dist/assets/{useSSE-pxsNTVkh.js.map → useSSE-DxH1PTAR.js.map} +1 -1
  92. package/extensions/dashboard-client/dist/index.html +1 -1
  93. package/extensions/dashboard-client/src/api/vector-cortex.ts +18 -0
  94. package/extensions/dashboard-client/src/tabs/VectorCortexMetric.tsx +10 -0
  95. package/extensions/dashboard-client/src/tabs/VectorCortexPlansCard.tsx +39 -0
  96. package/extensions/dashboard-client/src/tabs/VectorCortexRenderCard.tsx +38 -0
  97. package/extensions/dashboard-client/src/tabs/VectorCortexRolloutCard.tsx +44 -0
  98. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +19 -38
  99. package/extensions/dashboard-client/src/types/vector-cortex.ts +26 -0
  100. package/extensions/dashboard-server/api-contracts/vector-cortex.ts +52 -1
  101. package/extensions/dashboard-server/routes-rag-settings-helpers.ts +12 -0
  102. package/extensions/dashboard-server/routes-vector-cortex-render.ts +49 -0
  103. package/extensions/dashboard-server/routes-vector-cortex-rollout.ts +52 -0
  104. package/extensions/dashboard-server/routes-vector-cortex.ts +2 -0
  105. package/extensions/dashboard-server/routes.ts +2 -0
  106. package/extensions/dashboard-server/server.ts +4 -0
  107. package/extensions/mega-context/vector-cortex.ts +163 -0
  108. package/extensions/mega-runtime/vector-cortex-live.ts +165 -0
  109. package/package.json +1 -1
  110. package/src/config/vector-cortex.ts +26 -0
  111. package/src/config.ts +2 -0
  112. package/src/store/sqlite/global-sessions.ts +14 -2
  113. package/src/vector-cortex/provider/registry.ts +137 -0
  114. package/src/vector-cortex/provider/types.ts +163 -0
  115. package/src/vector-cortex/render/_acceptance-fixture.ts +128 -0
  116. package/src/vector-cortex/render/_acceptance-helpers.ts +39 -0
  117. package/src/vector-cortex/render/_acceptance-provider.ts +45 -0
  118. package/src/vector-cortex/render/_acceptance-scenario.ts +319 -0
  119. package/src/vector-cortex/render/renderer.ts +142 -0
  120. package/src/vector-cortex/render/types.ts +174 -0
  121. package/src/vector-cortex/render/validator.ts +120 -0
  122. package/src/vector-cortex/rollout/_acceptance-fixture.ts +94 -0
  123. package/src/vector-cortex/rollout/_acceptance-helpers.ts +24 -0
  124. package/src/vector-cortex/rollout/_acceptance-scenario.ts +96 -0
  125. package/src/vector-cortex/rollout/assign.ts +67 -0
  126. package/src/vector-cortex/rollout/emit.ts +81 -0
  127. package/src/vector-cortex/rollout/gate.ts +119 -0
  128. package/src/vector-cortex/rollout/types.ts +111 -0
  129. package/extensions/dashboard-client/dist/assets/VectorCortexTab-Bym21yVQ.js +0 -2
  130. package/extensions/dashboard-client/dist/assets/VectorCortexTab-Bym21yVQ.js.map +0 -1
@@ -15,6 +15,8 @@ import {
15
15
  fetchVectorCortexQuery,
16
16
  fetchVectorCortexReconstruct,
17
17
  fetchVectorCortexPlans,
18
+ fetchVectorCortexRender,
19
+ fetchVectorCortexRollout,
18
20
  fetchVectorCortexShards,
19
21
  fetchVectorCortexTopology,
20
22
  resetVectorCortexBreaker,
@@ -24,11 +26,17 @@ import {
24
26
  type VectorCortexQueryView,
25
27
  type VectorCortexReconstructView,
26
28
  type VectorCortexPlansView,
29
+ type VectorCortexRenderView,
30
+ type VectorCortexRolloutView,
27
31
  type VectorCortexShardsView,
28
32
  type VectorCortexTopologyView,
29
33
  } from "../api/vector-cortex";
30
34
  import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card";
31
35
  import { Badge } from "../components/ui/badge";
36
+ import { Metric } from "./VectorCortexMetric";
37
+ import { VectorCortexRenderCard } from "./VectorCortexRenderCard";
38
+ import { VectorCortexRolloutCard } from "./VectorCortexRolloutCard";
39
+ import { VectorCortexPlansCard } from "./VectorCortexPlansCard";
32
40
 
33
41
  function ModeChip({ mode, count }: { mode: string; count: number }): React.ReactElement {
34
42
  return (
@@ -39,15 +47,6 @@ function ModeChip({ mode, count }: { mode: string; count: number }): React.React
39
47
  );
40
48
  }
41
49
 
42
- function Metric({ label, value }: { label: string; value: string }): React.ReactElement {
43
- return (
44
- <div>
45
- <div className="text-xs text-muted-foreground">{label}</div>
46
- <div className="font-mono text-sm">{value}</div>
47
- </div>
48
- );
49
- }
50
-
51
50
  export default function VectorCortexTab(): React.ReactElement {
52
51
  const [data, setData] = useState<VectorCortexEvaluationSummary | null>(null);
53
52
  const [err, setError] = useState<string | null>(null);
@@ -60,6 +59,8 @@ export default function VectorCortexTab(): React.ReactElement {
60
59
  const [shards, setShards] = useState<VectorCortexShardsView | null>(null);
61
60
  const [reconstruct, setReconstruct] = useState<VectorCortexReconstructView | null>(null);
62
61
  const [plans, setPlans] = useState<VectorCortexPlansView | null>(null);
62
+ const [render, setRender] = useState<VectorCortexRenderView | null>(null);
63
+ const [rollout, setRollout] = useState<VectorCortexRolloutView | null>(null);
63
64
 
64
65
  const poll = useCallback(() => {
65
66
  fetchVectorCortexEvaluation()
@@ -89,6 +90,12 @@ export default function VectorCortexTab(): React.ReactElement {
89
90
  fetchVectorCortexPlans().then(setPlans).catch(() => {
90
91
  /* plan manifest card is best-effort (VC5A) */
91
92
  });
93
+ fetchVectorCortexRender().then(setRender).catch(() => {
94
+ /* render conformance card is best-effort (VC5B) */
95
+ });
96
+ fetchVectorCortexRollout().then(setRollout).catch(() => {
97
+ /* rollout card is best-effort (VC5C) */
98
+ });
92
99
  }, []);
93
100
 
94
101
  useEffect(() => {
@@ -403,35 +410,9 @@ export default function VectorCortexTab(): React.ReactElement {
403
410
  )}
404
411
  </CardContent>
405
412
  </Card>
406
- <Card>
407
- <CardHeader>
408
- <div className="flex items-center justify-between">
409
- <CardTitle>Plan Manifests (VC5A)</CardTitle>
410
- {plans?.enabled ? (
411
- <Badge variant="success">ACTIVE</Badge>
412
- ) : (
413
- <Badge variant="danger">OFF</Badge>
414
- )}
415
- </div>
416
- </CardHeader>
417
- <CardContent>
418
- {!plans?.enabled ? (
419
- <div className="vc-empty">PromptDagV1 + budgeted planner disabled (VC5A off).</div>
420
- ) : (
421
- <>
422
- <div className="grid grid-cols-2 gap-4 md:grid-cols-4">
423
- <Metric label="DAG fixtures" value={String(plans.dagCount)} />
424
- <Metric label="Plan fixtures" value={String(plans.plannerCount)} />
425
- <Metric label="Plans exposed" value={String(plans.plans.length)} />
426
- </div>
427
- <div className="mt-3 text-xs text-muted-foreground">
428
- Reader-only plan manifests only — no session payloads or prompt text.
429
- Per-run plan outputs are staged in-memory this sprint.
430
- </div>
431
- </>
432
- )}
433
- </CardContent>
434
- </Card>
413
+ <VectorCortexPlansCard view={plans} />
414
+ <VectorCortexRenderCard view={render} />
415
+ <VectorCortexRolloutCard view={rollout} />
435
416
  <Card>
436
417
  <CardHeader>
437
418
  <div className="flex items-center justify-between">
@@ -182,3 +182,29 @@ export interface VectorCortexPlansView {
182
182
  plans: VectorCortexPlanManifest[];
183
183
  updatedAt: string;
184
184
  }
185
+
186
+ /** Reader-only render + provider-profile view (VC5B). */
187
+ export interface VectorCortexRenderView {
188
+ enabled: boolean;
189
+ renderCount: number;
190
+ providerCount: number;
191
+ knownProfiles: string[];
192
+ updatedAt: string;
193
+ }
194
+
195
+ /**
196
+ * Reader-only live graduated-rollout view (VC5C, GET /api/vector-cortex/rollout).
197
+ * Aggregate only — current gate, bucket count, sessions/events counts, promotion
198
+ * state. Never session payloads or bucket→session mappings.
199
+ */
200
+ export interface VectorCortexRolloutView {
201
+ enabled: boolean;
202
+ gateIndex: number;
203
+ gatePct: number;
204
+ buckets: number;
205
+ bucketCount: number;
206
+ events: number;
207
+ sessions: number;
208
+ promotionBlocked: boolean;
209
+ updatedAt: string;
210
+ }
@@ -297,7 +297,58 @@ export interface VectorCortexPlansView {
297
297
  }
298
298
 
299
299
  /**
300
- * Reader-only occurrence-ledger view for GET /api/vector-cortex/ledger (VC1B).
300
+ * Reader-only render/profile view for GET /api/vector-cortex/render (VC5B).
301
+ * Reports the registered render (REN-001..) and provider-profile (PRO-001..)
302
+ * identifier counts + the known provider-profile keys. NEVER exposes rendered
303
+ * node bytes, prompt text, or the canonical outbound request (reader-only,
304
+ * SECURITY_PRIVACY: the exact ledger is not training data).
305
+ */
306
+ export interface VectorCortexRenderView {
307
+ /** Whether the VC5B render + provider-profile flag is enabled. */
308
+ readonly enabled: boolean;
309
+ /** Count of registered render fixtures (REN-001..). */
310
+ readonly renderCount: number;
311
+ /** Count of registered provider-profile fixtures (PRO-001..). */
312
+ readonly providerCount: number;
313
+ /** Known base provider-profile keys (provider//model), reader-only. */
314
+ readonly knownProfiles: readonly string[];
315
+ /** ISO timestamp of the snapshot. */
316
+ readonly updatedAt: string;
317
+ }
318
+
319
+ /**
320
+ * Reader-only live graduated-rollout view for GET /api/vector-cortex/rollout
321
+ * (VC5C). Purely an enabled-flag + aggregate over the rollout state — current
322
+ * gate, bucket count, sessions/events counts, and promotion-blocked state.
323
+ * Reader-only: NEVER exposes session payloads, prompt text, or bucket→session
324
+ * mappings (reader-only, SECURITY_PRIVACY). The rollout evidence is in-memory in
325
+ * this sprint (no durable store), so when no epoch has been observed the
326
+ * aggregates are truthfully zero. Non-fatal: a missing state degrades to
327
+ * `enabled:false`.
328
+ */
329
+ export interface VectorCortexRolloutView {
330
+ /** Whether the VC5C live graduated-rollout flag is enabled. */
331
+ readonly enabled: boolean;
332
+ /** Current gate index (0..4). */
333
+ readonly gateIndex: number;
334
+ /** Current gate percentage (ROLLOUT_GATES[gateIndex]). */
335
+ readonly gatePct: number;
336
+ /** Total stable buckets (10,000). */
337
+ readonly buckets: number;
338
+ /** Count of buckets currently exposed under the active gate. */
339
+ readonly bucketCount: number;
340
+ /** Total observed events in the window. */
341
+ readonly events: number;
342
+ /** Total distinct sessions observed in the window. */
343
+ readonly sessions: number;
344
+ /** True when a hard failure froze promotion. */
345
+ readonly promotionBlocked: boolean;
346
+ /** ISO timestamp of the snapshot. */
347
+ readonly updatedAt: string;
348
+ }
349
+
350
+ /**
351
+ * Reader-only occurrence-ledger identity view for GET /api/vector-cortex/ledger (VC1B).
301
352
  * Built on the LedgerReader capability surface. Exposes occurrence IDENTITY
302
353
  * (seq/eventId/kind/digest/toolCallId) and the per-session high-water/count —
303
354
  * NEVER sourceBytes or prompt text, honoring the reader-only no-ledger-text rule.
@@ -373,6 +373,18 @@ export const SETTINGS: ReadonlyArray<{
373
373
  "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).",
374
374
  true,
375
375
  ),
376
+ boolDirect(
377
+ "MEGACOMPACT_VC5B",
378
+ "VC5B Validated Renderer + Provider Profiles",
379
+ "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).",
380
+ true,
381
+ ),
382
+ boolDirect(
383
+ "MEGACOMPACT_VC5C",
384
+ "VC5C Live Graduated Rollout",
385
+ "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).",
386
+ true,
387
+ ),
376
388
  ],
377
389
  },
378
390
  {
@@ -0,0 +1,49 @@
1
+ /**
2
+ * dashboard-server/routes-vector-cortex-render.ts — VC5B render + provider-profile
3
+ * dashboard route.
4
+ *
5
+ * Reader-only GET /api/vector-cortex/render returning the registered render
6
+ * (REN-001..020) and provider-profile (PRO-001..015) identifier counts plus the
7
+ * known base provider-profile keys. NEVER exposes rendered node bytes, prompt
8
+ * text, or the canonical outbound request (reader-only, SECURITY_PRIVACY).
9
+ * Flag-gated on MEGACOMPACT_VC5B: `enabled:false` when off (byte-identical to
10
+ * the pre-VC5B predecessor).
11
+ *
12
+ * Guardrails: PREVENT-PI-004 (local in-process state only), PREVENT-011 (no
13
+ * `any`), reader-only aggregate (counts + profile keys only).
14
+ */
15
+
16
+ import type { IncomingMessage, ServerResponse } from "node:http";
17
+ import type { RouteContext } from "./routes-core.js";
18
+ import { VC5B_ENABLED } from "../../src/config.js";
19
+ import { REN_IDS } from "../../src/vector-cortex/render/types.js";
20
+ import { PRO_IDS } from "../../src/vector-cortex/provider/types.js";
21
+ import { KNOWN_PROVIDER_KEYS } from "../../src/vector-cortex/provider/registry.js";
22
+ import { sendJson } from "./routes-vector-cortex-shared.js";
23
+ import type { VectorCortexRenderView } from "./api-contracts/vector-cortex.js";
24
+
25
+ /** Reader-only GET /api/vector-cortex/render (VC5B). */
26
+ export function handleVectorCortexRender(
27
+ req: IncomingMessage,
28
+ res: ServerResponse,
29
+ _ctx: RouteContext,
30
+ ): boolean {
31
+ const url = req.url ?? "";
32
+ const path = url.split("?")[0] ?? url;
33
+ if (path !== "/api/vector-cortex/render") return false;
34
+ if (req.method !== "GET") {
35
+ sendJson(res, 405, { error: "method_not_allowed" });
36
+ return true;
37
+ }
38
+
39
+ const enabled = VC5B_ENABLED();
40
+ const body: VectorCortexRenderView = {
41
+ enabled,
42
+ renderCount: enabled ? REN_IDS.length : 0,
43
+ providerCount: enabled ? PRO_IDS.length : 0,
44
+ knownProfiles: enabled ? KNOWN_PROVIDER_KEYS : [],
45
+ updatedAt: new Date().toISOString(),
46
+ };
47
+ sendJson(res, 200, body);
48
+ return true;
49
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * dashboard-server/routes-vector-cortex-rollout.ts — VC5C live graduated-rollout
3
+ * dashboard route.
4
+ *
5
+ * Reader-only GET /api/vector-cortex/rollout returning the rollout aggregate:
6
+ * current gate, bucket count, sessions/events counts, and promotion-blocked
7
+ * state. NEVER exposes session payloads, prompt text, or bucket→session mappings
8
+ * (reader-only, SECURITY_PRIVACY). Flag-gated on MEGACOMPACT_VC5C: `enabled:false`
9
+ * when off (byte-identical to the pre-VC5C predecessor).
10
+ *
11
+ * Guardrails: PREVENT-PI-004 (local in-process state only), PREVENT-011 (no
12
+ * `any`), reader-only aggregate (counts + gate state only).
13
+ */
14
+
15
+ import type { IncomingMessage, ServerResponse } from "node:http";
16
+ import type { RouteContext } from "./routes-core.js";
17
+ import { VC5C_ENABLED } from "../../src/config.js";
18
+ import { ROLLOUT_GATES, ROLLOUT_BUCKETS } from "../../src/vector-cortex/rollout/types.js";
19
+ import { sendJson } from "./routes-vector-cortex-shared.js";
20
+ import type { VectorCortexRolloutView } from "./api-contracts/vector-cortex.js";
21
+
22
+ /** Reader-only GET /api/vector-cortex/rollout (VC5C). */
23
+ export function handleVectorCortexRollout(
24
+ req: IncomingMessage,
25
+ res: ServerResponse,
26
+ _ctx: RouteContext,
27
+ ): boolean {
28
+ const url = req.url ?? "";
29
+ const path = url.split("?")[0] ?? url;
30
+ if (path !== "/api/vector-cortex/rollout") return false;
31
+ if (req.method !== "GET") {
32
+ sendJson(res, 405, { error: "method_not_allowed" });
33
+ return true;
34
+ }
35
+
36
+ const enabled = VC5C_ENABLED();
37
+ const gateIndex = 0; // Ephemeral rollout state: no durable gate in this sprint.
38
+ const gatePct = ROLLOUT_GATES[gateIndex]!;
39
+ const body: VectorCortexRolloutView = {
40
+ enabled,
41
+ gateIndex: enabled ? gateIndex : 0,
42
+ gatePct: enabled ? gatePct : 0,
43
+ buckets: ROLLOUT_BUCKETS,
44
+ bucketCount: enabled ? gatePct * 100 : 0,
45
+ events: 0,
46
+ sessions: 0,
47
+ promotionBlocked: false,
48
+ updatedAt: new Date().toISOString(),
49
+ };
50
+ sendJson(res, 200, body);
51
+ return true;
52
+ }
@@ -23,3 +23,5 @@ export { handleVectorCortexShards } from "./routes-vector-cortex-shards.js";
23
23
  export { handleVectorCortexResidual } from "./routes-vector-cortex-residual.js";
24
24
  export { handleVectorCortexReconstruct } from "./routes-vector-cortex-reconstruct.js";
25
25
  export { handleVectorCortexPlans } from "./routes-vector-cortex-plans.js";
26
+ export { handleVectorCortexRender } from "./routes-vector-cortex-render.js";
27
+ export { handleVectorCortexRollout } from "./routes-vector-cortex-rollout.js";
@@ -51,4 +51,6 @@ export {
51
51
  handleVectorCortexResidual,
52
52
  handleVectorCortexReconstruct,
53
53
  handleVectorCortexPlans,
54
+ handleVectorCortexRender,
55
+ handleVectorCortexRollout,
54
56
  } from "./routes-vector-cortex.js";
@@ -67,6 +67,8 @@ import {
67
67
  handleVectorCortexResidual,
68
68
  handleVectorCortexReconstruct,
69
69
  handleVectorCortexPlans,
70
+ handleVectorCortexRender,
71
+ handleVectorCortexRollout,
70
72
  handleStatic,
71
73
  } from "./routes.js";
72
74
 
@@ -313,6 +315,8 @@ export async function launchDashboardServer(
313
315
  if (handleVectorCortexResidual(req, res, ctx)) return;
314
316
  if (handleVectorCortexReconstruct(req, res, ctx)) return;
315
317
  if (handleVectorCortexPlans(req, res, ctx)) return;
318
+ if (handleVectorCortexRender(req, res, ctx)) return;
319
+ if (handleVectorCortexRollout(req, res, ctx)) return;
316
320
  handleStatic(req, res, ctx);
317
321
  });
318
322
 
@@ -0,0 +1,163 @@
1
+ /**
2
+ * mega-context/vector-cortex.ts — VC5B delegation seam (the sprint's production
3
+ * ownership: `extensions/mega-context/vector-cortex.ts`).
4
+ *
5
+ * This is the ONLY extension-side surface VC5B owns. It delegates to the pi-
6
+ * agnostic `src/vector-cortex/render` + `src/vector-cortex/provider` logic and
7
+ * wires the two structured events the sprint emits:
8
+ * - `vector_cortex_render_validated` — a render passed validation and will be
9
+ * prepended via the host `before_agent_start` systemPrompt seam.
10
+ * - `vector_cortex_provider_bypassed` — an unknown provider/profile forced a
11
+ * clean bypass (triad C, the predecessor prompt path).
12
+ *
13
+ * GUARDRAIL PREVENT-PI-003 (critical): the rendered compacted context is placed
14
+ * via the host `before_agent_start` systemPrompt PREPEND seam — it is NEVER
15
+ * emitted as a `role:"system"` conversation message. The renderer returns a
16
+ * `RenderManifestV1`, not a raw system-role payload; this seam composes the
17
+ * manifest's prepend into `event.systemPrompt`.
18
+ *
19
+ * The context handler (extensions/mega-events/context-handler.ts) is 228 lines
20
+ * (already a delegate shell) and under the extension hard limit, so NO split was
21
+ * required — VC5B delegates from here rather than modifying that handler.
22
+ *
23
+ * Pi runtime adapter: imports only pi runtime types + the VC5B logic. Flag-gated
24
+ * on `VC5B_ENABLED()`; flag OFF is byte-identical to the predecessor (VC5A state
25
+ * — the DAG/plan path), so this seam returns the host's unmodified systemPrompt.
26
+ */
27
+
28
+ import type { ExtensionAPI, ExtensionContext, BeforeAgentStartEvent } from "@earendil-works/pi-coding-agent";
29
+
30
+ import { VC5B_ENABLED } from "../../src/config/vector-cortex.js";
31
+ import { resolveProviderProfile } from "../../src/vector-cortex/provider/registry.js";
32
+ import { renderPrompt } from "../../src/vector-cortex/render/renderer.js";
33
+ import { validateRender } from "../../src/vector-cortex/render/validator.js";
34
+ import type { RenderInput, RenderManifestV1, CanonicalOutboundRequest } from "../../src/vector-cortex/render/types.js";
35
+ import type { ProviderProfileBundle } from "../../src/vector-cortex/provider/types.js";
36
+
37
+ /** An injected emit callback — the same (event, fields) shape as the src seams. */
38
+ export type VectorCortexEmit = (event: string, fields: Record<string, unknown>) => void;
39
+
40
+ /** The VC5B seam result handed back to the before_agent_start handler. */
41
+ export interface VectorCortexRenderOutcome {
42
+ readonly validated: boolean;
43
+ readonly bypassed: boolean;
44
+ readonly manifest: RenderManifestV1 | null;
45
+ /** The text to prepend to the host systemPrompt (empty when not VC5B). */
46
+ readonly systemPromptPrepend: string;
47
+ readonly triad: "A" | "B" | "C";
48
+ }
49
+
50
+ /**
51
+ * Run the full VC5B render+validate pipeline. Returns a structured outcome the
52
+ * `before_agent_start` handler composes into the host systemPrompt. On a clean
53
+ * bypass (unknown profile) it emits `vector_cortex_provider_bypassed` and the
54
+ * host uses the predecessor prompt path (triad C). On a validated render it
55
+ * emits `vector_cortex_render_validated` (triad A).
56
+ *
57
+ * All emits are best-effort and non-fatal; the flag gates zero observability
58
+ * writes when OFF (byte-identical to predecessor).
59
+ */
60
+ export function runVectorCortexRender(
61
+ input: RenderInput,
62
+ emit?: VectorCortexEmit,
63
+ ): VectorCortexRenderOutcome {
64
+ const fire = (event: string, fields: Record<string, unknown>): void => {
65
+ try {
66
+ if (VC5B_ENABLED()) emit?.(event, fields);
67
+ } catch {
68
+ /* non-fatal observability — never break the agent loop */
69
+ }
70
+ };
71
+
72
+ const rendered = renderPrompt(input);
73
+ if (!rendered.ok) {
74
+ // Clean bypass (unknown profile) or a hard order mismatch. Bypass emits the
75
+ // provider-bypassed event and defers to the predecessor prompt path.
76
+ fire("vector_cortex_provider_bypassed", {
77
+ code: rendered.code,
78
+ triad: rendered.triad,
79
+ });
80
+ return {
81
+ validated: false,
82
+ bypassed: true,
83
+ manifest: null,
84
+ systemPromptPrepend: "",
85
+ triad: rendered.triad,
86
+ };
87
+ }
88
+
89
+ // Validate the canonical request BEFORE invocation. The profile at validation
90
+ // time must match the manifest profile (the UNIQUE injection swaps it → C).
91
+ const sourceToolBytes = new Map<string, string>();
92
+ for (const t of rendered.request.tools) sourceToolBytes.set(t.id, t.bytes);
93
+ const pinnedToolLengths = new Map<string, number>();
94
+ for (const t of rendered.request.tools) {
95
+ pinnedToolLengths.set(t.id, Buffer.byteLength(t.bytes, "utf8"));
96
+ }
97
+ const check = validateRender(
98
+ rendered.manifest,
99
+ rendered.request,
100
+ input.profile,
101
+ sourceToolBytes,
102
+ pinnedToolLengths,
103
+ );
104
+
105
+ if (!check.ok) {
106
+ fire("vector_cortex_provider_bypassed", {
107
+ code: check.code,
108
+ triad: check.triad,
109
+ });
110
+ return {
111
+ validated: false,
112
+ bypassed: true,
113
+ manifest: rendered.manifest,
114
+ systemPromptPrepend: "",
115
+ triad: check.triad,
116
+ };
117
+ }
118
+
119
+ fire("vector_cortex_render_validated", {
120
+ profileId: rendered.manifest.profileId,
121
+ requestDigest: rendered.manifest.requestDigest,
122
+ nodeCount: rendered.manifest.nodeOrder.length,
123
+ triad: "A",
124
+ });
125
+ return {
126
+ validated: true,
127
+ bypassed: false,
128
+ manifest: rendered.manifest,
129
+ systemPromptPrepend: rendered.request.systemPromptPrepend,
130
+ triad: "A",
131
+ };
132
+ }
133
+
134
+ /**
135
+ * Register the VC5B `before_agent_start` prepend seam on the host. Flag OFF →
136
+ * byte-identical to the predecessor (returns the host's unmodified systemPrompt).
137
+ * The composed prepend is placed on the HOST systemPrompt, never as role:system.
138
+ */
139
+ export function registerVectorCortexRender(
140
+ pi: ExtensionAPI,
141
+ _ctx: ExtensionContext,
142
+ emit?: VectorCortexEmit,
143
+ ): void {
144
+ pi.on("before_agent_start", (event: BeforeAgentStartEvent, ctx: ExtensionContext) => {
145
+ if (!VC5B_ENABLED()) return; // byte-identical predecessor behavior
146
+ // The host supplies the active (provider, model) so the seam can resolve the
147
+ // profile. Until the host passes a render input, the seam stays inert.
148
+ const pending = (ctx as unknown as { megaCompactVectorCortexRender?: RenderInput }).megaCompactVectorCortexRender;
149
+ if (pending === undefined) return;
150
+ const outcome = runVectorCortexRender(pending, emit);
151
+ if (!outcome.validated) return; // bypass / mismatch → predecessor path
152
+ return { systemPrompt: `${event.systemPrompt}\n\n${outcome.systemPromptPrepend}` };
153
+ });
154
+ }
155
+
156
+ /** Resolve a provider profile by (provider, model) for the host to pass in. */
157
+ export function resolveProfile(provider: string, model: string): ProviderProfileBundle | null {
158
+ const res = resolveProviderProfile(provider, model);
159
+ return res.ok ? res.bundle : null;
160
+ }
161
+
162
+ /** Re-export the core types the host adapter consumes (contract-first). */
163
+ export type { RenderInput, RenderManifestV1, CanonicalOutboundRequest };
@@ -0,0 +1,165 @@
1
+ /**
2
+ * vector-cortex-live.ts — VC5C live graduated-rollout integration seam.
3
+ *
4
+ * This adapter composes the rollout assign + gate + emit seams into the host
5
+ * provider-invocation path. It runs BEFORE provider invocation and decides, for
6
+ * the current session, which live path is active:
7
+ *
8
+ * - on a hard causal/tool/anchor/exact failure → select mode C (pre-VC prompt
9
+ * path) and FREEZE promotion (promotionBlocked=true) for the remainder of the
10
+ * cooldown/spool/restart/clock period satisfying TRIAD_RESILIENCE;
11
+ * - otherwise → the active gate decides whether the VC path is exposed to this
12
+ * session's bucket.
13
+ *
14
+ * PREVENT-PI-003: the rollout NEVER emits a `role:"system"` message. The VC
15
+ * prompt context is composed into the host `before_agent_start` systemPrompt
16
+ * prepend seam only. PREVENT-PI-004: zero network calls (local in-process state
17
+ * + injected clock only). PREVENT-011: no `any`. Non-fatal: any rollout noise
18
+ * degrades to mode C (pre-VC continuity), never breaking the agent loop.
19
+ *
20
+ * LIVENESS HONESTY (mirrors VC0C-Q01/Q06): the rollout decision state here is
21
+ * PER-PROCESS / IN-MEMORY and EPHEMERAL — there is NO persistent rollout runtime
22
+ * and NO live producer wiring. The gate decision is recomputed from injected
23
+ * evidence each epoch. The assigned/blocked events are emitted for observability
24
+ * only.
25
+ */
26
+
27
+ import { assignSession, bucketInGate, gatePctForIndex } from "../../src/vector-cortex/rollout/assign.js";
28
+ import {
29
+ decideGate,
30
+ selectsPreVcPath,
31
+ type RolloutClock,
32
+ type RolloutEvidence,
33
+ } from "../../src/vector-cortex/rollout/gate.js";
34
+ import { createRolloutReporter, type RolloutReporter } from "../../src/vector-cortex/rollout/emit.js";
35
+ import type { GateIndex, RolloutHardFault } from "../../src/vector-cortex/rollout/types.js";
36
+ import { VC5C_ENABLED } from "../../src/config/vector-cortex.js";
37
+
38
+ /** Host context the live seam needs. */
39
+ export interface VectorCortexLiveContext {
40
+ /** Monotonic clock for windows/cooldowns + gate eligibility (fake-clock testable). */
41
+ readonly clock?: RolloutClock;
42
+ /** Current gate index BEFORE this epoch (0..4). */
43
+ readonly currentGate?: GateIndex;
44
+ /** Injected rollout evidence for the current window. */
45
+ readonly evidence?: RolloutEvidence;
46
+ /** Hard faults observed this epoch (any entry forces C + freezes promotion). */
47
+ readonly hardFaults?: readonly RolloutHardFault[];
48
+ /** Optional emit callback for observability events. */
49
+ readonly emit?: (event: string, fields: Record<string, unknown>) => void;
50
+ }
51
+
52
+ /** The decision the live seam returns for one session epoch. */
53
+ export interface VectorCortexLiveDecision {
54
+ /** Whether the VC path is exposed to this session (true under current gate). */
55
+ readonly vcActive: boolean;
56
+ /** True when a hard failure forced mode C (pre-VC continuity). */
57
+ readonly forcedPreVc: boolean;
58
+ /**
59
+ * The selected triad mode for this epoch. The VC5C rollout seam only ever
60
+ * selects "A" (VC path exposed at the active gate) or "C" (pre-VC fallback:
61
+ * flag off, no evidence/clock, or a hard causal/tool/anchor/exact fault that
62
+ * freezes promotion). The deterministic-greedy triad "B" mode is NOT produced
63
+ * here — this seam is a pure gating/eligibility layer with no live renderer
64
+ * driver; a real mode-B greedy-render fallback belongs to the layer that
65
+ * actually runs renderers (a future sprint), not to this observability seam.
66
+ * Declaring "B" in this union while never producing it would be an overclaim.
67
+ */
68
+ readonly mode: "A" | "C";
69
+ /** The session's stable bucket (0..9999). */
70
+ readonly bucket: number;
71
+ /** The effective gate index after this epoch. */
72
+ readonly gateIndex: GateIndex;
73
+ /** True when promotion is frozen by a hard fault. */
74
+ readonly promotionBlocked: boolean;
75
+ /** The systemPrompt prepend the host `before_agent_start` seam should use. */
76
+ readonly systemPromptPrepend: string;
77
+ }
78
+
79
+ const NO_PREPEND = "";
80
+
81
+ /**
82
+ * Decide the live path for a session epoch. Pure over injected context; no
83
+ * I/O, no network. Flag OFF (or absent evidence/clock) degrades to mode C with
84
+ * the VC path inactive (pre-VC predecessor parity).
85
+ */
86
+ export function decideLivePath(
87
+ sessionId: string,
88
+ ctx: VectorCortexLiveContext,
89
+ ): VectorCortexLiveDecision {
90
+ const reporter: RolloutReporter = createRolloutReporter(ctx.emit);
91
+ const assignment = assignSession(sessionId);
92
+
93
+ if (!VC5C_ENABLED()) {
94
+ // Pre-VC predecessor: no rollout, no VC path. Never emit role:system.
95
+ return {
96
+ vcActive: false,
97
+ forcedPreVc: false,
98
+ mode: "C",
99
+ bucket: assignment.bucket,
100
+ gateIndex: 0,
101
+ promotionBlocked: false,
102
+ systemPromptPrepend: NO_PREPEND,
103
+ };
104
+ }
105
+
106
+ reporter.assigned({
107
+ sessionId,
108
+ bucket: assignment.bucket,
109
+ gateIndex: assignment.gateIndex,
110
+ gatePct: gatePctForIndex(assignment.gateIndex),
111
+ });
112
+
113
+ const hardFaults = ctx.hardFaults ?? [];
114
+ const hardFault = hardFaults.length > 0 ? hardFaults[0]! : undefined;
115
+ const forcedPreVc = selectsPreVcPath(hardFault);
116
+
117
+ if (forcedPreVc && hardFault) {
118
+ reporter.promotionBlocked({
119
+ gateIndex: ctx.currentGate ?? assignment.gateIndex,
120
+ kind: hardFault.kind,
121
+ detail: hardFault.detail,
122
+ });
123
+ // Hard failure → select C (pre-VC path) and freeze promotion.
124
+ return {
125
+ vcActive: false,
126
+ forcedPreVc: true,
127
+ mode: "C",
128
+ bucket: assignment.bucket,
129
+ gateIndex: ctx.currentGate ?? assignment.gateIndex,
130
+ promotionBlocked: true,
131
+ systemPromptPrepend: NO_PREPEND,
132
+ };
133
+ }
134
+
135
+ const clock = ctx.clock;
136
+ const evidence = ctx.evidence;
137
+ if (clock === undefined || evidence === undefined) {
138
+ // No live evidence/clock → pre-VC parity (no promotion, no VC exposure).
139
+ return {
140
+ vcActive: false,
141
+ forcedPreVc: false,
142
+ mode: "C",
143
+ bucket: assignment.bucket,
144
+ gateIndex: assignment.gateIndex,
145
+ promotionBlocked: false,
146
+ systemPromptPrepend: NO_PREPEND,
147
+ };
148
+ }
149
+
150
+ const outcome = decideGate(ctx.currentGate ?? assignment.gateIndex, evidence, clock);
151
+ const vcActive = bucketInGate(assignment.bucket, outcome.gatePct);
152
+
153
+ // PREVENT-PI-003: VC prompt context is composed into the host prepend seam,
154
+ // never as a role:system message. Empty prepend here (the actual prompt text
155
+ // is owned by the renderer seam); this seam only signals eligibility.
156
+ return {
157
+ vcActive,
158
+ forcedPreVc: false,
159
+ mode: vcActive ? "A" : "C",
160
+ bucket: assignment.bucket,
161
+ gateIndex: outcome.gateIndex,
162
+ promotionBlocked: outcome.promotionBlocked,
163
+ systemPromptPrepend: NO_PREPEND,
164
+ };
165
+ }