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,89 @@
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
+ import { sprintFlag } from "./vector-cortex-flag.js";
17
+ /** VC0A — baseline observability (MetricEventV1 / AnnotationV1). Default ON. */
18
+ export const VC0A_ENABLED = () => sprintFlag("MEGACOMPACT_VC0A");
19
+ /**
20
+ * VC0B — replay correctness (ReplayCutV2 / ReplayReportV2, M3 effective-cut-v2).
21
+ * Default ON. `MEGACOMPACT_VC0B=0` disables and is byte-identical to the
22
+ * predecessor (legacy capped-replay behavior preserved; the v2 cut/replay is
23
+ * only consulted on the vector-cortex path).
24
+ */
25
+ export const VC0B_ENABLED = () => sprintFlag("MEGACOMPACT_VC0B");
26
+ /**
27
+ * VC1A — canonical byte events (EventV2 / EventCodec).
28
+ * Default ON. `MEGACOMPACT_VC1A=0` disables and is byte-identical to the
29
+ * predecessor (mode C: ledger absent, current transcript codec unchanged).
30
+ * The single real consumer is the ledger emit seam (`ledger/emit.ts`): flag OFF
31
+ * gates zero observability writes.
32
+ */
33
+ export const VC1A_ENABLED = () => sprintFlag("MEGACOMPACT_VC1A");
34
+ /**
35
+ * VC1B — occurrence ledger + tool identity + compat journal (LedgerReader/
36
+ * Writer/Admin, CompatJournalV1, M2 occurrence-v2 migration).
37
+ * Default ON. `MEGACOMPACT_VC1B=0` disables and is byte-identical to the
38
+ * predecessor (mode C: the neutral occurrence ledger is not written, no
39
+ * journal rows, zero `vector_cortex_occurrence_appended` emissions). The real
40
+ * consumers are the ledger write integration seam and the compat-journal
41
+ * switch seam.
42
+ */
43
+ export const VC1B_ENABLED = () => sprintFlag("MEGACOMPACT_VC1B");
44
+ /**
45
+ * VC0C — live safety envelope (TriadResult / Breaker / KillDecision + durable
46
+ * spool). Default ON. `MEGACOMPACT_VC0C=0` disables and is byte-identical to
47
+ * the predecessor (mode C: selected before provider invocation, unchanged host
48
+ * transcript, breaker/spool idle and emitting nothing). The single real
49
+ * consumer is the resilience emit seam + the safety adapter's triad selection.
50
+ */
51
+ export const VC0C_ENABLED = () => sprintFlag("MEGACOMPACT_VC0C");
52
+ /**
53
+ * VC1C — cross-language conformance v2 (FixtureManifestV2 / DowngradeReport /
54
+ * MinHashV2 + M4 minhash-v2 migration).
55
+ * Default ON. `MEGACOMPACT_VC1C=0` disables and is byte-identical to the
56
+ * predecessor (mode C: a v2 conformance runner that accepts authority fixtures
57
+ * and the manifest validator idle; the sync dedup scan stays on the v1 path;
58
+ * zero `vector_cortex_*` VC1C emissions). The real consumers are the conformance
59
+ * emit seam, the minhash-v2 backfill seam and the downgrade-export seam.
60
+ */
61
+ export const VC1C_ENABLED = () => sprintFlag("MEGACOMPACT_VC1C");
62
+ /**
63
+ * VC2A — offline model runtime and asset decision (ModelManifestV1 /
64
+ * EncoderRuntime).
65
+ * Default ON. `MEGACOMPACT_VC2A=0` disables and is byte-identical to the
66
+ * predecessor (mode C: no asset manifest is read/verified, the encoder runtime
67
+ * idles in mode C, zero `vector_cortex_encoder_*` emissions; the trigram/lexical
68
+ * paths are unchanged). The real consumers are the encoder emit seam and the
69
+ * encoder runtime's A/B/C selection.
70
+ */
71
+ export const VC2A_ENABLED = () => sprintFlag("MEGACOMPACT_VC2A");
72
+ /**
73
+ * VC2B — multi-head encoder (VectorSetV1 / HeadCalibrationDraft).
74
+ * Default ON. `MEGACOMPACT_VC2B=0` disables and is byte-identical to the
75
+ * predecessor (the encoder emits no per-head vectors and no fallback-selected
76
+ * event; the trigram/lexical paths themselves are unchanged and are the
77
+ * predecessor's mode-B/C producers). The real consumers are the encoder-heads
78
+ * emit seam and the multi-head encoder producers (heads/trigram/lexical).
79
+ */
80
+ export const VC2B_ENABLED = () => sprintFlag("MEGACOMPACT_VC2B");
81
+ /**
82
+ * VC2C — encoder qualification + calibration (QualifiedEncoderV1 / CalibrationV1).
83
+ * Default ON. `MEGACOMPACT_VC2C=0` disables and is byte-identical to the
84
+ * predecessor (mode C: no qualification manifest is read or selected, the
85
+ * calibrate/select/fallback seams are idle, zero `vector_cortex_encoder_qualification_*`
86
+ * emissions; the trigram/lexical paths are unchanged). The real consumers are
87
+ * the encoder-qualification emit seam and the calibrate/select seams.
88
+ */
89
+ export const VC2C_ENABLED = () => sprintFlag("MEGACOMPACT_VC2C");
@@ -0,0 +1,25 @@
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
+ /** Positive sprint flag: `=0` or `_DISABLED=true` disables (default ON). */
17
+ export function sprintFlag(name) {
18
+ const v = process.env[name];
19
+ if (v === "0" || v === "false")
20
+ return false;
21
+ const disabled = process.env[name + "_DISABLED"];
22
+ if (disabled === "true" || disabled === "1")
23
+ return false;
24
+ return true;
25
+ }
@@ -8,89 +8,11 @@
8
8
  * The breaker/triad constants (TRIAD_RESILIENCE.md) live here so VC0C consumes
