@remnic/bench 9.7.0 → 9.7.2

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/index.d.ts CHANGED
@@ -3214,6 +3214,26 @@ interface DiagnoseLoComoProfileDeltaOptions {
3214
3214
  declare function diagnoseLoComoProfileDelta(options: DiagnoseLoComoProfileDeltaOptions): LoComoProfileDeltaReport;
3215
3215
  declare function renderLoComoProfileDeltaMarkdown(report: LoComoProfileDeltaReport): string;
3216
3216
 
3217
+ declare const LOCOMO_TASK_SELECTION_VERSION: 1;
3218
+ type LoCoMoTaskSelector = {
3219
+ taskIds: readonly string[];
3220
+ sampleSize?: never;
3221
+ seed?: never;
3222
+ } | {
3223
+ taskIds?: never;
3224
+ sampleSize: number;
3225
+ seed: number;
3226
+ };
3227
+ interface LoCoMoTaskSelectionManifest {
3228
+ algorithm: "explicit-task-ids" | "sha256-seeded-sample";
3229
+ version: typeof LOCOMO_TASK_SELECTION_VERSION;
3230
+ seed?: number;
3231
+ candidateCount: number;
3232
+ selectedCount: number;
3233
+ selectedTaskIds: string[];
3234
+ selectedTaskIdsSha256: string;
3235
+ }
3236
+
3217
3237
  declare const LOCOMO_FULL_TASK_COUNT = 1986;
3218
3238
  declare const LOCOMO_RECALL_EXCERPT_CHARS = 240;
3219
3239
  declare const LOCOMO_RECALL_DIFF_LINE_LIMIT = 20;
@@ -3289,6 +3309,7 @@ interface LoComoRecallResultProvenance {
3289
3309
  judgeModel: string;
3290
3310
  seeds: number[];
3291
3311
  taskPayloadSha256: string;
3312
+ taskSelection?: LoCoMoTaskSelectionManifest;
3292
3313
  }
3293
3314
  interface LoComoRecallDeltaReport {
3294
3315
  schemaVersion: 1;
@@ -3377,24 +3398,8 @@ declare const LOCOMO_RETRIEVAL_TRACE_SCHEMA_VERSION: 1;
3377
3398
  declare const LOCOMO_RETRIEVAL_TRACE_SELECTION_VERSION: 1;
3378
3399
  declare const LOCOMO_RETRIEVAL_TRACE_BUDGET_VERSION: 1;
3379
3400
  type LoCoMoRetrievalTraceProfile = "baseline" | "real";
3380
- type LoCoMoRetrievalTraceSelector = {
3381
- taskIds: readonly string[];
3382
- sampleSize?: never;
3383
- seed?: never;
3384
- } | {
3385
- taskIds?: never;
3386
- sampleSize: number;
3387
- seed: number;
3388
- };
3389
- interface LoCoMoRetrievalTraceSelectionManifest {
3390
- algorithm: "explicit-task-ids" | "sha256-seeded-sample";
3391
- version: typeof LOCOMO_RETRIEVAL_TRACE_SELECTION_VERSION;
3392
- seed?: number;
3393
- candidateCount: number;
3394
- selectedCount: number;
3395
- selectedTaskIds: string[];
3396
- selectedTaskIdsSha256: string;
3397
- }
3401
+ type LoCoMoRetrievalTraceSelector = LoCoMoTaskSelector;
3402
+ type LoCoMoRetrievalTraceSelectionManifest = LoCoMoTaskSelectionManifest;
3398
3403
  interface LoCoMoRetrievalTraceCoreCaptureReceipt {
3399
3404
  budget: BenchRecallTraceCoreCapture["budget"];
3400
3405
  filters: BenchRecallTraceCoreCapture["filters"];
package/dist/index.js CHANGED
@@ -21025,6 +21025,163 @@ async function loadDataset5(mode, datasetDir, limit) {
21025
21025
  return loaded.items;
21026
21026
  }
21027
21027
 
21028
+ // src/benchmarks/published/locomo/task-selection.ts
21029
+ var LOCOMO_TASK_SELECTION_VERSION = 1;
21030
+ function parseLoCoMoTaskSelectionManifest(value, label = "LoCoMo task selection") {
21031
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
21032
+ throw new Error(`${label} must be an object.`);
21033
+ }
21034
+ const record = value;
21035
+ const allowedKeys = /* @__PURE__ */ new Set([
21036
+ "algorithm",
21037
+ "version",
21038
+ "seed",
21039
+ "candidateCount",
21040
+ "selectedCount",
21041
+ "selectedTaskIds",
21042
+ "selectedTaskIdsSha256"
21043
+ ]);
21044
+ const unknownKey = Object.keys(record).find((key) => !allowedKeys.has(key));
21045
+ if (unknownKey !== void 0) {
21046
+ throw new Error(`${label} contains unknown field ${unknownKey}.`);
21047
+ }
21048
+ if (record.algorithm !== "explicit-task-ids" && record.algorithm !== "sha256-seeded-sample") {
21049
+ throw new Error(`${label}.algorithm is invalid.`);
21050
+ }
21051
+ if (record.version !== LOCOMO_TASK_SELECTION_VERSION) {
21052
+ throw new Error(
21053
+ `${label}.version must be ${LOCOMO_TASK_SELECTION_VERSION}.`
21054
+ );
21055
+ }
21056
+ const candidateCountRaw = record.candidateCount;
21057
+ const selectedCountRaw = record.selectedCount;
21058
+ if (typeof candidateCountRaw !== "number" || !Number.isSafeInteger(candidateCountRaw) || candidateCountRaw <= 0) {
21059
+ throw new Error(`${label}.candidateCount must be a positive safe integer.`);
21060
+ }
21061
+ if (typeof selectedCountRaw !== "number" || !Number.isSafeInteger(selectedCountRaw) || selectedCountRaw <= 0) {
21062
+ throw new Error(`${label}.selectedCount must be a positive safe integer.`);
21063
+ }
21064
+ const candidateCount = candidateCountRaw;
21065
+ const selectedCount = selectedCountRaw;
21066
+ if (selectedCount > candidateCount) {
21067
+ throw new Error(`${label}.selectedCount cannot exceed candidateCount.`);
21068
+ }
21069
+ if (!Array.isArray(record.selectedTaskIds) || record.selectedTaskIds.some(
21070
+ (taskId) => typeof taskId !== "string" || taskId.length === 0
21071
+ )) {
21072
+ throw new Error(`${label}.selectedTaskIds must contain non-empty strings.`);
21073
+ }
21074
+ const selectedTaskIds = [...record.selectedTaskIds];
21075
+ if (new Set(selectedTaskIds).size !== selectedTaskIds.length) {
21076
+ throw new Error(`${label}.selectedTaskIds must not contain duplicates.`);
21077
+ }
21078
+ if (selectedTaskIds.length !== selectedCount) {
21079
+ throw new Error(
21080
+ `${label}.selectedCount must equal selectedTaskIds.length.`
21081
+ );
21082
+ }
21083
+ const selectedTaskIdsSha256 = record.selectedTaskIdsSha256;
21084
+ if (typeof selectedTaskIdsSha256 !== "string" || !/^[0-9a-f]{64}$/u.test(selectedTaskIdsSha256) || selectedTaskIdsSha256 !== hashCanonicalJson(selectedTaskIds)) {
21085
+ throw new Error(`${label}.selectedTaskIdsSha256 does not match selectedTaskIds.`);
21086
+ }
21087
+ const seed = record.seed;
21088
+ if (record.algorithm === "explicit-task-ids") {
21089
+ if (seed !== void 0) {
21090
+ throw new Error(`${label}.seed is invalid for explicit task ids.`);
21091
+ }
21092
+ } else if (!Number.isSafeInteger(seed) || seed < 0) {
21093
+ throw new Error(`${label}.seed must be a non-negative safe integer.`);
21094
+ }
21095
+ return {
21096
+ algorithm: record.algorithm,
21097
+ version: LOCOMO_TASK_SELECTION_VERSION,
21098
+ ...seed === void 0 ? {} : { seed },
21099
+ candidateCount,
21100
+ selectedCount,
21101
+ selectedTaskIds,
21102
+ selectedTaskIdsSha256
21103
+ };
21104
+ }
21105
+ function selectLoCoMoTasks(tasks, selector) {
21106
+ const allIds = tasks.map((task) => task.taskId);
21107
+ if (allIds.some((taskId) => typeof taskId !== "string" || taskId.length === 0)) {
21108
+ throw new Error("LoCoMo candidate task ids must be non-empty strings.");
21109
+ }
21110
+ if (new Set(allIds).size !== allIds.length) {
21111
+ throw new Error("LoCoMo candidate task ids must be unique.");
21112
+ }
21113
+ const hasTaskIds = "taskIds" in selector && selector.taskIds !== void 0;
21114
+ const hasSampleSize = "sampleSize" in selector && selector.sampleSize !== void 0;
21115
+ if (Number(hasTaskIds) + Number(hasSampleSize) !== 1) {
21116
+ throw new Error("Choose exactly one LoCoMo task selector.");
21117
+ }
21118
+ if (hasTaskIds && "seed" in selector && selector.seed !== void 0) {
21119
+ throw new Error("LoCoMo task-selection seed is valid only for seeded sampling.");
21120
+ }
21121
+ let selected;
21122
+ let algorithm;
21123
+ let seed;
21124
+ if (hasTaskIds) {
21125
+ algorithm = "explicit-task-ids";
21126
+ const requestedTaskIds = selector.taskIds;
21127
+ if (!requestedTaskIds) {
21128
+ throw new Error("LoCoMo explicit task ids are required.");
21129
+ }
21130
+ const requested = [...requestedTaskIds];
21131
+ if (requested.length === 0) {
21132
+ throw new Error("LoCoMo explicit task selection cannot be empty.");
21133
+ }
21134
+ if (requested.some(
21135
+ (taskId) => typeof taskId !== "string" || taskId.length === 0
21136
+ )) {
21137
+ throw new Error("LoCoMo explicit task ids must be non-empty strings.");
21138
+ }
21139
+ if (new Set(requested).size !== requested.length) {
21140
+ throw new Error("LoCoMo explicit task ids must not contain duplicates.");
21141
+ }
21142
+ const available = new Set(allIds);
21143
+ const unknown = requested.find((taskId) => !available.has(taskId));
21144
+ if (unknown !== void 0) {
21145
+ throw new Error(`Unknown LoCoMo task id: ${unknown}`);
21146
+ }
21147
+ const requestedSet = new Set(requested);
21148
+ selected = allIds.filter((taskId) => requestedSet.has(taskId));
21149
+ } else {
21150
+ algorithm = "sha256-seeded-sample";
21151
+ const sampleSize = selector.sampleSize;
21152
+ seed = selector.seed;
21153
+ if (sampleSize === void 0 || seed === void 0) {
21154
+ throw new Error("LoCoMo seeded sampling requires sampleSize and seed.");
21155
+ }
21156
+ if (!Number.isSafeInteger(sampleSize) || sampleSize <= 0 || sampleSize > allIds.length) {
21157
+ throw new Error(
21158
+ `LoCoMo task-selection sampleSize must be an integer from 1 to ${allIds.length}.`
21159
+ );
21160
+ }
21161
+ if (!Number.isSafeInteger(seed) || seed < 0) {
21162
+ throw new Error(
21163
+ "LoCoMo task-selection seed must be a non-negative safe integer."
21164
+ );
21165
+ }
21166
+ const sampled = [...allIds].sort((left, right) => {
21167
+ const leftHash = hashString(`${seed}\0${left}`);
21168
+ const rightHash = hashString(`${seed}\0${right}`);
21169
+ return leftHash.localeCompare(rightHash) || left.localeCompare(right);
21170
+ }).slice(0, sampleSize);
21171
+ const sampledSet = new Set(sampled);
21172
+ selected = allIds.filter((taskId) => sampledSet.has(taskId));
21173
+ }
21174
+ return {
21175
+ algorithm,
21176
+ version: LOCOMO_TASK_SELECTION_VERSION,
21177
+ ...seed === void 0 ? {} : { seed },
21178
+ candidateCount: allIds.length,
21179
+ selectedCount: selected.length,
21180
+ selectedTaskIds: selected,
21181
+ selectedTaskIdsSha256: hashCanonicalJson(selected)
21182
+ };
21183
+ }
21184
+
21028
21185
  // src/benchmarks/published/locomo/runner.ts
21029
21186
  var CATEGORY_NAMES = {
21030
21187
  1: "single_hop",
@@ -21265,30 +21422,47 @@ var locomoDefinition = {
21265
21422
  }
21266
21423
  };
21267
21424
  async function runLoCoMoBenchmark(options) {
21425
+ const rawBenchmarkOptions = options.benchmarkOptions ?? {};
21426
+ if (rawBenchmarkOptions.taskSelection !== void 0) {
21427
+ throw new Error(
21428
+ "LoCoMo benchmarkOptions.taskSelection is runner-owned and cannot be supplied by callers."
21429
+ );
21430
+ }
21431
+ const taskSelector = resolvePinnedTaskSelector(
21432
+ rawBenchmarkOptions.taskSelector
21433
+ );
21434
+ if (taskSelector !== void 0) {
21435
+ assertTaskSelectorCompatibility(options, rawBenchmarkOptions);
21436
+ }
21268
21437
  const loaded = await loadLoCoMoDataset(
21269
21438
  options.mode,
21270
21439
  options.datasetDir,
21271
21440
  options.limit
21272
21441
  );
21273
21442
  const conversations = loaded.items;
21274
- const trialLimit = resolveTrialLimit(options.benchmarkOptions?.trialLimit);
21443
+ const trialLimit = resolveTrialLimit(rawBenchmarkOptions.trialLimit);
21275
21444
  const multiHopRecallComposition = resolveLoCoMoBooleanOption(
21276
- options.benchmarkOptions?.multiHopRecallComposition,
21445
+ rawBenchmarkOptions.multiHopRecallComposition,
21277
21446
  "multiHopRecallComposition",
21278
21447
  true
21279
21448
  );
21280
- const plans = applyTrialLimit(
21281
- conversations.map(
21282
- (conversation) => buildLoCoMoPlan(conversation, multiHopRecallComposition)
21283
- ),
21284
- trialLimit
21449
+ const allPlans = conversations.map(
21450
+ (conversation) => buildLoCoMoPlan(conversation, multiHopRecallComposition)
21285
21451
  );
21452
+ const selected = taskSelector === void 0 ? void 0 : applyTaskSelection(allPlans, taskSelector);
21453
+ const plans = selected === void 0 ? applyTrialLimit(allPlans, trialLimit) : selected.plans;
21454
+ const {
21455
+ taskSelector: _taskSelector,
21456
+ taskSelection: _taskSelection,
21457
+ ...callerBenchmarkOptions
21458
+ } = rawBenchmarkOptions;
21286
21459
  const benchmarkOptions = {
21287
- ...options.benchmarkOptions ?? {},
21460
+ ...callerBenchmarkOptions,
21288
21461
  ...trialLimit === void 0 ? {} : { trialLimit },
21462
+ ...selected === void 0 ? {} : { taskSelection: selected.manifest },
21289
21463
  multiHopRecallComposition
21290
21464
  };
21291
- return runPublishedHarness({
21465
+ const result = await runPublishedHarness({
21292
21466
  options: { ...options, benchmarkOptions },
21293
21467
  metricsSpec: {
21294
21468
  metrics: ["f1", "contains_answer", "rouge_l", "llm_judge"]
@@ -21296,6 +21470,87 @@ async function runLoCoMoBenchmark(options) {
21296
21470
  plans,
21297
21471
  totalCount: plans.reduce((sum, plan) => sum + plan.trials.length, 0)
21298
21472
  });
21473
+ result.meta.datasetHash = loaded.sha256;
21474
+ return result;
21475
+ }
21476
+ function resolvePinnedTaskSelector(raw) {
21477
+ if (raw === void 0) {
21478
+ return void 0;
21479
+ }
21480
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
21481
+ throw new Error("LoCoMo benchmarkOptions.taskSelector must be an object.");
21482
+ }
21483
+ const record = raw;
21484
+ const allowedKeys = /* @__PURE__ */ new Set([
21485
+ "kind",
21486
+ "taskIds",
21487
+ "expectedSelectedTaskIdsSha256"
21488
+ ]);
21489
+ const unknownKey = Object.keys(record).find((key) => !allowedKeys.has(key));
21490
+ if (unknownKey !== void 0) {
21491
+ throw new Error(
21492
+ `LoCoMo benchmarkOptions.taskSelector contains unknown field ${unknownKey}.`
21493
+ );
21494
+ }
21495
+ if (record.kind !== "explicit-task-ids") {
21496
+ throw new Error(
21497
+ 'LoCoMo benchmarkOptions.taskSelector.kind must be "explicit-task-ids".'
21498
+ );
21499
+ }
21500
+ if (!Array.isArray(record.taskIds) || record.taskIds.some(
21501
+ (taskId) => typeof taskId !== "string" || taskId.length === 0
21502
+ )) {
21503
+ throw new Error(
21504
+ "LoCoMo benchmarkOptions.taskSelector.taskIds must contain non-empty strings."
21505
+ );
21506
+ }
21507
+ if (typeof record.expectedSelectedTaskIdsSha256 !== "string" || !/^[0-9a-f]{64}$/u.test(record.expectedSelectedTaskIdsSha256)) {
21508
+ throw new Error(
21509
+ "LoCoMo benchmarkOptions.taskSelector.expectedSelectedTaskIdsSha256 must be 64 lowercase hexadecimal characters."
21510
+ );
21511
+ }
21512
+ return {
21513
+ kind: "explicit-task-ids",
21514
+ taskIds: [...record.taskIds],
21515
+ expectedSelectedTaskIdsSha256: record.expectedSelectedTaskIdsSha256
21516
+ };
21517
+ }
21518
+ function assertTaskSelectorCompatibility(options, benchmarkOptions) {
21519
+ if (options.mode !== "full") {
21520
+ throw new Error("LoCoMo task selection requires full benchmark mode.");
21521
+ }
21522
+ if (options.limit !== void 0) {
21523
+ throw new Error("LoCoMo task selection cannot be combined with limit.");
21524
+ }
21525
+ if (benchmarkOptions.trialLimit !== void 0) {
21526
+ throw new Error(
21527
+ "LoCoMo task selection cannot be combined with benchmarkOptions.trialLimit."
21528
+ );
21529
+ }
21530
+ if (benchmarkOptions.trialConcurrency !== void 0 && Number(benchmarkOptions.trialConcurrency) !== 1) {
21531
+ throw new Error(
21532
+ "LoCoMo task selection requires benchmarkOptions.trialConcurrency to be 1."
21533
+ );
21534
+ }
21535
+ }
21536
+ function applyTaskSelection(plans, selector) {
21537
+ const candidateTrials = plans.flatMap((plan) => plan.trials);
21538
+ const manifest = selectLoCoMoTasks(candidateTrials, {
21539
+ taskIds: selector.taskIds
21540
+ });
21541
+ if (manifest.selectedTaskIdsSha256 !== selector.expectedSelectedTaskIdsSha256) {
21542
+ throw new Error(
21543
+ "LoCoMo selected task-id hash does not match benchmarkOptions.taskSelector.expectedSelectedTaskIdsSha256."
21544
+ );
21545
+ }
21546
+ const selectedTaskIds = new Set(manifest.selectedTaskIds);
21547
+ const selectedPlans = plans.flatMap((plan) => {
21548
+ const trials = plan.trials.filter(
21549
+ (trial) => selectedTaskIds.has(trial.taskId)
21550
+ );
21551
+ return trials.length === 0 ? [] : [{ ...plan, trials }];
21552
+ });
21553
+ return { plans: selectedPlans, manifest };
21299
21554
  }
21300
21555
  function resolveLoCoMoBooleanOption(raw, optionName, defaultValue) {
21301
21556
  if (raw === void 0) {
@@ -38786,9 +39041,14 @@ function diagnoseLoComoRecallDelta(options) {
38786
39041
  const maxRegressions = parseNonNegativeInteger(options.maxRegressions ?? 20, "maxRegressions");
38787
39042
  assertEvidenceEnvelope(options.baseline, "baseline");
38788
39043
  assertEvidenceEnvelope(options.real, "real");
38789
- assertCompleteResult(options.baseline.result, "baseline");
38790
- assertCompleteResult(options.real.result, "real");
38791
- assertComparableResults(options.baseline.result, options.real.result);
39044
+ const baselineSelection = assertCompleteResult(options.baseline.result, "baseline");
39045
+ const realSelection = assertCompleteResult(options.real.result, "real");
39046
+ assertComparableResults(
39047
+ options.baseline.result,
39048
+ options.real.result,
39049
+ baselineSelection,
39050
+ realSelection
39051
+ );
38792
39052
  const joined = joinTasks2(options.baseline.result, options.real.result);
38793
39053
  assertMetricSets(joined, primaryMetric2);
38794
39054
  verifyAggregateMeans(options.baseline.result, joined, "baseline");
@@ -38807,8 +39067,8 @@ function diagnoseLoComoRecallDelta(options) {
38807
39067
  schemaVersion: 1,
38808
39068
  benchmarkId: "locomo",
38809
39069
  comparison: {
38810
- baseline: buildProvenance(options.baseline, "baseline", joined, "baseline"),
38811
- real: buildProvenance(options.real, "real", joined, "real")
39070
+ baseline: buildProvenance(options.baseline, "baseline", joined, "baseline", baselineSelection),
39071
+ real: buildProvenance(options.real, "real", joined, "real", realSelection)
38812
39072
  },
38813
39073
  taskCount: joined.length,
38814
39074
  primaryMetric: primaryMetric2,
@@ -38904,11 +39164,30 @@ function assertCompleteResult(result, label) {
38904
39164
  if (limit !== void 0 || trialLimit !== void 0) {
38905
39165
  throw new Error(`${label} result is limited and cannot be used as complete evidence.`);
38906
39166
  }
38907
- if (result.results.tasks.length !== LOCOMO_FULL_TASK_COUNT) {
39167
+ const benchmarkOptions = result.config.benchmarkOptions;
39168
+ const hasTaskSelection = benchmarkOptions !== null && typeof benchmarkOptions === "object" && Object.prototype.hasOwnProperty.call(benchmarkOptions, "taskSelection");
39169
+ const taskSelection = hasTaskSelection ? parseLoCoMoTaskSelectionManifest(
39170
+ benchmarkOptions.taskSelection,
39171
+ `${label} result taskSelection`
39172
+ ) : void 0;
39173
+ if (!taskSelection && result.results.tasks.length !== LOCOMO_FULL_TASK_COUNT) {
38908
39174
  throw new Error(
38909
39175
  `${label} result must contain exactly ${LOCOMO_FULL_TASK_COUNT} tasks; got ${result.results.tasks.length}.`
38910
39176
  );
38911
39177
  }
39178
+ if (taskSelection) {
39179
+ if (taskSelection.candidateCount !== LOCOMO_FULL_TASK_COUNT) {
39180
+ throw new Error(
39181
+ `${label} result taskSelection.candidateCount must be ${LOCOMO_FULL_TASK_COUNT}.`
39182
+ );
39183
+ }
39184
+ const resultTaskIds = result.results.tasks.map((task) => task.taskId);
39185
+ if (stableJson(resultTaskIds) !== stableJson(taskSelection.selectedTaskIds)) {
39186
+ throw new Error(
39187
+ `${label} result task ids must exactly match taskSelection.selectedTaskIds in canonical order.`
39188
+ );
39189
+ }
39190
+ }
38912
39191
  for (const task of result.results.tasks) {
38913
39192
  const details = asRecord(task.details);
38914
39193
  const failure = details?.benchmarkFailure;
@@ -38917,14 +39196,20 @@ function assertCompleteResult(result, label) {
38917
39196
  throw new Error(`${label} result contains failed task ${JSON.stringify(task.taskId)}.`);
38918
39197
  }
38919
39198
  }
39199
+ return taskSelection;
38920
39200
  }
38921
- function assertComparableResults(baseline, real) {
39201
+ function assertComparableResults(baseline, real, baselineSelection, realSelection) {
38922
39202
  if (baseline.config.runtimeProfile !== "baseline") {
38923
39203
  throw new Error('baseline result runtimeProfile must be "baseline".');
38924
39204
  }
38925
39205
  if (real.config.runtimeProfile !== "real") {
38926
39206
  throw new Error('real result runtimeProfile must be "real".');
38927
39207
  }
39208
+ if (stableJson(baselineSelection ?? null) !== stableJson(realSelection ?? null)) {
39209
+ throw new Error(
39210
+ `Results are not comparable: config.benchmarkOptions.taskSelection differs (${stableJson(baselineSelection ?? null)} vs ${stableJson(realSelection ?? null)}).`
39211
+ );
39212
+ }
38928
39213
  const checks = [
38929
39214
  ["meta.version", baseline.meta.version, real.meta.version],
38930
39215
  ["meta.remnicVersion", baseline.meta.remnicVersion, real.meta.remnicVersion],
@@ -39063,7 +39348,7 @@ function buildRegression(task, metric, excerptChars, maxDiffLines) {
39063
39348
  introducedLines: lineDelta(introduced, maxDiffLines, excerptChars)
39064
39349
  };
39065
39350
  }
39066
- function buildProvenance(evidence, profile, joined, side) {
39351
+ function buildProvenance(evidence, profile, joined, side, taskSelection) {
39067
39352
  const system = requireProvider(evidence.result.config.systemProvider, profile, "system");
39068
39353
  const judge = requireProvider(evidence.result.config.judgeProvider, profile, "judge");
39069
39354
  const payload = joined.map((task) => ({
@@ -39084,7 +39369,8 @@ function buildProvenance(evidence, profile, joined, side) {
39084
39369
  judgeProvider: judge.provider,
39085
39370
  judgeModel: judge.model,
39086
39371
  seeds: [...evidence.result.meta.seeds],
39087
- taskPayloadSha256: sha2562(stableJson(payload))
39372
+ taskPayloadSha256: sha2562(stableJson(payload)),
39373
+ ...taskSelection ? { taskSelection } : {}
39088
39374
  };
39089
39375
  }
39090
39376
  function summarizeMetric(tasks, metric) {
@@ -40082,7 +40368,7 @@ function isDigest(value) {
40082
40368
 
40083
40369
  // src/benchmarks/published/locomo/retrieval-trace-runner.ts
40084
40370
  var LOCOMO_RETRIEVAL_TRACE_SCHEMA_VERSION = 1;
40085
- var LOCOMO_RETRIEVAL_TRACE_SELECTION_VERSION = 1;
40371
+ var LOCOMO_RETRIEVAL_TRACE_SELECTION_VERSION = LOCOMO_TASK_SELECTION_VERSION;
40086
40372
  var LOCOMO_RETRIEVAL_TRACE_BUDGET_VERSION = 1;
40087
40373
  async function preflightLoCoMoRetrievalTraceCapture(options) {
40088
40374
  assertCaptureOptions(options);
@@ -40209,69 +40495,7 @@ async function captureLoCoMoRetrievalTrace(options) {
40209
40495
  };
40210
40496
  }
40211
40497
  function selectLoCoMoRetrievalTraceTasks(tasks, selector) {
40212
- const allIds = tasks.map((task) => task.taskId);
40213
- if (new Set(allIds).size !== allIds.length) {
40214
- throw new Error("LoCoMo retrieval trace task ids must be unique.");
40215
- }
40216
- let selected;
40217
- let algorithm;
40218
- let seed;
40219
- const hasTaskIds = "taskIds" in selector && selector.taskIds !== void 0;
40220
- const hasSampleSize = "sampleSize" in selector && selector.sampleSize !== void 0;
40221
- if (Number(hasTaskIds) + Number(hasSampleSize) !== 1) {
40222
- throw new Error("Choose exactly one LoCoMo retrieval trace selector.");
40223
- }
40224
- if (hasTaskIds && "seed" in selector && selector.seed !== void 0) {
40225
- throw new Error("LoCoMo retrieval trace seed is valid only for seeded sampling.");
40226
- }
40227
- if (hasTaskIds) {
40228
- algorithm = "explicit-task-ids";
40229
- const requestedTaskIds = selector.taskIds;
40230
- if (!requestedTaskIds) throw new Error("LoCoMo explicit task ids are required.");
40231
- const requested = [...requestedTaskIds];
40232
- if (requested.length === 0) {
40233
- throw new Error("LoCoMo retrieval trace explicit task selection cannot be empty.");
40234
- }
40235
- if (new Set(requested).size !== requested.length) {
40236
- throw new Error("LoCoMo retrieval trace explicit task ids must not contain duplicates.");
40237
- }
40238
- const available = new Set(allIds);
40239
- const unknown = requested.filter((taskId) => !available.has(taskId));
40240
- if (unknown.length > 0) {
40241
- throw new Error(`Unknown LoCoMo retrieval trace task id: ${unknown[0]}`);
40242
- }
40243
- const requestedSet = new Set(requested);
40244
- selected = allIds.filter((taskId) => requestedSet.has(taskId));
40245
- } else {
40246
- algorithm = "sha256-seeded-sample";
40247
- const sampleSize = selector.sampleSize;
40248
- seed = selector.seed;
40249
- if (sampleSize === void 0 || seed === void 0) {
40250
- throw new Error("LoCoMo seeded sampling requires sampleSize and seed.");
40251
- }
40252
- if (!Number.isSafeInteger(sampleSize) || sampleSize <= 0 || sampleSize > allIds.length) {
40253
- throw new Error(`LoCoMo retrieval trace sampleSize must be an integer from 1 to ${allIds.length}.`);
40254
- }
40255
- if (!Number.isSafeInteger(seed) || seed < 0) {
40256
- throw new Error("LoCoMo retrieval trace seed must be a non-negative safe integer.");
40257
- }
40258
- const sampled = [...allIds].sort((left, right) => {
40259
- const leftHash = hashString(`${seed}\0${left}`);
40260
- const rightHash = hashString(`${seed}\0${right}`);
40261
- return leftHash.localeCompare(rightHash) || left.localeCompare(right);
40262
- }).slice(0, sampleSize);
40263
- const sampledSet = new Set(sampled);
40264
- selected = allIds.filter((taskId) => sampledSet.has(taskId));
40265
- }
40266
- return {
40267
- algorithm,
40268
- version: LOCOMO_RETRIEVAL_TRACE_SELECTION_VERSION,
40269
- ...seed === void 0 ? {} : { seed },
40270
- candidateCount: allIds.length,
40271
- selectedCount: selected.length,
40272
- selectedTaskIds: selected,
40273
- selectedTaskIdsSha256: hashCanonicalJson(selected)
40274
- };
40498
+ return selectLoCoMoTasks(tasks, selector);
40275
40499
  }
40276
40500
  function serializeLoCoMoRetrievalTraceReceipt(receipt) {
40277
40501
  return `${canonicalJsonStringify(receipt, 2)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remnic/bench",
3
- "version": "9.7.0",
3
+ "version": "9.7.2",
4
4
  "description": "Retrieval latency ladder benchmarks + CI regression gates for @remnic/core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,8 +39,8 @@
39
39
  "hyparquet": "^1.25.7",
40
40
  "yaml": "^2.4.2",
41
41
  "zod": "^3.24.0",
42
- "@remnic/coding-graph": "^9.7.0",
43
- "@remnic/core": "^9.7.0"
42
+ "@remnic/coding-graph": "^9.7.2",
43
+ "@remnic/core": "^9.7.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsup": "^8.5.1",