pi-mega-compact 0.20.42 → 0.20.44

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 (63) hide show
  1. package/assets/vector-cortex/encoder-v1/manifest.json +1 -1
  2. package/assets/vector-cortex/encoder-v1/model-card.json +1 -1
  3. package/assets/vector-cortex/encoder-v1/model.onnx +0 -0
  4. package/assets/vector-cortex/encoder-v1/tokenizer.json +1 -1
  5. package/dist/config/vector-cortex-enc0a.js +32 -0
  6. package/dist/config/vector-cortex-enc0b.js +34 -0
  7. package/dist/config/vector-cortex.js +3 -3
  8. package/dist/config.js +1 -1
  9. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +2 -0
  10. package/dist/src/config/vector-cortex-enc0a.js +32 -0
  11. package/dist/src/config/vector-cortex-enc0b.js +34 -0
  12. package/dist/src/config/vector-cortex.js +3 -3
  13. package/dist/src/config.js +1 -1
  14. package/dist/src/vector-cortex/_acceptance-enc0a-contract.js +60 -0
  15. package/dist/src/vector-cortex/_acceptance-vc2a-conformance.js +90 -0
  16. package/dist/src/vector-cortex/_acceptance-vc2a-runtime.js +285 -0
  17. package/dist/src/vector-cortex/_acceptance-vc2b-conformance.js +92 -0
  18. package/dist/src/vector-cortex/_acceptance-vc2b-heads.js +221 -0
  19. package/dist/src/vector-cortex/encoder/asset.js +3 -2
  20. package/dist/src/vector-cortex/encoder/decision.js +75 -0
  21. package/dist/src/vector-cortex/encoder/emit.js +2 -0
  22. package/dist/src/vector-cortex/encoder/encoder-onnx-dispatch.js +58 -0
  23. package/dist/src/vector-cortex/encoder/onnx.js +147 -0
  24. package/dist/src/vector-cortex/encoder/runtime-wasm.js +17 -4
  25. package/dist/src/vector-cortex/encoder/runtime.js +17 -7
  26. package/dist/src/vector-cortex/encoder/types-vc2c.js +50 -0
  27. package/dist/src/vector-cortex/encoder/types.js +13 -34
  28. package/dist/vector-cortex/_acceptance-enc0a-contract.js +60 -0
  29. package/dist/vector-cortex/_acceptance-vc2a-conformance.js +90 -0
  30. package/dist/vector-cortex/_acceptance-vc2a-runtime.js +285 -0
  31. package/dist/vector-cortex/_acceptance-vc2b-conformance.js +92 -0
  32. package/dist/vector-cortex/_acceptance-vc2b-heads.js +221 -0
  33. package/dist/vector-cortex/encoder/asset.js +3 -2
  34. package/dist/vector-cortex/encoder/decision.js +75 -0
  35. package/dist/vector-cortex/encoder/emit.js +2 -0
  36. package/dist/vector-cortex/encoder/encoder-onnx-dispatch.js +58 -0
  37. package/dist/vector-cortex/encoder/onnx.js +147 -0
  38. package/dist/vector-cortex/encoder/runtime-wasm.js +17 -4
  39. package/dist/vector-cortex/encoder/runtime.js +17 -7
  40. package/dist/vector-cortex/encoder/types-vc2c.js +50 -0
  41. package/dist/vector-cortex/encoder/types.js +13 -34
  42. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +12 -0
  43. package/package.json +3 -2
  44. package/src/config/vector-cortex-enc0a.ts +34 -0
  45. package/src/config/vector-cortex-enc0b.ts +36 -0
  46. package/src/config/vector-cortex.ts +3 -3
  47. package/src/config.ts +2 -0
  48. package/src/vector-cortex/_acceptance-enc0a-contract.ts +71 -0
  49. package/src/vector-cortex/_acceptance-vc2a-conformance.ts +119 -0
  50. package/src/vector-cortex/_acceptance-vc2a-runtime.ts +300 -0
  51. package/src/vector-cortex/_acceptance-vc2b-conformance.ts +121 -0
  52. package/src/vector-cortex/_acceptance-vc2b-heads.ts +234 -0
  53. package/src/vector-cortex/encoder/asset.ts +3 -2
  54. package/src/vector-cortex/encoder/bench-export.ts +2 -2
  55. package/src/vector-cortex/encoder/decision.ts +125 -0
  56. package/src/vector-cortex/encoder/emit.ts +5 -1
  57. package/src/vector-cortex/encoder/encoder-onnx-dispatch.ts +76 -0
  58. package/src/vector-cortex/encoder/onnx.ts +198 -0
  59. package/src/vector-cortex/encoder/runtime-native.ts +1 -1
  60. package/src/vector-cortex/encoder/runtime-wasm.ts +21 -8
  61. package/src/vector-cortex/encoder/runtime.ts +27 -9
  62. package/src/vector-cortex/encoder/types-vc2c.ts +134 -0
  63. package/src/vector-cortex/encoder/types.ts +19 -115