9
9
  * them without re-declaring the ownership boundary. Pi-agnostic, dependency-free.
10
10
  */
11
- /** Positive sprint flag: `=0` or `_DISABLED=true` disables (default ON). */
12
- function sprintFlag(name) {
13
- const v = process.env[name];
14
- if (v === "0" || v === "false")
15
- return false;
16
- const disabled = process.env[name + "_DISABLED"];
17
- if (disabled === "true" || disabled === "1")
18
- return false;
19
- return true;
20
- }
21
- /** VC0A — baseline observability (MetricEventV1 / AnnotationV1). Default ON. */
22
- export const VC0A_ENABLED = () => sprintFlag("MEGACOMPACT_VC0A");
23
- /**
24
- * VC0B — replay correctness (ReplayCutV2 / ReplayReportV2, M3 effective-cut-v2).
25
- * Default ON. `MEGACOMPACT_VC0B=0` disables and is byte-identical to the
26
- * predecessor (legacy capped-replay behavior preserved; the v2 cut/replay is
27
- * only consulted on the vector-cortex path).
28
- */
29
- export const VC0B_ENABLED = () => sprintFlag("MEGACOMPACT_VC0B");
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 = () => sprintFlag("MEGACOMPACT_VC1A");
38
- /**
39
- * VC1B — occurrence ledger + tool identity + compat journal (LedgerReader/
40
- * Writer/Admin, CompatJournalV1, M2 occurrence-v2 migration).
41
- * Default ON. `MEGACOMPACT_VC1B=0` disables and is byte-identical to the
42
- * predecessor (mode C: the neutral occurrence ledger is not written, no
43
- * journal rows, zero `vector_cortex_occurrence_appended` emissions). The real
44
- * consumers are the ledger write integration seam and the compat-journal
45
- * switch seam.
46
- */
47
- export const VC1B_ENABLED = () => sprintFlag("MEGACOMPACT_VC1B");
48
- /**
49
- * VC0C — live safety envelope (TriadResult / Breaker / KillDecision + durable
50
- * spool). Default ON. `MEGACOMPACT_VC0C=0` disables and is byte-identical to
51
- * the predecessor (mode C: selected before provider invocation, unchanged host
52
- * transcript, breaker/spool idle and emitting nothing). The single real
53
- * consumer is the resilience emit seam + the safety adapter's triad selection.
54
- */
55
- export const VC0C_ENABLED = () => sprintFlag("MEGACOMPACT_VC0C");
56
- /**
57
- * VC1C — cross-language conformance v2 (FixtureManifestV2 / DowngradeReport /
58
- * MinHashV2 + M4 minhash-v2 migration).
59
- * Default ON. `MEGACOMPACT_VC1C=0` disables and is byte-identical to the
60
- * predecessor (mode C: a v2 conformance runner that accepts authority fixtures
61
- * and the manifest validator idle; the sync dedup scan stays on the v1 path;
62
- * zero `vector_cortex_*` VC1C emissions). The real consumers are the conformance
63
- * emit seam, the minhash-v2 backfill seam and the downgrade-export seam.
64
- */
65
- export const VC1C_ENABLED = () => sprintFlag("MEGACOMPACT_VC1C");
66
- /**
67
- * VC2A — offline model runtime and asset decision (ModelManifestV1 /
68
- * EncoderRuntime).
69
- * Default ON. `MEGACOMPACT_VC2A=0` disables and is byte-identical to the
70
- * predecessor (mode C: no asset manifest is read/verified, the encoder runtime
71
- * idles in mode C, zero `vector_cortex_encoder_*` emissions; the trigram/lexical
72
- * paths are unchanged). The real consumers are the encoder emit seam and the
73
- * encoder runtime's A/B/C selection.
74
- */
75
- export const VC2A_ENABLED = () => sprintFlag("MEGACOMPACT_VC2A");
76
- /**
77
- * VC2B — multi-head encoder (VectorSetV1 / HeadCalibrationDraft).
78
- * Default ON. `MEGACOMPACT_VC2B=0` disables and is byte-identical to the
79
- * predecessor (the encoder emits no per-head vectors and no fallback-selected
80
- * event; the trigram/lexical paths themselves are unchanged and are the
81
- * predecessor's mode-B/C producers). The real consumers are the encoder-heads
82
- * emit seam and the multi-head encoder producers (heads/trigram/lexical).
83
- */
84
- export const VC2B_ENABLED = () => sprintFlag("MEGACOMPACT_VC2B");
85
- /**
86
- * VC2C — encoder qualification + calibration (QualifiedEncoderV1 / CalibrationV1).
87
- * Default ON. `MEGACOMPACT_VC2C=0` disables and is byte-identical to the
88
- * predecessor (mode C: no qualification manifest is read or selected, the
89
- * calibrate/select/fallback seams are idle, zero `vector_cortex_encoder_qualification_*`
90
- * emissions; the trigram/lexical paths are unchanged). The real consumers are
91
- * the encoder-qualification emit seam and the calibrate/select seams.
92
- */
93
- export const VC2C_ENABLED = () => sprintFlag("MEGACOMPACT_VC2C");
11
+ import { sprintFlag } from "./vector-cortex-flag.js";
12
+ // VC0/VC1/VC2 foundation-phase flags extracted to vector-cortex-early.ts to keep
13
+ // this file under the 300-line soft limit. Re-exported here so every existing
14
+ // `from "./config/vector-cortex.js"` import keeps resolving unchanged.
15
+ export { VC0A_ENABLED, VC0B_ENABLED, VC0C_ENABLED, VC1A_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, } from "./vector-cortex-early.js";
94
16
  /**
95
17
  * VC3A — capability-gated cortex store (CortexReader/Writer/Admin, CortexRecordV1).
96
18
  * Default ON. `MEGACOMPACT_VC3A=0` disables and is byte-identical to the
@@ -251,6 +173,44 @@ export const VC6C_ENABLED = () => sprintFlag("MEGACOMPACT_VC6C");
251
173
  * UI, never in EXCLUDED_SETTINGS), mirroring VC4A..VC6C.
252
174
  */
