pi-mega-compact 0.20.71 → 0.20.72

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.
@@ -22,13 +22,14 @@ import { createHash } from "node:crypto";
22
22
  import { readFileSync, statSync } from "node:fs";
23
23
  import { join, dirname } from "node:path";
24
24
  import { fileURLToPath } from "node:url";
25
- import { VC9A_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED } from "../../src/config.js";
25
+ import { VC9A_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED, ENC_2A_ENABLED } from "../../src/config.js";
26
26
  import { readEncoderManifest, verifyEncoderAsset, detectPlatform } from "../../src/vector-cortex/encoder/asset.js";
27
27
  import { selectRuntimeBackend } from "../../src/vector-cortex/encoder/runtime-select.js";
28
28
  import { sendJson } from "./routes-vector-cortex-shared.js";
29
29
  import { deriveVcStatus } from "./vc-status.js";
30
30
  import { SETUP_CORTEX_BLOCKERS, computeSetupCortexBlockers } from "./setup-cortex-blockers.js";
31
31
  import { readQualificationRecord, encoderStateDir, QUALIFICATION_RECORD_UNAVAILABLE, } from "./qualification-record.js";
32
+ import { readEnc2aGuide } from "./routes-setup-enc2a.js";
32
33
  /** Resolve the committed encoder-v1 asset dir by walking up to the repo root. */