@@ -0,0 +1,32 @@
1
+ /**
2
+ * config/vector-cortex-enc0a.ts — ENC-0a learned-encoder backend-decision flag.
3
+ *
4
+ * Extracted from vector-cortex.ts so that file stays under the 300-line soft
5
+ * limit (soft-as-hard gate), exactly as vector-cortex-vc9a.ts..vector-cortex-vc9d.ts
6
+ * were. This is the first ENC (real learned encoder) sprint flag. vector-cortex.ts
7
+ * re-exports the ENUM below and root src/config.ts re-exports it, so no consumer
8
+ * import path changes.
9
+ *
10
+ * ENC-0a locks the runtime-backend choice (transformers.js/WASM vs
11
+ * onnxruntime-node native), the per-platform install-size matrix, the opset
12
+ * baseline (re-baselined 17 -> 21) and the license/pinning audit. It writes a
13
+ * durable decision record and bench JSON but touches neither the store schema
14
+ * nor stateDir tables (pure migration).
15
+ *
16
+ * The split is purely mechanical: ENC_0A_ENABLED is byte-identical in name,
17
+ * semantics, and default to the definition it replaces, and vector-cortex.ts
18
+ * re-exports it so every existing `from "./config/vector-cortex.js"` import
19
+ * keeps resolving unchanged.
20
+ *
21
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
22
+ */
23
+ import { sprintFlag } from "./vector-cortex-flag.js";
24
+ /**
25
+ * ENC-0a — learned-encoder backend-decision lock. Default ON.
26
+ * `MEGACOMPACT_ENC_0A=0` disables and is byte-identical to the predecessor
27
+ * (placeholder encoder): no decision record is written and no newer
28
+ * backend-resolution script runs — the runtime keeps serving mode B trigram
29
+ * exactly as before. This flag MUST also be a dashboard SETTINGS toggle (visible
30
+ * in config UI, never in EXCLUDED_SETTINGS), mirroring VC4A..VC9D.
31
+ */
32
+ export const ENC_0A_ENABLED = () => sprintFlag("MEGACOMPACT_ENC_0A");
@@ -0,0 +1,34 @@
1
+ /**
2
+ * config/vector-cortex-enc0b.ts — ENC-0b real ONNX trunk fetch + gated inference flag.
3
+ *
4
+ * Extracted from vector-cortex.ts so that file stays under the 300-line soft
5
+ * limit (soft-as-hard gate), exactly as vector-cortex-enc0a.ts and the
6
+ * VC8C/VC9A-D/ML5A-E/DEDUP_ATTR siblings were. vector-cortex.ts re-exports the
7
+ * flag below and root src/config.ts re-exports it, so no consumer import path
8
+ * changes.
9
+ *
10
+ * ENC-0b fetches the real bge-small-en-v1.5 int8 ONNX model from the Hugging
11
+ * Face Hub (build-time fetch into the assets directory, NOT a runtime network
12
+ * call — PREVENT-PI-004 safe), wires an ONNX InferenceSession via
13
+ * onnxruntime-web WASM, and runs gated inference through it. The gate is
14
+ * controlled by this flag: OFF = the LCG placeholder encoder serves
15
+ * byte-identical predecessor output and no ONNX session is constructed.
16
+ *
17
+ * The split is purely mechanical: ENC_0B_ENABLED is byte-identical in name,
18
+ * semantics, and default to the definition it replaces, and vector-cortex.ts
19
+ * re-exports it so every existing `from "./config/vector-cortex.js"` import
20
+ * keeps resolving unchanged.
21
+ *
22
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
23
+ */
24
+ import { sprintFlag } from "./vector-cortex-flag.js";
25
+ /**
26
+ * ENC-0b — real ONNX trunk fetch + gated inference. Default ON.
27
+ * `MEGACOMPACT_ENC_0B=0` disables and is byte-identical to the predecessor
28
+ * (ENC-0a / LCG placeholder): no ONNX session is built, the real bge-small
29
+ * model is not loaded, and the encoder continues serving the LCG placeholder
30
+ * output exactly as before. This flag MUST also be a dashboard SETTINGS toggle
31
+ * (visible in config UI, never in EXCLUDED_SETTINGS), mirroring ENC_0A and
32
+ * VC4A..VC9D.
33
+ */
34
+ export const ENC_0B_ENABLED = () => sprintFlag("MEGACOMPACT_ENC_0B");
@@ -5,8 +5,7 @@
5
5
  * `=0`/`_DISABLED` off. Flag-OFF is byte-identical to the predecessor sprint's
