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
@@ -0,0 +1,99 @@
1
+ /**
2
+ * config/vector-cortex-early.ts — VC0/VC1/VC2 phase sprint flags.
3
+ *
4
+ * Extracted from vector-cortex.ts to keep that file under the 300-line soft
5
+ * limit (soft-as-hard gate), exactly as vector-cortex-breakers.ts was. These are
6
+ * the FOUNDATION-phase flags (observability, ledger, conformance, encoder); the
7
+ * VC3+ derived-state and prompt-path flags stay in vector-cortex.ts alongside
8
+ * the shared `sprintFlag` reader they are documented against.
9
+ *
10
+ * The split is purely mechanical: every flag below is byte-identical in name,
11
+ * semantics, and default to its previous definition, and vector-cortex.ts
12
+ * re-exports all of them so no consumer import path changes.
13
+ *
14
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
15
+ */
16
+
17
+ import { sprintFlag } from "./vector-cortex-flag.js";
18
+
19
+ /** VC0A — baseline observability (MetricEventV1 / AnnotationV1). Default ON. */
20
+ export const VC0A_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC0A");
21
+
22
+ /**
23
+ * VC0B — replay correctness (ReplayCutV2 / ReplayReportV2, M3 effective-cut-v2).
24
+ * Default ON. `MEGACOMPACT_VC0B=0` disables and is byte-identical to the
25
+ * predecessor (legacy capped-replay behavior preserved; the v2 cut/replay is
26
+ * only consulted on the vector-cortex path).
27
+ */
28
+ export const VC0B_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC0B");
29
+
30
+ /**
31
+ * VC1A — canonical byte events (EventV2 / EventCodec).
32
+ * Default ON. `MEGACOMPACT_VC1A=0` disables and is byte-identical to the
33
+ * predecessor (mode C: ledger absent, current transcript codec unchanged).
34
+ * The single real consumer is the ledger emit seam (`ledger/emit.ts`): flag OFF
35
+ * gates zero observability writes.
36
+ */
37
+ export const VC1A_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC1A");
38
+
39
+ /**
40
+ * VC1B — occurrence ledger + tool identity + compat journal (LedgerReader/
41
+ * Writer/Admin, CompatJournalV1, M2 occurrence-v2 migration).
42
+ * Default ON. `MEGACOMPACT_VC1B=0` disables and is byte-identical to the
43
+ * predecessor (mode C: the neutral occurrence ledger is not written, no
44
+ * journal rows, zero `vector_cortex_occurrence_appended` emissions). The real
45
+ * consumers are the ledger write integration seam and the compat-journal
46
+ * switch seam.
47
+ */
48
+ export const VC1B_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC1B");
49
+
50
+ /**
51
+ * VC0C — live safety envelope (TriadResult / Breaker / KillDecision + durable
52
+ * spool). Default ON. `MEGACOMPACT_VC0C=0` disables and is byte-identical to
53
+ * the predecessor (mode C: selected before provider invocation, unchanged host
54
+ * transcript, breaker/spool idle and emitting nothing). The single real
55
+ * consumer is the resilience emit seam + the safety adapter's triad selection.
56
+ */
57
+ export const VC0C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC0C");
58
+
59
+ /**
60
+ * VC1C — cross-language conformance v2 (FixtureManifestV2 / DowngradeReport /
61
+ * MinHashV2 + M4 minhash-v2 migration).
62
+ * Default ON. `MEGACOMPACT_VC1C=0` disables and is byte-identical to the
63
+ * predecessor (mode C: a v2 conformance runner that accepts authority fixtures
64
+ * and the manifest validator idle; the sync dedup scan stays on the v1 path;
65
+ * zero `vector_cortex_*` VC1C emissions). The real consumers are the conformance
66
+ * emit seam, the minhash-v2 backfill seam and the downgrade-export seam.
67
+ */
68
+ export const VC1C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC1C");
69
+
70
+ /**
71
+ * VC2A — offline model runtime and asset decision (ModelManifestV1 /
72
+ * EncoderRuntime).
73
+ * Default ON. `MEGACOMPACT_VC2A=0` disables and is byte-identical to the
74
+ * predecessor (mode C: no asset manifest is read/verified, the encoder runtime
75
+ * idles in mode C, zero `vector_cortex_encoder_*` emissions; the trigram/lexical
76
+ * paths are unchanged). The real consumers are the encoder emit seam and the
77
+ * encoder runtime's A/B/C selection.
78
+ */
79
+ export const VC2A_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC2A");
80
+
81
+ /**
82
+ * VC2B — multi-head encoder (VectorSetV1 / HeadCalibrationDraft).
83
+ * Default ON. `MEGACOMPACT_VC2B=0` disables and is byte-identical to the
84
+ * predecessor (the encoder emits no per-head vectors and no fallback-selected
85
+ * event; the trigram/lexical paths themselves are unchanged and are the
86
+ * predecessor's mode-B/C producers). The real consumers are the encoder-heads
87
+ * emit seam and the multi-head encoder producers (heads/trigram/lexical).
88
+ */
89
+ export const VC2B_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC2B");
90
+
91
+ /**
92
+ * VC2C — encoder qualification + calibration (QualifiedEncoderV1 / CalibrationV1).
93
+ * Default ON. `MEGACOMPACT_VC2C=0` disables and is byte-identical to the
94
+ * predecessor (mode C: no qualification manifest is read or selected, the
95
+ * calibrate/select/fallback seams are idle, zero `vector_cortex_encoder_qualification_*`
96
+ * emissions; the trigram/lexical paths are unchanged). The real consumers are
97
+ * the encoder-qualification emit seam and the calibrate/select seams.
98
+ */
99
+ export const VC2C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC2C");
@@ -0,0 +1,24 @@
1
+ /**
2
+ * config/vector-cortex-flag.ts — the single positive sprint-flag reader.
3
+ *
4
+ * Extracted from vector-cortex.ts so the flag groups split across
5
+ * vector-cortex.ts and vector-cortex-early.ts share ONE definition of what
6
+ * "enabled" means. Duplicating this three-line function into each group would
7
+ * be the classic way a sprint flag silently acquires different off-semantics in
8
+ * different files; there is exactly one implementation and both groups import it.
9
+ *
10
+ * Semantics (unchanged, byte-identical to the original in-place definition):
11
+ * every sprint flag is POSITIVE and defaults ON. `MEGACOMPACT_<SPRINT>=0` or
12
+ * `=false` disables it, as does `MEGACOMPACT_<SPRINT>_DISABLED=true`/`=1`.
13
+ *
14
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
15
+ */
16
+
17
+ /** Positive sprint flag: `=0` or `_DISABLED=true` disables (default ON). */
18
+ export function sprintFlag(name: string): boolean {
19
+ const v = process.env[name];
20
+ if (v === "0" || v === "false") return false;
21
+ const disabled = process.env[name + "_DISABLED"];
22
+ if (disabled === "true" || disabled === "1") return false;
23
+ return true;
24
+ }
@@ -9,96 +9,22 @@
9
9
  * them without re-declaring the ownership boundary. Pi-agnostic, dependency-free.
