pi-mega-compact 0.20.46 → 0.20.48

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 (89) hide show
  1. package/dist/config/vector-cortex-enc0e.js +40 -0
  2. package/dist/config/vector-cortex-enc0f.js +36 -0
  3. package/dist/config/vector-cortex-vc3to8.js +239 -0
  4. package/dist/config/vector-cortex.js +5 -227
  5. package/dist/config.js +1 -1
  6. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +2 -0
  7. package/dist/extensions/dashboard-server/routes-setup-cortex.js +30 -1
  8. package/dist/extensions/dashboard-server/setup-cortex-blockers.js +2 -1
  9. package/dist/src/config/vector-cortex-enc0e.js +40 -0
  10. package/dist/src/config/vector-cortex-enc0f.js +36 -0
  11. package/dist/src/config/vector-cortex-vc3to8.js +239 -0
  12. package/dist/src/config/vector-cortex.js +5 -227
  13. package/dist/src/config.js +1 -1
  14. package/dist/src/vector-cortex/encoder/decision.js +17 -0
  15. package/dist/src/vector-cortex/encoder/qualify.js +50 -0
  16. package/dist/src/vector-cortex/encoder/runtime-emit.js +8 -2
  17. package/dist/src/vector-cortex/encoder/runtime-select.js +35 -1
  18. package/dist/vector-cortex/encoder/decision.js +17 -0
  19. package/dist/vector-cortex/encoder/qualify.js +50 -0
  20. package/dist/vector-cortex/encoder/runtime-emit.js +8 -2
  21. package/dist/vector-cortex/encoder/runtime-select.js +35 -1
  22. package/extensions/dashboard-client/dist/assets/{AreaChart-Cn6X7epL.js → AreaChart-COnj8FHi.js} +2 -2
  23. package/extensions/dashboard-client/dist/assets/{AreaChart-Cn6X7epL.js.map → AreaChart-COnj8FHi.js.map} +1 -1
  24. package/extensions/dashboard-client/dist/assets/{BarChart-APy1Wc7z.js → BarChart-BYqt8c5-.js} +2 -2
  25. package/extensions/dashboard-client/dist/assets/{BarChart-APy1Wc7z.js.map → BarChart-BYqt8c5-.js.map} +1 -1
  26. package/extensions/dashboard-client/dist/assets/{CacheTab-CEv_Ss9O.js → CacheTab-PLRjMrZV.js} +2 -2
  27. package/extensions/dashboard-client/dist/assets/{CacheTab-CEv_Ss9O.js.map → CacheTab-PLRjMrZV.js.map} +1 -1
  28. package/extensions/dashboard-client/dist/assets/{EventsTab-8jV1Pr0C.js → EventsTab-DXKSft6w.js} +2 -2
  29. package/extensions/dashboard-client/dist/assets/{EventsTab-8jV1Pr0C.js.map → EventsTab-DXKSft6w.js.map} +1 -1
  30. package/extensions/dashboard-client/dist/assets/{HealthTab-B2VgEz1j.js → HealthTab-BgVIsrde.js} +2 -2
  31. package/extensions/dashboard-client/dist/assets/{HealthTab-B2VgEz1j.js.map → HealthTab-BgVIsrde.js.map} +1 -1
  32. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-m37AlTbg.js → MaintenanceTab-DNgFC8KZ.js} +2 -2
  33. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-m37AlTbg.js.map → MaintenanceTab-DNgFC8KZ.js.map} +1 -1
  34. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-Co2jbqdT.js → MemoryMapTab-B6yY47sz.js} +2 -2
  35. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-Co2jbqdT.js.map → MemoryMapTab-B6yY47sz.js.map} +1 -1
  36. package/extensions/dashboard-client/dist/assets/{MetricsTab-D0yV9X6D.js → MetricsTab-BrhJ6rkx.js} +2 -2
  37. package/extensions/dashboard-client/dist/assets/{MetricsTab-D0yV9X6D.js.map → MetricsTab-BrhJ6rkx.js.map} +1 -1
  38. package/extensions/dashboard-client/dist/assets/{OverviewTab-J5TjXB14.js → OverviewTab-RFHU9L4x.js} +2 -2
  39. package/extensions/dashboard-client/dist/assets/{OverviewTab-J5TjXB14.js.map → OverviewTab-RFHU9L4x.js.map} +1 -1
  40. package/extensions/dashboard-client/dist/assets/{ReposTab-BadNIkWu.js → ReposTab-UFIWKkJM.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{ReposTab-BadNIkWu.js.map → ReposTab-UFIWKkJM.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/{SessionsTab-CdKShJuR.js → SessionsTab-BHFYsmK8.js} +2 -2
  43. package/extensions/dashboard-client/dist/assets/{SessionsTab-CdKShJuR.js.map → SessionsTab-BHFYsmK8.js.map} +1 -1
  44. package/extensions/dashboard-client/dist/assets/{SetupTab-CPemizDx.js → SetupTab-C3dnKa8y.js} +3 -3
  45. package/extensions/dashboard-client/dist/assets/{SetupTab-CPemizDx.js.map → SetupTab-C3dnKa8y.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-TvULibwW.js → TimeSavedCard-aPG5Knqn.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-TvULibwW.js.map → TimeSavedCard-aPG5Knqn.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/{TurnsTab-CglFIcYy.js → TurnsTab-fGm9n-Tk.js} +2 -2
  49. package/extensions/dashboard-client/dist/assets/{TurnsTab-CglFIcYy.js.map → TurnsTab-fGm9n-Tk.js.map} +1 -1
  50. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-H2bBNhrR.js → VcStatusBadge-BtmSNH8X.js} +2 -2
  51. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-H2bBNhrR.js.map → VcStatusBadge-BtmSNH8X.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-CXPv3sYQ.js → VectorCortexTab-meALMMOZ.js} +2 -2
  53. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-CXPv3sYQ.js.map → VectorCortexTab-meALMMOZ.js.map} +1 -1
  54. package/extensions/dashboard-client/dist/assets/{WikiTab-BNfN175_.js → WikiTab-0TK6q6g1.js} +2 -2
  55. package/extensions/dashboard-client/dist/assets/{WikiTab-BNfN175_.js.map → WikiTab-0TK6q6g1.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{button-DjN7aqD2.js → button-CKEnMZ98.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{button-DjN7aqD2.js.map → button-CKEnMZ98.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/assets/{card-DLHA5XP8.js → card-BVVhm3sL.js} +2 -2
  59. package/extensions/dashboard-client/dist/assets/{card-DLHA5XP8.js.map → card-BVVhm3sL.js.map} +1 -1
  60. package/extensions/dashboard-client/dist/assets/{client-extra-ZT6mIQZS.js → client-extra-BvGxKZpm.js} +2 -2
  61. package/extensions/dashboard-client/dist/assets/{client-extra-ZT6mIQZS.js.map → client-extra-BvGxKZpm.js.map} +1 -1
  62. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DAl4dRVG.js → generateCategoricalChart-B1PeCct1.js} +2 -2
  63. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DAl4dRVG.js.map → generateCategoricalChart-B1PeCct1.js.map} +1 -1
  64. package/extensions/dashboard-client/dist/assets/{index-H-sfROoW.js → index-DuThOA-d.js} +3 -3
  65. package/extensions/dashboard-client/dist/assets/{index-H-sfROoW.js.map → index-DuThOA-d.js.map} +1 -1
  66. package/extensions/dashboard-client/dist/assets/{switch-BCxvJYon.js → switch-7qLS7ajc.js} +2 -2
  67. package/extensions/dashboard-client/dist/assets/{switch-BCxvJYon.js.map → switch-7qLS7ajc.js.map} +1 -1
  68. package/extensions/dashboard-client/dist/assets/{toggle-DviUMYeg.js → toggle-D7mgOVxz.js} +2 -2
  69. package/extensions/dashboard-client/dist/assets/{toggle-DviUMYeg.js.map → toggle-D7mgOVxz.js.map} +1 -1
  70. package/extensions/dashboard-client/dist/assets/{useSSE-DP2O8vHY.js → useSSE-ChpyZVeX.js} +2 -2
  71. package/extensions/dashboard-client/dist/assets/{useSSE-DP2O8vHY.js.map → useSSE-ChpyZVeX.js.map} +1 -1
  72. package/extensions/dashboard-client/dist/index.html +1 -1
  73. package/extensions/dashboard-client/src/tabs/SetupTab/CortexBlockersCard.tsx +17 -1
  74. package/extensions/dashboard-client/src/tabs/SetupTab/CortexSetup.tsx +1 -0
  75. package/extensions/dashboard-client/src/types/setup-cortex.ts +10 -0
  76. package/extensions/dashboard-server/api-contracts/setup-cortex.ts +11 -0
  77. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +12 -0
  78. package/extensions/dashboard-server/routes-setup-cortex.ts +35 -1
  79. package/extensions/dashboard-server/setup-cortex-blockers.ts +2 -1
  80. package/package.json +1 -1
  81. package/src/config/vector-cortex-enc0e.ts +42 -0
  82. package/src/config/vector-cortex-enc0f.ts +38 -0
  83. package/src/config/vector-cortex-vc3to8.ts +256 -0
  84. package/src/config/vector-cortex.ts +23 -244
  85. package/src/config.ts +2 -0
  86. package/src/vector-cortex/encoder/decision.ts +28 -1
  87. package/src/vector-cortex/encoder/qualify.ts +83 -0
  88. package/src/vector-cortex/encoder/runtime-emit.ts +21 -4
  89. package/src/vector-cortex/encoder/runtime-select.ts +46 -1
@@ -25,13 +25,40 @@ import type { EncoderPlatform } from "./types.js";
25
25
  /** Backend demotion disposition for a platform row. */
26
26
  export type BackendDemotion = "none" | "wasm" | "modeB";
27
27
 
28
- /** One platform row: the concrete runtime + install size + demotion disposition. */
28
+ /**
29
+ * One platform row: the concrete runtime + install size + demotion disposition.
30
+ *
31
+ * `demotionReason` is the ENC-0e canonical reason string for a demoted platform
32
+ * (single source of truth — no literals scattered in routes or the event writer).
33
+ */
29
34
  export interface EncoderPlatformRow {
30
35
  readonly runtime: string;
31
36
  readonly installMiB: number;
32
37
  readonly demotion: BackendDemotion;
38
+ readonly demotionReason?: string;
33
39
  }
34
40
 
41
+ /**
42
+ * The ENC-0e canonical darwin-x64 demotion reason (HG-4 / ENC-0e).
43
+ *
44
+ * macOS Intel has no native onnxruntime-node binary upstream (arm64-only; a
45
+ * darwin-x64 transform-class package ships only WASM), so the runtime demotes
46
+ * to mode-B WASM. This is the SINGLE canonical string — consumed by
47
+ * runtime-select.ts (the runtime-selection event) and the Setup Cortex blockers
48
+ * card. No string literal for this reason survives anywhere else.
49
+ */
50
+ export const DARWIN_X64_DEMOTION_REASON =
51
+ "darwin-x64: no native binary upstream (arm64-only); mode-B WASM per HG-4";
52
+
53
+ /**
54
+ * Deterministic sentinel used when a darwin-x64 platform-matrix row is missing
55
+ * the `demotionReason` string (unique-failure injection per the ENC-0e spec):
56
+ * the selection must still choose mode-B WASM, never throw, and never fabricate
57
+ * a native claim — the reason just falls back to this sentinel.
58
+ */
59
+ export const DARWIN_X64_DEMOTION_REASON_SENTINEL =
60
+ "darwin-x64: demoted to WASM (reason unavailable in platform matrix)";
61
+
35
62
  /**
36
63
  * EncoderBackendDecisionV1 — the locked learned-encoder runtime-backend decision.
37
64
  *
@@ -0,0 +1,83 @@
1
+ /**
2
+ * vector-cortex/encoder/qualify.ts — ENC-0f pure qualification function.
3
+ *
4
+ * Constructs a {@link QualificationV1} record from a {@link BenchResultV1} by
5
+ * asserting four independent gates (latency, marginal-RSS, determinism, opset)
6
+ * plus the bench's own conjunctive `gates.all`. A gated-off bench can NEVER be
7
+ * swept into mode A by a sub-threshold p95 alone — `bench_gates_not_green`
8
+ * forces `"failed"` regardless of the sub-threshold values.
9
+ *
10
+ * Pure (TRIAD_RESILIENCE §pure): no `any` (PREVENT-011), no casts, no clock, no
11
+ * storage, no network (PREVENT-PI-004). Thresholds are sourced from
12
+ * {@link ENCODER_LATENCY_P95_MS} / {@link ENCODER_RSS_BUDGET_BYTES} /
13
+ * {@link ENCODER_OPSET} — never magic numbers.
14
+ */
15
+
16
+ import type { BenchResultV1 } from "./bench-export.js";
17
+ import {
18
+ ENCODER_LATENCY_P95_MS,
19
+ ENCODER_RSS_BUDGET_BYTES,
20
+ ENCODER_OPSET,
21
+ } from "./types.js";
22
+
23
+ /** The qualification verdict for a real trained encoder asset. */
24
+ export interface QualificationV1 {
25
+ readonly schema: "qualification-v1";
26
+ readonly verdict: "qualified" | "failed";
27
+ readonly reasons: string[];
28
+ readonly platform: string;
29
+ readonly p95Ms: number;
30
+ readonly rssMib: number;
31
+ readonly opset: number;
32
+ /** SHA-256 hex of the bench run's embedding output (never payload content). */
33
+ readonly digest: string;
34
+ }
35
+
36
+ /**
37
+ * Qualify a bench result against the four independent gates + the bench's own
38
+ * conjunctive gate. Returns a QualificationV1 with `verdict:"qualified"` only
39
+ * when ALL gates pass and `bench.gates.all` is true.
40
+ */
41
+ export function qualifyEncodedAsset(
42
+ bench: BenchResultV1,
43
+ platform: string,
44
+ ): QualificationV1 {
45
+ const reasons: string[] = [];
46
+
47
+ if (bench.p95Ms !== null && bench.p95Ms > ENCODER_LATENCY_P95_MS) {
48
+ reasons.push("latency");
49
+ }
50
+
51
+ if (
52
+ bench.rssMarginalMib !== null &&
53
+ bench.rssMarginalMib * 1024 * 1024 > ENCODER_RSS_BUDGET_BYTES
54
+ ) {
55
+ reasons.push("rss");
56
+ }
57
+
58
+ if (!bench.deterministic) {
59
+ reasons.push("determinism");
60
+ }
61
+
62
+ if (bench.opset !== null && bench.opset !== ENCODER_OPSET) {
63
+ reasons.push("opset");
64
+ }
65
+
66
+ if (!bench.gates.all && !reasons.includes("bench_gates_not_green")) {
67
+ reasons.push("bench_gates_not_green");
68
+ }
69
+
70
+ const verdict: "qualified" | "failed" =
71
+ reasons.length === 0 && bench.gates.all ? "qualified" : "failed";
72
+
73
+ return {
74
+ schema: "qualification-v1",
75
+ verdict,
76
+ reasons,
77
+ platform,
78
+ p95Ms: bench.p95Ms ?? 0,
79
+ rssMib: bench.rssMarginalMib ?? 0,
80
+ opset: bench.opset ?? 0,
81
+ digest: bench.digest ?? "",
82
+ };
83
+ }
@@ -22,16 +22,29 @@ import type { RuntimeSelectionResult } from "./runtime-select.js";
22
22
 
23
23
  /**
24
24
  * Emit the ML5-C `vector_cortex_runtime_selected` seller event (best-effort).
25
- * The event carries ONLY the four aggregate fields the sprint spec pins
26
- * ({backend, p95Ms, budgetOk, platform}) never message content.
25
+ * The event carries ONLY the aggregate fields the sprint specs pin
26
+ * ({backend, p95Ms, budgetOk, platform}) plus the ENC-0e additively-carried
27
+ * `demotionReason` (non-null only on a demoted platform under flag ON) —
28
+ * never message content. The event writer never throws.
27
29
  */
28
30
  export function emitRuntimeSelected(
29
31
  stateDir: string,
30
- result: Pick<RuntimeSelectionResult, "backend" | "p95Ms" | "budgetOk" | "platform">,
32
+ result: Pick<
33
+ RuntimeSelectionResult,
34
+ "backend" | "p95Ms" | "budgetOk" | "platform" | "demotionReason"
35
+ >,
31
36
  ): void {
32
37
  try {
33
38
  const path = defaultEventsPath(stateDir);
34
- const payload = {
39
+ const payload: {
40
+ ts: number;
41
+ event: string;
42
+ backend: string;
43
+ p95Ms: number | null;
44
+ budgetOk: boolean;
45
+ platform: string;
46
+ demotionReason?: string;
47
+ } = {
35
48
  ts: Date.now(),
36
49
  event: "vector_cortex_runtime_selected",
37
50
  backend: result.backend,
@@ -39,6 +52,10 @@ export function emitRuntimeSelected(
39
52
  budgetOk: result.budgetOk,
40
53
  platform: result.platform,
41
54
  };
55
+ // ENC-0e: carry the demotion reason additively, only when present.
56
+ if (result.demotionReason !== null && result.demotionReason !== undefined) {
57
+ payload.demotionReason = result.demotionReason;
58
+ }
42
59
  mkdirSync(dirname(path), { recursive: true });
43
60
  appendFileSync(path, JSON.stringify(payload) + "\n", "utf8");
44
61
  } catch {
@@ -24,7 +24,12 @@ import {
24
24
  type EncoderPlatform,
25
25
  } from "./types.js";
26
26
  import type { BenchResultV1 } from "./bench-export.js";
27
- import { ML5C_ENABLED } from "../../config/vector-cortex.js";
27
+ import { ML5C_ENABLED, ENC_0E_ENABLED } from "../../config/vector-cortex.js";
28
+ import type { EncoderPlatformRow } from "./decision.js";
29
+ import {
30
+ DARWIN_X64_DEMOTION_REASON,
31
+ DARWIN_X64_DEMOTION_REASON_SENTINEL,
32
+ } from "./decision.js";
28
33
 
29
34
  /** The chosen runtime backend name as it appears on the seller event. */
30
35
  export type RuntimeBackendChoice = "wasm" | "native" | "modeB";
@@ -56,6 +61,12 @@ export interface RuntimeSelectionResult {
56
61
  readonly platform: string;
57
62
  /** Short human-readable rationale for the choice (record on the event). */
58
63
  readonly rationale: string;
64
+ /**
65
+ * ENC-0e explicit demotion reason (non-null ONLY on a demoted platform under
66
+ * `MEGACOMPACT_ENC_0E`). Null on every other platform and on flag-off, so the
67
+ * flag-off selection is byte-identical to the ENC-0d predecessor.
68
+ */
69
+ readonly demotionReason: string | null;
59
70
  }
60
71
 
61
72
  /** The 80 MiB install budget in bytes (the HG-3 ceiling, unamended). */
@@ -99,6 +110,7 @@ export function selectRuntimeBackend(input: RuntimeSelectionInput): RuntimeSelec
99
110
  p95Ms: null,
100
111
  platform: input.platform,
101
112
  rationale: "flag-off: byte-identical mode-B trigram (no selection)",
113
+ demotionReason: null,
102
114
  };
103
115
  }
104
116
 
@@ -110,6 +122,12 @@ export function selectRuntimeBackend(input: RuntimeSelectionInput): RuntimeSelec
110
122
  p95Ms: null,
111
123
  platform: input.platform,
112
124
  rationale: "darwin-x64 demoted to WASM per HG-4 (never native on this platform)",
125
+ // ENC-0e: the reason is the single canonical string from the ENC-0a
126
+ // platform matrix (decision.ts). Under flag-off the reason is stripped
127
+ // (null), keeping the flag-off selection byte-identical to the ENC-0d
128
+ // predecessor. If the matrix row ever lacks the reason, fall back to a
129
+ // deterministic sentinel — never throw, never fabricate a native claim.
130
+ demotionReason: ENC_0E_ENABLED() ? darwinX64DemotionReason(undefined) : null,
113
131
  };
114
132
  }
115
133
 
@@ -127,6 +145,7 @@ export function selectRuntimeBackend(input: RuntimeSelectionInput): RuntimeSelec
127
145
  p95Ms: input.benchRecord?.p95Ms ?? null,
128
146
  platform: input.platform,
129
147
  rationale: `native opt-in (MEGACOMPACT_ENCODER_NATIVE=1); shipped ${shippedMib} MiB across 5 platforms → budget amended to ${shippedMib} MiB`,
148
+ demotionReason: null,
130
149
  };