6
6
  * behavior (for VC0A: mode C — observer absent, zero evaluation writes).
7
7
  *
8
- * The breaker/triad constants (TRIAD_RESILIENCE.md) live here so VC0C consumes
9
- * them without re-declaring the ownership boundary. Pi-agnostic, dependency-free.
8
+ * Breaker/triad constants (TRIAD_RESILIENCE.md) live here; pi-agnostic, dep-free.
10
9
  */
11
10
  import { sprintFlag } from "./vector-cortex-flag.js";
12
11
  // VC0/VC1/VC2 foundation-phase flags in vector-cortex-early.ts; re-exported
@@ -238,7 +237,6 @@ export const VC8A_ENABLED = () => sprintFlag("MEGACOMPACT_VC8A");
238
237
  * mirroring VC4A..VC8A.
239
238
  */
240
239
  export const VC8B_ENABLED = () => sprintFlag("MEGACOMPACT_VC8B");
241
- // VC8C extracted to vector-cortex-vc8c.ts; re-exported so existing imports keep resolving.
242
240
  export { VC8C_ENABLED } from "./vector-cortex-vc8c.js";
243
241
  export { VC9A_ENABLED } from "./vector-cortex-vc9a.js";
244
242
  export { VC9B_ENABLED } from "./vector-cortex-vc9b.js";
@@ -251,5 +249,7 @@ export { ML5C_ENABLED } from "./vector-cortex-ml5c.js";
251
249
  export { ML5D_ENABLED } from "./vector-cortex-ml5d.js";
252
250
  export { ML5E_ENABLED } from "./vector-cortex-ml5e.js";
253
251
  export { DEDUP_ATTR_ENABLED } from "./vector-cortex-dedup-attr.js";
252
+ export { ENC_0A_ENABLED } from "./vector-cortex-enc0a.js";
253
+ export { ENC_0B_ENABLED } from "./vector-cortex-enc0b.js";
254
254
  // Breaker constants (TRIAD_RESILIENCE.md §breaker) extracted to vector-cortex-breakers.ts.
255
255
  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, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_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, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_ENABLED, ENC_0A_ENABLED, ENC_0B_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";
