@remnic/bench 9.69.39 → 9.69.41
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.
|
@@ -2635,6 +2635,586 @@ ${renderProvenance(result, provenance)}
|
|
|
2635
2635
|
`;
|
|
2636
2636
|
}
|
|
2637
2637
|
|
|
2638
|
+
// src/provider-config.ts
|
|
2639
|
+
var BUILT_IN_PROVIDERS = [
|
|
2640
|
+
"openai",
|
|
2641
|
+
"anthropic",
|
|
2642
|
+
"ollama",
|
|
2643
|
+
"litellm",
|
|
2644
|
+
"local-llm",
|
|
2645
|
+
"codex-cli",
|
|
2646
|
+
"claude-cli"
|
|
2647
|
+
];
|
|
2648
|
+
var BENCH_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
|
|
2649
|
+
function quotedList(values) {
|
|
2650
|
+
const quoted = values.map((value) => `"${value}"`);
|
|
2651
|
+
return quoted.length <= 1 ? quoted.join("") : `${quoted.slice(0, -1).join(", ")}, or ${quoted[quoted.length - 1]}`;
|
|
2652
|
+
}
|
|
2653
|
+
var PROVIDER_ENUM_LIST = quotedList(BUILT_IN_PROVIDERS);
|
|
2654
|
+
var REASONING_EFFORT_LIST = quotedList(BENCH_REASONING_EFFORTS);
|
|
2655
|
+
var PROVIDER_CONFIG_FIELD_MARKERS = {
|
|
2656
|
+
provider: true,
|
|
2657
|
+
model: true,
|
|
2658
|
+
rubricVersion: true,
|
|
2659
|
+
baseUrl: true,
|
|
2660
|
+
apiKey: true,
|
|
2661
|
+
retryOptions: true,
|
|
2662
|
+
providerRequestTimeoutMs: true,
|
|
2663
|
+
disableThinking: true,
|
|
2664
|
+
reasoningEffort: true,
|
|
2665
|
+
responderContextBudgetChars: true,
|
|
2666
|
+
responderPromptBudgetChars: true,
|
|
2667
|
+
temperature: true,
|
|
2668
|
+
seed: true
|
|
2669
|
+
};
|
|
2670
|
+
var PROVIDER_CONFIG_VALIDATED_FIELDS = Object.keys(PROVIDER_CONFIG_FIELD_MARKERS);
|
|
2671
|
+
function isPositiveInteger(value) {
|
|
2672
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
2673
|
+
}
|
|
2674
|
+
function isNonNegativeFinite2(value) {
|
|
2675
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
2676
|
+
}
|
|
2677
|
+
function isNonNegativeInteger(value) {
|
|
2678
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
2679
|
+
}
|
|
2680
|
+
function checkOptional(container, key, accept, reason) {
|
|
2681
|
+
if (!(key in container)) {
|
|
2682
|
+
return null;
|
|
2683
|
+
}
|
|
2684
|
+
return accept(container[key]) ? null : { fieldPath: key, reason };
|
|
2685
|
+
}
|
|
2686
|
+
function firstIssue(...issues) {
|
|
2687
|
+
for (const issue of issues) {
|
|
2688
|
+
if (issue !== null) {
|
|
2689
|
+
return issue;
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
return null;
|
|
2693
|
+
}
|
|
2694
|
+
function validateProviderConfigShape(value) {
|
|
2695
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
2696
|
+
return { fieldPath: "", reason: "must be a provider config ({ provider, model })" };
|
|
2697
|
+
}
|
|
2698
|
+
const config = value;
|
|
2699
|
+
if (!BUILT_IN_PROVIDERS.includes(config.provider)) {
|
|
2700
|
+
return { fieldPath: "provider", reason: `must be one of ${PROVIDER_ENUM_LIST}` };
|
|
2701
|
+
}
|
|
2702
|
+
if (typeof config.model !== "string") {
|
|
2703
|
+
return { fieldPath: "model", reason: "must be a string" };
|
|
2704
|
+
}
|
|
2705
|
+
const rootIssue = firstIssue(
|
|
2706
|
+
checkOptional(config, "rubricVersion", (v) => typeof v === "string", "must be a string when present"),
|
|
2707
|
+
checkOptional(config, "baseUrl", (v) => typeof v === "string", "must be a string when present"),
|
|
2708
|
+
checkOptional(config, "apiKey", (v) => typeof v === "string", "must be a string when present"),
|
|
2709
|
+
checkOptional(config, "providerRequestTimeoutMs", isPositiveInteger, "must be a positive integer when present"),
|
|
2710
|
+
checkOptional(config, "disableThinking", (v) => typeof v === "boolean", "must be a boolean when present"),
|
|
2711
|
+
checkOptional(
|
|
2712
|
+
config,
|
|
2713
|
+
"reasoningEffort",
|
|
2714
|
+
(v) => BENCH_REASONING_EFFORTS.includes(v),
|
|
2715
|
+
`must be one of ${REASONING_EFFORT_LIST} when present`
|
|
2716
|
+
),
|
|
2717
|
+
checkOptional(config, "responderContextBudgetChars", isPositiveInteger, "must be a positive integer when present"),
|
|
2718
|
+
checkOptional(config, "responderPromptBudgetChars", isPositiveInteger, "must be a positive integer when present"),
|
|
2719
|
+
checkOptional(config, "temperature", isNonNegativeFinite2, "must be a finite non-negative number when present"),
|
|
2720
|
+
checkOptional(config, "seed", isNonNegativeInteger, "must be a non-negative integer when present")
|
|
2721
|
+
);
|
|
2722
|
+
if (rootIssue) {
|
|
2723
|
+
return rootIssue;
|
|
2724
|
+
}
|
|
2725
|
+
if (!("retryOptions" in config)) {
|
|
2726
|
+
return null;
|
|
2727
|
+
}
|
|
2728
|
+
const retry = config.retryOptions;
|
|
2729
|
+
if (typeof retry !== "object" || retry === null || Array.isArray(retry)) {
|
|
2730
|
+
return { fieldPath: "retryOptions", reason: "must be an object when present" };
|
|
2731
|
+
}
|
|
2732
|
+
const retryOptions = retry;
|
|
2733
|
+
const retryIssue = firstIssue(
|
|
2734
|
+
checkOptional(retryOptions, "maxAttempts", isPositiveInteger, "must be a positive integer when present"),
|
|
2735
|
+
checkOptional(retryOptions, "baseBackoffMs", isNonNegativeFinite2, "must be a finite non-negative number when present"),
|
|
2736
|
+
checkOptional(retryOptions, "timeoutMs", isNonNegativeFinite2, "must be a finite non-negative number when present"),
|
|
2737
|
+
checkOptional(retryOptions, "retryOnTimeout", (v) => typeof v === "boolean", "must be a boolean when present"),
|
|
2738
|
+
checkOptional(retryOptions, "max429WaitMs", isNonNegativeFinite2, "must be a finite non-negative number when present")
|
|
2739
|
+
);
|
|
2740
|
+
return retryIssue ? { fieldPath: `retryOptions.${retryIssue.fieldPath}`, reason: retryIssue.reason } : null;
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
// src/legacy-artifact.ts
|
|
2744
|
+
var LEGACY_ARTIFACT_SHAPE_VERSION = 1;
|
|
2745
|
+
function isRecord2(value) {
|
|
2746
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2747
|
+
}
|
|
2748
|
+
function isFiniteNumber(value) {
|
|
2749
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
2750
|
+
}
|
|
2751
|
+
var ArtifactRejected = class extends Error {
|
|
2752
|
+
constructor(reason) {
|
|
2753
|
+
super(reason);
|
|
2754
|
+
this.reason = reason;
|
|
2755
|
+
}
|
|
2756
|
+
reason;
|
|
2757
|
+
};
|
|
2758
|
+
function reject(reason) {
|
|
2759
|
+
throw new ArtifactRejected(reason);
|
|
2760
|
+
}
|
|
2761
|
+
function optionalString(where, container, key) {
|
|
2762
|
+
if (!(key in container)) {
|
|
2763
|
+
return void 0;
|
|
2764
|
+
}
|
|
2765
|
+
if (typeof container[key] !== "string") {
|
|
2766
|
+
reject(`${where} must be a string when present`);
|
|
2767
|
+
}
|
|
2768
|
+
return container[key];
|
|
2769
|
+
}
|
|
2770
|
+
function optionalFiniteNumber(where, container, key) {
|
|
2771
|
+
if (!(key in container)) {
|
|
2772
|
+
return void 0;
|
|
2773
|
+
}
|
|
2774
|
+
if (!isFiniteNumber(container[key])) {
|
|
2775
|
+
reject(`${where} must be a finite number when present`);
|
|
2776
|
+
}
|
|
2777
|
+
return container[key];
|
|
2778
|
+
}
|
|
2779
|
+
function optionalNonNegativeInteger(where, container, key) {
|
|
2780
|
+
if (!(key in container)) {
|
|
2781
|
+
return void 0;
|
|
2782
|
+
}
|
|
2783
|
+
const value = container[key];
|
|
2784
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
|
|
2785
|
+
reject(`${where} must be a non-negative integer when present`);
|
|
2786
|
+
}
|
|
2787
|
+
return value;
|
|
2788
|
+
}
|
|
2789
|
+
function isDeclaredMultiSample(legacy) {
|
|
2790
|
+
if (!isRecord2(legacy.meta)) {
|
|
2791
|
+
return false;
|
|
2792
|
+
}
|
|
2793
|
+
const runCount = legacy.meta.runCount;
|
|
2794
|
+
if (typeof runCount === "number" && Number.isFinite(runCount) && runCount > 1) {
|
|
2795
|
+
return true;
|
|
2796
|
+
}
|
|
2797
|
+
return Array.isArray(legacy.meta.seeds) && legacy.meta.seeds.length > 1;
|
|
2798
|
+
}
|
|
2799
|
+
function optionalMode(where, container) {
|
|
2800
|
+
if (!("mode" in container)) {
|
|
2801
|
+
return void 0;
|
|
2802
|
+
}
|
|
2803
|
+
if (container.mode !== "quick" && container.mode !== "full") {
|
|
2804
|
+
reject(`${where} must be "quick" or "full" when present`);
|
|
2805
|
+
}
|
|
2806
|
+
return container.mode;
|
|
2807
|
+
}
|
|
2808
|
+
function optionalTier(where, container) {
|
|
2809
|
+
if (!("benchmarkTier" in container)) {
|
|
2810
|
+
return void 0;
|
|
2811
|
+
}
|
|
2812
|
+
const value = container.benchmarkTier;
|
|
2813
|
+
if (value !== "published" && value !== "remnic" && value !== "custom") {
|
|
2814
|
+
reject(`${where} must be "published", "remnic", or "custom" when present`);
|
|
2815
|
+
}
|
|
2816
|
+
return value;
|
|
2817
|
+
}
|
|
2818
|
+
function optionalProviderConfig(where, value) {
|
|
2819
|
+
if (value === void 0 || value === null) {
|
|
2820
|
+
return null;
|
|
2821
|
+
}
|
|
2822
|
+
const issue = validateProviderConfigShape(value);
|
|
2823
|
+
if (issue) {
|
|
2824
|
+
reject(
|
|
2825
|
+
issue.fieldPath ? `${where}.${issue.fieldPath} ${issue.reason}` : `${where} ${issue.reason} or null when present`
|
|
2826
|
+
);
|
|
2827
|
+
}
|
|
2828
|
+
return value;
|
|
2829
|
+
}
|
|
2830
|
+
function optionalSeeds(where, value) {
|
|
2831
|
+
if (value === void 0) {
|
|
2832
|
+
return void 0;
|
|
2833
|
+
}
|
|
2834
|
+
if (!Array.isArray(value) || !value.every((item) => typeof item === "number" && Number.isInteger(item))) {
|
|
2835
|
+
reject(`${where} must be an array of integers when present`);
|
|
2836
|
+
}
|
|
2837
|
+
return value;
|
|
2838
|
+
}
|
|
2839
|
+
function isBenchRuntimeProfile(value) {
|
|
2840
|
+
return value === "baseline" || value === "real" || value === "openclaw-chain" || value === "local-lab";
|
|
2841
|
+
}
|
|
2842
|
+
function normalizeMetricAggregate(where, raw, taskCount, declaredMultiSample) {
|
|
2843
|
+
if (isRecord2(raw) && isFiniteNumber(raw.mean) && isFiniteNumber(raw.median) && isFiniteNumber(raw.stdDev) && isFiniteNumber(raw.min) && isFiniteNumber(raw.max)) {
|
|
2844
|
+
return raw;
|
|
2845
|
+
}
|
|
2846
|
+
if (!isRecord2(raw)) {
|
|
2847
|
+
reject(`${where} must be an object with a finite mean number`);
|
|
2848
|
+
}
|
|
2849
|
+
for (const field of ["mean", "median", "stdDev", "min", "max"]) {
|
|
2850
|
+
if (field in raw && !isFiniteNumber(raw[field])) {
|
|
2851
|
+
reject(`${where}.${field} must be a finite number when present`);
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
if (!isFiniteNumber(raw.mean)) {
|
|
2855
|
+
reject(`${where} must be an object with a finite mean number`);
|
|
2856
|
+
}
|
|
2857
|
+
const rawMedian = isFiniteNumber(raw.median) ? raw.median : void 0;
|
|
2858
|
+
const rawStdDev = isFiniteNumber(raw.stdDev) ? raw.stdDev : void 0;
|
|
2859
|
+
const rawMin = isFiniteNumber(raw.min) ? raw.min : void 0;
|
|
2860
|
+
const rawMax = isFiniteNumber(raw.max) ? raw.max : void 0;
|
|
2861
|
+
if (rawMedian !== void 0 || rawStdDev !== void 0 || rawMin !== void 0 || rawMax !== void 0) {
|
|
2862
|
+
reject(
|
|
2863
|
+
`${where} missing required fields (median, stdDev, min, max); partial aggregates cannot mix persisted and synthesized values`
|
|
2864
|
+
);
|
|
2865
|
+
}
|
|
2866
|
+
if (taskCount === 1 && !declaredMultiSample) {
|
|
2867
|
+
return {
|
|
2868
|
+
mean: raw.mean,
|
|
2869
|
+
median: raw.mean,
|
|
2870
|
+
stdDev: 0,
|
|
2871
|
+
min: raw.mean,
|
|
2872
|
+
max: raw.mean
|
|
2873
|
+
};
|
|
2874
|
+
}
|
|
2875
|
+
if (declaredMultiSample) {
|
|
2876
|
+
reject(
|
|
2877
|
+
`${where} missing required multi-sample fields (median, stdDev, min, max) for declared multi-run artifact`
|
|
2878
|
+
);
|
|
2879
|
+
}
|
|
2880
|
+
if (taskCount === 0) {
|
|
2881
|
+
reject(
|
|
2882
|
+
`${where} missing required fields (median, stdDev, min, max); mean-only upgrade requires exactly one recognized task`
|
|
2883
|
+
);
|
|
2884
|
+
}
|
|
2885
|
+
reject(
|
|
2886
|
+
`${where} missing required multi-sample fields (median, stdDev, min, max) for multi-task run (taskCount=${taskCount})`
|
|
2887
|
+
);
|
|
2888
|
+
}
|
|
2889
|
+
function upgradeMeta(legacy, recognizedTaskCount) {
|
|
2890
|
+
if (!isRecord2(legacy.meta)) {
|
|
2891
|
+
reject("meta with non-empty id, benchmark, and timestamp strings is required");
|
|
2892
|
+
}
|
|
2893
|
+
const meta = legacy.meta;
|
|
2894
|
+
for (const key of ["id", "benchmark", "timestamp"]) {
|
|
2895
|
+
const value = meta[key];
|
|
2896
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
2897
|
+
reject(`meta.${key} must be a non-empty string`);
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
if (!Number.isFinite(Date.parse(meta.timestamp))) {
|
|
2901
|
+
reject("meta.timestamp must be a parseable date");
|
|
2902
|
+
}
|
|
2903
|
+
const taskCount = recognizedTaskCount;
|
|
2904
|
+
const upgraded = {
|
|
2905
|
+
id: meta.id,
|
|
2906
|
+
benchmark: meta.benchmark,
|
|
2907
|
+
timestamp: meta.timestamp,
|
|
2908
|
+
// Old UI display default for an absent tier.
|
|
2909
|
+
benchmarkTier: optionalTier("meta.benchmarkTier", meta) ?? "custom",
|
|
2910
|
+
// Provenance is not knowable from a legacy artifact: recognition
|
|
2911
|
+
// rejects any payload with a present provenance key, so the only
|
|
2912
|
+
// honest value here is the explicit "unknown" marker.
|
|
2913
|
+
version: "unknown",
|
|
2914
|
+
remnicVersion: "unknown",
|
|
2915
|
+
gitSha: "unknown",
|
|
2916
|
+
// Old UI display default for an absent mode.
|
|
2917
|
+
mode: optionalMode("meta.mode", meta) ?? "quick",
|
|
2918
|
+
// Old UI fell back to the task count when runCount was absent.
|
|
2919
|
+
runCount: optionalNonNegativeInteger("meta.runCount", meta, "runCount") ?? taskCount,
|
|
2920
|
+
seeds: optionalSeeds("meta.seeds", meta.seeds) ?? []
|
|
2921
|
+
};
|
|
2922
|
+
const metaExtras = upgraded;
|
|
2923
|
+
for (const key of [
|
|
2924
|
+
"runId",
|
|
2925
|
+
"gitDirty",
|
|
2926
|
+
"gitDirtyEntryCount",
|
|
2927
|
+
"splitType",
|
|
2928
|
+
"qrelsSealedHash",
|
|
2929
|
+
"judgePromptHash",
|
|
2930
|
+
"datasetHash",
|
|
2931
|
+
"canaryScore",
|
|
2932
|
+
"canaryFloor",
|
|
2933
|
+
"status",
|
|
2934
|
+
"failureReason"
|
|
2935
|
+
]) {
|
|
2936
|
+
if (!(key in meta)) {
|
|
2937
|
+
continue;
|
|
2938
|
+
}
|
|
2939
|
+
if (key === "canaryFloor") {
|
|
2940
|
+
const floorVal = optionalFiniteNumber("meta.canaryFloor", meta, "canaryFloor");
|
|
2941
|
+
if (floorVal !== void 0) {
|
|
2942
|
+
if (floorVal < 0) {
|
|
2943
|
+
reject("meta.canaryFloor must be a non-negative number when present");
|
|
2944
|
+
}
|
|
2945
|
+
metaExtras[key] = floorVal;
|
|
2946
|
+
}
|
|
2947
|
+
continue;
|
|
2948
|
+
}
|
|
2949
|
+
if (key === "canaryScore" || key === "gitDirtyEntryCount") {
|
|
2950
|
+
const numeric = optionalFiniteNumber(`meta.${key}`, meta, key);
|
|
2951
|
+
if (numeric !== void 0) {
|
|
2952
|
+
metaExtras[key] = numeric;
|
|
2953
|
+
}
|
|
2954
|
+
continue;
|
|
2955
|
+
}
|
|
2956
|
+
if (key === "runId" || key === "qrelsSealedHash" || key === "judgePromptHash" || key === "datasetHash" || key === "failureReason") {
|
|
2957
|
+
const text = optionalString(`meta.${key}`, meta, key);
|
|
2958
|
+
if (text !== void 0) {
|
|
2959
|
+
metaExtras[key] = text;
|
|
2960
|
+
}
|
|
2961
|
+
continue;
|
|
2962
|
+
}
|
|
2963
|
+
if (key === "gitDirty") {
|
|
2964
|
+
if (typeof meta.gitDirty !== "boolean") {
|
|
2965
|
+
reject("meta.gitDirty must be a boolean when present");
|
|
2966
|
+
}
|
|
2967
|
+
metaExtras.gitDirty = meta.gitDirty;
|
|
2968
|
+
continue;
|
|
2969
|
+
}
|
|
2970
|
+
if (key === "status") {
|
|
2971
|
+
if (meta.status !== "complete" && meta.status !== "partial") {
|
|
2972
|
+
reject('meta.status must be "complete" or "partial" when present');
|
|
2973
|
+
}
|
|
2974
|
+
metaExtras.status = meta.status;
|
|
2975
|
+
continue;
|
|
2976
|
+
}
|
|
2977
|
+
if (meta.splitType !== "public" && meta.splitType !== "holdout") {
|
|
2978
|
+
reject('meta.splitType must be "public" or "holdout" when present');
|
|
2979
|
+
}
|
|
2980
|
+
metaExtras.splitType = meta.splitType;
|
|
2981
|
+
}
|
|
2982
|
+
return upgraded;
|
|
2983
|
+
}
|
|
2984
|
+
function upgradeConfig(legacy) {
|
|
2985
|
+
if (!("config" in legacy)) {
|
|
2986
|
+
return {
|
|
2987
|
+
systemProvider: null,
|
|
2988
|
+
judgeProvider: null,
|
|
2989
|
+
adapterMode: "unknown",
|
|
2990
|
+
remnicConfig: {}
|
|
2991
|
+
};
|
|
2992
|
+
}
|
|
2993
|
+
if (!isRecord2(legacy.config)) {
|
|
2994
|
+
reject("config must be an object when present");
|
|
2995
|
+
}
|
|
2996
|
+
const config = legacy.config;
|
|
2997
|
+
const upgraded = {
|
|
2998
|
+
systemProvider: optionalProviderConfig("config.systemProvider", config.systemProvider),
|
|
2999
|
+
judgeProvider: optionalProviderConfig("config.judgeProvider", config.judgeProvider),
|
|
3000
|
+
// Old UI display default for an absent adapter mode.
|
|
3001
|
+
adapterMode: optionalString("config.adapterMode", config, "adapterMode") ?? "unknown",
|
|
3002
|
+
remnicConfig: {}
|
|
3003
|
+
};
|
|
3004
|
+
if ("remnicConfig" in config) {
|
|
3005
|
+
if (!isRecord2(config.remnicConfig)) {
|
|
3006
|
+
reject("config.remnicConfig must be an object when present");
|
|
3007
|
+
}
|
|
3008
|
+
upgraded.remnicConfig = config.remnicConfig;
|
|
3009
|
+
}
|
|
3010
|
+
if ("internalProvider" in config && config.internalProvider !== void 0) {
|
|
3011
|
+
upgraded.internalProvider = optionalProviderConfig("config.internalProvider", config.internalProvider);
|
|
3012
|
+
}
|
|
3013
|
+
if ("runtimeProfile" in config && config.runtimeProfile !== void 0) {
|
|
3014
|
+
const profile = config.runtimeProfile;
|
|
3015
|
+
if (profile !== null && !isBenchRuntimeProfile(profile)) {
|
|
3016
|
+
reject(
|
|
3017
|
+
'config.runtimeProfile must be "baseline", "real", "openclaw-chain", "local-lab", or null when present'
|
|
3018
|
+
);
|
|
3019
|
+
}
|
|
3020
|
+
upgraded.runtimeProfile = profile;
|
|
3021
|
+
}
|
|
3022
|
+
if ("benchmarkOptions" in config && config.benchmarkOptions !== void 0) {
|
|
3023
|
+
if (!isRecord2(config.benchmarkOptions)) {
|
|
3024
|
+
reject("config.benchmarkOptions must be an object when present");
|
|
3025
|
+
}
|
|
3026
|
+
upgraded.benchmarkOptions = config.benchmarkOptions;
|
|
3027
|
+
}
|
|
3028
|
+
return upgraded;
|
|
3029
|
+
}
|
|
3030
|
+
function upgradeCost(legacy) {
|
|
3031
|
+
if (!("cost" in legacy)) {
|
|
3032
|
+
return {
|
|
3033
|
+
totalTokens: 0,
|
|
3034
|
+
inputTokens: 0,
|
|
3035
|
+
outputTokens: 0,
|
|
3036
|
+
estimatedCostUsd: 0,
|
|
3037
|
+
totalLatencyMs: 0,
|
|
3038
|
+
meanQueryLatencyMs: 0
|
|
3039
|
+
};
|
|
3040
|
+
}
|
|
3041
|
+
if (!isRecord2(legacy.cost)) {
|
|
3042
|
+
reject("cost must be an object when present");
|
|
3043
|
+
}
|
|
3044
|
+
const cost = legacy.cost;
|
|
3045
|
+
const upgraded = {
|
|
3046
|
+
totalTokens: optionalFiniteNumber("cost.totalTokens", cost, "totalTokens") ?? 0,
|
|
3047
|
+
inputTokens: optionalFiniteNumber("cost.inputTokens", cost, "inputTokens") ?? 0,
|
|
3048
|
+
outputTokens: optionalFiniteNumber("cost.outputTokens", cost, "outputTokens") ?? 0,
|
|
3049
|
+
estimatedCostUsd: optionalFiniteNumber("cost.estimatedCostUsd", cost, "estimatedCostUsd") ?? 0,
|
|
3050
|
+
totalLatencyMs: optionalFiniteNumber("cost.totalLatencyMs", cost, "totalLatencyMs") ?? 0,
|
|
3051
|
+
meanQueryLatencyMs: optionalFiniteNumber("cost.meanQueryLatencyMs", cost, "meanQueryLatencyMs") ?? 0
|
|
3052
|
+
};
|
|
3053
|
+
if ("judgeModelCalls" in cost) {
|
|
3054
|
+
upgraded.judgeModelCalls = optionalFiniteNumber("cost.judgeModelCalls", cost, "judgeModelCalls");
|
|
3055
|
+
}
|
|
3056
|
+
return upgraded;
|
|
3057
|
+
}
|
|
3058
|
+
function upgradeTask(where, task) {
|
|
3059
|
+
if (!isRecord2(task) || typeof task.taskId !== "string" || task.taskId.trim().length === 0) {
|
|
3060
|
+
return null;
|
|
3061
|
+
}
|
|
3062
|
+
if ("scores" in task && (!isRecord2(task.scores) || !Object.values(task.scores).every(isFiniteNumber))) {
|
|
3063
|
+
reject(`${where}.scores must map metric names to finite numbers when present`);
|
|
3064
|
+
}
|
|
3065
|
+
if ("tokens" in task && !isRecord2(task.tokens)) {
|
|
3066
|
+
reject(`${where}.tokens must be an object when present`);
|
|
3067
|
+
}
|
|
3068
|
+
const tokensSource = isRecord2(task.tokens) ? task.tokens : {};
|
|
3069
|
+
const upgraded = {
|
|
3070
|
+
taskId: task.taskId,
|
|
3071
|
+
// Old UI display defaults for absent task text fields.
|
|
3072
|
+
question: optionalString(`${where}.question`, task, "question") ?? "",
|
|
3073
|
+
expected: optionalString(`${where}.expected`, task, "expected") ?? "",
|
|
3074
|
+
actual: optionalString(`${where}.actual`, task, "actual") ?? "",
|
|
3075
|
+
scores: isRecord2(task.scores) ? task.scores : {},
|
|
3076
|
+
latencyMs: optionalFiniteNumber(`${where}.latencyMs`, task, "latencyMs") ?? 0,
|
|
3077
|
+
tokens: {
|
|
3078
|
+
input: optionalFiniteNumber(`${where}.tokens.input`, tokensSource, "input") ?? 0,
|
|
3079
|
+
output: optionalFiniteNumber(`${where}.tokens.output`, tokensSource, "output") ?? 0
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
const taskExtras = upgraded;
|
|
3083
|
+
for (const key of ["goldMemories", "attributionWitness", "details"]) {
|
|
3084
|
+
if (key in task) {
|
|
3085
|
+
taskExtras[key] = task[key];
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
return upgraded;
|
|
3089
|
+
}
|
|
3090
|
+
function upgradeResults(legacy) {
|
|
3091
|
+
const upgraded = { tasks: [], aggregates: {} };
|
|
3092
|
+
if (!("results" in legacy)) {
|
|
3093
|
+
return upgraded;
|
|
3094
|
+
}
|
|
3095
|
+
if (!isRecord2(legacy.results)) {
|
|
3096
|
+
reject("results must be an object when present");
|
|
3097
|
+
}
|
|
3098
|
+
const results = legacy.results;
|
|
3099
|
+
const declaredMultiSample = isDeclaredMultiSample(legacy);
|
|
3100
|
+
if ("tasks" in results) {
|
|
3101
|
+
if (!Array.isArray(results.tasks)) {
|
|
3102
|
+
reject("results.tasks must be an array when present");
|
|
3103
|
+
}
|
|
3104
|
+
upgraded.tasks = results.tasks.map((task, index) => upgradeTask(`results.tasks[${index}]`, task)).filter((task) => task !== null);
|
|
3105
|
+
}
|
|
3106
|
+
if ("aggregates" in results) {
|
|
3107
|
+
if (!isRecord2(results.aggregates)) {
|
|
3108
|
+
reject("results.aggregates must be an object when present");
|
|
3109
|
+
}
|
|
3110
|
+
const normalizedAggregates = {};
|
|
3111
|
+
for (const [metricName, rawValue] of Object.entries(results.aggregates)) {
|
|
3112
|
+
normalizedAggregates[metricName] = normalizeMetricAggregate(
|
|
3113
|
+
`results.aggregates.${metricName}`,
|
|
3114
|
+
rawValue,
|
|
3115
|
+
upgraded.tasks.length,
|
|
3116
|
+
declaredMultiSample
|
|
3117
|
+
);
|
|
3118
|
+
}
|
|
3119
|
+
upgraded.aggregates = normalizedAggregates;
|
|
3120
|
+
}
|
|
3121
|
+
const resultsExtras = upgraded;
|
|
3122
|
+
if ("categoryAggregates" in results && results.categoryAggregates !== void 0) {
|
|
3123
|
+
if (!isRecord2(results.categoryAggregates)) {
|
|
3124
|
+
reject("results.categoryAggregates must be an object when present");
|
|
3125
|
+
}
|
|
3126
|
+
const normalizedCategoryAggregates = {};
|
|
3127
|
+
for (const [catName, catAggs] of Object.entries(results.categoryAggregates)) {
|
|
3128
|
+
if (!isRecord2(catAggs)) {
|
|
3129
|
+
reject(`results.categoryAggregates.${catName} must be an object`);
|
|
3130
|
+
}
|
|
3131
|
+
const catNormalized = {};
|
|
3132
|
+
for (const [metricName, rawVal] of Object.entries(catAggs)) {
|
|
3133
|
+
catNormalized[metricName] = normalizeMetricAggregate(
|
|
3134
|
+
`results.categoryAggregates.${catName}.${metricName}`,
|
|
3135
|
+
rawVal,
|
|
3136
|
+
upgraded.tasks.length,
|
|
3137
|
+
declaredMultiSample
|
|
3138
|
+
);
|
|
3139
|
+
}
|
|
3140
|
+
normalizedCategoryAggregates[catName] = catNormalized;
|
|
3141
|
+
}
|
|
3142
|
+
resultsExtras.categoryAggregates = normalizedCategoryAggregates;
|
|
3143
|
+
}
|
|
3144
|
+
if ("statistics" in results) {
|
|
3145
|
+
resultsExtras.statistics = results.statistics;
|
|
3146
|
+
}
|
|
3147
|
+
const hasCategoryAggregate = isRecord2(resultsExtras.categoryAggregates) && Object.values(resultsExtras.categoryAggregates).some(
|
|
3148
|
+
(category) => isRecord2(category) && Object.keys(category).length > 0
|
|
3149
|
+
);
|
|
3150
|
+
if (upgraded.tasks.length === 0 && Object.keys(upgraded.aggregates).length === 0 && !hasCategoryAggregate) {
|
|
3151
|
+
reject("results must contain at least one recognized task or aggregate");
|
|
3152
|
+
}
|
|
3153
|
+
return upgraded;
|
|
3154
|
+
}
|
|
3155
|
+
function upgradeEnvironment(legacy) {
|
|
3156
|
+
if (!("environment" in legacy)) {
|
|
3157
|
+
return { os: "unknown", nodeVersion: "unknown" };
|
|
3158
|
+
}
|
|
3159
|
+
if (!isRecord2(legacy.environment)) {
|
|
3160
|
+
reject("environment must be an object when present");
|
|
3161
|
+
}
|
|
3162
|
+
const environment = legacy.environment;
|
|
3163
|
+
const upgraded = {
|
|
3164
|
+
os: optionalString("environment.os", environment, "os") ?? "unknown",
|
|
3165
|
+
nodeVersion: optionalString("environment.nodeVersion", environment, "nodeVersion") ?? "unknown"
|
|
3166
|
+
};
|
|
3167
|
+
if ("hardware" in environment) {
|
|
3168
|
+
upgraded.hardware = environment.hardware;
|
|
3169
|
+
}
|
|
3170
|
+
return upgraded;
|
|
3171
|
+
}
|
|
3172
|
+
function recognizeLegacyBenchmarkArtifact(value) {
|
|
3173
|
+
if (!isRecord2(value)) {
|
|
3174
|
+
return { ok: false, reason: "artifact is not a JSON object" };
|
|
3175
|
+
}
|
|
3176
|
+
if (isRecord2(value.meta)) {
|
|
3177
|
+
const meta = value.meta;
|
|
3178
|
+
const modernProvenance = "version" in meta || "remnicVersion" in meta || "gitSha" in meta;
|
|
3179
|
+
const modernTier = meta.benchmarkTier === "published" || meta.benchmarkTier === "remnic";
|
|
3180
|
+
const modernIntegrity = INTEGRITY_META_FIELDS.some((key) => key in meta);
|
|
3181
|
+
if (modernProvenance || modernTier || modernIntegrity) {
|
|
3182
|
+
return {
|
|
3183
|
+
ok: false,
|
|
3184
|
+
reason: !("results" in value) ? "modern provenance/integrity markers present; missing results is not a legacy artifact" : "modern provenance/integrity markers present; not a legacy artifact"
|
|
3185
|
+
};
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
try {
|
|
3189
|
+
return {
|
|
3190
|
+
ok: true,
|
|
3191
|
+
shapeVersion: LEGACY_ARTIFACT_SHAPE_VERSION,
|
|
3192
|
+
result: (() => {
|
|
3193
|
+
const results = upgradeResults(value);
|
|
3194
|
+
const upgraded = {
|
|
3195
|
+
meta: upgradeMeta(value, results.tasks.length),
|
|
3196
|
+
config: upgradeConfig(value),
|
|
3197
|
+
cost: upgradeCost(value),
|
|
3198
|
+
results,
|
|
3199
|
+
environment: upgradeEnvironment(value)
|
|
3200
|
+
};
|
|
3201
|
+
if (!("results" in value)) {
|
|
3202
|
+
reject("results must contain at least one recognized task or aggregate");
|
|
3203
|
+
}
|
|
3204
|
+
return upgraded;
|
|
3205
|
+
})()
|
|
3206
|
+
};
|
|
3207
|
+
} catch (error) {
|
|
3208
|
+
if (error instanceof ArtifactRejected) {
|
|
3209
|
+
return { ok: false, reason: error.reason };
|
|
3210
|
+
}
|
|
3211
|
+
return {
|
|
3212
|
+
ok: false,
|
|
3213
|
+
reason: error instanceof Error ? error.message : "legacy artifact upgrade failed"
|
|
3214
|
+
};
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
|
|
2638
3218
|
// src/results-store.ts
|
|
2639
3219
|
var BASELINE_NAME_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
2640
3220
|
var REPRO_MANIFEST_FILENAME = "MANIFEST.json";
|
|
@@ -2667,7 +3247,7 @@ function isBenchmarkMode(value) {
|
|
|
2667
3247
|
function isObjectRecord(value) {
|
|
2668
3248
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2669
3249
|
}
|
|
2670
|
-
function
|
|
3250
|
+
function isFiniteNumber2(value) {
|
|
2671
3251
|
return typeof value === "number" && Number.isFinite(value);
|
|
2672
3252
|
}
|
|
2673
3253
|
async function loadBenchmarkReportCardProvenance(outputDir, resultId) {
|
|
@@ -2693,12 +3273,12 @@ function isProviderConfigLike(value) {
|
|
|
2693
3273
|
if (value === null) {
|
|
2694
3274
|
return true;
|
|
2695
3275
|
}
|
|
2696
|
-
return
|
|
3276
|
+
return validateProviderConfigShape(value) === null;
|
|
2697
3277
|
}
|
|
2698
3278
|
function isNonEmptyString(value) {
|
|
2699
3279
|
return typeof value === "string" && value.trim().length > 0;
|
|
2700
3280
|
}
|
|
2701
|
-
function
|
|
3281
|
+
function isNonNegativeInteger2(value) {
|
|
2702
3282
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
2703
3283
|
}
|
|
2704
3284
|
function isUniqueMemoryIdList(value) {
|
|
@@ -2716,7 +3296,7 @@ function isTaskAttributionWitnessLike(value, goldMemories) {
|
|
|
2716
3296
|
return false;
|
|
2717
3297
|
}
|
|
2718
3298
|
const runtime = value.runtime;
|
|
2719
|
-
if (!isObjectRecord(runtime) || !isNonEmptyString(runtime.qmdCollection) || !isNonEmptyString(runtime.qmdIndex) || !
|
|
3299
|
+
if (!isObjectRecord(runtime) || !isNonEmptyString(runtime.qmdCollection) || !isNonEmptyString(runtime.qmdIndex) || !isNonNegativeInteger2(runtime.qmdMaxResults) || typeof runtime.attributionThreshold !== "number" || !Number.isFinite(runtime.attributionThreshold) || runtime.attributionThreshold < 0 || runtime.attributionThreshold > 1) {
|
|
2720
3300
|
return false;
|
|
2721
3301
|
}
|
|
2722
3302
|
if (!Array.isArray(value.golds) || goldMemories !== void 0 && value.golds.length !== goldMemories.length) {
|
|
@@ -2733,7 +3313,7 @@ function isTaskAttributionWitnessLike(value, goldMemories) {
|
|
|
2733
3313
|
}
|
|
2734
3314
|
const sessionIds = /* @__PURE__ */ new Set();
|
|
2735
3315
|
for (const retrieval of value.retrievals) {
|
|
2736
|
-
if (!isObjectRecord(retrieval) || !isNonEmptyString(retrieval.sessionId) || sessionIds.has(retrieval.sessionId) || !(retrieval.appliedCap === null ||
|
|
3316
|
+
if (!isObjectRecord(retrieval) || !isNonEmptyString(retrieval.sessionId) || sessionIds.has(retrieval.sessionId) || !(retrieval.appliedCap === null || isNonNegativeInteger2(retrieval.appliedCap)) || !isUniqueMemoryIdList(retrieval.atCapMemoryIds) || !isUniqueMemoryIdList(retrieval.headroomMemoryIds)) {
|
|
2737
3317
|
return false;
|
|
2738
3318
|
}
|
|
2739
3319
|
sessionIds.add(retrieval.sessionId);
|
|
@@ -2752,6 +3332,9 @@ function isTaskAttributionWitnessLike(value, goldMemories) {
|
|
|
2752
3332
|
}
|
|
2753
3333
|
return true;
|
|
2754
3334
|
}
|
|
3335
|
+
function isMetricAggregate(value) {
|
|
3336
|
+
return isObjectRecord(value) && isFiniteNumber2(value.mean) && isFiniteNumber2(value.median) && isFiniteNumber2(value.stdDev) && isFiniteNumber2(value.min) && isFiniteNumber2(value.max);
|
|
3337
|
+
}
|
|
2755
3338
|
function isBenchmarkResult(value) {
|
|
2756
3339
|
if (!isObjectRecord(value)) {
|
|
2757
3340
|
return false;
|
|
@@ -2760,7 +3343,7 @@ function isBenchmarkResult(value) {
|
|
|
2760
3343
|
if (!isObjectRecord(meta)) {
|
|
2761
3344
|
return false;
|
|
2762
3345
|
}
|
|
2763
|
-
const hasValidMeta = typeof meta.id === "string" && typeof meta.benchmark === "string" && (meta.benchmarkTier === "published" || meta.benchmarkTier === "remnic" || meta.benchmarkTier === "custom") && typeof meta.version === "string" && typeof meta.remnicVersion === "string" && typeof meta.gitSha === "string" && typeof meta.timestamp === "string" && isBenchmarkMode(meta.mode) &&
|
|
3346
|
+
const hasValidMeta = typeof meta.id === "string" && typeof meta.benchmark === "string" && (meta.benchmarkTier === "published" || meta.benchmarkTier === "remnic" || meta.benchmarkTier === "custom") && typeof meta.version === "string" && typeof meta.remnicVersion === "string" && typeof meta.gitSha === "string" && typeof meta.timestamp === "string" && isBenchmarkMode(meta.mode) && isFiniteNumber2(meta.runCount) && Array.isArray(meta.seeds) && meta.seeds.every(isFiniteNumber2) && (meta.canaryFloor === void 0 || isFiniteNumber2(meta.canaryFloor) && meta.canaryFloor >= 0) && (meta.canaryScore === void 0 || isFiniteNumber2(meta.canaryScore)) && (meta.failureReason === void 0 || typeof meta.failureReason === "string") && (meta.runId === void 0 || typeof meta.runId === "string") && (meta.gitDirty === void 0 || typeof meta.gitDirty === "boolean") && (meta.gitDirtyEntryCount === void 0 || isFiniteNumber2(meta.gitDirtyEntryCount)) && (meta.splitType === void 0 || meta.splitType === "public" || meta.splitType === "holdout") && (meta.qrelsSealedHash === void 0 || typeof meta.qrelsSealedHash === "string") && (meta.judgePromptHash === void 0 || typeof meta.judgePromptHash === "string") && (meta.datasetHash === void 0 || typeof meta.datasetHash === "string") && (meta.status === void 0 || meta.status === "complete" || meta.status === "partial");
|
|
2764
3347
|
if (!hasValidMeta) {
|
|
2765
3348
|
return false;
|
|
2766
3349
|
}
|
|
@@ -2769,13 +3352,23 @@ function isBenchmarkResult(value) {
|
|
|
2769
3352
|
return false;
|
|
2770
3353
|
}
|
|
2771
3354
|
const cost = value.cost;
|
|
2772
|
-
if (!isObjectRecord(cost) || !
|
|
3355
|
+
if (!isObjectRecord(cost) || !isFiniteNumber2(cost.totalTokens) || !isFiniteNumber2(cost.inputTokens) || !isFiniteNumber2(cost.outputTokens) || !isFiniteNumber2(cost.estimatedCostUsd) || !isFiniteNumber2(cost.totalLatencyMs) || !isFiniteNumber2(cost.meanQueryLatencyMs)) {
|
|
2773
3356
|
return false;
|
|
2774
3357
|
}
|
|
2775
3358
|
const results = value.results;
|
|
2776
|
-
if (!isObjectRecord(results) || !Array.isArray(results.tasks) || !results.tasks.every(isTaskResultLike) || !isObjectRecord(results.aggregates)) {
|
|
3359
|
+
if (!isObjectRecord(results) || !Array.isArray(results.tasks) || !results.tasks.every(isTaskResultLike) || !isObjectRecord(results.aggregates) || !Object.values(results.aggregates).every(isMetricAggregate)) {
|
|
2777
3360
|
return false;
|
|
2778
3361
|
}
|
|
3362
|
+
if (results.categoryAggregates !== void 0) {
|
|
3363
|
+
if (!isObjectRecord(results.categoryAggregates)) {
|
|
3364
|
+
return false;
|
|
3365
|
+
}
|
|
3366
|
+
for (const catAgg of Object.values(results.categoryAggregates)) {
|
|
3367
|
+
if (!isObjectRecord(catAgg) || !Object.values(catAgg).every(isMetricAggregate)) {
|
|
3368
|
+
return false;
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
}
|
|
2779
3372
|
const environment = value.environment;
|
|
2780
3373
|
return isObjectRecord(environment) && typeof environment.os === "string" && typeof environment.nodeVersion === "string" && (environment.hardware === void 0 || typeof environment.hardware === "string");
|
|
2781
3374
|
}
|
|
@@ -2791,7 +3384,7 @@ function isTaskResultLike(value) {
|
|
|
2791
3384
|
if (value.attributionWitness !== void 0 && !isTaskAttributionWitnessLike(value.attributionWitness, goldMemories)) {
|
|
2792
3385
|
return false;
|
|
2793
3386
|
}
|
|
2794
|
-
return typeof value.taskId === "string" && typeof value.question === "string" && typeof value.expected === "string" && typeof value.actual === "string" && isObjectRecord(value.scores) && Object.values(value.scores).every(
|
|
3387
|
+
return typeof value.taskId === "string" && typeof value.question === "string" && typeof value.expected === "string" && typeof value.actual === "string" && isObjectRecord(value.scores) && Object.values(value.scores).every(isFiniteNumber2) && isFiniteNumber2(value.latencyMs) && isObjectRecord(tokens) && isFiniteNumber2(tokens.input) && isFiniteNumber2(tokens.output);
|
|
2795
3388
|
}
|
|
2796
3389
|
function isStoredBenchmarkBaseline(value) {
|
|
2797
3390
|
if (!value || typeof value !== "object") {
|
|
@@ -2847,10 +3440,16 @@ function toBaselineSummary(baseline, filePath) {
|
|
|
2847
3440
|
async function loadBenchmarkResult(filePath) {
|
|
2848
3441
|
const content = await readFile3(filePath, "utf8");
|
|
2849
3442
|
const parsed = JSON.parse(content);
|
|
2850
|
-
if (
|
|
2851
|
-
|
|
3443
|
+
if (isBenchmarkResult(parsed)) {
|
|
3444
|
+
return parsed;
|
|
2852
3445
|
}
|
|
2853
|
-
|
|
3446
|
+
const legacy = recognizeLegacyBenchmarkArtifact(parsed);
|
|
3447
|
+
if (legacy.ok && isBenchmarkResult(legacy.result)) {
|
|
3448
|
+
return legacy.result;
|
|
3449
|
+
}
|
|
3450
|
+
throw new Error(
|
|
3451
|
+
`Invalid benchmark result file: ${filePath}${legacy.ok ? " (legacy artifact failed canonical re-validation)" : ` (${legacy.reason})`}`
|
|
3452
|
+
);
|
|
2854
3453
|
}
|
|
2855
3454
|
async function listBenchmarkResults(outputDir) {
|
|
2856
3455
|
if (!fs.existsSync(outputDir)) {
|
|
@@ -3372,10 +3971,10 @@ function sha256Buffer(value) {
|
|
|
3372
3971
|
}
|
|
3373
3972
|
async function sha256File(filePath) {
|
|
3374
3973
|
const hash = createHash3("sha256");
|
|
3375
|
-
await new Promise((resolve2,
|
|
3974
|
+
await new Promise((resolve2, reject2) => {
|
|
3376
3975
|
const stream = createReadStream(filePath);
|
|
3377
3976
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
3378
|
-
stream.on("error",
|
|
3977
|
+
stream.on("error", reject2);
|
|
3379
3978
|
stream.on("end", resolve2);
|
|
3380
3979
|
});
|
|
3381
3980
|
return hash.digest("hex");
|
|
@@ -13257,8 +13856,8 @@ function finalizeResult(state, status, invalidReason) {
|
|
|
13257
13856
|
}
|
|
13258
13857
|
function raceAbort(operation, signal) {
|
|
13259
13858
|
if (signal.aborted) return Promise.reject(new DOMException("aborted", "AbortError"));
|
|
13260
|
-
return new Promise((resolve2,
|
|
13261
|
-
const onAbort = () =>
|
|
13859
|
+
return new Promise((resolve2, reject2) => {
|
|
13860
|
+
const onAbort = () => reject2(new DOMException("aborted", "AbortError"));
|
|
13262
13861
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
13263
13862
|
operation.then(
|
|
13264
13863
|
(value) => {
|
|
@@ -13267,7 +13866,7 @@ function raceAbort(operation, signal) {
|
|
|
13267
13866
|
},
|
|
13268
13867
|
(error) => {
|
|
13269
13868
|
signal.removeEventListener("abort", onAbort);
|
|
13270
|
-
|
|
13869
|
+
reject2(error);
|
|
13271
13870
|
}
|
|
13272
13871
|
);
|
|
13273
13872
|
});
|
|
@@ -14049,8 +14648,8 @@ function finalizeResult2(state, status, invalidReason, evidence) {
|
|
|
14049
14648
|
}
|
|
14050
14649
|
async function raceSignal(operation, signal) {
|
|
14051
14650
|
if (signal.aborted) throw new DOMException("aborted", "AbortError");
|
|
14052
|
-
const { promise: aborted, reject } = Promise.withResolvers();
|
|
14053
|
-
const onAbort = () =>
|
|
14651
|
+
const { promise: aborted, reject: reject2 } = Promise.withResolvers();
|
|
14652
|
+
const onAbort = () => reject2(new DOMException("aborted", "AbortError"));
|
|
14054
14653
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
14055
14654
|
try {
|
|
14056
14655
|
return await Promise.race([operation, aborted]);
|
package/dist/index.d.ts
CHANGED
|
@@ -7663,6 +7663,7 @@ declare const H6BenchmarkDatasetSchema: z.ZodObject<{
|
|
|
7663
7663
|
}>;
|
|
7664
7664
|
}, "strip", z.ZodTypeAny, {
|
|
7665
7665
|
version: 1;
|
|
7666
|
+
seed: number;
|
|
7666
7667
|
tasks: {
|
|
7667
7668
|
title: string;
|
|
7668
7669
|
split: "dev" | "main" | "pilot";
|
|
@@ -7754,7 +7755,6 @@ declare const H6BenchmarkDatasetSchema: z.ZodObject<{
|
|
|
7754
7755
|
noTrapRevisionSha: string;
|
|
7755
7756
|
}[];
|
|
7756
7757
|
}[];
|
|
7757
|
-
seed: number;
|
|
7758
7758
|
createdAt: string;
|
|
7759
7759
|
inventoryHash: string;
|
|
7760
7760
|
supportArtifactHashes: {
|
|
@@ -7780,6 +7780,7 @@ declare const H6BenchmarkDatasetSchema: z.ZodObject<{
|
|
|
7780
7780
|
};
|
|
7781
7781
|
}, {
|
|
7782
7782
|
version: 1;
|
|
7783
|
+
seed: number;
|
|
7783
7784
|
tasks: {
|
|
7784
7785
|
title: string;
|
|
7785
7786
|
split: "dev" | "main" | "pilot";
|
|
@@ -7871,7 +7872,6 @@ declare const H6BenchmarkDatasetSchema: z.ZodObject<{
|
|
|
7871
7872
|
noTrapRevisionSha: string;
|
|
7872
7873
|
}[];
|
|
7873
7874
|
}[];
|
|
7874
|
-
seed: number;
|
|
7875
7875
|
createdAt: string;
|
|
7876
7876
|
inventoryHash: string;
|
|
7877
7877
|
supportArtifactHashes: {
|
package/dist/index.js
CHANGED
|
@@ -187,7 +187,7 @@ import {
|
|
|
187
187
|
writeLeaderboardArtifactsForResult,
|
|
188
188
|
writeRepeatedFailureRunMetadata,
|
|
189
189
|
writeRepeatedFailureStatistics
|
|
190
|
-
} from "./chunk-
|
|
190
|
+
} from "./chunk-QW6VEGZN.js";
|
|
191
191
|
|
|
192
192
|
// src/build-week-evidence-receipt.ts
|
|
193
193
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -46755,13 +46755,83 @@ function buildRecallPrompt(identity, variant) {
|
|
|
46755
46755
|
function trimSlash(url) {
|
|
46756
46756
|
return url.replace(/\/+$/, "");
|
|
46757
46757
|
}
|
|
46758
|
-
|
|
46758
|
+
function parseCompatUrl(baseUrl) {
|
|
46759
|
+
try {
|
|
46760
|
+
const parsed = new URL(baseUrl);
|
|
46761
|
+
let hostname2 = parsed.hostname.trim().toLowerCase();
|
|
46762
|
+
while (hostname2.endsWith(".")) hostname2 = hostname2.slice(0, -1);
|
|
46763
|
+
if (hostname2.length === 0) return void 0;
|
|
46764
|
+
return { protocol: parsed.protocol.toLowerCase(), hostname: hostname2 };
|
|
46765
|
+
} catch {
|
|
46766
|
+
return void 0;
|
|
46767
|
+
}
|
|
46768
|
+
}
|
|
46769
|
+
var OPENAI_API_HOSTS = Object.freeze(["api.openai.com"]);
|
|
46770
|
+
var NVIDIA_API_HOSTS = Object.freeze(["integrate.api.nvidia.com"]);
|
|
46771
|
+
function isExactAllowlistedHost(hostname2, allowlist) {
|
|
46772
|
+
return allowlist.includes(hostname2);
|
|
46773
|
+
}
|
|
46774
|
+
function isHttps(protocol) {
|
|
46775
|
+
return protocol === "https:";
|
|
46776
|
+
}
|
|
46777
|
+
function isLoopbackHttpHost(hostname2) {
|
|
46778
|
+
return hostname2 === "127.0.0.1" || hostname2 === "localhost";
|
|
46779
|
+
}
|
|
46780
|
+
function requireHttps(protocol, message) {
|
|
46781
|
+
if (!isHttps(protocol)) {
|
|
46782
|
+
throw new InjectionSuiteHostFault(message);
|
|
46783
|
+
}
|
|
46784
|
+
}
|
|
46785
|
+
function nonEmptyEnv(name) {
|
|
46786
|
+
const raw = process.env[name];
|
|
46787
|
+
if (typeof raw !== "string") return void 0;
|
|
46788
|
+
const trimmed = raw.trim();
|
|
46789
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
46790
|
+
}
|
|
46791
|
+
function requireEnvToken(envName, message) {
|
|
46792
|
+
const token = nonEmptyEnv(envName);
|
|
46793
|
+
if (token === void 0) {
|
|
46794
|
+
throw new InjectionSuiteHostFault(message);
|
|
46795
|
+
}
|
|
46796
|
+
return token;
|
|
46797
|
+
}
|
|
46798
|
+
function resolveOpenAiCompatToken(baseUrl) {
|
|
46799
|
+
const parsed = parseCompatUrl(baseUrl);
|
|
46800
|
+
if (parsed === void 0) {
|
|
46801
|
+
throw new InjectionSuiteHostFault("openai-compat requires a valid http(s) base URL");
|
|
46802
|
+
}
|
|
46803
|
+
const { protocol, hostname: hostname2 } = parsed;
|
|
46804
|
+
if (isExactAllowlistedHost(hostname2, NVIDIA_API_HOSTS)) {
|
|
46805
|
+
requireHttps(protocol, "openai-compat NVIDIA host requires https");
|
|
46806
|
+
return requireEnvToken(
|
|
46807
|
+
"NVIDIA_API_KEY",
|
|
46808
|
+
"openai-compat NVIDIA host requires NVIDIA_API_KEY"
|
|
46809
|
+
);
|
|
46810
|
+
}
|
|
46811
|
+
if (isExactAllowlistedHost(hostname2, OPENAI_API_HOSTS)) {
|
|
46812
|
+
requireHttps(protocol, "openai-compat OpenAI host requires https");
|
|
46813
|
+
return requireEnvToken(
|
|
46814
|
+
"OPENAI_API_KEY",
|
|
46815
|
+
"openai-compat OpenAI host requires OPENAI_API_KEY"
|
|
46816
|
+
);
|
|
46817
|
+
}
|
|
46818
|
+
if (!isHttps(protocol) && !isLoopbackHttpHost(hostname2)) {
|
|
46819
|
+
throw new InjectionSuiteHostFault(
|
|
46820
|
+
"openai-compat custom host requires https (loopback HTTP is allowed only for 127.0.0.1 or localhost)"
|
|
46821
|
+
);
|
|
46822
|
+
}
|
|
46823
|
+
return requireEnvToken(
|
|
46824
|
+
"REMNIC_OPENAI_COMPAT_API_KEY",
|
|
46825
|
+
"openai-compat unknown host requires REMNIC_OPENAI_COMPAT_API_KEY (or a known host: api.openai.com / integrate.api.nvidia.com); do not reuse OPENAI_API_KEY or NVIDIA_API_KEY"
|
|
46826
|
+
);
|
|
46827
|
+
}
|
|
46828
|
+
async function postJson(url, body, timeoutMs, extraHeaders) {
|
|
46759
46829
|
const controller = new AbortController();
|
|
46760
46830
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
46761
46831
|
try {
|
|
46762
46832
|
const response = await fetch(url, {
|
|
46763
46833
|
method: "POST",
|
|
46764
|
-
headers: { "content-type": "application/json" },
|
|
46834
|
+
headers: { "content-type": "application/json", ...extraHeaders },
|
|
46765
46835
|
body: JSON.stringify(body),
|
|
46766
46836
|
signal: controller.signal
|
|
46767
46837
|
});
|
|
@@ -46782,11 +46852,17 @@ async function completeChat(options, prompt) {
|
|
|
46782
46852
|
const model = options.model ?? DEFAULT_OLLAMA_MODEL;
|
|
46783
46853
|
if (options.kind === "openai-compat") {
|
|
46784
46854
|
const base2 = trimSlash(options.baseUrl ?? DEFAULT_OPENAI_COMPAT_BASE_URL);
|
|
46785
|
-
const
|
|
46786
|
-
|
|
46787
|
-
|
|
46788
|
-
|
|
46789
|
-
|
|
46855
|
+
const token = resolveOpenAiCompatToken(base2);
|
|
46856
|
+
const json2 = await postJson(
|
|
46857
|
+
`${base2}/chat/completions`,
|
|
46858
|
+
{
|
|
46859
|
+
model,
|
|
46860
|
+
messages: [{ role: "user", content: prompt }],
|
|
46861
|
+
temperature: 0
|
|
46862
|
+
},
|
|
46863
|
+
timeoutMs,
|
|
46864
|
+
{ Authorization: `Bearer ${token}` }
|
|
46865
|
+
);
|
|
46790
46866
|
const text2 = json2.choices?.[0]?.message?.content;
|
|
46791
46867
|
if (typeof text2 !== "string") throw new InjectionSuiteHostFault("openai-compat response missing content");
|
|
46792
46868
|
return text2;
|
|
@@ -48908,7 +48984,7 @@ async function writeRepeatedFailurePaperArtifacts(options) {
|
|
|
48908
48984
|
}
|
|
48909
48985
|
async function runRepeatedFailurePaperReportCliCommand(options) {
|
|
48910
48986
|
try {
|
|
48911
|
-
const { replayRepeatedFailureStatistics: replayRepeatedFailureStatistics2 } = await import("./repeated-failure-suite-runner-
|
|
48987
|
+
const { replayRepeatedFailureStatistics: replayRepeatedFailureStatistics2 } = await import("./repeated-failure-suite-runner-GEBPBTNL.js");
|
|
48912
48988
|
const replay = await replayRepeatedFailureStatistics2(options);
|
|
48913
48989
|
if (replay.exitCode !== 0) return replay;
|
|
48914
48990
|
const result = await writeRepeatedFailurePaperArtifacts(options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remnic/bench",
|
|
3
|
-
"version": "9.69.
|
|
3
|
+
"version": "9.69.41",
|
|
4
4
|
"description": "Retrieval latency ladder benchmarks + CI regression gates for @remnic/core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"hyparquet": "^1.25.7",
|
|
42
42
|
"yaml": "^2.4.2",
|
|
43
43
|
"zod": "^3.24.0",
|
|
44
|
-
"@remnic/coding-graph": "^9.69.
|
|
45
|
-
"@remnic/core": "^9.69.
|
|
44
|
+
"@remnic/coding-graph": "^9.69.41",
|
|
45
|
+
"@remnic/core": "^9.69.41"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"tsup": "^8.5.1",
|