131
150
  }
132
151
 
@@ -142,6 +161,7 @@ export function selectRuntimeBackend(input: RuntimeSelectionInput): RuntimeSelec
142
161
  p95Ms: input.benchRecord?.p95Ms ?? null,
143
162
  platform: input.platform,
144
163
  rationale: `no qualifying bench record — native fallback with budget amendment (${shippedMib} MiB shipped, HG-3 amendment recorded)`,
164
+ demotionReason: null,
145
165
  };
146
166
  }
147
167
 
@@ -154,6 +174,7 @@ export function selectRuntimeBackend(input: RuntimeSelectionInput): RuntimeSelec
154
174
  p95Ms: input.benchRecord.p95Ms,
155
175
  platform: input.platform,
156
176
  rationale: `WASM qualifies: p95 ${input.benchRecord.p95Ms}ms <= ${ENCODER_LATENCY_P95_MS}ms`,
177
+ demotionReason: null,
157
178
  };
158
179
  }
159
180
 
@@ -163,5 +184,29 @@ export function selectRuntimeBackend(input: RuntimeSelectionInput): RuntimeSelec
163
184
  p95Ms: input.benchRecord.p95Ms,
164
185
  platform: input.platform,
165
186
  rationale: `native required: p95 ${input.benchRecord.p95Ms}ms > ${ENCODER_LATENCY_P95_MS}ms on WASM`,