@@ -58,5 +58,7 @@ export const VECTOR_CORTEX_SETTINGS = {
58
58
  boolDirect("MEGACOMPACT_ML5_D", "ML5-D Dashboard Improve Cortex", "ML5-D dashboard 'Improve Cortex' surface: the ModelImprovementCard + POST /api/cortex/improve + GET /api/cortex/improve/status/:jobId. ON (default) = the card renders and Improve launches a local ML5-A training job. OFF = both improve endpoints return 404 and VectorCortexTab omits the card, byte-identical to ML5-C.", true),
59
59
  boolDirect("MEGACOMPACT_ML5_E", "ML5-E Nightly Retraining Cron", "ML5-E nightly retraining + feedback loop: the user's own post-redaction conversation turns become fresh training signal, the five heads are re-fit nightly via system cron, calibration is re-validated, and mode-A promotion is re-checked without human intervention. The cron is system-configured (crontab -e); the extension never installs or writes a crontab. Candidates are written to ~/.pi/mega-compact-encoder/candidates/ and promoted via the ML5-D Improve Cortex flow. ON (default) = the scripts may be invoked by the system cron. OFF = scripts are never invoked; byte-identical to ML5-D.", true),
60
60
  boolDirect("MEGACOMPACT_DEDUP_ATTR", "Dedup Tier Attribution Rollup", "Dedup tier-attribution rollup: per-tier dedup catch shares (L0/L1/L2/new percent of dedup decisions) read from the local events.log dedup_audit stream (GET /api/dedup-tier-attribution). OFF = 404 + no cache file, byte-identical predecessor.", true),
61
+ boolDirect("MEGACOMPACT_ENC_0A", "ENC-0a Encoder Backend Decision", "ENC-0a learned-encoder backend-decision lock: records the transformers.js/WASM vs onnxruntime-node choice, per-platform install matrix, opset-21 baseline and pinned digests in docs/vector-cortex/encoder-backend-decision.md. OFF = no decision record written / no resolver runs, mode B trigram byte-identical predecessor.", true),
62
+ boolDirect("MEGACOMPACT_ENC_0B", "ENC-0b Real Trunk Fetch & Gated Path", "ENC-0b real ONNX trunk fetch + gated inference: replaces the LCG placeholder with the real bge-small int8 model through an ONNX InferenceSession (onnxruntime-web WASM). OFF = LCG placeholder serves byte-identical predecessor output, no ONNX session built.", true),
61
63
  ],
62
64
  };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * config/vector-cortex-enc0a.ts — ENC-0a learned-encoder backend-decision flag.
