pi-mega-compact 0.20.8 → 0.20.10

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 (115) hide show
  1. package/dist/config/vector-cortex.js +29 -0
  2. package/dist/config.js +1 -1
  3. package/dist/extensions/dashboard-server/route-dispatch.js +8 -1
  4. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +2 -0
  5. package/dist/extensions/dashboard-server/routes-vector-cortex-heal.js +42 -3
  6. package/dist/extensions/dashboard-server/routes-vector-cortex-repair.js +63 -0
  7. package/dist/extensions/dashboard-server/routes-vector-cortex.js +3 -1
  8. package/dist/extensions/dashboard-server/routes.js +1 -1
  9. package/dist/src/config/vector-cortex.js +29 -0
  10. package/dist/src/config.js +1 -1
  11. package/dist/src/vector-cortex/heal/_repair-fixture.js +70 -0
  12. package/dist/src/vector-cortex/heal/_restore-fixture.js +96 -0
  13. package/dist/src/vector-cortex/heal/_vc6b-helpers.js +35 -0
  14. package/dist/src/vector-cortex/heal/controller.js +165 -0
  15. package/dist/src/vector-cortex/heal/rebuild.js +136 -0
  16. package/dist/src/vector-cortex/heal/repair-emit.js +83 -0
  17. package/dist/src/vector-cortex/heal/repair-types.js +74 -0
  18. package/dist/src/vector-cortex/heal/restore-emit.js +70 -0
  19. package/dist/src/vector-cortex/heal/restore-readers.js +114 -0
  20. package/dist/src/vector-cortex/heal/restore-types.js +66 -0
  21. package/dist/src/vector-cortex/heal/restore.js +140 -0
  22. package/dist/src/vector-cortex/heal/types.js +2 -0
  23. package/dist/src/vector-cortex/heal/verify.js +75 -0
  24. package/dist/vector-cortex/heal/_repair-fixture.js +70 -0
  25. package/dist/vector-cortex/heal/_restore-fixture.js +96 -0
  26. package/dist/vector-cortex/heal/_vc6b-helpers.js +35 -0
  27. package/dist/vector-cortex/heal/controller.js +165 -0
  28. package/dist/vector-cortex/heal/rebuild.js +136 -0
  29. package/dist/vector-cortex/heal/repair-emit.js +83 -0
  30. package/dist/vector-cortex/heal/repair-types.js +74 -0
  31. package/dist/vector-cortex/heal/restore-emit.js +70 -0
  32. package/dist/vector-cortex/heal/restore-readers.js +114 -0
  33. package/dist/vector-cortex/heal/restore-types.js +66 -0
  34. package/dist/vector-cortex/heal/restore.js +140 -0
  35. package/dist/vector-cortex/heal/types.js +2 -0
  36. package/dist/vector-cortex/heal/verify.js +75 -0
  37. package/extensions/dashboard-client/dist/assets/{AreaChart-5yxaI8IO.js → AreaChart-BDMjyRQp.js} +2 -2
  38. package/extensions/dashboard-client/dist/assets/{AreaChart-5yxaI8IO.js.map → AreaChart-BDMjyRQp.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/{BarChart-BoHhCqH-.js → BarChart-CqzPzOkj.js} +2 -2
  40. package/extensions/dashboard-client/dist/assets/{BarChart-BoHhCqH-.js.map → BarChart-CqzPzOkj.js.map} +1 -1
  41. package/extensions/dashboard-client/dist/assets/{CacheTab-Di6L3CsF.js → CacheTab-Bo8SH9q8.js} +2 -2
  42. package/extensions/dashboard-client/dist/assets/{CacheTab-Di6L3CsF.js.map → CacheTab-Bo8SH9q8.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/{EventsTab-Cdff3h6s.js → EventsTab-DIEs6zC-.js} +2 -2
  44. package/extensions/dashboard-client/dist/assets/{EventsTab-Cdff3h6s.js.map → EventsTab-DIEs6zC-.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{HealthTab-MthYYVLw.js → HealthTab-3a8IjwIK.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{HealthTab-MthYYVLw.js.map → HealthTab-3a8IjwIK.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-D9G4ntsG.js → MaintenanceTab-CdKwAcXo.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-D9G4ntsG.js.map → MaintenanceTab-CdKwAcXo.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-CN8Lr5Qf.js → MemoryMapTab-D2hHuNj-.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-CN8Lr5Qf.js.map → MemoryMapTab-D2hHuNj-.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/{MetricsTab-CgO32kSo.js → MetricsTab-CFhIhqrr.js} +2 -2
  52. package/extensions/dashboard-client/dist/assets/{MetricsTab-CgO32kSo.js.map → MetricsTab-CFhIhqrr.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/{OverviewTab-Cb4kR0h1.js → OverviewTab-Dzp5ZoiA.js} +2 -2
  54. package/extensions/dashboard-client/dist/assets/{OverviewTab-Cb4kR0h1.js.map → OverviewTab-Dzp5ZoiA.js.map} +1 -1
  55. package/extensions/dashboard-client/dist/assets/{ReposTab-Dt1FGnMR.js → ReposTab-CFJT9mDR.js} +2 -2
  56. package/extensions/dashboard-client/dist/assets/{ReposTab-Dt1FGnMR.js.map → ReposTab-CFJT9mDR.js.map} +1 -1
  57. package/extensions/dashboard-client/dist/assets/{SessionsTab-D7D2RW6U.js → SessionsTab-BhP1z6_y.js} +2 -2
  58. package/extensions/dashboard-client/dist/assets/{SessionsTab-D7D2RW6U.js.map → SessionsTab-BhP1z6_y.js.map} +1 -1
  59. package/extensions/dashboard-client/dist/assets/{SetupTab-CgV5xCzz.js → SetupTab-2Glh7MKk.js} +2 -2
  60. package/extensions/dashboard-client/dist/assets/{SetupTab-CgV5xCzz.js.map → SetupTab-2Glh7MKk.js.map} +1 -1
  61. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-CCNuJjyO.js → TimeSavedCard-DmwBDhkw.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-CCNuJjyO.js.map → TimeSavedCard-DmwBDhkw.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/assets/{TurnsTab-Cv1OCttJ.js → TurnsTab-CYIaOUUZ.js} +2 -2
  64. package/extensions/dashboard-client/dist/assets/{TurnsTab-Cv1OCttJ.js.map → TurnsTab-CYIaOUUZ.js.map} +1 -1
  65. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DD7vGaRS.js +2 -0
  66. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DD7vGaRS.js.map +1 -0
  67. package/extensions/dashboard-client/dist/assets/{WikiTab-B48QnQrK.js → WikiTab-CP-JEd17.js} +2 -2
  68. package/extensions/dashboard-client/dist/assets/{WikiTab-B48QnQrK.js.map → WikiTab-CP-JEd17.js.map} +1 -1
  69. package/extensions/dashboard-client/dist/assets/{button-BBQl2MiF.js → button-B1RhLsGs.js} +2 -2
  70. package/extensions/dashboard-client/dist/assets/{button-BBQl2MiF.js.map → button-B1RhLsGs.js.map} +1 -1
  71. package/extensions/dashboard-client/dist/assets/{card-BYbefUur.js → card-BLPT2-8G.js} +2 -2
  72. package/extensions/dashboard-client/dist/assets/{card-BYbefUur.js.map → card-BLPT2-8G.js.map} +1 -1
  73. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-swm0YZe0.js → generateCategoricalChart-DVOMJzL2.js} +2 -2
  74. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-swm0YZe0.js.map → generateCategoricalChart-DVOMJzL2.js.map} +1 -1
  75. package/extensions/dashboard-client/dist/assets/{index-DeIky7xm.js → index-CuLdiHRl.js} +3 -3
  76. package/extensions/dashboard-client/dist/assets/{index-DeIky7xm.js.map → index-CuLdiHRl.js.map} +1 -1
  77. package/extensions/dashboard-client/dist/assets/{switch-CctU78ww.js → switch-C5tqzhcl.js} +2 -2
  78. package/extensions/dashboard-client/dist/assets/{switch-CctU78ww.js.map → switch-C5tqzhcl.js.map} +1 -1
  79. package/extensions/dashboard-client/dist/assets/{toggle-BRCNCoiI.js → toggle-HcM6W2Yl.js} +2 -2
  80. package/extensions/dashboard-client/dist/assets/{toggle-BRCNCoiI.js.map → toggle-HcM6W2Yl.js.map} +1 -1
  81. package/extensions/dashboard-client/dist/assets/{useSSE-WfOiWDH_.js → useSSE-BtWUs2kL.js} +2 -2
  82. package/extensions/dashboard-client/dist/assets/{useSSE-WfOiWDH_.js.map → useSSE-BtWUs2kL.js.map} +1 -1
  83. package/extensions/dashboard-client/dist/index.html +1 -1
  84. package/extensions/dashboard-client/src/api/vector-cortex.ts +18 -0
  85. package/extensions/dashboard-client/src/tabs/VectorCortexRepairCard.tsx +43 -0
  86. package/extensions/dashboard-client/src/tabs/VectorCortexRestoreCard.tsx +42 -0
  87. package/extensions/dashboard-client/src/tabs/VectorCortexShardsCard.tsx +89 -0
  88. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +22 -60
  89. package/extensions/dashboard-client/src/types/vector-cortex.ts +33 -0
  90. package/extensions/dashboard-server/api-contracts/vector-cortex-heal.ts +68 -0
  91. package/extensions/dashboard-server/api-contracts/vector-cortex.ts +5 -1
  92. package/extensions/dashboard-server/route-dispatch.ts +6 -0
  93. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +12 -0
  94. package/extensions/dashboard-server/routes-vector-cortex-heal.ts +51 -4
  95. package/extensions/dashboard-server/routes-vector-cortex-repair.ts +72 -0
  96. package/extensions/dashboard-server/routes-vector-cortex.ts +6 -1
  97. package/extensions/dashboard-server/routes.ts +1 -0
  98. package/package.json +1 -1
  99. package/src/config/vector-cortex.ts +31 -0
  100. package/src/config.ts +2 -0
  101. package/src/vector-cortex/heal/_repair-fixture.ts +138 -0
  102. package/src/vector-cortex/heal/_restore-fixture.ts +163 -0
  103. package/src/vector-cortex/heal/_vc6b-helpers.ts +55 -0
  104. package/src/vector-cortex/heal/controller.ts +189 -0
  105. package/src/vector-cortex/heal/rebuild.ts +200 -0
  106. package/src/vector-cortex/heal/repair-emit.ts +118 -0
  107. package/src/vector-cortex/heal/repair-types.ts +227 -0
  108. package/src/vector-cortex/heal/restore-emit.ts +94 -0
  109. package/src/vector-cortex/heal/restore-readers.ts +145 -0
  110. package/src/vector-cortex/heal/restore-types.ts +185 -0
  111. package/src/vector-cortex/heal/restore.ts +165 -0
  112. package/src/vector-cortex/heal/types.ts +50 -0
  113. package/src/vector-cortex/heal/verify.ts +93 -0
  114. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DTabQo6h.js +0 -2
  115. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DTabQo6h.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ /**
2
+ * VectorCortexShardsCard.tsx — VC4A dual-tier shard aggregate + VC4C
3
+ * reconstruction-fidelity cards.
4
+ *
5
+ * Extracted verbatim from VectorCortexTab.tsx (delegate-shell + sibling-card
6
+ * pattern already used by VectorCortexRenderCard / VectorCortexRestoreCard) so
7
+ * the tab stays well under the 400-line extension soft limit as later sprints
8
+ * add cards. Both are reader-only count/byte aggregates — no payload.
9
+ */
10
+ import type React from "react";
11
+ import type {
12
+ VectorCortexReconstructView,
13
+ VectorCortexShardsView,
14
+ } from "../api/vector-cortex";
15
+ import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card";
16
+ import { Badge } from "../components/ui/badge";
17
+ import { Metric } from "./VectorCortexMetric";
18
+
19
+ /** Reader-only dual-tier shard aggregate (VC4A). */
20
+ export function VectorCortexShardsCard({ view }: { view: VectorCortexShardsView | null }): React.ReactElement {
21
+ return (
22
+ <Card>
23
+ <CardHeader>
24
+ <div className="flex items-center justify-between">
25
+ <CardTitle>Dual-Tier Shards (VC4A)</CardTitle>
26
+ {view?.enabled ? (
27
+ <Badge variant="success">ACTIVE</Badge>
28
+ ) : (
29
+ <Badge variant="danger">OFF</Badge>
30
+ )}
31
+ </div>
32
+ </CardHeader>
33
+ <CardContent>
34
+ {!view?.enabled ? (
35
+ <div className="vc-empty">Dual-tier shards disabled (VC4A off).</div>
36
+ ) : (
37
+ <>
38
+ <div className="grid grid-cols-2 gap-4 md:grid-cols-4">
39
+ <Metric label="Semantic shards" value={String(view.semanticCount)} />
40
+ <Metric label="Exact shards" value={String(view.exactCount)} />
41
+ <Metric label="Byte total" value={String(view.byteTotal)} />
42
+ <Metric label="Protected bytes" value={String(view.protectedByteTotal)} />
43
+ </div>
44
+ <div className="mt-3 text-xs text-muted-foreground">
45
+ Reader-only count/byte aggregate; staged in-memory this sprint.
46
+ </div>
47
+ </>
48
+ )}
49
+ </CardContent>
50
+ </Card>
51
+ );
52
+ }
53
+
54
+ /** Reader-only reconstruction-fidelity aggregate (VC4C). */
55
+ export function VectorCortexReconstructCard({ view }: { view: VectorCortexReconstructView | null }): React.ReactElement {
56
+ return (
57
+ <Card>
58
+ <CardHeader>
59
+ <div className="flex items-center justify-between">
60
+ <CardTitle>Reconstruction Fidelity (VC4C)</CardTitle>
61
+ {view?.enabled ? (
62
+ <Badge variant="success">ACTIVE</Badge>
63
+ ) : (
64
+ <Badge variant="danger">OFF</Badge>
65
+ )}
66
+ </div>
67
+ </CardHeader>
68
+ <CardContent>
69
+ {!view?.enabled ? (
70
+ <div className="vc-empty">Reconstruction fidelity disabled (VC4C off).</div>
71
+ ) : (
72
+ <>
73
+ <div className="grid grid-cols-2 gap-4 md:grid-cols-4">
74
+ <Metric label="Closure attempts" value={String(view.closureAttempts)} />
75
+ <Metric label="Closure rejections" value={String(view.closureRejections)} />
76
+ <Metric label="Validated" value={String(view.validatedCount)} />
77
+ <Metric label="Invalidated" value={String(view.invalidatedCount)} />
78
+ <Metric label="Span total" value={String(view.spanTotal)} />
79
+ <Metric label="Byte total" value={String(view.byteTotal)} />
80
+ </div>
81
+ <div className="mt-3 text-xs text-muted-foreground">
82
+ Reader-only closure/validation aggregate; staged in-memory this sprint.
83
+ </div>
84
+ </>
85
+ )}
86
+ </CardContent>
87
+ </Card>
88
+ );
89
+ }
@@ -18,6 +18,8 @@ import {
18
18
  fetchVectorCortexRender,
19
19
  fetchVectorCortexRollout,
20
20
  fetchVectorCortexClosureProof,
21
+ fetchVectorCortexRestore,
22
+ fetchVectorCortexRepair,
21
23
  fetchVectorCortexShards,
22
24
  fetchVectorCortexTopology,
23
25
  resetVectorCortexBreaker,
@@ -30,6 +32,8 @@ import {
30
32
  type VectorCortexRenderView,
31
33
  type VectorCortexRolloutView,
32
34
  type VectorCortexClosureProofView,
35
+ type VectorCortexRestoreView,
36
+ type VectorCortexRepairView,
33
37
  type VectorCortexShardsView,
34
38
  type VectorCortexTopologyView,
35
39
  } from "../api/vector-cortex";
@@ -39,6 +43,12 @@ import { Metric } from "./VectorCortexMetric";
39
43
  import { VectorCortexRenderCard } from "./VectorCortexRenderCard";
40
44
  import { VectorCortexRolloutCard } from "./VectorCortexRolloutCard";
41
45
  import { VectorCortexClosureCard } from "./VectorCortexClosureCard";
46
+ import { VectorCortexRestoreCard } from "./VectorCortexRestoreCard";
47
+ import { VectorCortexRepairCard } from "./VectorCortexRepairCard";
48
+ import {
49
+ VectorCortexShardsCard,
50
+ VectorCortexReconstructCard,
51
+ } from "./VectorCortexShardsCard";
42
52
  import { VectorCortexPlansCard } from "./VectorCortexPlansCard";
43
53
  import { VectorCortexTopologyCard } from "./VectorCortexTopologyCard";
44
54
  import { VectorCortexLedgerCard } from "./VectorCortexLedgerCard";
@@ -67,6 +77,8 @@ export default function VectorCortexTab(): React.ReactElement {
67
77
  const [render, setRender] = useState<VectorCortexRenderView | null>(null);
68
78
  const [rollout, setRollout] = useState<VectorCortexRolloutView | null>(null);
69
79
  const [closureProof, setClosureProof] = useState<VectorCortexClosureProofView | null>(null);
80
+ const [restore, setRestore] = useState<VectorCortexRestoreView | null>(null);
81
+ const [repair, setRepair] = useState<VectorCortexRepairView | null>(null);
70
82
 
71
83
  const poll = useCallback(() => {
72
84
  fetchVectorCortexEvaluation()
@@ -105,6 +117,12 @@ export default function VectorCortexTab(): React.ReactElement {
105
117
  fetchVectorCortexClosureProof().then(setClosureProof).catch(() => {
106
118
  /* closure-optimization card is best-effort (VC6A) */
107
119
  });
120
+ fetchVectorCortexRestore().then(setRestore).catch(() => {
121
+ /* exact-source-restoration card is best-effort (VC6B) */
122
+ });
123
+ fetchVectorCortexRepair().then(setRepair).catch(() => {
124
+ /* self-healing derived-state card is best-effort (VC6C) */
125
+ });
108
126
  }, []);
109
127
 
110
128
  useEffect(() => {
@@ -256,70 +274,14 @@ export default function VectorCortexTab(): React.ReactElement {
256
274
  </CardContent>
257
275
  </Card>
258
276
  <VectorCortexTopologyCard topology={topology} query={query} />
259
- <Card>
260
- <CardHeader>
261
- <div className="flex items-center justify-between">
262
- <CardTitle>Dual-Tier Shards (VC4A)</CardTitle>
263
- {shards?.enabled ? (
264
- <Badge variant="success">ACTIVE</Badge>
265
- ) : (
266
- <Badge variant="danger">OFF</Badge>
267
- )}
268
- </div>
269
- </CardHeader>
270
- <CardContent>
271
- {!shards?.enabled ? (
272
- <div className="vc-empty">Dual-tier shards disabled (VC4A off).</div>
273
- ) : (
274
- <>
275
- <div className="grid grid-cols-2 gap-4 md:grid-cols-4">
276
- <Metric label="Semantic shards" value={String(shards.semanticCount)} />
277
- <Metric label="Exact shards" value={String(shards.exactCount)} />
278
- <Metric label="Byte total" value={String(shards.byteTotal)} />
279
- <Metric label="Protected bytes" value={String(shards.protectedByteTotal)} />
280
- </div>
281
- <div className="mt-3 text-xs text-muted-foreground">
282
- Reader-only count/byte aggregate; staged in-memory this sprint.
283
- </div>
284
- </>
285
- )}
286
- </CardContent>
287
- </Card>
288
- <Card>
289
- <CardHeader>
290
- <div className="flex items-center justify-between">
291
- <CardTitle>Reconstruction Fidelity (VC4C)</CardTitle>
292
- {reconstruct?.enabled ? (
293
- <Badge variant="success">ACTIVE</Badge>
294
- ) : (
295
- <Badge variant="danger">OFF</Badge>
296
- )}
297
- </div>
298
- </CardHeader>
299
- <CardContent>
300
- {!reconstruct?.enabled ? (
301
- <div className="vc-empty">Reconstruction fidelity disabled (VC4C off).</div>
302
- ) : (
303
- <>
304
- <div className="grid grid-cols-2 gap-4 md:grid-cols-4">
305
- <Metric label="Closure attempts" value={String(reconstruct.closureAttempts)} />
306
- <Metric label="Closure rejections" value={String(reconstruct.closureRejections)} />
307
- <Metric label="Validated" value={String(reconstruct.validatedCount)} />
308
- <Metric label="Invalidated" value={String(reconstruct.invalidatedCount)} />
309
- <Metric label="Span total" value={String(reconstruct.spanTotal)} />
310
- <Metric label="Byte total" value={String(reconstruct.byteTotal)} />
311
- </div>
312
- <div className="mt-3 text-xs text-muted-foreground">
313
- Reader-only closure/validation aggregate; staged in-memory this sprint.
314
- </div>
315
- </>
316
- )}
317
- </CardContent>
318
- </Card>
277
+ <VectorCortexShardsCard view={shards} />
278
+ <VectorCortexReconstructCard view={reconstruct} />
319
279
  <VectorCortexPlansCard view={plans} />
320
280
  <VectorCortexRenderCard view={render} />
321
281
  <VectorCortexRolloutCard view={rollout} />
322
282
  <VectorCortexClosureCard view={closureProof} />
283
+ <VectorCortexRestoreCard view={restore} />
284
+ <VectorCortexRepairCard view={repair} />
323
285
  <VectorCortexLedgerCard ledger={ledger} />
324
286
  </div>
325
287
  );
@@ -209,6 +209,39 @@ export interface VectorCortexRolloutView {
209
209
  updatedAt: string;
210
210
  }
211
211
 
212
+ /**
213
+ * Reader-only exact-source-restoration view (VC6B). Counts + HEAL_RESTORE_*
214
+ * codes only — there is no payload endpoint, so no restored bytes, span ids,
215
+ * node ids, or ledger text ever reach the client.
216
+ */
217
+ export interface VectorCortexRestoreView {
218
+ enabled: boolean;
219
+ mode: "A" | "B" | "C";
220
+ restoreAttempts: number;
221
+ restoredCount: number;
222
+ missingCount: number;
223
+ digestRejections: number;
224
+ lastRejection: string | null;
225
+ updatedAt: string;
226
+ }
227
+
228
+ /**
229
+ * Reader-only self-healing derived-state view (VC6C). Counts + HEAL_REPAIR_*
230
+ * codes only — there is no payload endpoint, so no subsystem source bytes, gap
231
+ * ranges, high-water marks, root digests, or ledger text ever reach the client.
232
+ */
233
+ export interface VectorCortexRepairView {
234
+ enabled: boolean;
235
+ mode: "A" | "B" | "C";
236
+ repairAttempts: number;
237
+ repairsPlanned: number;
238
+ pointersSwitched: number;
239
+ backoffs: number;
240
+ lastBackoffMs: number | null;
241
+ lastFailure: string | null;
242
+ updatedAt: string;
243
+ }
244
+
212
245
  /** Reader-only closure-optimization diagnostics view (VC6A). Aggregate only. */
213
246
  export interface VectorCortexClosureProofView {
214
247
  enabled: boolean;
@@ -41,3 +41,71 @@ export interface VectorCortexClosureProofView {
41
41
  /** ISO timestamp of the snapshot. */
42
42
  readonly updatedAt: string;
43
43
  }
44
+
45
+ /**
46
+ * Reader-only exact-source-restoration diagnostics view for
47
+ * GET /api/vector-cortex/restore (VC6B).
48
+ *
49
+ * COUNTS + ERROR CODES ONLY. There is NO payload endpoint for restoration, ever:
50
+ * this view deliberately carries no restored bytes, span ids, node ids, byte
51
+ * ranges, shard identifiers, or ledger text (SECURITY_PRIVACY — the exact ledger
52
+ * is never rendered through a diagnostic surface). Only the restore counters and
53
+ * the last HEAL_RESTORE_* failure code are exposed; the per-span detail lives in
54
+ * the structured event log, not the dashboard.
55
+ */
56
+ export interface VectorCortexRestoreView {
57
+ /** Whether the VC6B exact-source-restoration flag is enabled. */
58
+ readonly enabled: boolean;
59
+ /** Runtime triad mode: "A" exact shard, "B" ledger range scan, "C" loss disclosed. */
60
+ readonly mode: "A" | "B" | "C";
61
+ /** Total restore attempts observed (event counter). */
62
+ readonly restoreAttempts: number;
63
+ /** Spans restored with a verified SHA-256 digest (event counter). */
64
+ readonly restoredCount: number;
65
+ /** Spans with no exact source available (HEAL_RESTORE_SOURCE_MISSING). */
66
+ readonly missingCount: number;
67
+ /** Restores rejected by digest verification (HEAL_RESTORE_DIGEST_MISMATCH). */
68
+ readonly digestRejections: number;
69
+ /** Last rejection reason (a HEAL_RESTORE_* code), or null if none yet. */
70
+ readonly lastRejection: string | null;
71
+ /** ISO timestamp of the snapshot. */
72
+ readonly updatedAt: string;
73
+ }
74
+
75
+ /**
76
+ * Reader-only self-healing derived-state diagnostics view for
77
+ * GET /api/vector-cortex/repair (VC6C).
78
+ *
79
+ * COUNTS + ERROR CODES ONLY. Like the restore view, this surface deliberately
80
+ * carries no payload: no subsystem source bytes, no rebuilt derived rows, no
81
+ * subsystem names paired with their gap ranges, no high-water values, no root
82
+ * digests, and no ledger text (SECURITY_PRIVACY — a diagnostic surface never
83
+ * renders the authority's contents). Only the controller's rebuild counters,
84
+ * the backoff schedule's observable timing, and the last HEAL_REPAIR_* failure
85
+ * code are exposed; the per-subsystem gap detail lives in the structured event
86
+ * log, not the dashboard.
87
+ */
88
+ export interface VectorCortexRepairView {
89
+ /** Whether the VC6C self-healing derived-controller flag is enabled. */
90
+ readonly enabled: boolean;
91
+ /**
92
+ * Runtime triad mode: "A" targeted single-subsystem rebuild, "B" full
93
+ * deterministic rebuild (ambiguous gap), "C" derived state disabled (both
94
+ * rebuild paths failed, or the controller is not running at all).
95
+ */
96
+ readonly mode: "A" | "B" | "C";
97
+ /** Total rebuild attempts started by the controller (event counter). */
98
+ readonly repairAttempts: number;
99
+ /** Rebuilds planned after gap detection, before rate limiting (counter). */
100
+ readonly repairsPlanned: number;
101
+ /** Rebuilds that reached a verified atomic pointer switch (counter). */
102
+ readonly pointersSwitched: number;
103
+ /** Attempts deferred by the rate limiter / exponential backoff (counter). */
104
+ readonly backoffs: number;
105
+ /** Most recent deterministic backoff delay in ms, or null if none yet. */
106
+ readonly lastBackoffMs: number | null;
107
+ /** Last failure reason (a HEAL_REPAIR_* code), or null if none yet. */
108
+ readonly lastFailure: string | null;
109
+ /** ISO timestamp of the snapshot. */
110
+ readonly updatedAt: string;
111
+ }
@@ -374,4 +374,8 @@ export interface VectorCortexLedgerView {
374
374
  readonly updatedAt: string;
375
375
  }
376
376
 
377
- export type { VectorCortexClosureProofView } from "./vector-cortex-heal.js";
377
+ export type {
378
+ VectorCortexClosureProofView,
379
+ VectorCortexRestoreView,
380
+ VectorCortexRepairView,
381
+ } from "./vector-cortex-heal.js";
@@ -55,7 +55,11 @@ import {
55
55
  handleVectorCortexRender,
56
56
  handleVectorCortexRollout,
57
57
  handleVectorCortexClosureProof,
58
+ handleVectorCortexRestore,
58
59
  } from "./routes.js";
60
+ // VC6C repair lives in its own module (routes-vector-cortex-repair.ts) so the
61
+ // heal route file stays well under the 400-line extension soft limit.
62
+ import { handleVectorCortexRepair } from "./routes-vector-cortex-repair.js";
59
63
 
60
64
  /**
61
65
  * Dispatch a request through every registered route handler.
@@ -108,5 +112,7 @@ export function dispatchRoutes(
108
112
  if (handleVectorCortexRender(req, res, ctx)) return true;
109
113
  if (handleVectorCortexRollout(req, res, ctx)) return true;
110
114
  if (handleVectorCortexClosureProof(req, res, ctx)) return true;
115
+ if (handleVectorCortexRestore(req, res, ctx)) return true;
116
+ if (handleVectorCortexRepair(req, res, ctx)) return true;
111
117
  return false;
112
118
  }
@@ -144,5 +144,17 @@ export const VECTOR_CORTEX_SETTINGS: SettingGroup = {
144
144
  "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.",
145
145
  true,
146
146
  ),
147
+ boolDirect(
148
+ "MEGACOMPACT_VC6B",
149
+ "VC6B Exact Source Restoration",
150
+ "Exact source restoration: restores the original bytes of closure spans ONLY from an exact shard (mode A) or a verified ledger range scan (mode B) — never inferred, reconstructed, or paraphrased from embeddings or semantic text. Requests are hard-bounded at 64 spans / 4MiB (HEAL_RESTORE_LIMIT); every span's SHA-256 is recomputed and bytes are inserted only after all requested span metadata validates, so a single bad span fails the whole request closed (HEAL_RESTORE_DIGEST_MISMATCH, HEAL_RESTORE_RANGE_MISMATCH). When no exact source exists (HEAL_RESTORE_SOURCE_MISSING) the old context is omitted and the loss is disclosed (mode C) rather than filled in. OFF = byte-identical predecessor (VC6A).",
151
+ true,
152
+ ),
153
+ boolDirect(
154
+ "MEGACOMPACT_VC6C",
155
+ "VC6C Self-Healing Derived State",
156
+ "Self-healing derived-state controller: detects gaps between each derived subsystem's high-water mark and the durable authority high-water, then rebuilds derived state by copy -> root-digest verification -> atomic pointer switch, so a partially rebuilt subsystem is never made visible. A targeted single-subsystem rebuild is mode A; an ambiguous gap escalates to a full deterministic rebuild (mode B); if both rebuild paths fail the derived state is disabled rather than served stale (mode C). Rebuilds are rate-limited to one per subsystem per 5 minutes with deterministic exponential backoff, so a persistently failing subsystem cannot spin. OFF = byte-identical predecessor (VC6B); no controller runs, so the dashboard reports mode C.",
157
+ true,
158
+ ),
147
159
  ],
148
160
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * dashboard-server/routes-vector-cortex-heal.ts — VC6A closure-optimization
3
- * dashboard route.
2
+ * dashboard-server/routes-vector-cortex-heal.ts — VC6A closure-optimization and
3
+ * VC6B exact-source-restoration dashboard routes.
4
4
  *
5
5
  * Reader-only GET /api/vector-cortex/closure-proof returning aggregate-only
6
6
  * closure diagnostics: whether the flag is enabled, the runtime triad mode, and
@@ -12,15 +12,22 @@
12
12
  * (the conservative VC4C closure, no reduction) — that is exactly the spec's
13
13
  * fallback rule — so `mode:"B"` + `enabled:false` is the byte-stable OFF view.
14
14
  *
15
+ * Reader-only GET /api/vector-cortex/restore (VC6B) returns restore COUNTS and
16
+ * HEAL_RESTORE_* error codes only. There is NO payload endpoint for restoration,
17
+ * ever — no restored bytes, span ids, node ids, byte ranges, or ledger text.
18
+ *
15
19
  * Guardrails: PREVENT-PI-004 (local in-process state only), PREVENT-011 (no
16
20
  * `any`), reader-only aggregate (counts + mode only).
17
21
  */
18
22
 
19
23
  import type { IncomingMessage, ServerResponse } from "node:http";
20
24
  import type { RouteContext } from "./routes-core.js";
21
- import { VC6A_ENABLED } from "../../src/config.js";
25
+ import { VC6A_ENABLED, VC6B_ENABLED } from "../../src/config.js";
22
26
  import { sendJson } from "./routes-vector-cortex-shared.js";
23
- import type { VectorCortexClosureProofView } from "./api-contracts/vector-cortex.js";
27
+ import type {
28
+ VectorCortexClosureProofView,
29
+ VectorCortexRestoreView,
30
+ } from "./api-contracts/vector-cortex.js";
24
31
 
25
32
  /** Reader-only GET /api/vector-cortex/closure-proof (VC6A). */
26
33
  export function handleVectorCortexClosureProof(
@@ -54,3 +61,43 @@ export function handleVectorCortexClosureProof(
54
61
  sendJson(res, 200, body);
55
62
  return true;
56
63
  }
64
+
65
+ /**
66
+ * Reader-only GET /api/vector-cortex/restore (VC6B).
67
+ *
68
+ * Counts and HEAL_RESTORE_* codes only — this is a static reader-only aggregate
69
+ * seam (same shape as the VC6A handler): there is no payload endpoint and never
70
+ * will be, so no restored bytes/span ids/node ids/ledger text can leak here.
71
+ */
72
+ export function handleVectorCortexRestore(
73
+ req: IncomingMessage,
74
+ res: ServerResponse,
75
+ _ctx: RouteContext,
76
+ ): boolean {
77
+ const url = req.url ?? "";
78
+ const path = url.split("?")[0] ?? url;
79
+ if (path !== "/api/vector-cortex/restore") return false;
80
+ if (req.method !== "GET") {
81
+ sendJson(res, 405, { error: "method_not_allowed" });
82
+ return true;
83
+ }
84
+
85
+ const enabled = VC6B_ENABLED();
86
+ // Flag-off routes to mode C: with VC6B off there is no exact-restoration path
87
+ // at all, so the honest OFF view is the disclose-loss mode (old context is
88
+ // omitted rather than inferred) — mirroring how VC6A's OFF view reports the
89
+ // conservative fallback it actually takes.
90
+ const mode: "A" | "B" | "C" = enabled ? "A" : "C";
91
+ const body: VectorCortexRestoreView = {
92
+ enabled,
93
+ mode,
94
+ restoreAttempts: 0,
95
+ restoredCount: 0,
96
+ missingCount: 0,
97
+ digestRejections: 0,
98
+ lastRejection: null,
99
+ updatedAt: new Date().toISOString(),
100
+ };
101
+ sendJson(res, 200, body);
102
+ return true;
103
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * dashboard-server/routes-vector-cortex-repair.ts — VC6C self-healing
3
+ * derived-state dashboard route.
4
+ *
5
+ * Reader-only GET /api/vector-cortex/repair returning the self-healing
6
+ * controller's aggregate diagnostics: whether the flag is enabled, the runtime
7
+ * triad mode, cumulative rebuild/pointer-switch/backoff counters, the last
8
+ * deterministic backoff delay, and the last HEAL_REPAIR_* failure code.
9
+ *
10
+ * COUNTS + ERROR CODES ONLY. NEVER exposes subsystem source bytes, rebuilt
11
+ * derived rows, per-subsystem gap ranges, high-water marks, root digests, or
12
+ * ledger text (reader-only, SECURITY_PRIVACY — the per-subsystem gap detail
13
+ * lives in the structured event log, not the dashboard). There is no mutation
14
+ * seam here either: rebuilds are driven by the controller's own gap detection,
15
+ * never by a dashboard request, so non-GET is rejected outright.
16
+ *
17
+ * Split into its own file (rather than grown into routes-vector-cortex-heal.ts)
18
+ * to keep every extensions/ file well under the 400-line soft-as-hard limit.
19
+ *
20
+ * Guardrails: PREVENT-PI-004 (local in-process state only), PREVENT-011 (no
21
+ * `any`), reader-only aggregate (counts + codes only).
22
+ */
23
+
24
+ import type { IncomingMessage, ServerResponse } from "node:http";
25
+ import type { RouteContext } from "./routes-core.js";
26
+ import { VC6C_ENABLED } from "../../src/config.js";
27
+ import { sendJson } from "./routes-vector-cortex-shared.js";
28
+ import type { VectorCortexRepairView } from "./api-contracts/vector-cortex.js";
29
+
30
+ /**
31
+ * Reader-only GET /api/vector-cortex/repair (VC6C).
32
+ *
33
+ * Counts and HEAL_REPAIR_* codes only — this is a static reader-only aggregate
34
+ * seam (same shape as the VC6A/VC6B handlers): there is no payload endpoint and
35
+ * never will be, so no subsystem bytes, gap ranges, high-water marks, or root
36
+ * digests can leak here.
37
+ */
38
+ export function handleVectorCortexRepair(
39
+ req: IncomingMessage,
40
+ res: ServerResponse,
41
+ _ctx: RouteContext,
42
+ ): boolean {
43
+ const url = req.url ?? "";
44
+ const path = url.split("?")[0] ?? url;
45
+ if (path !== "/api/vector-cortex/repair") return false;
46
+ if (req.method !== "GET") {
47
+ sendJson(res, 405, { error: "method_not_allowed" });
48
+ return true;
49
+ }
50
+
51
+ const enabled = VC6C_ENABLED();
52
+ // Flag-off routes to mode C: with VC6C off no self-healing controller runs at
53
+ // all, so neither the targeted rebuild (mode A) nor the full deterministic
54
+ // rebuild (mode B) path is available. Mode C is exactly the spec's "derived
55
+ // state disabled" outcome — the honest OFF view is that derived state is not
56
+ // being healed, rather than implying a rebuild path that is not wired.
57
+ // Mirrors how VC6B's OFF view reports the disclose-loss mode it actually takes.
58
+ const mode: "A" | "B" | "C" = enabled ? "A" : "C";
59
+ const body: VectorCortexRepairView = {
60
+ enabled,
61
+ mode,
62
+ repairAttempts: 0,
63
+ repairsPlanned: 0,
64
+ pointersSwitched: 0,
65
+ backoffs: 0,
66
+ lastBackoffMs: null,
67
+ lastFailure: null,
68
+ updatedAt: new Date().toISOString(),
69
+ };
70
+ sendJson(res, 200, body);
71
+ return true;
72
+ }
@@ -9,6 +9,8 @@
9
9
  * VC0C health/reset-> routes-vector-cortex-health.ts(GET /health, POST /breakers/reset)
10
10
  * VC1B ledger -> routes-vector-cortex-ledger.ts (GET /ledger)
11
11
  * VC3A topology -> routes-vector-cortex-topology.ts(GET /topology)
12
+ * VC6A closure -> routes-vector-cortex-heal.ts (GET /closure-proof)
13
+ * VC6B restore -> routes-vector-cortex-heal.ts (GET /restore)
12
14
  *
13
15
  * Guardrails: PREVENT-PI-004 (local filesystem read only), PREVENT-011 (no
14
16
  * `any`), reader-only aggregates (never payloads/prompts/ledger text).
@@ -25,4 +27,7 @@ export { handleVectorCortexReconstruct } from "./routes-vector-cortex-reconstruc
25
27
  export { handleVectorCortexPlans } from "./routes-vector-cortex-plans.js";
26
28
  export { handleVectorCortexRender } from "./routes-vector-cortex-render.js";
27
29
  export { handleVectorCortexRollout } from "./routes-vector-cortex-rollout.js";
28
- export { handleVectorCortexClosureProof } from "./routes-vector-cortex-heal.js";
30
+ export {
31
+ handleVectorCortexClosureProof,
32
+ handleVectorCortexRestore,
33
+ } from "./routes-vector-cortex-heal.js";
@@ -54,4 +54,5 @@ export {
54
54
  handleVectorCortexRender,
55
55
  handleVectorCortexRollout,
56
56
  handleVectorCortexClosureProof,
57
+ handleVectorCortexRestore,
57
58
  } from "./routes-vector-cortex.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.20.8",
3
+ "version": "0.20.10",
4
4
  "description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
@@ -227,6 +227,37 @@ export const VC5C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC5C");
227
227
  */
228
228
  export const VC6A_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC6A");
229
229
 
230
+ /**
231
+ * VC6B — exact source restoration. Default ON. `MEGACOMPACT_VC6B=0` disables and
232
+ * is byte-identical to the predecessor (VC6A): the `restoreSources` /
233
+ * `verifyRestored` arithmetic STILL RUNS (it is PURE — an exact-source read plus
234
+ * a SHA-256 comparison, with no clock, storage, or network), but the
235
+ * `vector_cortex_source_restored` / `vector_cortex_restore_digest_rejected`
236
+ * events are never emitted and the dashboard restoration diagnostics seam is
237
+ * suppressed. Flag OFF gates the reporter + dashboard seam, never the
238
+ * restore/verify arithmetic, so flag-off outbound/predecessor golden bytes match
239
+ * exactly. This flag MUST also be a dashboard SETTINGS toggle (visible in config
240
+ * UI, never in EXCLUDED_SETTINGS), mirroring VC4A/VC4B/VC4C/VC5A/VC5B/VC5C/VC6A.
241
+ */
242
+ export const VC6B_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC6B");
243
+
244
+ /**
245
+ * VC6C — self-healing derived controller. Default ON. `MEGACOMPACT_VC6C=0`
246
+ * disables and is byte-identical to the predecessor (VC6B): the `detectGaps` /
247
+ * `planRebuild` / `rebuildGeneration` / `switchPointer` arithmetic STILL RUNS (it
248
+ * is PURE — a high-water comparison plus a SHA-256 root-digest check, with an
249
+ * INJECTED clock and no storage or network), but the
250
+ * `vector_cortex_repair_planned` / `vector_cortex_repair_pointer_switched` /
251
+ * `vector_cortex_repair_backoff` events are never emitted and the dashboard
252
+ * repair diagnostics seam is suppressed. Flag OFF gates the reporter + dashboard
253
+ * seam, never the gap-detection/rebuild arithmetic (in particular, an unverified
254
+ * pointer switch stays refused with the flag off), so flag-off
255
+ * outbound/predecessor golden bytes match exactly. This flag MUST also be a
256
+ * dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS),
257
+ * mirroring VC4A/VC4B/VC4C/VC5A/VC5B/VC5C/VC6A/VC6B.
258
+ */
259
+ export const VC6C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC6C");
260
+
230
261
  // ---------------------------------------------------------------------------
231
262
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker).
232
263
  // Rolled numbers for one 60s window; VC0C consumes these at its breaker seam.
package/src/config.ts CHANGED
@@ -170,6 +170,8 @@ export {
170
170
  VC5B_ENABLED,
171
171
  VC5C_ENABLED,
172
172
  VC6A_ENABLED,
173
+ VC6B_ENABLED,
174
+ VC6C_ENABLED,
173
175
  BREAKER_WINDOW_MS,
174
176
  BREAKER_MIN_ATTEMPTS,
175
177
  BREAKER_PERF_FAILURES,