187
+ demotionReason: null,
166
188
  };
167
189
  }
190
+
191
+ /**
192
+ * ENC-0e — resolve the canonical darwin-x64 demotion reason (pure).
193
+ *
194
+ * `provider` is the ENC-0a platform-matrix row for darwin-x64 if the caller has
195
+ * one (the resolver owns a concrete matrix; runtime-select normally passes
196
+ * none and falls back to the canonical constant). Resolution order:
197
+ * 1. the provider row's `demotionReason` (single canonical source);
198
+ * 2. the canonical DARWIN_X64_DEMOTION_REASON constant;
199
+ * 3. the deterministic SENTINEL when a row EXISTS but lacks the reason
200
+ * (unique-failure injection per ENC-0e) — never a throw, never a
201
+ * fabricated native claim.
202
+ * Kept pure so tests inject the platform seam with no real Mac.
203
+ */
204
+ export function darwinX64DemotionReason(provider: EncoderPlatformRow | undefined): string {
205
+ if (provider) {
206
+ if (provider.demotionReason && provider.demotionReason.length > 0) {
207
+ return provider.demotionReason;
208
+ }
209
+ return DARWIN_X64_DEMOTION_REASON_SENTINEL;
210
+ }
211
+ return DARWIN_X64_DEMOTION_REASON;
212
+ }