10
10
  */
11
11
 
12
- /** Positive sprint flag: `=0` or `_DISABLED=true` disables (default ON). */
13
- function sprintFlag(name: string): boolean {
14
- const v = process.env[name];
15
- if (v === "0" || v === "false") return false;
16
- const disabled = process.env[name + "_DISABLED"];
17
- if (disabled === "true" || disabled === "1") return false;
18
- return true;
19
- }
12
+ import { sprintFlag } from "./vector-cortex-flag.js";
20
13
 
21
- /** VC0A baseline observability (MetricEventV1 / AnnotationV1). Default ON. */
22
- export const VC0A_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC0A");
23
-
24
- /**
25
- * VC0B — replay correctness (ReplayCutV2 / ReplayReportV2, M3 effective-cut-v2).
26
- * Default ON. `MEGACOMPACT_VC0B=0` disables and is byte-identical to the
27
- * predecessor (legacy capped-replay behavior preserved; the v2 cut/replay is
28
- * only consulted on the vector-cortex path).
29
- */
30
- export const VC0B_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC0B");
31
-
32
- /**
33
- * VC1A — canonical byte events (EventV2 / EventCodec).
34
- * Default ON. `MEGACOMPACT_VC1A=0` disables and is byte-identical to the
35
- * predecessor (mode C: ledger absent, current transcript codec unchanged).
36
- * The single real consumer is the ledger emit seam (`ledger/emit.ts`): flag OFF
37
- * gates zero observability writes.
38
- */
39
- export const VC1A_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC1A");
40
-
41
- /**
42
- * VC1B — occurrence ledger + tool identity + compat journal (LedgerReader/
43
- * Writer/Admin, CompatJournalV1, M2 occurrence-v2 migration).
44
- * Default ON. `MEGACOMPACT_VC1B=0` disables and is byte-identical to the
45
- * predecessor (mode C: the neutral occurrence ledger is not written, no
46
- * journal rows, zero `vector_cortex_occurrence_appended` emissions). The real
47
- * consumers are the ledger write integration seam and the compat-journal
48
- * switch seam.
49
- */
50
- export const VC1B_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC1B");
51
-
52
- /**
53
- * VC0C — live safety envelope (TriadResult / Breaker / KillDecision + durable
54
- * spool). Default ON. `MEGACOMPACT_VC0C=0` disables and is byte-identical to
55
- * the predecessor (mode C: selected before provider invocation, unchanged host
56
- * transcript, breaker/spool idle and emitting nothing). The single real
57
- * consumer is the resilience emit seam + the safety adapter's triad selection.
58
- */
59
- export const VC0C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC0C");
60
-
61
- /**
62
- * VC1C — cross-language conformance v2 (FixtureManifestV2 / DowngradeReport /
63
- * MinHashV2 + M4 minhash-v2 migration).
64
- * Default ON. `MEGACOMPACT_VC1C=0` disables and is byte-identical to the
65
- * predecessor (mode C: a v2 conformance runner that accepts authority fixtures
66
- * and the manifest validator idle; the sync dedup scan stays on the v1 path;
67
- * zero `vector_cortex_*` VC1C emissions). The real consumers are the conformance
68
- * emit seam, the minhash-v2 backfill seam and the downgrade-export seam.
69
- */
70
- export const VC1C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC1C");
71
-
72
- /**
73
- * VC2A — offline model runtime and asset decision (ModelManifestV1 /
74
- * EncoderRuntime).
75
- * Default ON. `MEGACOMPACT_VC2A=0` disables and is byte-identical to the
76
- * predecessor (mode C: no asset manifest is read/verified, the encoder runtime
77
- * idles in mode C, zero `vector_cortex_encoder_*` emissions; the trigram/lexical
78
- * paths are unchanged). The real consumers are the encoder emit seam and the
79
- * encoder runtime's A/B/C selection.
80
- */
81
- export const VC2A_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC2A");
82
-
83
- /**
84
- * VC2B — multi-head encoder (VectorSetV1 / HeadCalibrationDraft).
85
- * Default ON. `MEGACOMPACT_VC2B=0` disables and is byte-identical to the
86
- * predecessor (the encoder emits no per-head vectors and no fallback-selected
87
- * event; the trigram/lexical paths themselves are unchanged and are the
88
- * predecessor's mode-B/C producers). The real consumers are the encoder-heads
89
- * emit seam and the multi-head encoder producers (heads/trigram/lexical).
90
- */
91
- export const VC2B_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC2B");
92
-
93
- /**
94
- * VC2C — encoder qualification + calibration (QualifiedEncoderV1 / CalibrationV1).
95
- * Default ON. `MEGACOMPACT_VC2C=0` disables and is byte-identical to the
96
- * predecessor (mode C: no qualification manifest is read or selected, the
97
- * calibrate/select/fallback seams are idle, zero `vector_cortex_encoder_qualification_*`
98
- * emissions; the trigram/lexical paths are unchanged). The real consumers are
99
- * the encoder-qualification emit seam and the calibrate/select seams.
100
- */
101
- export const VC2C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC2C");
14
+ // VC0/VC1/VC2 foundation-phase flags extracted to vector-cortex-early.ts to keep
15
+ // this file under the 300-line soft limit. Re-exported here so every existing
16
+ // `from "./config/vector-cortex.js"` import keeps resolving unchanged.
17
+ export {
18
+ VC0A_ENABLED,
19
+ VC0B_ENABLED,
20
+ VC0C_ENABLED,
21
+ VC1A_ENABLED,
22
+ VC1B_ENABLED,
23
+ VC1C_ENABLED,
24
+ VC2A_ENABLED,
25
+ VC2B_ENABLED,
26
+ VC2C_ENABLED,
27
+ } from "./vector-cortex-early.js";
102
28
 
