pi-mega-compact 0.20.13 → 0.20.15

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 (103) hide show
  1. package/dist/config/vector-cortex-early.js +89 -0
  2. package/dist/config/vector-cortex-flag.js +25 -0
  3. package/dist/config/vector-cortex.js +43 -83
  4. package/dist/config.js +1 -1
  5. package/dist/extensions/dashboard-server/api-contracts/vector-cortex-economics.js +20 -0
  6. package/dist/extensions/dashboard-server/route-dispatch.js +7 -0
  7. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +2 -0
  8. package/dist/extensions/dashboard-server/routes-vector-cortex-economics.js +59 -0
  9. package/dist/src/config/vector-cortex-early.js +89 -0
  10. package/dist/src/config/vector-cortex-flag.js +25 -0
  11. package/dist/src/config/vector-cortex.js +43 -83
  12. package/dist/src/config.js +1 -1
  13. package/dist/src/vector-cortex/cache/_economics-fixture.js +41 -0
  14. package/dist/src/vector-cortex/cache/compiler.js +201 -0
  15. package/dist/src/vector-cortex/cache/economics-emit.js +85 -0
  16. package/dist/src/vector-cortex/migrations/request-hash-v2-ops.js +143 -0
  17. package/dist/src/vector-cortex/migrations/request-hash-v2-types.js +30 -0
  18. package/dist/src/vector-cortex/migrations/request-hash-v2.js +56 -0
  19. package/dist/src/vector-cortex/provider/economics-ids.js +29 -0
  20. package/dist/src/vector-cortex/provider/economics.js +176 -0
  21. package/dist/src/vector-cortex/provider/experiments.js +166 -0
  22. package/dist/vector-cortex/cache/_economics-fixture.js +41 -0
  23. package/dist/vector-cortex/cache/compiler.js +201 -0
  24. package/dist/vector-cortex/cache/economics-emit.js +85 -0
  25. package/dist/vector-cortex/migrations/request-hash-v2-ops.js +143 -0
  26. package/dist/vector-cortex/migrations/request-hash-v2-types.js +30 -0
  27. package/dist/vector-cortex/migrations/request-hash-v2.js +56 -0
  28. package/dist/vector-cortex/provider/economics-ids.js +29 -0
  29. package/dist/vector-cortex/provider/economics.js +176 -0
  30. package/dist/vector-cortex/provider/experiments.js +166 -0
  31. package/extensions/dashboard-client/dist/assets/{AreaChart-CB-U7ViX.js → AreaChart-CV8WqMmt.js} +2 -2
  32. package/extensions/dashboard-client/dist/assets/{AreaChart-CB-U7ViX.js.map → AreaChart-CV8WqMmt.js.map} +1 -1
  33. package/extensions/dashboard-client/dist/assets/{BarChart-DnLw0fxA.js → BarChart-M-HEBq9l.js} +2 -2
  34. package/extensions/dashboard-client/dist/assets/{BarChart-DnLw0fxA.js.map → BarChart-M-HEBq9l.js.map} +1 -1
  35. package/extensions/dashboard-client/dist/assets/{CacheTab-CjyTVDiP.js → CacheTab-DJ_yPAhP.js} +2 -2
  36. package/extensions/dashboard-client/dist/assets/{CacheTab-CjyTVDiP.js.map → CacheTab-DJ_yPAhP.js.map} +1 -1
  37. package/extensions/dashboard-client/dist/assets/{EventsTab-Bz3QEWam.js → EventsTab-DNVlKzt6.js} +2 -2
  38. package/extensions/dashboard-client/dist/assets/{EventsTab-Bz3QEWam.js.map → EventsTab-DNVlKzt6.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/{HealthTab-CUylEvEY.js → HealthTab-B5yjuInb.js} +2 -2
  40. package/extensions/dashboard-client/dist/assets/{HealthTab-CUylEvEY.js.map → HealthTab-B5yjuInb.js.map} +1 -1
  41. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Cz_hj_E7.js → MaintenanceTab-DoQedESF.js} +2 -2
  42. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Cz_hj_E7.js.map → MaintenanceTab-DoQedESF.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-Dh8brIR1.js → MemoryMapTab-CuL5CzdH.js} +2 -2
  44. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-Dh8brIR1.js.map → MemoryMapTab-CuL5CzdH.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{MetricsTab-CkqSXc6e.js → MetricsTab-CZSTaCpK.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{MetricsTab-CkqSXc6e.js.map → MetricsTab-CZSTaCpK.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{OverviewTab-DGbJcx6d.js → OverviewTab-vkZlXRW6.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{OverviewTab-DGbJcx6d.js.map → OverviewTab-vkZlXRW6.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{ReposTab-BawS3nfF.js → ReposTab-DgPD96rF.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{ReposTab-BawS3nfF.js.map → ReposTab-DgPD96rF.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/{SessionsTab-CUVnmYks.js → SessionsTab-XPbWh7XN.js} +2 -2
  52. package/extensions/dashboard-client/dist/assets/{SessionsTab-CUVnmYks.js.map → SessionsTab-XPbWh7XN.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/{SetupTab-cxTuyZNk.js → SetupTab-Dz74XAtR.js} +2 -2
  54. package/extensions/dashboard-client/dist/assets/{SetupTab-cxTuyZNk.js.map → SetupTab-Dz74XAtR.js.map} +1 -1
  55. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Cv5SENkE.js → TimeSavedCard-FynCpJdx.js} +2 -2
  56. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Cv5SENkE.js.map → TimeSavedCard-FynCpJdx.js.map} +1 -1
  57. package/extensions/dashboard-client/dist/assets/{TurnsTab-yl6BBG_F.js → TurnsTab-C7m3GDy0.js} +2 -2
  58. package/extensions/dashboard-client/dist/assets/{TurnsTab-yl6BBG_F.js.map → TurnsTab-C7m3GDy0.js.map} +1 -1
  59. package/extensions/dashboard-client/dist/assets/VectorCortexTab-jRd_Iztk.js +2 -0
  60. package/extensions/dashboard-client/dist/assets/VectorCortexTab-jRd_Iztk.js.map +1 -0
  61. package/extensions/dashboard-client/dist/assets/{WikiTab-DKv-0xCQ.js → WikiTab-C6viLa0u.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{WikiTab-DKv-0xCQ.js.map → WikiTab-C6viLa0u.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/assets/{button-CVPrO4UU.js → button-mBEgbBVU.js} +2 -2
  64. package/extensions/dashboard-client/dist/assets/{button-CVPrO4UU.js.map → button-mBEgbBVU.js.map} +1 -1
  65. package/extensions/dashboard-client/dist/assets/{card-BFLnQJEo.js → card-CalUQAKG.js} +2 -2
  66. package/extensions/dashboard-client/dist/assets/{card-BFLnQJEo.js.map → card-CalUQAKG.js.map} +1 -1
  67. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-B-IUoLd1.js → generateCategoricalChart-CMmkuwj5.js} +2 -2
  68. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-B-IUoLd1.js.map → generateCategoricalChart-CMmkuwj5.js.map} +1 -1
  69. package/extensions/dashboard-client/dist/assets/{index-Do749WlW.js → index-Dz8GPBOE.js} +3 -3
  70. package/extensions/dashboard-client/dist/assets/{index-Do749WlW.js.map → index-Dz8GPBOE.js.map} +1 -1
  71. package/extensions/dashboard-client/dist/assets/{switch-3uFnZmtq.js → switch-8QKO6CTU.js} +2 -2
  72. package/extensions/dashboard-client/dist/assets/{switch-3uFnZmtq.js.map → switch-8QKO6CTU.js.map} +1 -1
  73. package/extensions/dashboard-client/dist/assets/{toggle-C1rYLeXe.js → toggle-9eCkWI4q.js} +2 -2
  74. package/extensions/dashboard-client/dist/assets/{toggle-C1rYLeXe.js.map → toggle-9eCkWI4q.js.map} +1 -1
  75. package/extensions/dashboard-client/dist/assets/{useSSE-D1qzLzgR.js → useSSE-s6IqOKoD.js} +2 -2
  76. package/extensions/dashboard-client/dist/assets/{useSSE-D1qzLzgR.js.map → useSSE-s6IqOKoD.js.map} +1 -1
  77. package/extensions/dashboard-client/dist/index.html +1 -1
  78. package/extensions/dashboard-client/src/api/vector-cortex.ts +18 -0
  79. package/extensions/dashboard-client/src/tabs/VectorCortexEconomicsCard.tsx +41 -0
  80. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +24 -114
  81. package/extensions/dashboard-client/src/tabs/useVectorCortexPoll.ts +123 -0
  82. package/extensions/dashboard-client/src/types/vector-cortex-vc7.ts +63 -0
  83. package/extensions/dashboard-client/src/types/vector-cortex.ts +5 -19
  84. package/extensions/dashboard-server/api-contracts/vector-cortex-economics.ts +47 -0
  85. package/extensions/dashboard-server/route-dispatch.ts +6 -0
  86. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +12 -0
  87. package/extensions/dashboard-server/routes-vector-cortex-economics.ts +68 -0
  88. package/package.json +1 -1
  89. package/src/config/vector-cortex-early.ts +99 -0
  90. package/src/config/vector-cortex-flag.ts +24 -0
  91. package/src/config/vector-cortex.ts +55 -89
  92. package/src/config.ts +2 -0
  93. package/src/vector-cortex/cache/_economics-fixture.ts +128 -0
  94. package/src/vector-cortex/cache/compiler.ts +280 -0
  95. package/src/vector-cortex/cache/economics-emit.ts +116 -0
  96. package/src/vector-cortex/migrations/request-hash-v2-ops.ts +195 -0
  97. package/src/vector-cortex/migrations/request-hash-v2-types.ts +87 -0
  98. package/src/vector-cortex/migrations/request-hash-v2.ts +80 -0
  99. package/src/vector-cortex/provider/economics-ids.ts +38 -0
  100. package/src/vector-cortex/provider/economics.ts +289 -0
  101. package/src/vector-cortex/provider/experiments.ts +248 -0
  102. package/extensions/dashboard-client/dist/assets/VectorCortexTab-94fqVjat.js +0 -2
  103. package/extensions/dashboard-client/dist/assets/VectorCortexTab-94fqVjat.js.map +0 -1
@@ -4,50 +4,26 @@
4
4
  * GET /api/vector-cortex/evaluation. VC0C (task 5): live safety envelope health
5
5
  * card (breaker state, window/probe/backoff, durable spool frontier/lag) from
6
6
  * GET /api/vector-cortex/health plus an admin "reset cooldown" action. Polls
7
- * every 5s.
7
+ * every 5s via useVectorCortexPoll.
8
8
  */
9
9
 
10
- import { useState, useEffect, useCallback } from "react";
10
+ import { useState } from "react";
11
11
  import {
12
- fetchVectorCortexEvaluation,
13
- fetchVectorCortexHealth,
14
- fetchVectorCortexLedger,
15
- fetchVectorCortexQuery,
16
- fetchVectorCortexReconstruct,
17
- fetchVectorCortexPlans,
18
- fetchVectorCortexRender,
19
- fetchVectorCortexRollout,
20
- fetchVectorCortexClosureProof,
21
- fetchVectorCortexRestore,
22
- fetchVectorCortexRepair,
23
- fetchVectorCortexCrystals,
24
- fetchVectorCortexShards,
25
- fetchVectorCortexTopology,
26
12
  resetVectorCortexBreaker,
27
- type VectorCortexEvaluationSummary,
13
+ fetchVectorCortexHealth,
28
14
  type VectorCortexHealthCard,
29
- type VectorCortexLedgerView,
30
- type VectorCortexQueryView,
31
- type VectorCortexReconstructView,
32
- type VectorCortexPlansView,
33
- type VectorCortexRenderView,
34
- type VectorCortexRolloutView,
35
- type VectorCortexClosureProofView,
36
- type VectorCortexRestoreView,
37
- type VectorCortexRepairView,
38
- type VectorCortexCrystalsView,
39
- type VectorCortexShardsView,
40
- type VectorCortexTopologyView,
41
15
  } from "../api/vector-cortex";
42
16
  import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card";
43
17
  import { Badge } from "../components/ui/badge";
44
18
  import { Metric } from "./VectorCortexMetric";
19
+ import { useVectorCortexPoll } from "./useVectorCortexPoll";
45
20
  import { VectorCortexRenderCard } from "./VectorCortexRenderCard";
46
21
  import { VectorCortexRolloutCard } from "./VectorCortexRolloutCard";
47
22
  import { VectorCortexClosureCard } from "./VectorCortexClosureCard";
48
23
  import { VectorCortexRestoreCard } from "./VectorCortexRestoreCard";
49
24
  import { VectorCortexRepairCard } from "./VectorCortexRepairCard";
50
25
  import { VectorCortexCrystalsCard } from "./VectorCortexCrystalsCard";
26
+ import { VectorCortexEconomicsCard } from "./VectorCortexEconomicsCard";
51
27
  import {
52
28
  VectorCortexShardsCard,
53
29
  VectorCortexReconstructCard,
@@ -66,77 +42,10 @@ function ModeChip({ mode, count }: { mode: string; count: number }): React.React
66
42
  }
67
43
 
68
44
  export default function VectorCortexTab(): React.ReactElement {
69
- const [data, setData] = useState<VectorCortexEvaluationSummary | null>(null);
70
- const [err, setError] = useState<string | null>(null);
71
- const [loading, setLoading] = useState(true);
72
- const [health, setHealth] = useState<VectorCortexHealthCard | null>(null);
45
+ const [poll, refetch] = useVectorCortexPoll();
73
46
  const [resetMsg, setResetMsg] = useState<string | null>(null);
74
- const [ledger, setLedger] = useState<VectorCortexLedgerView | null>(null);
75
- const [topology, setTopology] = useState<VectorCortexTopologyView | null>(null);
76
- const [query, setQuery] = useState<VectorCortexQueryView | null>(null);
77
- const [shards, setShards] = useState<VectorCortexShardsView | null>(null);
78
- const [reconstruct, setReconstruct] = useState<VectorCortexReconstructView | null>(null);
79
- const [plans, setPlans] = useState<VectorCortexPlansView | null>(null);
80
- const [render, setRender] = useState<VectorCortexRenderView | null>(null);
81
- const [rollout, setRollout] = useState<VectorCortexRolloutView | null>(null);
82
- const [closureProof, setClosureProof] = useState<VectorCortexClosureProofView | null>(null);
83
- const [restore, setRestore] = useState<VectorCortexRestoreView | null>(null);
84
- const [repair, setRepair] = useState<VectorCortexRepairView | null>(null);
85
- const [crystals, setCrystals] = useState<VectorCortexCrystalsView | null>(null);
86
-
87
- const poll = useCallback(() => {
88
- fetchVectorCortexEvaluation()
89
- .then(setData)
90
- .catch((e: unknown) =>
91
- setError(e instanceof Error ? e.message : String(e)),
92
- )
93
- .finally(() => setLoading(false));
94
- fetchVectorCortexHealth().then(setHealth).catch(() => {
95
- /* health card is best-effort (VC0C) */
96
- });
97
- fetchVectorCortexLedger().then(setLedger).catch(() => {
98
- /* ledger card is best-effort (VC1B) */
99
- });
100
- fetchVectorCortexTopology().then(setTopology).catch(() => {
101
- /* topology card is best-effort (VC3A) */
102
- });
103
- fetchVectorCortexQuery().then(setQuery).catch(() => {
104
- /* query diagnostics card is best-effort (VC3C) */
105
- });
106
- fetchVectorCortexShards().then(setShards).catch(() => {
107
- /* dual-tier shards card is best-effort (VC4A) */
108
- });
109
- fetchVectorCortexReconstruct().then(setReconstruct).catch(() => {
110
- /* reconstruction-fidelity card is best-effort (VC4C) */
111
- });
112
- fetchVectorCortexPlans().then(setPlans).catch(() => {
113
- /* plan manifest card is best-effort (VC5A) */
114
- });
115
- fetchVectorCortexRender().then(setRender).catch(() => {
116
- /* render conformance card is best-effort (VC5B) */
117
- });
118
- fetchVectorCortexRollout().then(setRollout).catch(() => {
119
- /* rollout card is best-effort (VC5C) */
120
- });
121
- fetchVectorCortexClosureProof().then(setClosureProof).catch(() => {
122
- /* closure-optimization card is best-effort (VC6A) */
123
- });
124
- fetchVectorCortexRestore().then(setRestore).catch(() => {
125
- /* exact-source-restoration card is best-effort (VC6B) */
126
- });
127
- fetchVectorCortexRepair().then(setRepair).catch(() => {
128
- /* self-healing derived-state card is best-effort (VC6C) */
129
- });
130
- fetchVectorCortexCrystals().then(setCrystals).catch(() => {
131
- /* frozen-range-crystal card is best-effort (VC7A) */
132
- });
133
- }, []);
134
47
 
135
- useEffect(() => {
136
- poll();
137
- const id = setInterval(poll, 5000);
138
- return () => clearInterval(id);
139
- }, [poll]);
48
+ const { loading, error, data, health } = poll;
140
49
 
141
50
  const onReset = () => {
142
51
  resetVectorCortexBreaker("provider")
@@ -146,7 +55,7 @@ export default function VectorCortexTab(): React.ReactElement {
146
55
  );
147
56
  return fetchVectorCortexHealth();
148
57
  })
149
- .then(setHealth)
58
+ .then((h: VectorCortexHealthCard | null) => { void h; refetch(); })
150
59
  .catch((e: unknown) =>
151
60
  setResetMsg(e instanceof Error ? e.message : String(e)),
152
61
  );
@@ -154,8 +63,8 @@ export default function VectorCortexTab(): React.ReactElement {
154
63
 
155
64
  if (loading && !data)
156
65
  return <div className="vc-loading">Loading vector-cortex evaluation…</div>;
157
- if (err && !data)
158
- return <div className="vc-error">Error: {err}</div>;
66
+ if (error && !data)
67
+ return <div className="vc-error">Error: {error}</div>;
159
68
  if (!data)
160
69
  return <div className="vc-empty">No evaluation data available.</div>;
161
70
 
@@ -274,23 +183,24 @@ export default function VectorCortexTab(): React.ReactElement {
274
183
  }
275
184
  />
276
185
  <Metric label="Spool lag" value={String(health.spoolLag)} />
277
- <Metric label="Encoder mode" value={health.encoderMode} />
278
- <Metric label="Encoder asset" value={health.encoderAssetDigest ? health.encoderAssetDigest.slice(0, 12) : "none"} />
186
+ <Metric label="Encoder mode" value={health.encoderMode} />
187
+ <Metric label="Encoder asset" value={health.encoderAssetDigest ? health.encoderAssetDigest.slice(0, 12) : "none"} />
279
188
  </div>
280
189
  )}
281
190
  </CardContent>
282
191
  </Card>
283
- <VectorCortexTopologyCard topology={topology} query={query} />
284
- <VectorCortexShardsCard view={shards} />
285
- <VectorCortexReconstructCard view={reconstruct} />
286
- <VectorCortexPlansCard view={plans} />
287
- <VectorCortexRenderCard view={render} />
288
- <VectorCortexRolloutCard view={rollout} />
289
- <VectorCortexClosureCard view={closureProof} />
290
- <VectorCortexRestoreCard view={restore} />
291
- <VectorCortexRepairCard view={repair} />
292
- <VectorCortexCrystalsCard view={crystals} />
293
- <VectorCortexLedgerCard ledger={ledger} />
192
+ <VectorCortexTopologyCard topology={poll.topology} query={poll.query} />
193
+ <VectorCortexShardsCard view={poll.shards} />
194
+ <VectorCortexReconstructCard view={poll.reconstruct} />
195
+ <VectorCortexPlansCard view={poll.plans} />
196
+ <VectorCortexRenderCard view={poll.render} />
197
+ <VectorCortexRolloutCard view={poll.rollout} />
198
+ <VectorCortexClosureCard view={poll.closureProof} />
199
+ <VectorCortexRestoreCard view={poll.restore} />
200
+ <VectorCortexRepairCard view={poll.repair} />
201
+ <VectorCortexCrystalsCard view={poll.crystals} />
202
+ <VectorCortexEconomicsCard view={poll.economics} />
203
+ <VectorCortexLedgerCard ledger={poll.ledger} />
294
204
  </div>
295
205
  );
296
206
  }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * useVectorCortexPoll — extracted from VectorCortexTab to keep the tab under
3
+ * the 400-line soft limit. Fetches all vector-cortex reader views in parallel
4
+ * every 5s; each fetch is best-effort (a failure sets its slice to null/state).
5
+ */
6
+ import { useState, useEffect, useCallback } from "react";
7
+ import {
8
+ fetchVectorCortexEvaluation,
9
+ fetchVectorCortexHealth,
10
+ fetchVectorCortexLedger,
11
+ fetchVectorCortexQuery,
12
+ fetchVectorCortexReconstruct,
13
+ fetchVectorCortexPlans,
14
+ fetchVectorCortexRender,
15
+ fetchVectorCortexRollout,
16
+ fetchVectorCortexClosureProof,
17
+ fetchVectorCortexRestore,
18
+ fetchVectorCortexRepair,
19
+ fetchVectorCortexCrystals,
20
+ fetchVectorCortexEconomics,
21
+ fetchVectorCortexDiagnostics,
22
+ fetchVectorCortexShards,
23
+ fetchVectorCortexTopology,
24
+ type VectorCortexEvaluationSummary,
25
+ type VectorCortexHealthCard,
26
+ type VectorCortexLedgerView,
27
+ type VectorCortexQueryView,
28
+ type VectorCortexReconstructView,
29
+ type VectorCortexPlansView,
30
+ type VectorCortexRenderView,
31
+ type VectorCortexRolloutView,
32
+ type VectorCortexClosureProofView,
33
+ type VectorCortexRestoreView,
34
+ type VectorCortexRepairView,
35
+ type VectorCortexCrystalsView,
36
+ type VectorCortexEconomicsView,
37
+ type VectorCortexDiagnosticsView,
38
+ type VectorCortexShardsView,
39
+ type VectorCortexTopologyView,
40
+ } from "../api/vector-cortex";
41
+
42
+ export interface VectorCortexPollState {
43
+ loading: boolean;
44
+ error: string | null;
45
+ data: VectorCortexEvaluationSummary | null;
46
+ health: VectorCortexHealthCard | null;
47
+ ledger: VectorCortexLedgerView | null;
48
+ topology: VectorCortexTopologyView | null;
49
+ query: VectorCortexQueryView | null;
50
+ shards: VectorCortexShardsView | null;
51
+ reconstruct: VectorCortexReconstructView | null;
52
+ plans: VectorCortexPlansView | null;
53
+ render: VectorCortexRenderView | null;
54
+ rollout: VectorCortexRolloutView | null;
55
+ closureProof: VectorCortexClosureProofView | null;
56
+ restore: VectorCortexRestoreView | null;
57
+ repair: VectorCortexRepairView | null;
58
+ crystals: VectorCortexCrystalsView | null;
59
+ economics: VectorCortexEconomicsView | null;
60
+ diagnostics: VectorCortexDiagnosticsView | null;
61
+ }
62
+
63
+ export function useVectorCortexPoll(): [
64
+ VectorCortexPollState,
65
+ () => void,
66
+ ] {
67
+ const [state, setState] = useState<VectorCortexPollState>({
68
+ loading: true,
69
+ error: null,
70
+ data: null,
71
+ health: null,
72
+ ledger: null,
73
+ topology: null,
74
+ query: null,
75
+ shards: null,
76
+ reconstruct: null,
77
+ plans: null,
78
+ render: null,
79
+ rollout: null,
80
+ closureProof: null,
81
+ restore: null,
82
+ repair: null,
83
+ crystals: null,
84
+ economics: null,
85
+ diagnostics: null,
86
+ });
87
+
88
+ const poll = useCallback(() => {
89
+ setState((prev) => ({ ...prev, loading: true }));
90
+ fetchVectorCortexEvaluation()
91
+ .then((data) => setState((prev) => ({ ...prev, data, loading: false, error: null })))
92
+ .catch((e: unknown) =>
93
+ setState((prev) => ({
94
+ ...prev,
95
+ loading: false,
96
+ error: e instanceof Error ? e.message : String(e),
97
+ })),
98
+ );
99
+ fetchVectorCortexHealth().then((health) => setState((p) => ({ ...p, health }))).catch(() => {});
100
+ fetchVectorCortexLedger().then((ledger) => setState((p) => ({ ...p, ledger }))).catch(() => {});
101
+ fetchVectorCortexTopology().then((topology) => setState((p) => ({ ...p, topology }))).catch(() => {});
102
+ fetchVectorCortexQuery().then((query) => setState((p) => ({ ...p, query }))).catch(() => {});
103
+ fetchVectorCortexShards().then((shards) => setState((p) => ({ ...p, shards }))).catch(() => {});
104
+ fetchVectorCortexReconstruct().then((reconstruct) => setState((p) => ({ ...p, reconstruct }))).catch(() => {});
105
+ fetchVectorCortexPlans().then((plans) => setState((p) => ({ ...p, plans }))).catch(() => {});
106
+ fetchVectorCortexRender().then((render) => setState((p) => ({ ...p, render }))).catch(() => {});
107
+ fetchVectorCortexRollout().then((rollout) => setState((p) => ({ ...p, rollout }))).catch(() => {});
108
+ fetchVectorCortexClosureProof().then((closureProof) => setState((p) => ({ ...p, closureProof }))).catch(() => {});
109
+ fetchVectorCortexRestore().then((restore) => setState((p) => ({ ...p, restore }))).catch(() => {});
110
+ fetchVectorCortexRepair().then((repair) => setState((p) => ({ ...p, repair }))).catch(() => {});
111
+ fetchVectorCortexCrystals().then((crystals) => setState((p) => ({ ...p, crystals }))).catch(() => {});
112
+ fetchVectorCortexEconomics().then((economics) => setState((p) => ({ ...p, economics }))).catch(() => {});
113
+ fetchVectorCortexDiagnostics().then((diagnostics) => setState((p) => ({ ...p, diagnostics }))).catch(() => {});
114
+ }, []);
115
+
116
+ useEffect(() => {
117
+ poll();
118
+ const id = setInterval(poll, 5000);
119
+ return () => clearInterval(id);
120
+ }, [poll]);
121
+
122
+ return [state, poll];
123
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * dashboard-client/src/types/vector-cortex-vc7.ts — VC7-era client view types.
3
+ *
4
+ * Extracted from vector-cortex.ts to keep the parent file under the 300-line
5
+ * soft limit (soft-as-hard gate). Each interface mirrors a reader-only server
6
+ * API contract: counts + codes only, never prompt payloads, digests, or session
7
+ * bytes.
8
+ */
9
+
10
+ /**
11
+ * Reader-only frozen-crystal cache view (VC7A). Counts + byte volumes + CRY_*
12
+ * codes only — a crystal is a rendered prompt, so no frozen bytes, covered
13
+ * ranges, digests, or session ids ever reach the client.
14
+ */
15
+ export interface VectorCortexCrystalsView {
16
+ enabled: boolean;
17
+ mode: "A" | "B" | "C";
18
+ crystalCount: number;
19
+ totalBytes: number;
20
+ hits: number;
21
+ misses: number;
22
+ hitBytes: number;
23
+ writes: number;
24
+ duplicateWrites: number;
25
+ collisions: number;
26
+ lastFailure: string | null;
27
+ updatedAt: string;
28
+ }
29
+
30
+ /**
31
+ * Reader-only cache-economics diagnostics view (VC7B). Counts + ECON_* codes only
32
+ * — never prices, digests, ranges, or session ids.
33
+ */
34
+ export interface VectorCortexEconomicsView {
35
+ enabled: boolean;
36
+ mode: "A" | "B" | "C";
37
+ profileCount: number;
38
+ provenExclusions: number;
39
+ unprovenExclusions: number;
40
+ lastFailure: string | null;
41
+ updatedAt: string;
42
+ }
43
+
44
+ /**
45
+ * Reader-only cache miss-diagnostics view (VC7C). One count per EXCLUSIVE miss
46
+ * class plus breaker state and CACHE_* / M5_* codes only — a miss diagnostic would
47
+ * otherwise carry the missed request itself, so no request payload, request
48
+ * digest, covered range, span digest, or session id ever reaches the client.
49
+ */
50
+ export interface VectorCortexDiagnosticsView {
51
+ enabled: boolean;
52
+ mode: "A" | "B" | "C";
53
+ profileMisses: number;
54
+ rangeMisses: number;
55
+ dependencyMisses: number;
56
+ requestMisses: number;
57
+ generationMisses: number;
58
+ unknownMisses: number;
59
+ serveBlocked: number;
60
+ breakerState: string;
61
+ lastFailure: string | null;
62
+ updatedAt: string;
63
+ }
@@ -256,22 +256,8 @@ export interface VectorCortexClosureProofView {
256
256
  updatedAt: string;
257
257
  }
258
258
 
259
- /**
260
- * Reader-only frozen-crystal cache view (VC7A). Counts + byte volumes + CRY_*
261
- * codes only — a crystal is a rendered prompt, so no frozen bytes, covered
262
- * ranges, digests, or session ids ever reach the client.
263
- */
264
- export interface VectorCortexCrystalsView {
265
- enabled: boolean;
266
- mode: "A" | "B" | "C";
267
- crystalCount: number;
268
- totalBytes: number;
269
- hits: number;
270
- misses: number;
271
- hitBytes: number;
272
- writes: number;
273
- duplicateWrites: number;
274
- collisions: number;
275
- lastFailure: string | null;
276
- updatedAt: string;
277
- }
259
+ export type {
260
+ VectorCortexCrystalsView,
261
+ VectorCortexEconomicsView,
262
+ VectorCortexDiagnosticsView,
263
+ } from "./vector-cortex-vc7.js";
@@ -0,0 +1,47 @@
1
+ /**
2
+ * api-contracts/vector-cortex-economics.ts — VC7B cache-economics API contract.
3
+ *
4
+ * PREVENT-PI-004: type definitions only, no network code.
5
+ * PREVENT-011: no `any` type.
6
+ *
7
+ * Reader-only GET /api/vector-cortex/cache-economics diagnostics view (VC7B).
8
+ *
9
+ * COUNTS + CODES ONLY. Cache economics price a FROZEN RENDERED PROMPT's reuse, so
10
+ * this is the surface where an unguarded payload field would leak the frozen
11
+ * bytes, the covered ranges, the span/covered digests, the request digests, or
12
+ * the session ids that identify the framed conversation. It exposes ONLY:
13
+ * - whether the VC7B flag is enabled and the runtime triad mode it implies;
14
+ * - how many provider profiles carry economics and how many exclusions are
15
+ * proven vs unproven (a count, never the excluded pointer or its bytes);
16
+ * - the last ECON_* rejection code (an outcome code, not a payload).
17
+ * Per-profile prices, digests, ranges, and session ids live in the structured
18
+ * event log / conformance corpus, never here (SECURITY_PRIVACY).
19
+ */
20
+
21
+ /** Runtime triad mode implied by the VC7B flag state. */
22
+ export type VectorCortexEconomicsMode = "A" | "B" | "C";
23
+
24
+ /**
25
+ * Reader-only cache-economics diagnostics view for
26
+ * GET /api/vector-cortex/cache-economics (VC7B).
27
+ */
28
+ export interface VectorCortexEconomicsView {
29
+ /** Whether the VC7B cache-economics flag is enabled. */
30
+ readonly enabled: boolean;
31
+ /**
32
+ * Runtime triad mode: "A" economics applied to a cached/compiled render,
33
+ * "B" economics computed against an uncached fresh render,
34
+ * "C" economics bypassed (flag off) so no economics are served.
35
+ */
36
+ readonly mode: VectorCortexEconomicsMode;
37
+ /** Provider profiles that declare cache economics (a count, not the prices). */
38
+ readonly profileCount: number;
39
+ /** Exclusions that carry a proving fixture id (count only). */
40
+ readonly provenExclusions: number;
41
+ /** Exclusions rejected for lacking a fixture id (count only). */
42
+ readonly unprovenExclusions: number;
43
+ /** Last economics rejection reason (an ECON_* code), or null if none. */
44
+ readonly lastFailure: string | null;
45
+ /** ISO timestamp of the snapshot. */
46
+ readonly updatedAt: string;
47
+ }
@@ -64,6 +64,11 @@ import { handleVectorCortexRepair } from "./routes-vector-cortex-repair.js";
64
64
  // stays independent of the heal/repair handlers and every file stays well under
65
65
  // the 400-line extension limit.
66
66
  import { handleVectorCortexCrystals } from "./routes-vector-cortex-crystals.js";
67
+ // VC7B cache economics likewise get their own module so the economics seam stays
68
+ // independent of the crystals handler and every file stays well under the
69
+ // 400-line extension soft limit.
70
+ import { handleVectorCortexEconomics } from "./routes-vector-cortex-economics.js";
71
+ // VC7C cache miss diagnostics + breakers handler will be imported here when VC7C ships.
67
72
 
68
73
  /**
69
74
  * Dispatch a request through every registered route handler.
@@ -119,5 +124,6 @@ export function dispatchRoutes(
119
124
  if (handleVectorCortexRestore(req, res, ctx)) return true;
120
125
  if (handleVectorCortexRepair(req, res, ctx)) return true;
121
126
  if (handleVectorCortexCrystals(req, res, ctx)) return true;
127
+ if (handleVectorCortexEconomics(req, res, ctx)) return true;
122
128
  return false;
123
129
  }
@@ -162,5 +162,17 @@ export const VECTOR_CORTEX_SETTINGS: SettingGroup = {
162
162
  "Frozen range crystals: caches a rendered prompt under an IMMUTABLE key built from the source ranges it covers, the digest of those covered bytes, the validated durable dependency high-water, and the renderer + provider profile — and deliberately NOT the global ledger frontier, so an unrelated append leaves the key unchanged instead of invalidating every crystal on every turn. Any covered-byte, dependency, renderer, or profile change invalidates 100%. Ranges are sorted by source start and overlapping ranges are rejected (CRY_RANGE_OVERLAP) rather than merged. The store is content-addressed and write-once: identical bytes re-written are idempotent, but a same-key/different-bytes write returns CRY_KEY_COLLISION and never overwrites, surfacing renderer non-determinism instead of hiding it. A store hit is mode A, a miss/collision forces a fresh deterministic render (mode B), and an unavailable store bypasses the cache entirely (mode C). OFF = byte-identical predecessor (VC6C); the crystal/store arithmetic still runs, only the reporter + dashboard seam is suppressed.",
163
163
  true,
164
164
  ),
165
+ boolDirect(
166
+ "MEGACOMPACT_VC7B",
167
+ "VC7B Provider Cache Economics",
168
+ "Provider cache economics: extends the VC5B provider registry with cache economics (read/write price, TTL, minimum prefix, and a mandatory exclusion fixture id). Answers whether reusing a frozen crystal is actually worth it — a cache WRITE typically costs more than an uncached token, so a cache only pays off once a written prefix is re-read enough times before TTL expiry. Net savings are reported (never clamped at zero, so a losing cache stays visible) and every exclusion MUST name a proving conformance fixture or it is rejected (ECON_EXCLUSION_UNPROVEN). A compiled crystal boundary still reuses the VC7A key unchanged, and a randomized session-level experiment assigns arms by a stable hash so a lost assignment journal re-derives the same arm. OFF = byte-identical predecessor (VC7A); the economics/compiler/experiment arithmetic still runs, only the reporter + dashboard seam is suppressed.",
169
+ true,
170
+ ),
171
+ boolDirect(
172
+ "MEGACOMPACT_VC7C",
173
+ "VC7C Cache Diagnostics & Breakers",
174
+ "Cache miss diagnostics + cache-level breakers + the completed M5 request-hash-v2 switch. Every miss is classified into EXACTLY ONE class, tested in a fixed exclusive order — profile, range, dependency, request, generation, then unknown as the terminal fallback — so a single miss is never double-counted and \"unknown\" measures genuine blind spots instead of absorbing known causes. Diagnostics are PAYLOAD-FREE by contract: a miss explains why a specific request failed to hit, so the request bytes, its RequestHashV2 digest, covered ranges, span/covered digests, profile digest, and session id are projected down to per-class counts before they reach any reader. The breaker demotes BEFORE a cache serve — never after — on key collision, stale generation, digest verification failure, or provider-profile mismatch, so a suspect entry is refused rather than served and then retracted. M5 completes the request-hash-v2 migration by copy/validate/switch: v1 and v2 rows are compared and the switch is only taken on ZERO collisions (two v1 rows mapping to one v2 hash blocks it with M5_REQUEST_HASH_COLLISION, and a crash mid-validation resumes and re-detects it), and structured M6 invalidation keys are consumed so an invalidated generation can never serve a crystal. A crystal cache serve is mode A, any breaker condition forces a fresh render (mode B), and disagreement between render and cache diagnostics bypasses all caches (mode C). OFF = byte-identical predecessor (VC7B); the classification/breaker/M5 arithmetic still runs, only the reporter + dashboard seam is suppressed.",
175
+ true,
176
+ ),
165
177
  ],
166
178
  };
@@ -0,0 +1,68 @@
1
+ /**
2
+ * dashboard-server/routes-vector-cortex-economics.ts — VC7B cache-economics
3
+ * dashboard route.
4
+ *
5
+ * Reader-only GET /api/vector-cortex/cache-economics returning the cache-
6
+ * economics aggregate diagnostics: whether the VC7B flag is enabled, the runtime
7
+ * triad mode, how many provider profiles carry economics, how many exclusions
8
+ * are proven vs unproven, and the last ECON_* failure code.
9
+ *
10
+ * COUNTS + CODES ONLY. Cache economics price a FROZEN RENDERED PROMPT's reuse,
11
+ * so a careless payload field would leak the frozen bytes, the covered ranges,
12
+ * the span/covered digests, the request digests, or session ids that identify
13
+ * the framed conversation. This route NEVER exposes frozen bytes, ranges,
14
+ * digests, session ids, or request digests — only aggregate counts and the
15
+ * observable ECON_* outcome code (reader-only, SECURITY_PRIVACY). There is no
16
+ * mutation seam: economics are computed by the render path, never by a dashboard
17
+ * request. Non-GET is rejected outright.
18
+ *
19
+ * Split into its own file (rather than grown into routes-vector-cortex-crystals.ts)
20
+ * to keep every extensions/ file well under the 400-line soft-as-hard limit.
21
+ *
22
+ * Guardrails: PREVENT-PI-004 (local in-process state only), PREVENT-011 (no
23
+ * `any`), reader-only aggregate (counts + codes only).
24
+ */
25
+
26
+ import type { IncomingMessage, ServerResponse } from "node:http";
27
+ import type { RouteContext } from "./routes-core.js";
28
+ import { VC7B_ENABLED } from "../../src/config.js";
29
+ import { sendJson } from "./routes-vector-cortex-shared.js";
30
+ import type { VectorCortexEconomicsView } from "./api-contracts/vector-cortex-economics.js";
31
+
32
+ /**
33
+ * Reader-only GET /api/vector-cortex/cache-economics (VC7B).
34
+ *
35
+ * Counts, profile tallies, and ECON_* codes only — a static reader-only
36
+ * aggregate seam with the same shape as the VC7A crystals handler.
37
+ */
38
+ export function handleVectorCortexEconomics(
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/cache-economics") return false;
46
+ if (req.method !== "GET") {
47
+ sendJson(res, 405, { error: "method_not_allowed" });
48
+ return true;
49
+ }
50
+
51
+ const enabled = VC7B_ENABLED();
52
+ // Flag-off routes to mode C: with VC7B off no cache economics are served, which
53
+ // is exactly the spec's "economics bypass" outcome. Reporting A (cached render
54
+ // priced) or B (fresh render priced) would imply an economics path that is not
55
+ // wired at all. Mirrors how VC6C/VC7A OFF views report the mode they take.
56
+ const mode: "A" | "B" | "C" = enabled ? "A" : "C";
57
+ const body: VectorCortexEconomicsView = {
58
+ enabled,
59
+ mode,
60
+ profileCount: 0,
61
+ provenExclusions: 0,
62
+ unprovenExclusions: 0,
63
+ lastFailure: null,
64
+ updatedAt: new Date().toISOString(),
65
+ };
66
+ sendJson(res, 200, body);
67
+ return true;
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.20.13",
3
+ "version": "0.20.15",
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",