pi-mega-compact 0.20.48 → 0.20.49
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.
- package/dist/config/vector-cortex-enc0g.js +37 -0
- package/dist/config/vector-cortex.js +1 -0
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/qualification-record.js +71 -0
- package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -0
- package/dist/extensions/dashboard-server/routes-setup-cortex-actions.js +49 -3
- package/dist/extensions/dashboard-server/routes-setup-cortex.js +65 -16
- package/dist/extensions/dashboard-server/setup-cortex-actions.js +21 -4
- package/dist/extensions/dashboard-server/setup-cortex-blockers.js +3 -69
- package/dist/src/config/vector-cortex-enc0g.js +37 -0
- package/dist/src/config/vector-cortex.js +1 -0
- package/dist/src/config.js +1 -1
- package/dist/src/vector-cortex/setup-cortex-blockers-compute.js +160 -0
- package/dist/vector-cortex/setup-cortex-blockers-compute.js +160 -0
- package/extensions/dashboard-server/api-contracts/setup-cortex.ts +6 -2
- package/extensions/dashboard-server/qualification-record.ts +70 -0
- package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +6 -0
- package/extensions/dashboard-server/routes-setup-cortex-actions.ts +50 -3
- package/extensions/dashboard-server/routes-setup-cortex.ts +92 -16
- package/extensions/dashboard-server/setup-cortex-actions.ts +23 -4
- package/extensions/dashboard-server/setup-cortex-blockers.ts +3 -97
- package/package.json +1 -1
- package/src/config/vector-cortex-enc0g.ts +39 -0
- package/src/config/vector-cortex.ts +1 -0
- package/src/config.ts +1 -0
- package/src/vector-cortex/setup-cortex-blockers-compute.ts +216 -0
|
@@ -36,6 +36,11 @@ import {
|
|
|
36
36
|
verifyEncoderAsset,
|
|
37
37
|
detectPlatform,
|
|
38
38
|
} from "../../src/vector-cortex/encoder/asset.js";
|
|
39
|
+
import { ENC_0G_ENABLED, ENC_0F_ENABLED } from "../../src/config.js";
|
|
40
|
+
import {
|
|
41
|
+
readQualificationRecord,
|
|
42
|
+
encoderStateDir,
|
|
43
|
+
} from "./qualification-record.js";
|
|
39
44
|
|
|
40
45
|
/** Cap applied to every log tail served by the action-log route. */
|
|
41
46
|
export const ACTION_LOG_TAIL_BYTES = 8192;
|
|
@@ -174,23 +179,37 @@ function runVerifyAsset(stateDir: string): SetupCortexActionResult {
|
|
|
174
179
|
};
|
|
175
180
|
}
|
|
176
181
|
|
|
182
|
+
/**
|
|
183
|
+
* The ENC-0g honesty suffix for the verify-asset summary line: when both gates
|
|
184
|
+
* are ON, surface the QualificationV1 record verdict so the action log is honest
|
|
185
|
+
* alongside the (possibly demoted) status card. Returns "" byte-identical when
|
|
186
|
+
* ENC_0G is off. Bounded + redacted (verdict + reasons only).
|
|
187
|
+
*/
|
|
188
|
+
function qualificationRecordSuffix(): string {
|
|
189
|
+
if (!ENC_0G_ENABLED() || !ENC_0F_ENABLED()) return "";
|
|
190
|
+
const record = readQualificationRecord(encoderStateDir());
|
|
191
|
+
if (record === null) return " record_verdict=unavailable";
|
|
192
|
+
return ` record_verdict=${record.verdict} record_reasons=${record.reasons.join(",")}`;
|
|
193
|
+
}
|
|
194
|
+
|
|
177
195
|
/** Compute the redacted verify-asset summary lines (digests + codes only). */
|
|
178
196
|
function buildVerifySummary(): string {
|
|
197
|
+
const suffix = qualificationRecordSuffix();
|
|
179
198
|
const dir = encoderAssetDir();
|
|
180
199
|
if (dir === null) {
|
|
181
|
-
return
|
|
200
|
+
return `mode=C verdict=unavailable reason=asset_missing${suffix}\n`;
|
|
182
201
|
}
|
|
183
202
|
const manifest = readEncoderManifest(dir);
|
|
184
203
|
if (manifest === null) {
|
|
185
|
-
return
|
|
204
|
+
return `mode=B verdict=demoted reason=ENC_MANIFEST_INVALID${suffix}\n`;
|
|
186
205
|
}
|
|
187
206
|
const platform = detectPlatform();
|
|
188
207
|
const verify = verifyEncoderAsset(dir, manifest, platform);
|
|
189
208
|
if (verify.ok) {
|
|
190
209
|
const prefix = verify.onnxDigest.slice(0, 12);
|
|
191
|
-
return `mode=A verdict=qualified onnx_digest_prefix=${prefix} embedded_bytes=${verify.embeddedBytes}\n`;
|
|
210
|
+
return `mode=A verdict=qualified onnx_digest_prefix=${prefix} embedded_bytes=${verify.embeddedBytes}${suffix}\n`;
|
|
192
211
|
}
|
|
193
|
-
return `mode=B verdict=demoted reason=${verify.code}\n`;
|
|
212
|
+
return `mode=B verdict=demoted reason=${verify.code}${suffix}\n`;
|
|
194
213
|
}
|
|
195
214
|
|
|
196
215
|
/** Walk up to the committed encoder-v1 asset dir (mirrors routes-setup-cortex.ts). */
|
|
@@ -1,99 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dashboard-server/setup-cortex-blockers.ts —
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* The hard-gate items enumerated in docs/vector-cortex/vc2-model-prep.md §6
|
|
6
|
-
* (per the 2026-08-05 research update: the opset-14→17 re-export blocker is
|
|
7
|
-
* REMOVED because onnx-community exports are now opset 21). This module is the
|
|
8
|
-
* SINGLE canonical source of those blockers — the route file
|
|
9
|
-
* (routes-setup-cortex.ts) carries NO string literals for them; it reads this
|
|
10
|
-
* static manifest so the UI rows and the spec stay in one place.
|
|
11
|
-
*
|
|
12
|
-
* Reader-only, static: zero network, no writes (PREVENT-PI-004), no `any`
|
|
13
|
-
* (PREVENT-011).
|
|
2
|
+
* dashboard-server/setup-cortex-blockers.ts — thin shell re-exporting the
|
|
3
|
+
* canonical Setup Cortex blocker compute from src (single source of truth).
|
|
14
4
|
*/
|
|
15
|
-
|
|
16
|
-
/** The open hard-gate items VC9A surfaces (nothing is closed in-workstream). */
|
|
17
|
-
export interface SetupCortexBlockerV1 {
|
|
18
|
-
/** Stable machine id (e.g. HG-1) the client can key rows on. */
|
|
19
|
-
readonly id: string;
|
|
20
|
-
/** Human title shown on the blockers card. */
|
|
21
|
-
readonly title: string;
|
|
22
|
-
/** Severity: blocker | high | medium. */
|
|
23
|
-
readonly severity: "blocker" | "high" | "medium";
|
|
24
|
-
/** Lifecycle state — all OPEN (hard gates are never silently closed). */
|
|
25
|
-
readonly status: "open";
|
|
26
|
-
/** Optional candidate resolution surfaced for the controller / user. */
|
|
27
|
-
readonly resolution?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The four blockers VC9A reports. Enumerates the vc2-model-prep §6 items that
|
|
32
|
-
* remain per the 2026-08-05 research. The opset re-export blocker (formerly
|
|
33
|
-
* §6 #2) is NOT listed: onnx-community exports are opset 21, so it is removed.
|
|
34
|
-
*/
|
|
35
|
-
export const SETUP_CORTEX_BLOCKERS: readonly SetupCortexBlockerV1[] = [
|
|
36
|
-
{
|
|
37
|
-
id: "HG-1",
|
|
38
|
-
title: "Five projection heads do not exist",
|
|
39
|
-
severity: "blocker",
|
|
40
|
-
status: "open",
|
|
41
|
-
resolution:
|
|
42
|
-
"Supervision transfer onto a frozen bge-small-en-v1.5 trunk (contradiction distilled from cross-encoder/nli-deberta-v3-small; dependency NLI-assisted; cache-stability deterministic; payload-routing small MLP) — VC2B training + export.",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: "HG-3",
|
|
46
|
-
title: "onnxruntime-node install exceeds the 80 MiB asset budget",
|
|
47
|
-
severity: "blocker",
|
|
48
|
-
status: "open",
|
|
49
|
-
resolution:
|
|
50
|
-
"onnxruntime-node bundles ~258 MiB across all platforms. Candidate: transformers.js v4.2.0 (9.5 MiB shell, pure-Node via onnxruntime-web WASM) measured against budget + p95 gate before committing.",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: "HG-4",
|
|
54
|
-
title: "No darwin-x64 binary in onnxruntime-node",
|
|
55
|
-
severity: "high",
|
|
56
|
-
status: "open",
|
|
57
|
-
resolution:
|
|
58
|
-
"Intel-Mac mode-A users demote to the WASM path (if HG-3 resolves that way) or mode B. " +
|
|
59
|
-
"darwin-x64: no native binary upstream (arm64-only); mode-B WASM per HG-4.",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
id: "HG-5",
|
|
63
|
-
title: "RSS margin at 512 tokens is ~0.5%",
|
|
64
|
-
severity: "medium",
|
|
65
|
-
status: "open",
|
|
66
|
-
resolution:
|
|
67
|
-
"149.2 MiB vs 150 MiB cap with run-to-run variance 119-149 MiB; considers capping mode A at 384 tokens or using the marginal-footprint accounting runtime.ts already implements.",
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
/** Look up one blocker by id; undefined when unknown (defensive). */
|
|
72
|
-
export function setupCortexBlocker(id: string): SetupCortexBlockerV1 | undefined {
|
|
73
|
-
return SETUP_CORTEX_BLOCKERS.find((b) => b.id === id);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ─── VC9B action gating ─────────────────────────────────────────────────────
|
|
77
|
-
|
|
78
|
-
/** The VC9B action kinds the drivers know how to run. */
|
|
79
|
-
export type SetupCortexActionKind = "fetch-model" | "bench" | "verify-asset";
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The open hard-gate ids that BLOCK a given action. fetch-model and bench are
|
|
83
|
-
* gated by HG-1 (five-head training open) and HG-3 (install budget open) per the
|
|
84
|
-
* VC9 workstream plan; verify-asset is a pure re-read of committed assets and is
|
|
85
|
-
* NOT gated. When a gated action is requested, the route returns
|
|
86
|
-
* action_blocked_by_open_item with these ids and does NOT spawn. The ids are
|
|
87
|
-
* always drawn from SETUP_CORTEX_BLOCKERS (each exists — verified by test).
|
|
88
|
-
*/
|
|
89
|
-
export function setupCortexActionBlockers(
|
|
90
|
-
action: SetupCortexActionKind,
|
|
91
|
-
): readonly string[] {
|
|
92
|
-
switch (action) {
|
|
93
|
-
case "fetch-model":
|
|
94
|
-
case "bench":
|
|
95
|
-
return ["HG-1", "HG-3"];
|
|
96
|
-
case "verify-asset":
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
}
|
|
5
|
+
export * from "../../src/vector-cortex/setup-cortex-blockers-compute.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-mega-compact",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.49",
|
|
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",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config/vector-cortex-enc0g.ts — ENC-0g Setup Cortex status route honest state.
|
|
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 .. enc0f.ts and
|
|
6
|
+
* the VC8C/VC9A-D/ML5A-E/DEDUP_ATTR siblings were. vector-cortex.ts re-exports
|
|
7
|
+
* the flag below and root src/config.ts re-exports it, so no consumer import
|
|
8
|
+
* path changes.
|
|
9
|
+
*
|
|
10
|
+
* ENC-0g makes the Setup Cortex status route honest: the status route reads the
|
|
11
|
+
* latest ENC-0f `QualificationV1` record (when ENC_0F is ON and a record
|
|
12
|
+
* exists) and lets its verdict override the structural verifyEncoderAsset
|
|
13
|
+
* result for the `qualification` field; the blocker list becomes a pure
|
|
14
|
+
* computed function over (platform, qualification record, manifest head-count)
|
|
15
|
+
* with corrected HG statuses/wording; and VC9B action gating is re-derived from
|
|
16
|
+
* the live computed blockers instead of the stale static manifest.
|
|
17
|
+
*
|
|
18
|
+
* `MEGACOMPACT_ENC_0G=0` disables: the status route derives its `qualification`
|
|
19
|
+
* verdict from `verifyEncoderAsset(...).ok` alone, the blocker list is the
|
|
20
|
+
* static `SETUP_CORTEX_BLOCKERS` array exactly as ENC-0f-era, and action gating
|
|
21
|
+
* reads the static table as today — byte-identical to the predecessor. The flag
|
|
22
|
+
* MUST also be a dashboard SETTINGS toggle (visible in config UI, never in
|
|
23
|
+
* EXCLUDED_SETTINGS).
|
|
24
|
+
*
|
|
25
|
+
* Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { sprintFlag } from "./vector-cortex-flag.js";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* ENC-0g — Setup Cortex status route honest state (verdict override + live
|
|
32
|
+
* blockers + re-derived gating). Default ON. `MEGACOMPACT_ENC_0G=0` disables
|
|
33
|
+
* and is byte-identical to the predecessor (ENC-0f): verdict from
|
|
34
|
+
* `verifyEncoderAsset` alone, static `SETUP_CORTEX_BLOCKERS`, static
|
|
35
|
+
* `setupCortexActionBlockers`. This flag MUST also be a dashboard SETTINGS
|
|
36
|
+
* toggle (visible in config UI, never in EXCLUDED_SETTINGS), mirroring
|
|
37
|
+
* ENC_0A/ENC_0B/ENC_0C/ENC_0D/ENC_0E/ENC_0F.
|
|
38
|
+
*/
|
|
39
|
+
export const ENC_0G_ENABLED = (): boolean => sprintFlag("MEGACOMPACT_ENC_0G");
|
|
@@ -61,6 +61,7 @@ export { ENC_0C_ENABLED } from "./vector-cortex-enc0c.js";
|
|
|
61
61
|
export { ENC_0D_ENABLED } from "./vector-cortex-enc0d.js";
|
|
62
62
|
export { ENC_0E_ENABLED } from "./vector-cortex-enc0e.js";
|
|
63
63
|
export { ENC_0F_ENABLED } from "./vector-cortex-enc0f.js";
|
|
64
|
+
export { ENC_0G_ENABLED } from "./vector-cortex-enc0g.js";
|
|
64
65
|
// Breaker constants (TRIAD_RESILIENCE.md §breaker) extracted to vector-cortex-breakers.ts.
|
|
65
66
|
export {
|
|
66
67
|
BREAKER_WINDOW_MS,
|
package/src/config.ts
CHANGED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/vector-cortex/setup-cortex-blockers-compute.ts — canonical blocker
|
|
3
|
+
* manifest + pure computed blocker derivation for the Setup Cortex status
|
|
4
|
+
* read path (VC9A/ENC-0g).
|
|
5
|
+
*
|
|
6
|
+
* The hard-gate items enumerated in docs/vector-cortex/vc2-model-prep.md §6
|
|
7
|
+
* (per the 2026-08-05 research update: the opset-14→17 re-export blocker is
|
|
8
|
+
* REMOVED because onnx-community exports are now opset 21). This module is the
|
|
9
|
+
* SINGLE canonical source of those blockers — the route file
|
|
10
|
+
* (routes-setup-cortex.ts) carries NO string literals for them; it reads this
|
|
11
|
+
* manifest so the UI rows and the spec stay in one place.
|
|
12
|
+
*
|
|
13
|
+
* ENC-0g: `SETUP_CORTEX_BLOCKERS` remains the canonical BASE data (authored
|
|
14
|
+
* all-open, byte-identical to ENC-0f-era for flag-off). `computeSetupCortexBlockers`
|
|
15
|
+
* is a PURE function over (platform, ENC-0f QualificationV1 record, asset-manifest
|
|
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
|
|
20
|
+
* action gating from the live computed blockers (intersects each action's
|
|
21
|
+
* static candidate gate ids with the currently-open blocker ids).
|
|
22
|
+
*
|
|
23
|
+
* Reader-only, pure computation: zero network, no writes (PREVENT-PI-004), no
|
|
24
|
+
* `any` (PREVENT-011). Thresholds come from src/vector-cortex/encoder/types.js
|
|
25
|
+
* (ENCODER_HEAD_ORDER / ENCODER_LATENCY_P95_MS / ENCODER_RSS_BUDGET_BYTES) —
|
|
26
|
+
* never magic numbers in the computed path.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import type { QualificationV1 } from "./encoder/qualify.js";
|
|
30
|
+
import {
|
|
31
|
+
ENCODER_HEAD_ORDER,
|
|
32
|
+
ENCODER_LATENCY_P95_MS,
|
|
33
|
+
ENCODER_RSS_BUDGET_BYTES,
|
|
34
|
+
} from "./encoder/types.js";
|
|
35
|
+
|
|
36
|
+
const MIB = 1024 * 1024;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Marker threshold-failure emitted by the status route when NO QualificationV1
|
|
40
|
+
* record exists on the device (or it is missing / unreadable / corrupt) — the
|
|
41
|
+
* route falls back to the verify-only verdict and includes this marker, never a
|
|
42
|
+
* fabricated pass and never a bare silent fallback. SINGLE source: the status
|
|
43
|
+
* route references this const, never a re-literal (no-scattered-literal scan).
|
|
44
|
+
*/
|
|
45
|
+
export const QUALIFICATION_RECORD_UNAVAILABLE = "qualification_record_unavailable";
|
|
46
|
+
|
|
47
|
+
/** Lifecycle of a hard-gate item surfaced on the blockers card. */
|
|
48
|
+
export type SetupCortexBlockerStatusV1 = "open" | "closed" | "superseded";
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A hard-gate item VC9A surfaces. `status` is `"open"` by default (a hard gate
|
|
52
|
+
* is never silently closed); a computed blocker may mark it `"closed"` (a
|
|
53
|
+
* measured/gated close) or `"superseded"` (an open question, but no live
|
|
54
|
+
* measurement exists on this device). The client renders `status` as a row
|
|
55
|
+
* label (no exhaustive switch), so widening is renderer-safe.
|
|
56
|
+
*/
|
|
57
|
+
export interface SetupCortexBlockerV1 {
|
|
58
|
+
/** Stable machine id (e.g. HG-1) the client can key rows on. */
|
|
59
|
+
readonly id: string;
|
|
60
|
+
/** Human title shown on the blockers card. */
|
|
61
|
+
readonly title: string;
|
|
62
|
+
/** Severity: blocker | high | medium. */
|
|
63
|
+
readonly severity: "blocker" | "high" | "medium";
|
|
64
|
+
/** Lifecycle state — authored OPEN (ENC-0f-era base), computed from live state. */
|
|
65
|
+
readonly status: SetupCortexBlockerStatusV1;
|
|
66
|
+
/** Optional candidate resolution surfaced for the controller / user. */
|
|
67
|
+
readonly resolution?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The four blockers VC9A reports. Enumerates the vc2-model-prep §6 items that
|
|
72
|
+
* remain per the 2026-08-05 research. The opset re-export blocker (formerly
|
|
73
|
+
* §6 #2) is NOT listed: onnx-community exports are opset 21, so it is removed.
|
|
74
|
+
* This is the canonical BASE (all `status:"open"`); `computeSetupCortexBlockers`
|
|
75
|
+
* derives the live list from it. Flag-off consumes this array verbatim.
|
|
76
|
+
*/
|
|
77
|
+
export const SETUP_CORTEX_BLOCKERS: readonly SetupCortexBlockerV1[] = [
|
|
78
|
+
{
|
|
79
|
+
id: "HG-1",
|
|
80
|
+
title: "Five projection heads do not exist",
|
|
81
|
+
severity: "blocker",
|
|
82
|
+
status: "open",
|
|
83
|
+
resolution:
|
|
84
|
+
"Supervision transfer onto a frozen bge-small-en-v1.5 trunk (contradiction distilled from cross-encoder/nli-deberta-v3-small; dependency NLI-assisted; cache-stability deterministic; payload-routing small MLP) — VC2B training + export.",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "HG-3",
|
|
88
|
+
title: "onnxruntime-node install exceeds the 80 MiB asset budget",
|
|
89
|
+
severity: "blocker",
|
|
90
|
+
status: "open",
|
|
91
|
+
resolution:
|
|
92
|
+
"onnxruntime-node bundles ~258 MiB across all platforms. Candidate: transformers.js v4.2.0 (9.5 MiB shell, pure-Node via onnxruntime-web WASM) measured against budget + p95 gate before committing.",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "HG-4",
|
|
96
|
+
title: "No darwin-x64 binary in onnxruntime-node",
|
|
97
|
+
severity: "high",
|
|
98
|
+
status: "open",
|
|
99
|
+
resolution:
|
|
100
|
+
"Intel-Mac mode-A users demote to the WASM path (if HG-3 resolves that way) or mode B. " +
|
|
101
|
+
"darwin-x64: no native binary upstream (arm64-only); mode-B WASM per HG-4.",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: "HG-5",
|
|
105
|
+
title: "RSS margin at 512 tokens is ~0.5%",
|
|
106
|
+
severity: "medium",
|
|
107
|
+
status: "open",
|
|
108
|
+
resolution:
|
|
109
|
+
"149.2 MiB vs 150 MiB cap with run-to-run variance 119-149 MiB; considers capping mode A at 384 tokens or using the marginal-footprint accounting runtime.ts already implements.",
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
/** Look up one blocker by id; undefined when unknown (defensive). */
|
|
114
|
+
export function setupCortexBlocker(id: string): SetupCortexBlockerV1 | undefined {
|
|
115
|
+
return SETUP_CORTEX_BLOCKERS.find((b) => b.id === id);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The live blockers computed from (platform, ENC-0f QualificationV1 record,
|
|
120
|
+
* asset-manifest head-count). Pure + deterministic — no IO, no clock, no flag
|
|
121
|
+
* dependence. Rules:
|
|
122
|
+
* - HG-1 → `"closed"` when the asset manifest declares all five projection
|
|
123
|
+
* heads (`headCount === ENCODER_HEAD_ORDER.length`); otherwise stays open.
|
|
124
|
+
* - HG-3 → unchanged (genuinely open — onnxruntime-node budget unresolved).
|
|
125
|
+
* - HG-4 → stays `"open"` (the upstream binary gap is unchanged); resolution
|
|
126
|
+
* notes that ENC-0e ships the darwin demotion visibility surface.
|
|
127
|
+
* - HG-5 → derived from the qualification record: an empty record is
|
|
128
|
+
* `"superseded"` (no measurement on this device); a `failed` verdict closes
|
|
129
|
+
* it with the measured p95/RSS wording; a `qualified` verdict closes it with
|
|
130
|
+
* "measured" wording. Severity stays `"medium"` from the base row.
|
|
131
|
+
* `platform` is carried for contract symmetry with Worker B's route input; the
|
|
132
|
+
* HG rules here do not branch on it (HG-4's darwin note applies regardless).
|
|
133
|
+
*/
|
|
134
|
+
export function computeSetupCortexBlockers(input: {
|
|
135
|
+
platform: string | null;
|
|
136
|
+
qualification: QualificationV1 | null;
|
|
137
|
+
headCount: number | null;
|
|
138
|
+
}): readonly SetupCortexBlockerV1[] {
|
|
139
|
+
const { qualification, headCount } = input;
|
|
140
|
+
return SETUP_CORTEX_BLOCKERS.map((base): SetupCortexBlockerV1 => {
|
|
141
|
+
switch (base.id) {
|
|
142
|
+
case "HG-1":
|
|
143
|
+
return headCount === ENCODER_HEAD_ORDER.length
|
|
144
|
+
? { ...base, status: "closed" }
|
|
145
|
+
: base;
|
|
146
|
+
case "HG-4":
|
|
147
|
+
return {
|
|
148
|
+
...base,
|
|
149
|
+
resolution: `${base.resolution} ENC-0e shipped the darwin demotion visibility surface.`,
|
|
150
|
+
};
|
|
151
|
+
case "HG-5":
|
|
152
|
+
if (qualification === null) {
|
|
153
|
+
return {
|
|
154
|
+
...base,
|
|
155
|
+
status: "superseded",
|
|
156
|
+
resolution:
|
|
157
|
+
"No QualificationV1 record on this device — run the gate (scripts/encoder/gate-qualify.mjs) to measure.",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (qualification.verdict === "failed") {
|
|
161
|
+
return {
|
|
162
|
+
...base,
|
|
163
|
+
title: "Real-asset qualification: failed (latency + marginal-RSS over budget)",
|
|
164
|
+
status: "closed",
|
|
165
|
+
resolution:
|
|
166
|
+
`p95 ${qualification.p95Ms} ms vs ${ENCODER_LATENCY_P95_MS} ms gate, marginal RSS ${qualification.rssMib} MiB vs ${ENCODER_RSS_BUDGET_BYTES / MIB} MiB cap — mode A requires the native onnxruntime-node selection`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
...base,
|
|
171
|
+
title: "Real-asset qualification: measured",
|
|
172
|
+
status: "closed",
|
|
173
|
+
};
|
|
174
|
+
default:
|
|
175
|
+
return base;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ─── VC9B action gating ─────────────────────────────────────────────────────
|
|
181
|
+
|
|
182
|
+
/** The VC9B action kinds the drivers know how to run. */
|
|
183
|
+
export type SetupCortexActionKind = "fetch-model" | "bench" | "verify-asset";
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The static PER-ACTION CANDIDATE gate ids — this is POLICY, NOT the derived
|
|
187
|
+
* gating. fetch-model and bench ARE candidates for HG-1 (five-head training)
|
|
188
|
+
* and HG-3 (install budget); verify-asset is a pure re-read of committed assets
|
|
189
|
+
* and is NEVER gated (empty candidate list). The derived gating (below)
|
|
190
|
+
* intersects these candidates with the currently-OPEN blockers from the live
|
|
191
|
+
* computed list, so a candidate only blocks when its blocker is actually open.
|
|
192
|
+
*/
|
|
193
|
+
const ACTION_GATE_CANDIDATES: Readonly<Record<SetupCortexActionKind, readonly string[]>> = {
|
|
194
|
+
"fetch-model": ["HG-1", "HG-3"],
|
|
195
|
+
bench: ["HG-1", "HG-3"],
|
|
196
|
+
"verify-asset": [],
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Re-derived VC9B action gating from the LIVE computed blockers. An action is
|
|
201
|
+
* gated by exactly the candidate ids that are `status:"open"` AND
|
|
202
|
+
* `severity:"blocker"` in the supplied blockers. `blockers` defaults to the
|
|
203
|
+
* base `SETUP_CORTEX_BLOCKERS` (authored all-open) for backward compatibility
|
|
204
|
+
* with single-arg callers — with HG-1 closed by a computed list, fetch-model
|
|
205
|
+
* and bench surface `["HG-3"]`; verify-asset always `[]`.
|
|
206
|
+
*/
|
|
207
|
+
export function setupCortexActionBlockers(
|
|
208
|
+
action: SetupCortexActionKind,
|
|
209
|
+
blockers?: readonly SetupCortexBlockerV1[],
|
|
210
|
+
): readonly string[] {
|
|
211
|
+
const live = blockers ?? SETUP_CORTEX_BLOCKERS;
|
|
212
|
+
const openBlockerIds = new Set(
|
|
213
|
+
live.filter((b) => b.status === "open" && b.severity === "blocker").map((b) => b.id),
|
|
214
|
+
);
|
|
215
|
+
return ACTION_GATE_CANDIDATES[action].filter((id) => openBlockerIds.has(id));
|
|
216
|
+
}
|