103
29
  /**
104
30
  * VC3A — capability-gated cortex store (CortexReader/Writer/Admin, CortexRecordV1).
@@ -273,6 +199,46 @@ export const VC6C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC6C");
273
199
  */
274
200
  export const VC7A_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC7A");
275
201
 
202
+ /**
203
+ * VC7B — provider cache economics + crystal compiler. Default ON.
204
+ * `MEGACOMPACT_VC7B=0` disables and is byte-identical to the predecessor
205
+ * (VC7A): `computeEconomics`, `compileCrystalBoundaries` and `assignExperiment`
206
+ * STILL RUN (they are PURE — exact integer/rational arithmetic and a SHA-256
207
+ * session bucket, with no clock, storage, or network), so a session keeps its
208
+ * SAME experiment arm and the compiler keeps producing the SAME boundaries with
209
+ * the flag off. Crucially the compiler never changes request identity in either
210
+ * state, so the outbound canonical request — and therefore the VC7A crystal key
211
+ * and the predecessor golden bytes — are unaffected by this flag.
212
+ *
213
+ * The flag gates ONLY the `vector_cortex_cache_experiment_assigned` /
214
+ * `vector_cortex_cache_economics_estimated` events and the cache-economics
215
+ * dashboard seam, which reports `enabled:false` + mode C when off. This flag
216
+ * MUST also be a dashboard SETTINGS toggle (visible in config UI, never in
217
+ * EXCLUDED_SETTINGS), mirroring VC4A..VC7A.
218
+ */
219
+ export const VC7B_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC7B");
220
+
221
+ /**
222
+ * VC7C — cache miss diagnostics, cache-level breakers and the completed M5
223
+ * request-hash-v2 switch. Default ON. `MEGACOMPACT_VC7C=0` disables and is
224
+ * byte-identical to the predecessor (VC7B): the miss `classify`, the breaker
225
+ * demotion decision and the M5 request-hash-v2 ARITHMETIC STILL RUN (they are
226
+ * PURE — an exclusive ordered comparison over already-computed digests plus a
227
+ * canonical length-prefixed SHA-256, with no clock, storage, or network), so a
228
+ * miss is classified into the SAME single class, a collision / stale generation
229
+ * / digest failure / profile mismatch still demotes BEFORE any cache serve, and
230
+ * the v2 hash of a given request is unchanged with the flag off. A cache is
231
+ * never allowed to serve a stale or colliding entry merely because reporting is
232
+ * off — that would be a correctness change, not a reporting change.
233
+ *
234
+ * The flag gates ONLY the `vector_cortex_cache_miss_classified` /
235
+ * `vector_cortex_cache_serve_blocked` events and the cache-diagnostics dashboard
236
+ * seam, which reports `enabled:false` + mode C when off. This flag MUST also be
237
+ * a dashboard SETTINGS toggle (visible in config UI, never in
238
+ * EXCLUDED_SETTINGS), mirroring VC4A..VC7B.
239
+ */
240
+ export const VC7C_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_VC7C");
241
+
276
242
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker) extracted to
277
243
  // vector-cortex-breakers.ts to keep this file under the 300-line soft limit.