3
+ *
4
+ * Extracted from vector-cortex.ts so that file stays under the 300-line soft
5
+ * limit (soft-as-hard gate), exactly as vector-cortex-vc9a.ts..vector-cortex-vc9d.ts
6
+ * were. This is the first ENC (real learned encoder) sprint flag. vector-cortex.ts
7
+ * re-exports the ENUM below and root src/config.ts re-exports it, so no consumer
8
+ * import path changes.
9
+ *
10
+ * ENC-0a locks the runtime-backend choice (transformers.js/WASM vs
11
+ * onnxruntime-node native), the per-platform install-size matrix, the opset
12
+ * baseline (re-baselined 17 -> 21) and the license/pinning audit. It writes a
13
+ * durable decision record and bench JSON but touches neither the store schema
14
+ * nor stateDir tables (pure migration).
15
+ *
16
+ * The split is purely mechanical: ENC_0A_ENABLED is byte-identical in name,
17
+ * semantics, and default to the definition it replaces, and vector-cortex.ts
18
+ * re-exports it so every existing `from "./config/vector-cortex.js"` import
19
+ * keeps resolving unchanged.
20
+ *
21
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
22
+ */
23
+ import { sprintFlag } from "./vector-cortex-flag.js";
24
+ /**
25
+ * ENC-0a — learned-encoder backend-decision lock. Default ON.
26
+ * `MEGACOMPACT_ENC_0A=0` disables and is byte-identical to the predecessor
27
+ * (placeholder encoder): no decision record is written and no newer
28
+ * backend-resolution script runs — the runtime keeps serving mode B trigram
29
+ * exactly as before. This flag MUST also be a dashboard SETTINGS toggle (visible
30
+ * in config UI, never in EXCLUDED_SETTINGS), mirroring VC4A..VC9D.
31
+ */
32
+ export const ENC_0A_ENABLED = () => sprintFlag("MEGACOMPACT_ENC_0A");
@@ -0,0 +1,34 @@
1
+ /**
2
+ * config/vector-cortex-enc0b.ts — ENC-0b real ONNX trunk fetch + gated inference flag.
3
+ *
4
+ * Extracted from vector-cortex.ts so that file stays under the 300-line soft
5
+ * limit (soft-as-hard gate), exactly as vector-cortex-enc0a.ts and the
6
+ * VC8C/VC9A-D/ML5A-E/DEDUP_ATTR siblings were. vector-cortex.ts re-exports the
7
+ * flag below and root src/config.ts re-exports it, so no consumer import path
8
+ * changes.
9
+ *
10
+ * ENC-0b fetches the real bge-small-en-v1.5 int8 ONNX model from the Hugging
11
+ * Face Hub (build-time fetch into the assets directory, NOT a runtime network
12
+ * call — PREVENT-PI-004 safe), wires an ONNX InferenceSession via
13
+ * onnxruntime-web WASM, and runs gated inference through it. The gate is
14
+ * controlled by this flag: OFF = the LCG placeholder encoder serves
15
+ * byte-identical predecessor output and no ONNX session is constructed.
16
+ *
17
+ * The split is purely mechanical: ENC_0B_ENABLED is byte-identical in name,
18
+ * semantics, and default to the definition it replaces, and vector-cortex.ts
19
+ * re-exports it so every existing `from "./config/vector-cortex.js"` import
20
+ * keeps resolving unchanged.
21
+ *
22
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
23
+ */
24
+ import { sprintFlag } from "./vector-cortex-flag.js";
25
+ /**
26
+ * ENC-0b — real ONNX trunk fetch + gated inference. Default ON.
27
+ * `MEGACOMPACT_ENC_0B=0` disables and is byte-identical to the predecessor
28
+ * (ENC-0a / LCG placeholder): no ONNX session is built, the real bge-small
29
+ * model is not loaded, and the encoder continues serving the LCG placeholder
30
+ * output exactly as before. This flag MUST also be a dashboard SETTINGS toggle
31
+ * (visible in config UI, never in EXCLUDED_SETTINGS), mirroring ENC_0A and
32
+ * VC4A..VC9D.
33
+ */
34
+ export const ENC_0B_ENABLED = () => sprintFlag("MEGACOMPACT_ENC_0B");
@@ -5,8 +5,7 @@
5
5
  * `=0`/`_DISABLED` off. Flag-OFF is byte-identical to the predecessor sprint's
6
6
  * behavior (for VC0A: mode C — observer absent, zero evaluation writes).
7
7
  *
8
- * The breaker/triad constants (TRIAD_RESILIENCE.md) live here so VC0C consumes
9
- * them without re-declaring the ownership boundary. Pi-agnostic, dependency-free.
8
+ * Breaker/triad constants (TRIAD_RESILIENCE.md) live here; pi-agnostic, dep-free.
10
9
  */
11
10
  import { sprintFlag } from "./vector-cortex-flag.js";
12
11
  // VC0/VC1/VC2 foundation-phase flags in vector-cortex-early.ts; re-exported
@@ -238,7 +237,6 @@ export const VC8A_ENABLED = () => sprintFlag("MEGACOMPACT_VC8A");
238
237
  * mirroring VC4A..VC8A.
239
238
  */
240
239
  export const VC8B_ENABLED = () => sprintFlag("MEGACOMPACT_VC8B");
241
- // VC8C extracted to vector-cortex-vc8c.ts; re-exported so existing imports keep resolving.
242
240
  export { VC8C_ENABLED } from "./vector-cortex-vc8c.js";
243
241
  export { VC9A_ENABLED } from "./vector-cortex-vc9a.js";
244
242
  export { VC9B_ENABLED } from "./vector-cortex-vc9b.js";
@@ -251,5 +249,7 @@ export { ML5C_ENABLED } from "./vector-cortex-ml5c.js";
251
249
  export { ML5D_ENABLED } from "./vector-cortex-ml5d.js";
252
250
  export { ML5E_ENABLED } from "./vector-cortex-ml5e.js";