33
34
  function encoderAssetDir() {
34
35
  let dir = dirname(fileURLToPath(import.meta.url));
@@ -164,12 +165,17 @@ export function handleSetupCortexStatus(req, res, _ctx) {
164
165
  const recordGate = enc0g && ENC_0F_ENABLED();
165
166
  const record = recordGate ? readQualificationRecord(encoderStateDir()) : null;
166
167
  const facts = enabled ? setupCortexFacts(record, recordGate) : null;
168
+ // ENC-2a native ORT detection: pass the installed version + retest verdict to
169
+ // the blockers compute so HG-3 can close when native is installed + qualified.
170
+ const enc2a = enabled && ENC_2A_ENABLED() ? readEnc2aGuide(encoderStateDir()) : null;
171
+ const nativeOrtInstalledVersion = enc2a?.installedVersion ?? null;
167
172
  const blocks = enabled
168
173
  ? enc0g
169
174
  ? [...computeSetupCortexBlockers({
170
175
  platform: detectPlatform(),
171
176
  qualification: record,
172
177
  headCount: facts ? facts.headCount : null,
178
+ nativeOrtInstalledVersion,
173
179
  })]
174
180
  : [...SETUP_CORTEX_BLOCKERS]
175
181
  : [];
@@ -14,9 +14,12 @@
14
14
  * all-open, byte-identical to ENC-0f-era for flag-off). `computeSetupCortexBlockers`
15
15
  * is a PURE function over (platform, ENC-0f QualificationV1 record, asset-manifest
16
16
  * head-count) that returns the live blocker list: HG-1 closes on a five-head
17
- * manifest (ENC-0c), HG-5 reflects the measured qualification verdict, HG-4
18
- * notes the ENC-0e visibility close while the binary gap persists, HG-3 stays
19
- * open (genuinely unresolved). `setupCortexActionBlockers` re-derives VC9B
17
+ * manifest (ENC-0c), HG-5 reflects the measured qualification verdict, HG-4 is
18
+ * superseded (upstream arm64-only darwin binary gap, ENC-0e demotion surface),
19
+ * HG-6 is superseded (4-thread mandate = runtime p95 gate), HG-7 closes (frozen
20
+ * model card / dataset manifest / calibration), HG-3 closes when native
21
+ * onnxruntime-node is installed (ENC-2a/2b). `setupCortexActionBlockers`
22
+ * re-derives VC9B
20
23
  * action gating from the live computed blockers (intersects each action's
21
24
  * static candidate gate ids with the currently-open blocker ids).
22
25
  *
@@ -26,6 +29,7 @@
26
29
  * never magic numbers in the computed path.
27
30
  */
28
31
  import { ENCODER_HEAD_ORDER, ENCODER_LATENCY_P95_MS, ENCODER_RSS_BUDGET_BYTES, } from "./encoder/types.js";
32
+ import { INSTALL_BUDGET_DEFAULT_MIB } from "./encoder/decision.js";
29
33
  const MIB = 1024 * 1024;
30
34
  /**
31
35
  * Marker threshold-failure emitted by the status route when NO QualificationV1
@@ -100,14 +104,20 @@ export function setupCortexBlocker(id) {
100
104
  * - HG-1 → `"closed"` when the asset manifest declares all five projection
101
105
  * heads (`headCount === ENCODER_HEAD_ORDER.length`); otherwise stays open.
102
106
  * - HG-3 → unchanged (genuinely open — onnxruntime-node budget unresolved).
103
- * - HG-4 → stays `"open"` (the upstream binary gap is unchanged); resolution
104
- * notes that ENC-0e ships the darwin demotion visibility surface.
107
+ * - HG-4 → `"superseded"` (documented upstream platform gap onnxruntime-node
108
+ * is arm64-only for darwin; ENC-0e ships the demotion surface, no code fix
109
+ * is possible).
105
110
  * - HG-5 → derived from the qualification record: an empty record is
106
111
  * `"superseded"` (no measurement on this device); a `failed` verdict closes
107
112
  * it with the measured p95/RSS wording; a `qualified` verdict closes it with
108
113
  * "measured" wording. Severity stays `"medium"` from the base row.
114
+ * - HG-6 → `"superseded"` (the 4-thread mandate is a runtime p95 gate enforced
115
+ * by the ENC-0f qualification bench — a platform failing the p95 threshold
116
+ * auto-demotes to mode B; no separate code surface needed).
117
+ * - HG-7 → `"closed"` (model card, dataset manifest, and VC2C calibration
118
+ * thresholds are all committed and frozen).
109
119
  * `platform` is carried for contract symmetry with Worker B's route input; the
110
- * HG rules here do not branch on it (HG-4's darwin note applies regardless).
120
+ * HG rules here do not branch on it (the closures are unconditional).
111
121
  */
112
122
  export function computeSetupCortexBlockers(input) {
113
123
  const { qualification, headCount } = input;
@@ -117,10 +127,36 @@ export function computeSetupCortexBlockers(input) {
117
127
  return headCount === ENCODER_HEAD_ORDER.length
118
128
  ? { ...base, status: "closed" }
119
129
  : base;
130
+ case "HG-3":
131
+ // HG-3 is the install-budget gate: closes when native onnxruntime-node is
132
+ // installed (the ~101 MiB tarball fits within the 300 MiB default budget).
133
+ // The runtime p95/RSS qualification is HG-5's domain — this gate only asks
134
+ // "is the binding installed and within budget?".
135
+ if (input.nativeOrtInstalledVersion != null) {
136
+ return {
137
+ ...base,
138
+ status: "closed",
139
+ resolution: `Native onnxruntime-node ${input.nativeOrtInstalledVersion} installed (~101 MiB, within the ${INSTALL_BUDGET_DEFAULT_MIB} MiB budget). Runtime qualification is HG-5.`,
140
+ };
141
+ }
142
+ return base;
120
143
  case "HG-4":
121
144
  return {
122
145
  ...base,
123
- resolution: `${base.resolution} ENC-0e shipped the darwin demotion visibility surface.`,
146
+ status: "superseded",
147
+ resolution: "Upstream onnxruntime-node ships arm64-only for darwin. ENC-0e ships the demotion surface: darwin-x64 users use the WASM path (mode B) or lexical fallback (mode C). No code fix is possible — the binary does not exist upstream.",
148
+ };
149
+ case "HG-6":
150
+ return {
151
+ ...base,
152
+ status: "superseded",
153
+ resolution: "The 4-thread mandate is a runtime p95 gate enforced by the qualification bench (ENC-0f gate-qualify.mjs). A platform that fails the p95 latency threshold (40ms) is automatically demoted to mode B — no separate code surface needed. Low-core platforms are handled by the same qualification gate.",
154
+ };
155
+ case "HG-7":
156
+ return {
157
+ ...base,
158
+ status: "closed",
159
+ resolution: "Model card (training/vector-cortex/model-card.json), dataset manifest (training/vector-cortex/dataset-manifest.json), and VC2C calibration thresholds (EVALUATION_THRESHOLDS in types-vc2c.ts) are all committed and frozen.",
124
160
  };
125
161
  case "HG-5":
126
162
  if (qualification === null) {
@@ -14,9 +14,12 @@
14
14
  * all-open, byte-identical to ENC-0f-era for flag-off). `computeSetupCortexBlockers`
15
15
  * is a PURE function over (platform, ENC-0f QualificationV1 record, asset-manifest
16
16
  * head-count) that returns the live blocker list: HG-1 closes on a five-head
17
- * manifest (ENC-0c), HG-5 reflects the measured qualification verdict, HG-4
18
- * notes the ENC-0e visibility close while the binary gap persists, HG-3 stays
19
- * open (genuinely unresolved). `setupCortexActionBlockers` re-derives VC9B
17
+ * manifest (ENC-0c), HG-5 reflects the measured qualification verdict, HG-4 is
18
+ * superseded (upstream arm64-only darwin binary gap, ENC-0e demotion surface),
19
+ * HG-6 is superseded (4-thread mandate = runtime p95 gate), HG-7 closes (frozen
20
+ * model card / dataset manifest / calibration), HG-3 closes when native
21
+ * onnxruntime-node is installed (ENC-2a/2b). `setupCortexActionBlockers`
22
+ * re-derives VC9B
20
23
  * action gating from the live computed blockers (intersects each action's
21
24
  * static candidate gate ids with the currently-open blocker ids).
22
25
  *
@@ -26,6 +29,7 @@
26
29
  * never magic numbers in the computed path.
27
30
  */
28
31
  import { ENCODER_HEAD_ORDER, ENCODER_LATENCY_P95_MS, ENCODER_RSS_BUDGET_BYTES, } from "./encoder/types.js";
32
+ import { INSTALL_BUDGET_DEFAULT_MIB } from "./encoder/decision.js";
29
33
  const MIB = 1024 * 1024;
30
34
  /**
31
35
  * Marker threshold-failure emitted by the status route when NO QualificationV1
@@ -100,14 +104,20 @@ export function setupCortexBlocker(id) {
100
104
  * - HG-1 → `"closed"` when the asset manifest declares all five projection
101
105
  * heads (`headCount === ENCODER_HEAD_ORDER.length`); otherwise stays open.
102
106
  * - HG-3 → unchanged (genuinely open — onnxruntime-node budget unresolved).
103
- * - HG-4 → stays `"open"` (the upstream binary gap is unchanged); resolution
104
- * notes that ENC-0e ships the darwin demotion visibility surface.
107
+ * - HG-4 → `"superseded"` (documented upstream platform gap onnxruntime-node
108
+ * is arm64-only for darwin; ENC-0e ships the demotion surface, no code fix
109
+ * is possible).
105
110
  * - HG-5 → derived from the qualification record: an empty record is
106
111
  * `"superseded"` (no measurement on this device); a `failed` verdict closes
107
112
  * it with the measured p95/RSS wording; a `qualified` verdict closes it with
108
113
  * "measured" wording. Severity stays `"medium"` from the base row.
114
+ * - HG-6 → `"superseded"` (the 4-thread mandate is a runtime p95 gate enforced
115
+ * by the ENC-0f qualification bench — a platform failing the p95 threshold
116
+ * auto-demotes to mode B; no separate code surface needed).
117
+ * - HG-7 → `"closed"` (model card, dataset manifest, and VC2C calibration
118
+ * thresholds are all committed and frozen).
109
119
  * `platform` is carried for contract symmetry with Worker B's route input; the
110
- * HG rules here do not branch on it (HG-4's darwin note applies regardless).
120
+ * HG rules here do not branch on it (the closures are unconditional).
111
121
  */
112
122
  export function computeSetupCortexBlockers(input) {
113
123
  const { qualification, headCount } = input;
@@ -117,10 +127,36 @@ export function computeSetupCortexBlockers(input) {
117
127
  return headCount === ENCODER_HEAD_ORDER.length
118
128
  ? { ...base, status: "closed" }
119
129
  : base;
130
+ case "HG-3":
131
+ // HG-3 is the install-budget gate: closes when native onnxruntime-node is
132
+ // installed (the ~101 MiB tarball fits within the 300 MiB default budget).
133
+ // The runtime p95/RSS qualification is HG-5's domain — this gate only asks
134
+ // "is the binding installed and within budget?".
135
+ if (input.nativeOrtInstalledVersion != null) {
136
+ return {
137
+ ...base,
138
+ status: "closed",
139
+ resolution: `Native onnxruntime-node ${input.nativeOrtInstalledVersion} installed (~101 MiB, within the ${INSTALL_BUDGET_DEFAULT_MIB} MiB budget). Runtime qualification is HG-5.`,
140
+ };
141
+ }
142
+ return base;
120
143
  case "HG-4":
121
144
  return {
122
145
  ...base,
123
- resolution: `${base.resolution} ENC-0e shipped the darwin demotion visibility surface.`,
146
+ status: "superseded",
147
+ resolution: "Upstream onnxruntime-node ships arm64-only for darwin. ENC-0e ships the demotion surface: darwin-x64 users use the WASM path (mode B) or lexical fallback (mode C). No code fix is possible — the binary does not exist upstream.",
148
+ };
149
+ case "HG-6":
150
+ return {
151
+ ...base,
152
+ status: "superseded",
153
+ resolution: "The 4-thread mandate is a runtime p95 gate enforced by the qualification bench (ENC-0f gate-qualify.mjs). A platform that fails the p95 latency threshold (40ms) is automatically demoted to mode B — no separate code surface needed. Low-core platforms are handled by the same qualification gate.",
154
+ };
155
+ case "HG-7":
156
+ return {
157
+ ...base,
158
+ status: "closed",
159
+ resolution: "Model card (training/vector-cortex/model-card.json), dataset manifest (training/vector-cortex/dataset-manifest.json), and VC2C calibration thresholds (EVALUATION_THRESHOLDS in types-vc2c.ts) are all committed and frozen.",
124
160
  };
125
161
  case "HG-5":
126
162
  if (qualification === null) {
@@ -25,7 +25,7 @@ import { readFileSync, statSync } from "node:fs";
25
25
  import { join, dirname } from "node:path";
26
26
  import { fileURLToPath } from "node:url";
27
27
  import type { RouteContext } from "./routes-core.js";
28
- import { VC9A_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED } from "../../src/config.js";
28
+ import { VC9A_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED, ENC_2A_ENABLED } from "../../src/config.js";
29
29
  import { readEncoderManifest, verifyEncoderAsset, detectPlatform } from "../../src/vector-cortex/encoder/asset.js";
30
30
  import type { QualificationV1 } from "../../src/vector-cortex/encoder/qualify.js";
31
31
  import { selectRuntimeBackend } from "../../src/vector-cortex/encoder/runtime-select.js";
@@ -37,6 +37,7 @@ import {
37
37
  encoderStateDir,
38
38
  QUALIFICATION_RECORD_UNAVAILABLE,
39
39
  } from "./qualification-record.js";
40
+ import { readEnc2aGuide } from "./routes-setup-enc2a.js";
40
41
  import type {
41
42
  SetupCortexStatusResponse,
42
43
  BlockerV1,
@@ -214,12 +215,18 @@ export function handleSetupCortexStatus(
214
215
 
215
216
  const facts = enabled ? setupCortexFacts(record, recordGate) : null;
216
217
 
218
+ // ENC-2a native ORT detection: pass the installed version + retest verdict to
219
+ // the blockers compute so HG-3 can close when native is installed + qualified.
220
+ const enc2a = enabled && ENC_2A_ENABLED() ? readEnc2aGuide(encoderStateDir()) : null;
221
+ const nativeOrtInstalledVersion = enc2a?.installedVersion ?? null;
222
+
217
223
  const blocks: BlockerV1[] = enabled
218
224
  ? enc0g
219
225
  ? [...computeSetupCortexBlockers({
220
226
  platform: detectPlatform(),
221
227
  qualification: record,
222
228
  headCount: facts ? facts.headCount : null,
229
+ nativeOrtInstalledVersion,
223
230
  })]
224
231
  : [...SETUP_CORTEX_BLOCKERS]
225
232
  : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.20.71",
3
+ "version": "0.20.72",
4
4
  "description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
@@ -14,9 +14,12 @@
14
14
  * all-open, byte-identical to ENC-0f-era for flag-off). `computeSetupCortexBlockers`
15
15
  * is a PURE function over (platform, ENC-0f QualificationV1 record, asset-manifest
16
16
  * head-count) that returns the live blocker list: HG-1 closes on a five-head
17
- * manifest (ENC-0c), HG-5 reflects the measured qualification verdict, HG-4
18
- * notes the ENC-0e visibility close while the binary gap persists, HG-3 stays
19
- * open (genuinely unresolved). `setupCortexActionBlockers` re-derives VC9B
17
+ * manifest (ENC-0c), HG-5 reflects the measured qualification verdict, HG-4 is
18
+ * superseded (upstream arm64-only darwin binary gap, ENC-0e demotion surface),
19
+ * HG-6 is superseded (4-thread mandate = runtime p95 gate), HG-7 closes (frozen
20
+ * model card / dataset manifest / calibration), HG-3 closes when native
21
+ * onnxruntime-node is installed (ENC-2a/2b). `setupCortexActionBlockers`
22
+ * re-derives VC9B
20
23
  * action gating from the live computed blockers (intersects each action's
21
24
  * static candidate gate ids with the currently-open blocker ids).
22
25
  *
@@ -32,6 +35,7 @@ import {
32
35
  ENCODER_LATENCY_P95_MS,
33
36
  ENCODER_RSS_BUDGET_BYTES,
34
37
  } from "./encoder/types.js";
38
+ import { INSTALL_BUDGET_DEFAULT_MIB } from "./encoder/decision.js";
35
39
 
36
40
  const MIB = 1024 * 1024;
37
41
 
@@ -140,19 +144,27 @@ export function setupCortexBlocker(id: string): SetupCortexBlockerV1 | undefined
140
144
  * - HG-1 → `"closed"` when the asset manifest declares all five projection
141
145
  * heads (`headCount === ENCODER_HEAD_ORDER.length`); otherwise stays open.
142
146
  * - HG-3 → unchanged (genuinely open — onnxruntime-node budget unresolved).
143
- * - HG-4 → stays `"open"` (the upstream binary gap is unchanged); resolution
144
- * notes that ENC-0e ships the darwin demotion visibility surface.
147
+ * - HG-4 → `"superseded"` (documented upstream platform gap onnxruntime-node
148
+ * is arm64-only for darwin; ENC-0e ships the demotion surface, no code fix
149
+ * is possible).
145
150
  * - HG-5 → derived from the qualification record: an empty record is
146
151
  * `"superseded"` (no measurement on this device); a `failed` verdict closes
147
152
  * it with the measured p95/RSS wording; a `qualified` verdict closes it with
148
153
  * "measured" wording. Severity stays `"medium"` from the base row.
154
+ * - HG-6 → `"superseded"` (the 4-thread mandate is a runtime p95 gate enforced
155
+ * by the ENC-0f qualification bench — a platform failing the p95 threshold
156
+ * auto-demotes to mode B; no separate code surface needed).
157
+ * - HG-7 → `"closed"` (model card, dataset manifest, and VC2C calibration
158
+ * thresholds are all committed and frozen).
149
159
  * `platform` is carried for contract symmetry with Worker B's route input; the
150
- * HG rules here do not branch on it (HG-4's darwin note applies regardless).
160
+ * HG rules here do not branch on it (the closures are unconditional).
151
161
  */
152
162
  export function computeSetupCortexBlockers(input: {
153
163
  platform: string | null;
154
164
  qualification: QualificationV1 | null;
155
165
  headCount: number | null;
166
+ /** Installed native onnxruntime-node version (null = not installed). */
167
+ nativeOrtInstalledVersion?: string | null;
156
168
  }): readonly SetupCortexBlockerV1[] {
157
169
  const { qualification, headCount } = input;
158
170
  return SETUP_CORTEX_BLOCKERS.map((base): SetupCortexBlockerV1 => {
@@ -161,10 +173,39 @@ export function computeSetupCortexBlockers(input: {
161
173
  return headCount === ENCODER_HEAD_ORDER.length
162
174
  ? { ...base, status: "closed" }
163
175
  : base;
176
+ case "HG-3":
177
+ // HG-3 is the install-budget gate: closes when native onnxruntime-node is
178
+ // installed (the ~101 MiB tarball fits within the 300 MiB default budget).
179
+ // The runtime p95/RSS qualification is HG-5's domain — this gate only asks
180
+ // "is the binding installed and within budget?".
181
+ if (input.nativeOrtInstalledVersion != null) {
182
+ return {
183
+ ...base,
184
+ status: "closed",
185
+ resolution: `Native onnxruntime-node ${input.nativeOrtInstalledVersion} installed (~101 MiB, within the ${INSTALL_BUDGET_DEFAULT_MIB} MiB budget). Runtime qualification is HG-5.`,
186
+ };
187
+ }
188
+ return base;
164
189
  case "HG-4":
165
190
  return {
166
191
  ...base,
167
- resolution: `${base.resolution} ENC-0e shipped the darwin demotion visibility surface.`,
192
+ status: "superseded",
193
+ resolution:
194
+ "Upstream onnxruntime-node ships arm64-only for darwin. ENC-0e ships the demotion surface: darwin-x64 users use the WASM path (mode B) or lexical fallback (mode C). No code fix is possible — the binary does not exist upstream.",
195
+ };
196
+ case "HG-6":
197
+ return {
198
+ ...base,
199
+ status: "superseded",
200
+ resolution:
201
+ "The 4-thread mandate is a runtime p95 gate enforced by the qualification bench (ENC-0f gate-qualify.mjs). A platform that fails the p95 latency threshold (40ms) is automatically demoted to mode B — no separate code surface needed. Low-core platforms are handled by the same qualification gate.",
202
+ };
203
+ case "HG-7":
204
+ return {
205
+ ...base,
206
+ status: "closed",
207
+ resolution:
208
+ "Model card (training/vector-cortex/model-card.json), dataset manifest (training/vector-cortex/dataset-manifest.json), and VC2C calibration thresholds (EVALUATION_THRESHOLDS in types-vc2c.ts) are all committed and frozen.",
168
209
  };
169
210
  case "HG-5":
170
211
  if (qualification === null) {