pi-mega-compact 0.18.0 → 0.18.1

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.
@@ -163,3 +163,113 @@ export const ENC_IDS: readonly string[] = [
163
163
  "ENC-007",
164
164
  "ENC-008",
165
165
  ];
166
+
167
+ // ---------------------------------------------------------------------------
168
+ // VC2B — multi-head encoder (VectorSetV1 / HeadCalibrationDraft).
169
+ // ---------------------------------------------------------------------------
170
+
171
+ /** The five independent projection heads in STABLE order (MODEL_ASSET
172
+ * §decision record; VC2B task 2 "stable order"). The array order is the
173
+ * normative ordering consumed by consumers: semantic, dependency,
174
+ * contradiction, cache-stability, payload-routing. */
175
+ export const ENCODER_HEAD_ORDER = [
176
+ "semantic",
177
+ "dependency",
178
+ "contradiction",
179
+ "cacheStability",
180
+ "payloadRouting",
181
+ ] as const;
182
+
183
+ /** Five head names (stable, matching ENCODER_HEAD_ORDER). */
184
+ export type EncoderHeadName = (typeof ENCODER_HEAD_ORDER)[number];
185
+
186
+ /** The ordered per-head output dimensions: semantic 384, dependency 128,
187
+ * contradiction 128, cacheStability 64, payloadRouting 32 (VC2B task 2). */
188
+ export const ENCODER_HEAD_DIMS: Readonly<Record<EncoderHeadName, number>> = {
189
+ semantic: 384,
190
+ dependency: 128,
191
+ contradiction: 128,
192
+ cacheStability: 64,
193
+ payloadRouting: 32,
194
+ };
195
+
196
+ /** Ordered dimension list matching ENCODER_HEAD_ORDER (384/128/128/64/32). */
197
+ export const ENCODER_HEAD_DIM_ORDER: readonly number[] = ENCODER_HEAD_ORDER.map(
198
+ (h) => ENCODER_HEAD_DIMS[h],
199
+ );
200
+
201
+ /**
202
+ * Weighted training losses per head (MODEL_ASSET §data/losses/calibration):
203
+ * semantic .35, dependency .20, contradiction .20, cache .15, payload .10.
204
+ * These are normative (VC2B task 3: "losses exactly .35/.20/.20/.15/.10").
205
+ */
206
+ export const ENCODER_HEAD_LOSS_WEIGHTS: Readonly<Record<EncoderHeadName, number>> = {
207
+ semantic: 0.35,
208
+ dependency: 0.2,
209
+ contradiction: 0.2,
210
+ cacheStability: 0.15,
211
+ payloadRouting: 0.1,
212
+ };
213
+
214
+ /** Sum of the five loss weights must be exactly 1.0 (asserted in tests). */
215
+ export const ENCODER_HEAD_LOSS_SUM = 1.0;
216
+
217
+ /** Deterministic seed shared by Python/NumPy training and ONNX export (VC2B
218
+ * task 3: "seed ... at 1729"). */
219
+ export const ENCODER_SEED = 1729;
220
+
221
+ /**
222
+ * A single produced per-head vector. `head` names the head (stable order),
223
+ * `dim` is that head's declared dimension, `values` is the L2-normalized
224
+ * Float32Array (all-zero when the raw projection had zero norm — VC2B task 2).
225
+ */
226
+ export interface HeadVector {
227
+ readonly head: EncoderHeadName;
228
+ readonly dim: number;
229
+ readonly values: Float32Array;
230
+ }
231
+
232
+ /**
233
+ * VectorSetV1 — the produced multi-head encoded vectors for one input slice,
234
+ * in STABLE order (semantic → payloadRouting). This is the VC2B-owned contract
235
+ * handed to VC3A ("VC3A receives qualified VectorSet or explicit B/C mode").
236
+ */
237
+ export interface VectorSetV1 {
238
+ readonly schema: "vector-set-v1";
239
+ readonly inputTokens: readonly number[];
240
+ readonly heads: readonly HeadVector[];
241
+ /** True when every head was L2-normalized (or all-zero on zero norm). */
242
+ readonly normalized: boolean;
243
+ }
244
+
245
+ /**
246
+ * HeadCalibrationDraft — the VC2B-owned calibration draft produced BEFORE
247
+ * training/export logic (task 1). Calibration is FITTED on the calibration
248
+ * split only in VC2C (CalibrationV1); this draft records the frozen per-head
249
+ * losses, seed, dimension order, and the corpus/split digests that training
250
+ * must reproduce (task 3).
251
+ */
252
+ export interface HeadCalibrationDraft {
253
+ readonly schema: "head-calibration-draft-v1";
254
+ readonly headOrder: readonly EncoderHeadName[];
255
+ readonly dims: Readonly<Record<EncoderHeadName, number>>;
256
+ readonly losses: Readonly<Record<EncoderHeadName, number>>;
257
+ readonly seed: number;
258
+ /** SHA-256 of the training corpus manifest (task 3, persisted). */
259
+ readonly corpusDigest: string;
260
+ /** SHA-256 of the split assignment (train/calibration/test) by
261
+ * repository+session group (EVALUATION.md §corpus). */
262
+ readonly splitDigest: string;
263
+ }
264
+
265
+ /** The 16 registered VC2B conformance IDs (task 1: "register ENC-009..016"). */
266
+ export const ENC2B_IDS: readonly string[] = [
267
+ "ENC-009",
268
+ "ENC-010",
269
+ "ENC-011",
270
+ "ENC-012",
271
+ "ENC-013",
272
+ "ENC-014",
273
+ "ENC-015",
274
+ "ENC-016",
275
+ ];