253
175
  export const VC7A_ENABLED = () => sprintFlag("MEGACOMPACT_VC7A");
176
+ /**
177
+ * VC7B — provider cache economics + crystal compiler. Default ON.
178
+ * `MEGACOMPACT_VC7B=0` disables and is byte-identical to the predecessor
179
+ * (VC7A): `computeEconomics`, `compileCrystalBoundaries` and `assignExperiment`
180
+ * STILL RUN (they are PURE — exact integer/rational arithmetic and a SHA-256
181
+ * session bucket, with no clock, storage, or network), so a session keeps its
182
+ * SAME experiment arm and the compiler keeps producing the SAME boundaries with
183
+ * the flag off. Crucially the compiler never changes request identity in either
184
+ * state, so the outbound canonical request — and therefore the VC7A crystal key
185
+ * and the predecessor golden bytes — are unaffected by this flag.
186
+ *
187
+ * The flag gates ONLY the `vector_cortex_cache_experiment_assigned` /
188
+ * `vector_cortex_cache_economics_estimated` events and the cache-economics
189
+ * dashboard seam, which reports `enabled:false` + mode C when off. This flag
190
+ * MUST also be a dashboard SETTINGS toggle (visible in config UI, never in
191
+ * EXCLUDED_SETTINGS), mirroring VC4A..VC7A.
192
+ */
193
+ export const VC7B_ENABLED = () => sprintFlag("MEGACOMPACT_VC7B");
194
+ /**
195
+ * VC7C — cache miss diagnostics, cache-level breakers and the completed M5
196
+ * request-hash-v2 switch. Default ON. `MEGACOMPACT_VC7C=0` disables and is
197
+ * byte-identical to the predecessor (VC7B): the miss `classify`, the breaker
198
+ * demotion decision and the M5 request-hash-v2 ARITHMETIC STILL RUN (they are
199
+ * PURE — an exclusive ordered comparison over already-computed digests plus a
200
+ * canonical length-prefixed SHA-256, with no clock, storage, or network), so a
201
+ * miss is classified into the SAME single class, a collision / stale generation
202
+ * / digest failure / profile mismatch still demotes BEFORE any cache serve, and
203
+ * the v2 hash of a given request is unchanged with the flag off. A cache is
204
+ * never allowed to serve a stale or colliding entry merely because reporting is
205
+ * off — that would be a correctness change, not a reporting change.
206
+ *
207
+ * The flag gates ONLY the `vector_cortex_cache_miss_classified` /
208
+ * `vector_cortex_cache_serve_blocked` events and the cache-diagnostics dashboard
209
+ * seam, which reports `enabled:false` + mode C when off. This flag MUST also be
210
+ * a dashboard SETTINGS toggle (visible in config UI, never in
211
+ * EXCLUDED_SETTINGS), mirroring VC4A..VC7B.
212
+ */
213
+ export const VC7C_ENABLED = () => sprintFlag("MEGACOMPACT_VC7C");
254
214
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker) extracted to
255
215
  // vector-cortex-breakers.ts to keep this file under the 300-line soft limit.