278
244
  export {
package/src/config.ts CHANGED
@@ -173,6 +173,8 @@ export {
173
173
  VC6B_ENABLED,
174
174
  VC6C_ENABLED,
175
175
  VC7A_ENABLED,
176
+ VC7B_ENABLED,
177
+ VC7C_ENABLED,
176
178
  BREAKER_WINDOW_MS,
177
179
  BREAKER_MIN_ATTEMPTS,
178
180
  BREAKER_PERF_FAILURES,
@@ -0,0 +1,128 @@
1
+ /**
2
+ * cache/_economics-fixture.ts — conformance fixture I/O for VC7B economics rows.
3
+ *
4
+ * Sibling of `./_crystal-fixture.ts`, same job for a different corpus: turn
5
+ * canonical JSON back into the REAL production types the economics / compiler /
6
+ * experiments modules consume. Fixtures cannot express bigints, so token counts
7
+ * stored as numbers are converted here — if that conversion were lossy the
8
+ * computed digests would diverge and the acceptance rows would fail loudly.
9
+ *
10
+ * No mocks, no stubs, no parallel "test shape": the decoded objects ARE
11
+ * `ProviderEconomicsV1` / `CacheUsageV1` / `CacheExperimentV1` and are fed
12
+ * verbatim into `validateProfileEconomics`, `computeEconomics`, `compileCrystalBoundaries`,
13
+ * and `assignExperiment`.
14
+ */
15
+
16
+ import { readFileSync } from "node:fs";
17
+ import { join } from "node:path";
18
+ import assert from "node:assert/strict";
19
+
20
+ import { V2, readManifest } from "../heal/_acceptance-fixture.js";
21
+
22
+ /** A `ProviderProfileExclusion` as it appears in JSON. */
23
+ export interface EconFxExclusion {
24
+ pointer: string;
25
+ fixtureId: string;
26
+ proofDigest: string;
27
+ }
28
+
29
+ /** A `ProviderProfileV1` as it appears in JSON (exclusions flattened). */
30
+ export interface EconFxProfile {
31
+ profileId: string;
32
+ profileVersion: string;
33
+ exclusionFixtureId: string | null;
34
+ exclusions: readonly EconFxExclusion[];
35
+ }
36
+
37
+ /** A `CacheUsageV1` as it appears in JSON (matches `CacheUsageV1` exactly). */
38
+ export interface EconFxUsage {
39
+ cachedTokens: number;
40
+ writeCount: number;
41
+ hitCount: number;
42
+ }
43
+
44
+ /** A compiler input range as it appears in JSON (matches `DagSpan` minus seq). */
45
+ export interface EconFxCompilerRange {
46
+ sessionId: string;
47
+ startSeq: number;
48
+ endSeq: number;
49
+ startByte: number;
50
+ endByte: number;
51
+ digest: string;
52
+ }
53
+
54
+ export interface EconFxExperiment {
55
+ experimentId: string;
56
+ sessionId: string;
57
+ arm: "A" | "B" | "C";
58
+ source: "randomized" | "forced" | "shadow";
59
+ }
60
+
61
+ export interface EconFxInput {
62
+ scenario: "economics" | "exclusion" | "compile" | "experiment" | "eligibility";
63
+ mode: string;
64
+ economics?: ProviderEconomicsV1Lite;
65
+ profile?: EconFxProfile;
66
+ exclusion?: EconFxExclusion;
67
+ usage?: EconFxUsage;
68
+ prefixTokens?: number;
69
+ ageMs?: number;
70
+ ranges?: readonly EconFxCompilerRange[];
71
+ experiment?: EconFxExperiment;
72
+ repeatAssignments?: number;
73
+ loseJournalAfterFirst?: boolean;
74
+ }
75
+
76
+ export interface ProviderEconomicsV1Lite {
77
+ profileId: string;
78
+ profileVersion: string;
79
+ basePrice: number;
80
+ readPrice: number;
81
+ writePrice: number;
82
+ ttlMs: number;
83
+ minPrefix: number;
84
+ exclusionFixtureId: string | null;
85
+ }
86
+
87
+ export interface EconFxExpected {
88
+ ok: boolean;
89
+ code?: string;
90
+ netSavings?: number;
91
+ tokenSavings?: number;
92
+ breakEvenHits?: number | null;
93
+ eligible?: boolean;
94
+ identityPreserved?: boolean;
95
+ repeatArm?: "A" | "B" | "C";
96
+ }
97
+
98
+ export interface EconFx {
99
+ id: string;
100
+ schema: string;
101
+ producer: string;
102
+ assertion: string;
103
+ kind: string;
104
+ input: EconFxInput;
105
+ expected: EconFxExpected;
106
+ }
107
+
108
+ /** Read one registered cache-economics fixture (asserting it IS registered). */
109
+ export function economicsFixture(id: string): EconFx {
110
+ const m = readManifest();
111
+ const row = m.fixtures.find((f) => f.id === id && f.path.startsWith("cache-economics/"));
112
+ assert.ok(row, `fixture ${id} registered under cache-economics/ in manifest`);
113
+ return JSON.parse(readFileSync(join(V2, row!.path), "utf8")) as EconFx;
114
+ }
115
+
116
+ /** Flag-pinned wrapper: VC7B gated by MEGACOMPACT_VC7B (defaults ON). */
117
+ export function withVc7bFlag(value: string, fn: () => void): () => void {
118
+ return (): void => {
119
+ const saved = process.env.MEGACOMPACT_VC7B;
120
+ process.env.MEGACOMPACT_VC7B = value;
121
+ try {
122
+ fn();
123
+ } finally {
124
+ if (saved === undefined) delete process.env.MEGACOMPACT_VC7B;
125
+ else process.env.MEGACOMPACT_VC7B = saved;
126
+ }
127
+ };
128
+ }