253
251
  export { DEDUP_ATTR_ENABLED } from "./vector-cortex-dedup-attr.js";
252
+ export { ENC_0A_ENABLED } from "./vector-cortex-enc0a.js";
253
+ export { ENC_0B_ENABLED } from "./vector-cortex-enc0b.js";
254
254
  // Breaker constants (TRIAD_RESILIENCE.md §breaker) extracted to vector-cortex-breakers.ts.
255
255
  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";
@@ -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, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_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, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_ENABLED, ENC_0A_ENABLED, ENC_0B_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,60 @@
1
+ /** ENC-0a buildDecision contract constructor suite — extracted from
2
+ * enc0a-acceptance.test.ts for soft-limit compliance. Receives the contract
3
+ * constructor + constants from the aggregator (no import cycle).
4
+ */
5
+ import { test, describe } from "node:test";
6
+ import assert from "node:assert/strict";
7
+ export function registerEnc0aContract(ctx) {
8
+ const { buildDecision, PLATFORMS } = ctx;
9
+ describe("buildDecision contract constructor", () => {
10
+ test("rejects an incomplete platform matrix", () => {
11
+ const matrix = {
12
+ "linux-x64": { runtime: "onnxruntime-web", installMiB: 33, demotion: "none" },
13
+ "linux-arm64": { runtime: "onnxruntime-web", installMiB: 33, demotion: "none" },
14
+ "darwin-x64": { runtime: "onnxruntime-web", installMiB: 33, demotion: "wasm" },
15
+ "darwin-arm64": { runtime: "onnxruntime-web", installMiB: 33, demotion: "none" },
16
+ // win32-x64 omitted
17
+ };
18
+ assert.throws(() => buildDecision({
19
+ backend: "wasm",
20
+ budgetOk: true,
21
+ p95Ms: 18.2,
22
+ platformMatrix: matrix,
23
+ modelPath: "model.onnx",
24
+ modelBytes: 1,
25
+ modelSha256: "a".repeat(64),
26
+ tokenizerPath: "tokenizer.json",
27
+ tokenizerBytes: 1,
28
+ tokenizerSha256: "b".repeat(64),
29
+ blockedBy: [],
30
+ }));
31
+ });
32
+ test("builds a valid decision with opset 21 + MIT license for a complete matrix", () => {
33
+ const matrix = {
34
+ "linux-x64": { runtime: "onnxruntime-web", installMiB: 33, demotion: "none" },
35
+ "linux-arm64": { runtime: "onnxruntime-web", installMiB: 33, demotion: "none" },
36
+ "darwin-x64": { runtime: "onnxruntime-web", installMiB: 33, demotion: "wasm" },
37
+ "darwin-arm64": { runtime: "onnxruntime-web", installMiB: 33, demotion: "none" },
38
+ "win32-x64": { runtime: "onnxruntime-web", installMiB: 33, demotion: "none" },
39
+ };
40
+ const d = buildDecision({
41
+ backend: "wasm",
42
+ budgetOk: true,
43
+ p95Ms: 18.2,
44
+ platformMatrix: matrix,
45
+ modelPath: "model.onnx",
46
+ modelBytes: 24117248,
47
+ modelSha256: "a".repeat(64),
48
+ tokenizerPath: "tokenizer.json",
49
+ tokenizerBytes: 50000,
50
+ tokenizerSha256: "b".repeat(64),
51
+ blockedBy: [],
52
+ });
53
+ assert.equal(d.schema, "encoder-backend-decision-v1");
54
+ assert.equal(d.opset, 21);
55
+ assert.equal(d.backend, "wasm");
56
+ assert.deepEqual(d.license, { spdx: "MIT", redistribution: true });
57
+ assert.equal(d.platformMatrix["darwin-x64"].demotion, "wasm");
58
+ });
59
+ });
60
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * _acceptance-vc2a-conformance.ts — ENC-001..008 conformance rows + the named
3
+ * assertions (ENC-ASSET-001 / ENC-DIGEST-002 / ENC-PLATFORM-003), each driven
4
+ * through the REAL encoder asset/runtime (no mocks). Extracted from
5
+ * vc2a-acceptance.test.ts so the aggregator stays under the tests/ soft limit.
6
+ *
7
+ * The aggregator passes its shared imports/helpers as a context object, so this
8
+ * sibling never imports the aggregator (no import cycle at module load).
9
+ */
10
+ import { test, describe } from "node:test";
11
+ import assert from "node:assert/strict";
12
+ export function registerVc2aConformance(ctx) {
13
+ const { ENC_IDS, ENC_FAIL, fixture, buildDir, rmBuilt, optionsFor, createEncoderRuntime, verifyEncoderAsset, readEncoderManifest, } = ctx;
14
+ // -------------------------------------------------------------------------
15
+ // ENC-001..008 conformance rows through the real runtime
16
+ // -------------------------------------------------------------------------
17
+ describe("ENC-001..008 conformance rows", () => {
18
+ for (const id of ENC_IDS) {
19
+ test(`${id}: resolves through the real runtime to the documented result`, () => {
20
+ const fx = fixture(id);
21
+ const built = buildDir(fx.input.scenario);
22
+ try {
23
+ const rt = createEncoderRuntime(optionsFor(fx.input.scenario));
24
+ const load = rt.load(built.dir);
25
+ assert.equal(load.ok, fx.expected.ok, `${id} ok`);
26
+ if (!load.ok) {
27
+ assert.equal(load.code, fx.expected.code, `${id} exact failure code`);
28
+ if (fx.expected.mode)
29
+ assert.equal(load.mode, fx.expected.mode, `${id} mode`);
30
+ }
31
+ else {
32
+ assert.equal(load.mode, "A", `${id} should be mode A`);
33
+ }
34
+ }
35
+ finally {
36
+ rmBuilt(built);
37
+ }
38
+ });
39
+ }
40
+ });
41
+ // -------------------------------------------------------------------------
42
+ // VC2A named assertions
43
+ // -------------------------------------------------------------------------
44
+ describe("VC2A named assertions", () => {
45
+ test("ENC-ASSET-001: opset21 manifest + matching digests load as mode A", () => {
46
+ const fx = fixture("ENC-ASSET-001");
47
+ assert.equal(fx.expected.ok, true);
48
+ const built = buildDir("valid");
49
+ try {
50
+ const load = createEncoderRuntime().load(built.dir);
51
+ assert.equal(load.ok, true);
52
+ if (load.ok)
53
+ assert.equal(load.mode, "A");
54
+ }
55
+ finally {
56
+ rmBuilt(built);
57
+ }
58
+ });
59
+ test("ENC-DIGEST-002: one-byte model mutation demotes before load", () => {
60
+ const fx = fixture("ENC-DIGEST-002");
61
+ assert.equal(fx.expected.code, ENC_FAIL.DIGEST_MISMATCH);
62
+ const built = buildDir("mutate-onnx");
63
+ try {
64
+ const res = verifyEncoderAsset(built.dir, readEncoderManifest(built.dir));
65
+ assert.equal(res.ok, false);
66
+ if (!res.ok)
67
+ assert.equal(res.code, ENC_FAIL.DIGEST_MISMATCH);
68
+ }
69
+ finally {
70
+ rmBuilt(built);
71
+ }
72
+ });
73
+ test("ENC-PLATFORM-003: unsupported architecture selects trigram B", () => {
74
+ const fx = fixture("ENC-PLATFORM-003");
75
+ assert.equal(fx.expected.mode, "B");
76
+ const built = buildDir("valid");
77
+ try {
78
+ const load = createEncoderRuntime({ platform: () => null }).load(built.dir);
79
+ assert.equal(load.ok, false);
80
+ if (!load.ok) {
81
+ assert.equal(load.mode, "B", "trigram B selected");
82
+ assert.equal(load.code, ENC_FAIL.PLATFORM_UNSUPPORTED);
83
+ }
84
+ }
85
+ finally {
86
+ rmBuilt(built);
87
+ }
88
+ });
89
+ });
90
+ }