256
216
  export { BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./vector-cortex-breakers.js";
package/dist/config.js CHANGED
@@ -114,4 +114,4 @@ export const NEW_UI = () => ragEnabled("MEGACOMPACT_NEW_UI");
114
114
  // default ON, `=0`/`_DISABLED` off. Re-exported from src/config/vector-cortex.ts
115
115
  // so root consumers share one source of truth.
116
116
  // ---------------------------------------------------------------------------
117
- export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
117
+ export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, VC7B_ENABLED, VC7C_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
@@ -0,0 +1,20 @@
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
+ export {};
@@ -16,6 +16,11 @@ import { handleVectorCortexRepair } from "./routes-vector-cortex-repair.js";
16
16
  // stays independent of the heal/repair handlers and every file stays well under
17
17
  // the 400-line extension limit.
18
18
  import { handleVectorCortexCrystals } from "./routes-vector-cortex-crystals.js";
19
+ // VC7B cache economics likewise get their own module so the economics seam stays
20
+ // independent of the crystals handler and every file stays well under the
21
+ // 400-line extension soft limit.
22
+ import { handleVectorCortexEconomics } from "./routes-vector-cortex-economics.js";
23
+ // VC7C cache miss diagnostics + breakers handler will be imported here when VC7C ships.
19
24
  /**
20
25
  * Dispatch a request through every registered route handler.
21
26
  * Returns true if a handler claimed the request (ended the response).
@@ -111,5 +116,7 @@ export function dispatchRoutes(req, res, ctx) {
111
116
  return true;
112
117
  if (handleVectorCortexCrystals(req, res, ctx))
113
118
  return true;
119
+ if (handleVectorCortexEconomics(req, res, ctx))
120
+ return true;
114
121
  return false;
115
122
  }
@@ -43,5 +43,7 @@ export const VECTOR_CORTEX_SETTINGS = {
43
43
  boolDirect("MEGACOMPACT_VC6B", "VC6B Exact Source Restoration", "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).", true),
44
44
  boolDirect("MEGACOMPACT_VC6C", "VC6C Self-Healing Derived State", "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.", true),
45
45
  boolDirect("MEGACOMPACT_VC7A", "VC7A Frozen Range Crystals", "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.", true),
46
+ boolDirect("MEGACOMPACT_VC7B", "VC7B Provider Cache Economics", "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.", true),
47
+ boolDirect("MEGACOMPACT_VC7C", "VC7C Cache Diagnostics & Breakers", "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.", true),
46
48
  ],
47
49
  };
@@ -0,0 +1,59 @@
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
+ import { VC7B_ENABLED } from "../../src/config.js";
26
+ import { sendJson } from "./routes-vector-cortex-shared.js";
27
+ /**
28
+ * Reader-only GET /api/vector-cortex/cache-economics (VC7B).
29
+ *
30
+ * Counts, profile tallies, and ECON_* codes only — a static reader-only
31
+ * aggregate seam with the same shape as the VC7A crystals handler.
32
+ */
33
+ export function handleVectorCortexEconomics(req, res, _ctx) {
34
+ const url = req.url ?? "";
35
+ const path = url.split("?")[0] ?? url;
36
+ if (path !== "/api/vector-cortex/cache-economics")
37
+ return false;
38
+ if (req.method !== "GET") {
39
+ sendJson(res, 405, { error: "method_not_allowed" });
40
+ return true;
41
+ }
42
+ const enabled = VC7B_ENABLED();
43
+ // Flag-off routes to mode C: with VC7B off no cache economics are served, which
44
+ // is exactly the spec's "economics bypass" outcome. Reporting A (cached render
45
+ // priced) or B (fresh render priced) would imply an economics path that is not
46
+ // wired at all. Mirrors how VC6C/VC7A OFF views report the mode they take.
47
+ const mode = enabled ? "A" : "C";
48
+ const body = {
49
+ enabled,
50
+ mode,
51
+ profileCount: 0,
52
+ provenExclusions: 0,
53
+ unprovenExclusions: 0,
54
+ lastFailure: null,
55
+ updatedAt: new Date().toISOString(),
56
+ };
57
+ sendJson(res, 200, body);
58
+ return true;
59
+ }
@@ -0,0 +1,89 @@
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
+ import { sprintFlag } from "./vector-cortex-flag.js";
17
+ /** VC0A — baseline observability (MetricEventV1 / AnnotationV1). Default ON. */
18
+ export const VC0A_ENABLED = () => sprintFlag("MEGACOMPACT_VC0A");
19
+ /**
20
+ * VC0B — replay correctness (ReplayCutV2 / ReplayReportV2, M3 effective-cut-v2).
21
+ * Default ON. `MEGACOMPACT_VC0B=0` disables and is byte-identical to the
22
+ * predecessor (legacy capped-replay behavior preserved; the v2 cut/replay is
23
+ * only consulted on the vector-cortex path).
24
+ */
25
+ export const VC0B_ENABLED = () => sprintFlag("MEGACOMPACT_VC0B");
26
+ /**
27
+ * VC1A — canonical byte events (EventV2 / EventCodec).
28
+ * Default ON. `MEGACOMPACT_VC1A=0` disables and is byte-identical to the
29
+ * predecessor (mode C: ledger absent, current transcript codec unchanged).
30
+ * The single real consumer is the ledger emit seam (`ledger/emit.ts`): flag OFF
31
+ * gates zero observability writes.
32
+ */
33
+ export const VC1A_ENABLED = () => sprintFlag("MEGACOMPACT_VC1A");
34
+ /**
35
+ * VC1B — occurrence ledger + tool identity + compat journal (LedgerReader/
36
+ * Writer/Admin, CompatJournalV1, M2 occurrence-v2 migration).
37
+ * Default ON. `MEGACOMPACT_VC1B=0` disables and is byte-identical to the
38
+ * predecessor (mode C: the neutral occurrence ledger is not written, no
39
+ * journal rows, zero `vector_cortex_occurrence_appended` emissions). The real
40
+ * consumers are the ledger write integration seam and the compat-journal
41
+ * switch seam.
42
+ */
43
+ export const VC1B_ENABLED = () => sprintFlag("MEGACOMPACT_VC1B");
44
+ /**
45
+ * VC0C — live safety envelope (TriadResult / Breaker / KillDecision + durable
46
+ * spool). Default ON. `MEGACOMPACT_VC0C=0` disables and is byte-identical to
47
+ * the predecessor (mode C: selected before provider invocation, unchanged host
48
+ * transcript, breaker/spool idle and emitting nothing). The single real
49
+ * consumer is the resilience emit seam + the safety adapter's triad selection.
50
+ */
51
+ export const VC0C_ENABLED = () => sprintFlag("MEGACOMPACT_VC0C");
52
+ /**
53
+ * VC1C — cross-language conformance v2 (FixtureManifestV2 / DowngradeReport /
54
+ * MinHashV2 + M4 minhash-v2 migration).
55
+ * Default ON. `MEGACOMPACT_VC1C=0` disables and is byte-identical to the
56
+ * predecessor (mode C: a v2 conformance runner that accepts authority fixtures
57
+ * and the manifest validator idle; the sync dedup scan stays on the v1 path;
58
+ * zero `vector_cortex_*` VC1C emissions). The real consumers are the conformance
59
+ * emit seam, the minhash-v2 backfill seam and the downgrade-export seam.
60
+ */
61
+ export const VC1C_ENABLED = () => sprintFlag("MEGACOMPACT_VC1C");
62
+ /**
63
+ * VC2A — offline model runtime and asset decision (ModelManifestV1 /
64
+ * EncoderRuntime).
65
+ * Default ON. `MEGACOMPACT_VC2A=0` disables and is byte-identical to the
66
+ * predecessor (mode C: no asset manifest is read/verified, the encoder runtime
67
+ * idles in mode C, zero `vector_cortex_encoder_*` emissions; the trigram/lexical
68
+ * paths are unchanged). The real consumers are the encoder emit seam and the
69
+ * encoder runtime's A/B/C selection.
70
+ */
71
+ export const VC2A_ENABLED = () => sprintFlag("MEGACOMPACT_VC2A");
72
+ /**
73
+ * VC2B — multi-head encoder (VectorSetV1 / HeadCalibrationDraft).
74
+ * Default ON. `MEGACOMPACT_VC2B=0` disables and is byte-identical to the
75
+ * predecessor (the encoder emits no per-head vectors and no fallback-selected
76
+ * event; the trigram/lexical paths themselves are unchanged and are the
77
+ * predecessor's mode-B/C producers). The real consumers are the encoder-heads
78
+ * emit seam and the multi-head encoder producers (heads/trigram/lexical).
79
+ */
80
+ export const VC2B_ENABLED = () => sprintFlag("MEGACOMPACT_VC2B");
81
+ /**
82
+ * VC2C — encoder qualification + calibration (QualifiedEncoderV1 / CalibrationV1).
83
+ * Default ON. `MEGACOMPACT_VC2C=0` disables and is byte-identical to the
84
+ * predecessor (mode C: no qualification manifest is read or selected, the
85
+ * calibrate/select/fallback seams are idle, zero `vector_cortex_encoder_qualification_*`
86
+ * emissions; the trigram/lexical paths are unchanged). The real consumers are
87
+ * the encoder-qualification emit seam and the calibrate/select seams.
88
+ */
89
+ export const VC2C_ENABLED = () => sprintFlag("MEGACOMPACT_VC2C");
@@ -0,0 +1,25 @@
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
+ /** Positive sprint flag: `=0` or `_DISABLED=true` disables (default ON). */
17
+ export function sprintFlag(name) {
18
+ const v = process.env[name];
19
+ if (v === "0" || v === "false")
20
+ return false;
21
+ const disabled = process.env[name + "_DISABLED"];
22
+ if (disabled === "true" || disabled === "1")
23
+ return false;
24
+ return true;
25
+ }
@@ -8,89 +8,11 @@
8
8
  * The breaker/triad constants (TRIAD_RESILIENCE.md) live here so VC0C consumes
9
9
  * them without re-declaring the ownership boundary. Pi-agnostic, dependency-free.
10
10
  */
11
- /** Positive sprint flag: `=0` or `_DISABLED=true` disables (default ON). */
12
- function sprintFlag(name) {
13
- const v = process.env[name];
14
- if (v === "0" || v === "false")
15
- return false;
16
- const disabled = process.env[name + "_DISABLED"];
17
- if (disabled === "true" || disabled === "1")
18
- return false;
19
- return true;
20
- }
21
- /** VC0A — baseline observability (MetricEventV1 / AnnotationV1). Default ON. */
22
- export const VC0A_ENABLED = () => sprintFlag("MEGACOMPACT_VC0A");
23
- /**
24
- * VC0B — replay correctness (ReplayCutV2 / ReplayReportV2, M3 effective-cut-v2).
25
- * Default ON. `MEGACOMPACT_VC0B=0` disables and is byte-identical to the
26
- * predecessor (legacy capped-replay behavior preserved; the v2 cut/replay is
27
- * only consulted on the vector-cortex path).
28
- */
29
- export const VC0B_ENABLED = () => sprintFlag("MEGACOMPACT_VC0B");
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 = () => sprintFlag("MEGACOMPACT_VC1A");
38
- /**
39
- * VC1B — occurrence ledger + tool identity + compat journal (LedgerReader/
40
- * Writer/Admin, CompatJournalV1, M2 occurrence-v2 migration).
41
- * Default ON. `MEGACOMPACT_VC1B=0` disables and is byte-identical to the
42
- * predecessor (mode C: the neutral occurrence ledger is not written, no
43
- * journal rows, zero `vector_cortex_occurrence_appended` emissions). The real
44
- * consumers are the ledger write integration seam and the compat-journal
45
- * switch seam.
46
- */
47
- export const VC1B_ENABLED = () => sprintFlag("MEGACOMPACT_VC1B");
48
- /**
49
- * VC0C — live safety envelope (TriadResult / Breaker / KillDecision + durable
50
- * spool). Default ON. `MEGACOMPACT_VC0C=0` disables and is byte-identical to
51
- * the predecessor (mode C: selected before provider invocation, unchanged host
52
- * transcript, breaker/spool idle and emitting nothing). The single real
53
- * consumer is the resilience emit seam + the safety adapter's triad selection.
54
- */
55
- export const VC0C_ENABLED = () => sprintFlag("MEGACOMPACT_VC0C");
56
- /**
57
- * VC1C — cross-language conformance v2 (FixtureManifestV2 / DowngradeReport /
58
- * MinHashV2 + M4 minhash-v2 migration).
59
- * Default ON. `MEGACOMPACT_VC1C=0` disables and is byte-identical to the
60
- * predecessor (mode C: a v2 conformance runner that accepts authority fixtures
61
- * and the manifest validator idle; the sync dedup scan stays on the v1 path;
62
- * zero `vector_cortex_*` VC1C emissions). The real consumers are the conformance
63
- * emit seam, the minhash-v2 backfill seam and the downgrade-export seam.
64
- */
65
- export const VC1C_ENABLED = () => sprintFlag("MEGACOMPACT_VC1C");
66
- /**
67
- * VC2A — offline model runtime and asset decision (ModelManifestV1 /
68
- * EncoderRuntime).
69
- * Default ON. `MEGACOMPACT_VC2A=0` disables and is byte-identical to the
70
- * predecessor (mode C: no asset manifest is read/verified, the encoder runtime
71
- * idles in mode C, zero `vector_cortex_encoder_*` emissions; the trigram/lexical
72
- * paths are unchanged). The real consumers are the encoder emit seam and the
73
- * encoder runtime's A/B/C selection.
74
- */
75
- export const VC2A_ENABLED = () => sprintFlag("MEGACOMPACT_VC2A");
76
- /**
77
- * VC2B — multi-head encoder (VectorSetV1 / HeadCalibrationDraft).
78
- * Default ON. `MEGACOMPACT_VC2B=0` disables and is byte-identical to the
79
- * predecessor (the encoder emits no per-head vectors and no fallback-selected
80
- * event; the trigram/lexical paths themselves are unchanged and are the
81
- * predecessor's mode-B/C producers). The real consumers are the encoder-heads
82
- * emit seam and the multi-head encoder producers (heads/trigram/lexical).
83
- */
84
- export const VC2B_ENABLED = () => sprintFlag("MEGACOMPACT_VC2B");
85
- /**
86
- * VC2C — encoder qualification + calibration (QualifiedEncoderV1 / CalibrationV1).
87
- * Default ON. `MEGACOMPACT_VC2C=0` disables and is byte-identical to the
88
- * predecessor (mode C: no qualification manifest is read or selected, the
89
- * calibrate/select/fallback seams are idle, zero `vector_cortex_encoder_qualification_*`
90
- * emissions; the trigram/lexical paths are unchanged). The real consumers are
91
- * the encoder-qualification emit seam and the calibrate/select seams.
92
- */
93
- export const VC2C_ENABLED = () => sprintFlag("MEGACOMPACT_VC2C");
11
+ import { sprintFlag } from "./vector-cortex-flag.js";
12
+ // VC0/VC1/VC2 foundation-phase flags extracted to vector-cortex-early.ts to keep
13
+ // this file under the 300-line soft limit. Re-exported here so every existing
14
+ // `from "./config/vector-cortex.js"` import keeps resolving unchanged.
15
+ export { VC0A_ENABLED, VC0B_ENABLED, VC0C_ENABLED, VC1A_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, } from "./vector-cortex-early.js";
94
16
  /**
95
17
  * VC3A — capability-gated cortex store (CortexReader/Writer/Admin, CortexRecordV1).
96
18
  * Default ON. `MEGACOMPACT_VC3A=0` disables and is byte-identical to the
@@ -251,6 +173,44 @@ export const VC6C_ENABLED = () => sprintFlag("MEGACOMPACT_VC6C");
251
173
  * UI, never in EXCLUDED_SETTINGS), mirroring VC4A..VC6C.
252
174
  */
253
175
  export const VC7A_ENABLED = () => sprintFlag("MEGACOMPACT_VC7A");
176
+ /**
177
+ * VC7B — provider cache economics + crystal compiler. Default ON.
178
+ * `MEGACOMPACT_VC7B=0` disables and is byte-identical to the predecessor
179
+ * (VC7A): `computeEconomics`, `compileCrystalBoundaries` and `assignExperiment`
180
+ * STILL RUN (they are PURE — exact integer/rational arithmetic and a SHA-256
181
+ * session bucket, with no clock, storage, or network), so a session keeps its
182
+ * SAME experiment arm and the compiler keeps producing the SAME boundaries with
183
+ * the flag off. Crucially the compiler never changes request identity in either
184
+ * state, so the outbound canonical request — and therefore the VC7A crystal key
185
+ * and the predecessor golden bytes — are unaffected by this flag.
186
+ *
187
+ * The flag gates ONLY the `vector_cortex_cache_experiment_assigned` /
188
+ * `vector_cortex_cache_economics_estimated` events and the cache-economics
189
+ * dashboard seam, which reports `enabled:false` + mode C when off. This flag
190
+ * MUST also be a dashboard SETTINGS toggle (visible in config UI, never in
191
+ * EXCLUDED_SETTINGS), mirroring VC4A..VC7A.
192
+ */
193
+ export const VC7B_ENABLED = () => sprintFlag("MEGACOMPACT_VC7B");
194
+ /**
195
+ * VC7C — cache miss diagnostics, cache-level breakers and the completed M5
196
+ * request-hash-v2 switch. Default ON. `MEGACOMPACT_VC7C=0` disables and is
197
+ * byte-identical to the predecessor (VC7B): the miss `classify`, the breaker
198
+ * demotion decision and the M5 request-hash-v2 ARITHMETIC STILL RUN (they are
199
+ * PURE — an exclusive ordered comparison over already-computed digests plus a
200
+ * canonical length-prefixed SHA-256, with no clock, storage, or network), so a
201
+ * miss is classified into the SAME single class, a collision / stale generation
202
+ * / digest failure / profile mismatch still demotes BEFORE any cache serve, and
203
+ * the v2 hash of a given request is unchanged with the flag off. A cache is
204
+ * never allowed to serve a stale or colliding entry merely because reporting is
205
+ * off — that would be a correctness change, not a reporting change.
206
+ *
207
+ * The flag gates ONLY the `vector_cortex_cache_miss_classified` /
208
+ * `vector_cortex_cache_serve_blocked` events and the cache-diagnostics dashboard
209
+ * seam, which reports `enabled:false` + mode C when off. This flag MUST also be
210
+ * a dashboard SETTINGS toggle (visible in config UI, never in
211
+ * EXCLUDED_SETTINGS), mirroring VC4A..VC7B.
212
+ */
213
+ export const VC7C_ENABLED = () => sprintFlag("MEGACOMPACT_VC7C");
254
214
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker) extracted to
255
215
  // vector-cortex-breakers.ts to keep this file under the 300-line soft limit.
256
216
  export { BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./vector-cortex-breakers.js";