pi-mega-compact 0.20.41 → 0.20.43
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/assets/vector-cortex/encoder-v1/manifest.json +1 -1
- package/dist/config/vector-cortex-dedup-attr.js +14 -0
- package/dist/config/vector-cortex-enc0a.js +32 -0
- package/dist/config/vector-cortex.js +3 -3
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/api-contracts/dedup-attribution.js +13 -0
- package/dist/extensions/dashboard-server/api-contracts/endpoints/registry-ext.js +7 -0
- package/dist/extensions/dashboard-server/route-dispatch.js +3 -1
- package/dist/extensions/dashboard-server/routes-dedup-attribution.js +150 -0
- package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +2 -0
- package/dist/extensions/dashboard-server/routes.js +1 -0
- package/dist/src/config/vector-cortex-dedup-attr.js +14 -0
- package/dist/src/config/vector-cortex-enc0a.js +32 -0
- package/dist/src/config/vector-cortex.js +3 -3
- package/dist/src/config.js +1 -1
- package/dist/src/vector-cortex/_acceptance-enc0a-contract.js +60 -0
- package/dist/src/vector-cortex/_acceptance-vc2a-conformance.js +90 -0
- package/dist/src/vector-cortex/_acceptance-vc2a-runtime.js +285 -0
- package/dist/src/vector-cortex/_acceptance-vc2b-conformance.js +92 -0
- package/dist/src/vector-cortex/_acceptance-vc2b-heads.js +221 -0
- package/dist/src/vector-cortex/dedup-attr/rollup.js +97 -0
- package/dist/src/vector-cortex/encoder/asset.js +3 -2
- package/dist/src/vector-cortex/encoder/decision.js +75 -0
- package/dist/src/vector-cortex/encoder/types-vc2c.js +41 -0
- package/dist/src/vector-cortex/encoder/types.js +13 -34
- package/dist/vector-cortex/_acceptance-enc0a-contract.js +60 -0
- package/dist/vector-cortex/_acceptance-vc2a-conformance.js +90 -0
- package/dist/vector-cortex/_acceptance-vc2a-runtime.js +285 -0
- package/dist/vector-cortex/_acceptance-vc2b-conformance.js +92 -0
- package/dist/vector-cortex/_acceptance-vc2b-heads.js +221 -0
- package/dist/vector-cortex/dedup-attr/rollup.js +97 -0
- package/dist/vector-cortex/encoder/asset.js +3 -2
- package/dist/vector-cortex/encoder/decision.js +75 -0
- package/dist/vector-cortex/encoder/types-vc2c.js +41 -0
- package/dist/vector-cortex/encoder/types.js +13 -34
- package/extensions/dashboard-client/dist/assets/{AreaChart-BT7YPcp7.js → AreaChart-Cn6X7epL.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-BT7YPcp7.js.map → AreaChart-Cn6X7epL.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-DceGcBUh.js → BarChart-APy1Wc7z.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-DceGcBUh.js.map → BarChart-APy1Wc7z.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-B9lCouRl.js → CacheTab-CEv_Ss9O.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-B9lCouRl.js.map → CacheTab-CEv_Ss9O.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-oqJ11jY7.js → EventsTab-8jV1Pr0C.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-oqJ11jY7.js.map → EventsTab-8jV1Pr0C.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-Dbosf2Ik.js → HealthTab-B2VgEz1j.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-Dbosf2Ik.js.map → HealthTab-B2VgEz1j.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-6TiApCVE.js → MaintenanceTab-m37AlTbg.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-6TiApCVE.js.map → MaintenanceTab-m37AlTbg.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-cBsE4mTf.js → MemoryMapTab-Co2jbqdT.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-cBsE4mTf.js.map → MemoryMapTab-Co2jbqdT.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-CX-X9hhy.js → MetricsTab-D0yV9X6D.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-CX-X9hhy.js.map → MetricsTab-D0yV9X6D.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-CpPYaTJF.js → OverviewTab-J5TjXB14.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-CpPYaTJF.js.map → OverviewTab-J5TjXB14.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-D_Ot4QbU.js → ReposTab-BadNIkWu.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-D_Ot4QbU.js.map → ReposTab-BadNIkWu.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-BUzO3iGK.js → SessionsTab-CdKShJuR.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-BUzO3iGK.js.map → SessionsTab-CdKShJuR.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SetupTab-Be4w9v4j.js → SetupTab-CPemizDx.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SetupTab-Be4w9v4j.js.map → SetupTab-CPemizDx.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Cx-g6CXH.js → TimeSavedCard-TvULibwW.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Cx-g6CXH.js.map → TimeSavedCard-TvULibwW.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-CC_7T7ad.js → TurnsTab-CglFIcYy.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-CC_7T7ad.js.map → TurnsTab-CglFIcYy.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-ZTItXSiH.js → VcStatusBadge-H2bBNhrR.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-ZTItXSiH.js.map → VcStatusBadge-H2bBNhrR.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-DgAUZ4Pg.js → VectorCortexTab-CXPv3sYQ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-DgAUZ4Pg.js.map → VectorCortexTab-CXPv3sYQ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{WikiTab-DnKupXTv.js → WikiTab-BNfN175_.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-DnKupXTv.js.map → WikiTab-BNfN175_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-CFt3e0yc.js → button-DjN7aqD2.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-CFt3e0yc.js.map → button-DjN7aqD2.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-C6ZjsHrl.js → card-DLHA5XP8.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-C6ZjsHrl.js.map → card-DLHA5XP8.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{client-extra-DdEdGTIe.js → client-extra-ZT6mIQZS.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{client-extra-DdEdGTIe.js.map → client-extra-ZT6mIQZS.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-C9_fu2hc.js → generateCategoricalChart-DAl4dRVG.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-C9_fu2hc.js.map → generateCategoricalChart-DAl4dRVG.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-DY81TY4f.js → index-H-sfROoW.js} +16 -16
- package/extensions/dashboard-client/dist/assets/index-H-sfROoW.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{switch-BOqa1d6x.js → switch-BCxvJYon.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-BOqa1d6x.js.map → switch-BCxvJYon.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-DToFaIEd.js → toggle-DviUMYeg.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-DToFaIEd.js.map → toggle-DviUMYeg.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-CZqkhU18.js → useSSE-DP2O8vHY.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-CZqkhU18.js.map → useSSE-DP2O8vHY.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-server/api-contracts/dedup-attribution.ts +69 -0
- package/extensions/dashboard-server/api-contracts/endpoints/registry-ext.ts +15 -0
- package/extensions/dashboard-server/api-contracts/index.ts +8 -0
- package/extensions/dashboard-server/route-dispatch.ts +2 -0
- package/extensions/dashboard-server/routes-dedup-attribution.ts +166 -0
- package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +12 -0
- package/extensions/dashboard-server/routes.ts +1 -0
- package/package.json +1 -1
- package/src/config/vector-cortex-dedup-attr.ts +16 -0
- package/src/config/vector-cortex-enc0a.ts +34 -0
- package/src/config/vector-cortex.ts +3 -3
- package/src/config.ts +2 -0
- package/src/vector-cortex/_acceptance-enc0a-contract.ts +71 -0
- package/src/vector-cortex/_acceptance-vc2a-conformance.ts +119 -0
- package/src/vector-cortex/_acceptance-vc2a-runtime.ts +300 -0
- package/src/vector-cortex/_acceptance-vc2b-conformance.ts +121 -0
- package/src/vector-cortex/_acceptance-vc2b-heads.ts +234 -0
- package/src/vector-cortex/dedup-attr/rollup.ts +136 -0
- package/src/vector-cortex/encoder/asset.ts +3 -2
- package/src/vector-cortex/encoder/bench-export.ts +2 -2
- package/src/vector-cortex/encoder/decision.ts +125 -0
- package/src/vector-cortex/encoder/runtime-native.ts +1 -1
- package/src/vector-cortex/encoder/runtime-wasm.ts +1 -1
- package/src/vector-cortex/encoder/types-vc2c.ts +124 -0
- package/src/vector-cortex/encoder/types.ts +18 -115
- package/extensions/dashboard-client/dist/assets/index-DY81TY4f.js.map +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/dedup-attr/rollup.ts — DEDUP-ATTR pure tier-attribution rollup.
|
|
3
|
+
*
|
|
4
|
+
* Pure function: reads an array of parsed dedup-audit events, buckets them by
|
|
5
|
+
* tier over a query window, and returns the per-tier catch shares. No I/O, no
|
|
6
|
+
* clock — the route passes `now: Date` (new Date()) at request time, so this
|
|
7
|
+
* module is deterministically reproducible and trivially testable (DEDUP-ATTR-004).
|
|
8
|
+
*
|
|
9
|
+
* Missing `similarity` is fine here: L0/L1 are hash/verify tiers and emit no
|
|
10
|
+
* score, and the rollup never consults it. Malformed lines (non-object, wrong
|
|
11
|
+
* type) are skipped silently — the route's events.log reader already guards its
|
|
12
|
+
* JSON.parse (PREVENT-001), and this layer defends against a hostile/mixed
|
|
13
|
+
* `dedup_audit` array as well.
|
|
14
|
+
*
|
|
15
|
+
* The returned shape is structurally identical to the authoritative contract in
|
|
16
|
+
* `extensions/dashboard-server/api-contracts/dedup-attribution.ts` (the existing
|
|
17
|
+
* src-mirrors-dashboard-contract pattern); src/ stays pi-agnostic and never
|
|
18
|
+
* imports dashboard types. Status here is computed from the pure signal the
|
|
19
|
+
* rollup owns (a non-empty window) — the route additionally derives the sent
|
|
20
|
+
* `status` via `deriveVcStatus` from the shared vc-status module.
|
|
21
|
+
*
|
|
22
|
+
* Guardrails: PREVENT-PI-004 (zero I/O/network), PREVENT-011 (no `any`).
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Roll up dedup-audit events over [now - windowMs, now] into per-tier shares.
|
|
26
|
+
*
|
|
27
|
+
* Only events whose ISO-8601 `ts` falls inside the window are counted; events of
|
|
28
|
+
* any other `type` (or a missing/unparseable `ts`) are skipped silently. Shares
|
|
29
|
+
* are fractions of the window's total decisions, each in [0, 1]; an empty window
|
|
30
|
+
* yields all-zero shares with `status:"awaiting_data"` — never a fabricated
|
|
31
|
+
* zero-share table presented as real.
|
|
32
|
+
*/
|
|
33
|
+
export function computeDedupTierRollup(events, windowMs, now) {
|
|
34
|
+
const winMs = windowMs > 0 ? windowMs : 24 * 60 * 60 * 1000;
|
|
35
|
+
const windowStart = now.getTime() - winMs;
|
|
36
|
+
const windowEnd = now.getTime();
|
|
37
|
+
const acc = {
|
|
38
|
+
l0: { deduped: 0, passed: 0 },
|
|
39
|
+
l1: { deduped: 0, passed: 0 },
|
|
40
|
+
l2: { deduped: 0, passed: 0 },
|
|
41
|
+
storedNew: 0,
|
|
42
|
+
};
|
|
43
|
+
let total = 0;
|
|
44
|
+
for (const ev of events) {
|
|
45
|
+
if (!ev || typeof ev !== "object")
|
|
46
|
+
continue;
|
|
47
|
+
if (ev.type !== "dedup_audit")
|
|
48
|
+
continue;
|
|
49
|
+
const ts = Date.parse(ev.ts);
|
|
50
|
+
if (Number.isNaN(ts) || ts < windowStart || ts > windowEnd)
|
|
51
|
+
continue;
|
|
52
|
+
total += 1;
|
|
53
|
+
switch (ev.tier) {
|
|
54
|
+
case "L0":
|
|
55
|
+
if (ev.status === "deduped")
|
|
56
|
+
acc.l0.deduped += 1;
|
|
57
|
+
else if (ev.status === "passed")
|
|
58
|
+
acc.l0.passed += 1;
|
|
59
|
+
break;
|
|
60
|
+
case "L1":
|
|
61
|
+
if (ev.status === "deduped")
|
|
62
|
+
acc.l1.deduped += 1;
|
|
63
|
+
else if (ev.status === "passed")
|
|
64
|
+
acc.l1.passed += 1;
|
|
65
|
+
break;
|
|
66
|
+
case "L2":
|
|
67
|
+
if (ev.status === "deduped")
|
|
68
|
+
acc.l2.deduped += 1;
|
|
69
|
+
else if (ev.status === "passed")
|
|
70
|
+
acc.l2.passed += 1;
|
|
71
|
+
break;
|
|
72
|
+
case "new":
|
|
73
|
+
acc.storedNew += 1;
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const byTier = {
|
|
80
|
+
l0: { deduped: acc.l0.deduped, passed: acc.l0.passed },
|
|
81
|
+
l1: { deduped: acc.l1.deduped, passed: acc.l1.passed },
|
|
82
|
+
l2: { deduped: acc.l2.deduped, passed: acc.l2.passed },
|
|
83
|
+
new: acc.storedNew,
|
|
84
|
+
};
|
|
85
|
+
const shareOf = (n) => (total > 0 ? n / total : 0);
|
|
86
|
+
return {
|
|
87
|
+
schema: "dedup-tier-rollup-v1",
|
|
88
|
+
windowStart: new Date(windowStart).toISOString(),
|
|
89
|
+
windowEnd: now.toISOString(),
|
|
90
|
+
totalDecisions: total,
|
|
91
|
+
byTier,
|
|
92
|
+
l0Share: shareOf(acc.l0.deduped + acc.l0.passed),
|
|
93
|
+
l1Share: shareOf(acc.l1.deduped + acc.l1.passed),
|
|
94
|
+
l2Share: shareOf(acc.l2.deduped + acc.l2.passed),
|
|
95
|
+
status: total > 0 ? "live" : "awaiting_data",
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* vector-cortex/encoder/asset.ts — VC2A asset verification (task 2).
|
|
3
3
|
*
|
|
4
4
|
* Verifies a ModelManifestV1 before any allocation: SHA-256 the ONNX and
|
|
5
|
-
* tokenizer against the manifest digests, require opset
|
|
5
|
+
* tokenizer against the manifest digests, require opset 21 (ENC-0a re-baseline),
|
|
6
|
+
* batch exactly 1 and
|
|
6
7
|
* maximum 512 tokens, and confirm the current platform is in the supported
|
|
7
8
|
* matrix. On ANY of these the caller demotes to mode B (asset-free trigram) —
|
|
8
9
|
* never a remote fetch (PREVENT-PI-004). A truncated/unreadable asset during
|
|
@@ -73,7 +74,7 @@ function isManifest(m) {
|
|
|
73
74
|
*
|
|
74
75
|
* - manifest parse/shape failure -> ENC_MANIFEST_INVALID -> mode B
|
|
75
76
|
* - unsupported platform -> ENC_PLATFORM_UNSUPPORTED -> mode B
|
|
76
|
-
* - opset !=
|
|
77
|
+
* - opset != 21 -> ENC_OPSET_INVALID -> mode B
|
|
77
78
|
* - batch != 1 -> ENC_BATCH_INVALID -> mode B
|
|
78
79
|
* - maxTokens > 512 -> ENC_TOKENS_EXCEEDED -> mode B
|
|
79
80
|
* - on-disk digest != manifest digest -> ENC_DIGEST_MISMATCH (one-byte mutation)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/encoder/decision.ts — ENC-0a backend-decision contract.
|
|
3
|
+
*
|
|
4
|
+
* The durable EncoderBackendDecisionV1 record: which ONNX runtime backend the
|
|
5
|
+
* real learned encoder ships on (transformers.js/WASM vs onnxruntime-node
|
|
6
|
+
* native), whether the 80 MiB install budget holds, the per-platform install
|
|
7
|
+
* matrix, the opset baseline (locked 21 by ENC-0a), the license verdict, and
|
|
8
|
+
* the pinned model/tokenizer sha256 digests.
|
|
9
|
+
*
|
|
10
|
+
* ENC-0a is the DECISION + MEASUREMENT sprint: this contract is what the
|
|
11
|
+
* deterministic resolver (`scripts/encoder/resolve-backend-decision.mjs`) and
|
|
12
|
+
* the durable record (`docs/vector-cortex/encoder-backend-decision.md`) both
|
|
13
|
+
* consume. ENC-0a also owns the opset flip: ENCODER_OPSET is re-baselined to 21
|
|
14
|
+
* in `types.ts` alongside the placeholder manifest (the 2026-08-05 trunk
|
|
15
|
+
* research dropped the earlier Xenova opset-17 requirement). ENC-0b asserts the
|
|
16
|
+
* staged real asset is opset 21 — no further constant change.
|
|
17
|
+
*
|
|
18
|
+
* Contract-first (ENGINEERING_PRACTICES §3). Pi-agnostic, dependency-free
|
|
19
|
+
* (PREVENT-PI-004 — local computation only, never a fetch). No `any`
|
|
20
|
+
* (PREVENT-011).
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* The normative ENC-0a budget: the 80 MiB install/asset cap (MODEL_ASSET.md
|
|
24
|
+
* §Qualification). Backend qualifies (budgetOk) iff the shipped byte-count fits.
|
|
25
|
+
*/
|
|
26
|
+
export const ENCODER_INSTALL_BUDGET_MIB = 80;
|
|
27
|
+
/** The p95 latency gate at 512 tokens / 4 threads on linux-x64 (ms). */
|
|
28
|
+
export const ENCODER_DECISION_P95_MS = 40;
|
|
29
|
+
/**
|
|
30
|
+
* buildDecision — assemble a valid, platform-complete EncoderBackendDecisionV1.
|
|
31
|
+
*
|
|
32
|
+
* Pure helper consumed by the acceptance aggregator (and any TS consumer of the
|
|
33
|
+
* decision). Every EncoderPlatform must resolve to a row, and the passed
|
|
34
|
+
* per-platform rows must be complete (no row omitted) — a partial matrix is a
|
|
35
|
+
* contract violation, not a valid decision. All fields are passed in; this is a
|
|
36
|
+
* structural constructor, not a rules engine (the resolver owns the decision
|
|
37
|
+
* rule).
|
|
38
|
+
*/
|
|
39
|
+
export function buildDecision(input) {
|
|
40
|
+
const { platformMatrix } = input;
|
|
41
|
+
const platforms = [
|
|
42
|
+
"linux-x64",
|
|
43
|
+
"linux-arm64",
|
|
44
|
+
"darwin-x64",
|
|
45
|
+
"darwin-arm64",
|
|
46
|
+
"win32-x64",
|
|
47
|
+
];
|
|
48
|
+
for (const p of platforms) {
|
|
49
|
+
if (!Object.prototype.hasOwnProperty.call(platformMatrix, p)) {
|
|
50
|
+
throw new Error(`platform matrix is incomplete: missing row for ${p}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
schema: "encoder-backend-decision-v1",
|
|
55
|
+
backend: input.backend,
|
|
56
|
+
budgetOk: input.budgetOk,
|
|
57
|
+
opset: 21,
|
|
58
|
+
platformMatrix,
|
|
59
|
+
license: { spdx: "MIT", redistribution: true },
|
|
60
|
+
artifacts: {
|
|
61
|
+
model: {
|
|
62
|
+
path: input.modelPath,
|
|
63
|
+
bytes: input.modelBytes,
|
|
64
|
+
sha256: input.modelSha256,
|
|
65
|
+
},
|
|
66
|
+
tokenizer: {
|
|
67
|
+
path: input.tokenizerPath,
|
|
68
|
+
bytes: input.tokenizerBytes,
|
|
69
|
+
sha256: input.tokenizerSha256,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
p95Ms: input.p95Ms,
|
|
73
|
+
blockedBy: input.blockedBy,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/encoder/types-vc2c.ts — VC2C qualification + calibration
|
|
3
|
+
* contracts (QualifiedEncoderV1 / CalibrationV1 / EVALUATION_THRESHOLDS).
|
|
4
|
+
*
|
|
5
|
+
* Extracted from types.ts (delegate-shell split) when types.ts crossed the
|
|
6
|
+
* 300-line soft limit. types.ts re-exports everything here; consumers import
|
|
7
|
+
* from types.ts unchanged.
|
|
8
|
+
*
|
|
9
|
+
* Pi-agnostic and dependency-free (PREVENT-PI-004). No `any` (PREVENT-011).
|
|
10
|
+
*/
|
|
11
|
+
/** Normative per-head + asset qualification thresholds (MODEL_ASSET §qualification
|
|
12
|
+
* + EVALUATION.md §metrics). These are the constants `select.ts` evaluates the
|
|
13
|
+
* candidate's held-out metrics against (task 3 atomic check). */
|
|
14
|
+
export const EVALUATION_THRESHOLDS = {
|
|
15
|
+
semantic: { spearman: 0.75, recallAt10: 0.9 },
|
|
16
|
+
dependency: { precision: 0.97, recall: 0.95 },
|
|
17
|
+
contradiction: { precision: 0.98, recall: 0.9, ece: 0.05 },
|
|
18
|
+
cacheStability: { precision: 0.999, recall: 0.9 },
|
|
19
|
+
payloadRouting: { macroF1: 0.97, exactAnchorRecall: 1.0 },
|
|
20
|
+
reconstruction: { dependencyClosureRecall: 1.0 },
|
|
21
|
+
asset: { maxTokens: 512, maxLatencyP95Ms: 40, maxRssDeltaMib: 150 },
|
|
22
|
+
};
|
|
23
|
+
/** VC2C-specific qualification failure codes (returned, never thrown). */
|
|
24
|
+
export const ENC_QUALIFICATION_FAIL = {
|
|
25
|
+
/** The qualification manifest hash does not match the calibration that was fit
|
|
26
|
+
* (corrupt qualification manifest after calibration before selection). */
|
|
27
|
+
DIGEST_MISMATCH: "ENC_QUALIFICATION_DIGEST_MISMATCH",
|
|
28
|
+
/** One or more per-head EVALUATION thresholds failed (demotes all of A). */
|
|
29
|
+
THRESHOLD_FAILED: "ENC_QUALIFICATION_THRESHOLD_FAILED",
|
|
30
|
+
/** An asset-field qualification check (asset/latency/RSS) failed. */
|
|
31
|
+
ASSET_FAILED: "ENC_QUALIFICATION_ASSET_FAILED",
|
|
32
|
+
/** Calibration was attempted using held-out labels (fit prohibition). */
|
|
33
|
+
HELD_OUT_IN_FIT: "ENC_QUALIFICATION_HELD_OUT_IN_FIT",
|
|
34
|
+
};
|
|
35
|
+
/** The 4 registered VC2C conformance IDs (task 1: "register ENC-017..020"). */
|
|
36
|
+
export const ENC2C_IDS = [
|
|
37
|
+
"ENC-017",
|
|
38
|
+
"ENC-018",
|
|
39
|
+
"ENC-019",
|
|
40
|
+
"ENC-020",
|
|
41
|
+
];
|
|
@@ -24,8 +24,13 @@ export const ENCODER_SUPPORTED_PLATFORMS = [
|
|
|
24
24
|
"darwin-arm64",
|
|
25
25
|
"win32-x64",
|
|
26
26
|
];
|
|
27
|
-
/** ONNX opset required by the normative v1 target
|
|
28
|
-
|
|
27
|
+
/** ONNX opset required by the normative v1 target. ENC-0a re-baselines from 17
|
|
28
|
+
* to 21: the committed placeholder asset (assets/vector-cortex/encoder-v1/)
|
|
29
|
+
* declares opset 21 in its manifest (the 2026-08-05 BAAI/bge-small-en-v1.5
|
|
30
|
+
* upstream export is opset 21; the earlier Xenova opset-17 requirement was
|
|
31
|
+
* dropped). The locked decision is recorded in
|
|
32
|
+
* docs/vector-cortex/encoder-backend-decision.md. */
|
|
33
|
+
export const ENCODER_OPSET = 21;
|
|
29
34
|
/** Batch must be exactly 1 (single-request inference). */
|
|
30
35
|
export const ENCODER_BATCH = 1;
|
|
31
36
|
/** Maximum accepted token count (WordPiece, deterministic truncation). */
|
|
@@ -45,7 +50,7 @@ export const ENCODER_LATENCY_P95_MS = 40;
|
|
|
45
50
|
export const ENCODER_SEMANTIC_WIDTH = 384;
|
|
46
51
|
/** Exact VC2A failure codes (returned, never thrown across the boundary). */
|
|
47
52
|
export const ENC_FAIL = {
|
|
48
|
-
/** opset !=
|
|
53
|
+
/** opset != 21 (ENC-0a re-baseline applied; placeholder manifest updated alongside). */
|
|
49
54
|
OPSET_INVALID: "ENC_OPSET_INVALID",
|
|
50
55
|
/** batch != 1. */
|
|
51
56
|
BATCH_INVALID: "ENC_BATCH_INVALID",
|
|
@@ -136,34 +141,8 @@ export const ENC2B_IDS = [
|
|
|
136
141
|
"ENC-015",
|
|
137
142
|
"ENC-016",
|
|
138
143
|
];
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
dependency: { precision: 0.97, recall: 0.95 },
|
|
145
|
-
contradiction: { precision: 0.98, recall: 0.9, ece: 0.05 },
|
|
146
|
-
cacheStability: { precision: 0.999, recall: 0.9 },
|
|
147
|
-
payloadRouting: { macroF1: 0.97, exactAnchorRecall: 1.0 },
|
|
148
|
-
reconstruction: { dependencyClosureRecall: 1.0 },
|
|
149
|
-
asset: { maxTokens: 512, maxLatencyP95Ms: 40, maxRssDeltaMib: 150 },
|
|
150
|
-
};
|
|
151
|
-
/** VC2C-specific qualification failure codes (returned, never thrown). */
|
|
152
|
-
export const ENC_QUALIFICATION_FAIL = {
|
|
153
|
-
/** The qualification manifest hash does not match the calibration that was fit
|
|
154
|
-
* (corrupt qualification manifest after calibration before selection). */
|
|
155
|
-
DIGEST_MISMATCH: "ENC_QUALIFICATION_DIGEST_MISMATCH",
|
|
156
|
-
/** One or more per-head EVALUATION thresholds failed (demotes all of A). */
|
|
157
|
-
THRESHOLD_FAILED: "ENC_QUALIFICATION_THRESHOLD_FAILED",
|
|
158
|
-
/** An asset-field qualification check (asset/latency/RSS) failed. */
|
|
159
|
-
ASSET_FAILED: "ENC_QUALIFICATION_ASSET_FAILED",
|
|
160
|
-
/** Calibration was attempted using held-out labels (fit prohibition). */
|
|
161
|
-
HELD_OUT_IN_FIT: "ENC_QUALIFICATION_HELD_OUT_IN_FIT",
|
|
162
|
-
};
|
|
163
|
-
/** The 4 registered VC2C conformance IDs (task 1: "register ENC-017..020"). */
|
|
164
|
-
export const ENC2C_IDS = [
|
|
165
|
-
"ENC-017",
|
|
166
|
-
"ENC-018",
|
|
167
|
-
"ENC-019",
|
|
168
|
-
"ENC-020",
|
|
169
|
-
];
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
// VC2C — encoder qualification + calibration: extracted to types-vc2c.ts
|
|
146
|
+
// (delegate-shell split, soft-limit compliance). Re-exported here.
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
export { EVALUATION_THRESHOLDS, ENC_QUALIFICATION_FAIL, ENC2C_IDS, } from "./types-vc2c.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
|
+
}
|