@tangle-network/agent-eval 0.86.0 → 0.90.0
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/CHANGELOG.md +9 -1
- package/dist/adapters/http.d.ts +3 -3
- package/dist/adapters/langchain.d.ts +3 -3
- package/dist/adapters/otel.d.ts +6 -6
- package/dist/adversarial-DIVcDoI_.d.ts +88 -0
- package/dist/analyst/index.d.ts +11 -10
- package/dist/analyst/index.js +13 -8
- package/dist/analyst/index.js.map +1 -1
- package/dist/analyze-runs-DwCEkpO_.d.ts +81 -0
- package/dist/belief-state/index.d.ts +4 -4
- package/dist/belief-state/index.js +1 -1
- package/dist/benchmarks/index.d.ts +3 -3
- package/dist/campaign/index.d.ts +165 -18
- package/dist/campaign/index.js +289 -14
- package/dist/campaign/index.js.map +1 -1
- package/dist/chunk-45EEMHTC.js +35 -0
- package/dist/chunk-45EEMHTC.js.map +1 -0
- package/dist/{chunk-FZWAFVAA.js → chunk-4FBZZIYD.js} +2 -2
- package/dist/{chunk-YV7J7X5N.js → chunk-5HRORJQY.js} +22 -12
- package/dist/chunk-5HRORJQY.js.map +1 -0
- package/dist/{chunk-OTYQPHPL.js → chunk-6SOJM3VR.js} +5 -5
- package/dist/chunk-BOD4O7OF.js +40 -0
- package/dist/chunk-BOD4O7OF.js.map +1 -0
- package/dist/{chunk-Z7VFTS2J.js → chunk-CY6U5S3X.js} +2 -2
- package/dist/{chunk-VIDQF3F5.js → chunk-D3V5B42D.js} +5 -34
- package/dist/chunk-D3V5B42D.js.map +1 -0
- package/dist/{chunk-YGYXHNAQ.js → chunk-FIUKOSWI.js} +21 -8
- package/dist/chunk-FIUKOSWI.js.map +1 -0
- package/dist/{chunk-WJL2NJXN.js → chunk-GSH6QNNS.js} +2 -2
- package/dist/{chunk-RBNA5AZT.js → chunk-L3JOU6XM.js} +2 -2
- package/dist/{chunk-IDVBLYCY.js → chunk-LMZQ2Z4U.js} +56 -2
- package/dist/{chunk-IDVBLYCY.js.map → chunk-LMZQ2Z4U.js.map} +1 -1
- package/dist/{chunk-VUINJM5M.js → chunk-QAY5UIJO.js} +2 -193
- package/dist/chunk-QAY5UIJO.js.map +1 -0
- package/dist/{chunk-P2J6SOXT.js → chunk-QG2OVF2D.js} +5 -3
- package/dist/{chunk-P2J6SOXT.js.map → chunk-QG2OVF2D.js.map} +1 -1
- package/dist/chunk-REVYNR6C.js +100 -0
- package/dist/chunk-REVYNR6C.js.map +1 -0
- package/dist/chunk-STGVSCDH.js +202 -0
- package/dist/chunk-STGVSCDH.js.map +1 -0
- package/dist/{chunk-ZZ2HOPME.js → chunk-TWS7AZEY.js} +2 -2
- package/dist/chunk-UHMJT4T7.js +200 -0
- package/dist/chunk-UHMJT4T7.js.map +1 -0
- package/dist/chunk-UMMZHCPB.js +190 -0
- package/dist/chunk-UMMZHCPB.js.map +1 -0
- package/dist/chunk-VZSRQ272.js +149 -0
- package/dist/chunk-VZSRQ272.js.map +1 -0
- package/dist/{chunk-L5G7OUKD.js → chunk-XY4DDNEG.js} +8 -190
- package/dist/chunk-XY4DDNEG.js.map +1 -0
- package/dist/chunk-Y47J2LJ3.js +859 -0
- package/dist/chunk-Y47J2LJ3.js.map +1 -0
- package/dist/{chunk-BABOZOSN.js → chunk-ZFIBGEOL.js} +3 -3
- package/dist/chunk-ZFIBGEOL.js.map +1 -0
- package/dist/{code-agent-session-BRXmavYv.d.ts → code-agent-session-BO8nCnv3.d.ts} +1 -1
- package/dist/contract/index.d.ts +24 -95
- package/dist/contract/index.js +25 -764
- package/dist/contract/index.js.map +1 -1
- package/dist/{control-GeE8OhpN.d.ts → control-_Qb7skHX.d.ts} +2 -2
- package/dist/control.d.ts +5 -5
- package/dist/corpus-BoR-041R.d.ts +560 -0
- package/dist/cost-ledger-DuSqlw5B.d.ts +113 -0
- package/dist/counterfactual-Dwibr5IW.d.ts +85 -0
- package/dist/{dataset-B2kL-fSM.d.ts → dataset-BbGkaN2I.d.ts} +1 -1
- package/dist/{registry-DrEQ3Luj.d.ts → default-registry-zoGHUQEH.d.ts} +29 -2
- package/dist/diagnose.d.ts +251 -0
- package/dist/diagnose.js +381 -0
- package/dist/diagnose.js.map +1 -0
- package/dist/{errors-Dwqw-T_m.d.ts → errors-CzMUYo7b.d.ts} +1 -1
- package/dist/{feedback-trajectory-B3rErRsh.d.ts → feedback-trajectory-D9OVLrg9.d.ts} +1 -1
- package/dist/fuzz.d.ts +484 -0
- package/dist/fuzz.js +613 -0
- package/dist/fuzz.js.map +1 -0
- package/dist/governance/index.d.ts +4 -4
- package/dist/hosted/index.d.ts +6 -6
- package/dist/{index-DE3RXAXD.d.ts → index-Bx3gZ8xl.d.ts} +1 -1
- package/dist/index.d.ts +718 -455
- package/dist/index.js +1604 -793
- package/dist/index.js.map +1 -1
- package/dist/{insight-report-3ADTfClO.d.ts → insight-report-BBwvOh6x.d.ts} +2 -2
- package/dist/{integrity-CJzrpUua.d.ts → integrity-VJ9A7aST.d.ts} +1 -1
- package/dist/{judge-calibration-DilmB3Ml.d.ts → judge-calibration-0p2QcWNE.d.ts} +1 -1
- package/dist/{kind-factory-CVecZZG_.d.ts → kind-factory-5b7xXXOr.d.ts} +2 -2
- package/dist/{llm-client-CuUg2Mn3.d.ts → llm-client-BeEcAokY.d.ts} +1 -1
- package/dist/matrix/index.d.ts +2 -2
- package/dist/meta-eval/index.d.ts +177 -3
- package/dist/meta-eval/index.js +260 -1
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/{multi-layer-verifier-DlWCXuxL.d.ts → multi-layer-verifier-DUZXrPDA.d.ts} +7 -1
- package/dist/multishot/index.d.ts +25 -11
- package/dist/multishot/index.js +36 -7
- package/dist/multishot/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/perf/index.d.ts +123 -0
- package/dist/perf/index.js +18 -0
- package/dist/pipelines/index.js +2 -2
- package/dist/{agent-profile-D0PBIWlV.d.ts → pre-registration-DELOEJ8v.d.ts} +144 -4
- package/dist/{provenance-DPpNIOJD.d.ts → provenance-LnqRT0sS.d.ts} +5 -5
- package/dist/{red-team-DW9Ca_tj.d.ts → red-team-BXHil6c8.d.ts} +1 -1
- package/dist/{release-report-hlNtD12q.d.ts → release-report-euXIV_Sk.d.ts} +3 -3
- package/dist/reporting.d.ts +8 -8
- package/dist/reporting.js +3 -3
- package/dist/{researcher-BLPHBbNV.d.ts → researcher-DE6Gpnb4.d.ts} +4 -4
- package/dist/rl.d.ts +194 -656
- package/dist/rl.js +231 -149
- package/dist/rl.js.map +1 -1
- package/dist/{rubric-predictive-validity-CnEl9Jc8.d.ts → rubric-predictive-validity-Cy_W-hWZ.d.ts} +1 -1
- package/dist/{run-campaign-4Y5V5CN3.js → run-campaign-RDGAM5KJ.js} +3 -3
- package/dist/run-campaign-RDGAM5KJ.js.map +1 -0
- package/dist/{run-improvement-loop-CNqQckTj.d.ts → run-improvement-loop-5z_l5zDz.d.ts} +2 -2
- package/dist/{run-record-De9VarXR.d.ts → run-record-e7vj1uZQ.d.ts} +1 -1
- package/dist/{runtime-trajectory-BLRiaifm.d.ts → runtime-trajectory-BDgfGZSr.d.ts} +1 -1
- package/dist/{semantic-concept-judge-DIEgr_6v.d.ts → semantic-concept-judge-Dn8Z6KEG.d.ts} +5 -31
- package/dist/series-convergence-D5OWMBg6.d.ts +33 -0
- package/dist/{statistics-CnC1FMbx.d.ts → statistics-C7PozGrZ.d.ts} +71 -2
- package/dist/{summary-report-Db0dDSWP.d.ts → summary-report-DGmUucwQ.d.ts} +1 -1
- package/dist/traces.d.ts +3 -3
- package/dist/traces.js +8 -6
- package/dist/{types-Cu3u_x59.d.ts → types-2VVIL04s.d.ts} +2 -2
- package/dist/{types-D7lLRYe9.d.ts → types-BU-7W85F.d.ts} +21 -1
- package/dist/{types-CqPax19X.d.ts → types-mn5Aqk7x.d.ts} +1 -1
- package/dist/{verdict-CeEgtjyI.d.ts → verdict-C9MlYujm.d.ts} +3 -0
- package/dist/wire/index.d.ts +3 -3
- package/dist/workflow/index.d.ts +12 -11
- package/dist/workflow/index.js +1 -1
- package/package.json +16 -1
- package/dist/chunk-BABOZOSN.js.map +0 -1
- package/dist/chunk-L5G7OUKD.js.map +0 -1
- package/dist/chunk-SHTXZ4O2.js +0 -113
- package/dist/chunk-SHTXZ4O2.js.map +0 -1
- package/dist/chunk-VIDQF3F5.js.map +0 -1
- package/dist/chunk-VUINJM5M.js.map +0 -1
- package/dist/chunk-YGYXHNAQ.js.map +0 -1
- package/dist/chunk-YV7J7X5N.js.map +0 -1
- /package/dist/{chunk-FZWAFVAA.js.map → chunk-4FBZZIYD.js.map} +0 -0
- /package/dist/{chunk-OTYQPHPL.js.map → chunk-6SOJM3VR.js.map} +0 -0
- /package/dist/{chunk-Z7VFTS2J.js.map → chunk-CY6U5S3X.js.map} +0 -0
- /package/dist/{chunk-WJL2NJXN.js.map → chunk-GSH6QNNS.js.map} +0 -0
- /package/dist/{chunk-RBNA5AZT.js.map → chunk-L3JOU6XM.js.map} +0 -0
- /package/dist/{chunk-ZZ2HOPME.js.map → chunk-TWS7AZEY.js.map} +0 -0
- /package/dist/{run-campaign-4Y5V5CN3.js.map → perf/index.js.map} +0 -0
package/dist/campaign/index.d.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { A as AnalyzeTracesOptions, a as AnalyzeTracesInput, b as AnalyzeTracesResult } from '../analyst-C8HHvfJp.js';
|
|
2
|
-
import { S as Scenario, M as MutableSurface, b as DispatchContext, a as JudgeConfig, I as ImprovementDriver, q as ProposeContext, J as JudgeScore, L as LabeledScenarioStore, r as LabeledScenarioWrite, s as LabeledScenarioSampleArgs, t as LabeledScenarioRecord, u as LabelTrust, v as LabeledScenarioSource, g as CampaignResult, i as CodeSurface } from '../types-
|
|
3
|
-
export { C as CampaignAggregates, d as CampaignArtifactWriter, e as CampaignCellResult, f as CampaignCostMeter, w as CampaignTokenUsage, h as CampaignTraceWriter, D as DispatchFn,
|
|
4
|
-
import { b as RunCampaignOptions, c as RunImprovementLoopOptions, C as CampaignStorage } from '../run-improvement-loop-
|
|
5
|
-
export { e as GepaDriverConstraints, G as GepaDriverOptions, O as OpenAutoPrOptions, h as OpenAutoPrResult, a as RunImprovementLoopResult, R as RunOptimizationOptions, j as RunOptimizationResult, k as countSentenceEdits, l as defaultRenderDiff, m as extractH2Sections, f as fsCampaignStorage, g as gepaDriver, i as inMemoryCampaignStorage, o as openAutoPr, r as runCampaign, d as runImprovementLoop, n as runOptimization, s as surfaceHash } from '../run-improvement-loop-
|
|
6
|
-
export { A as AxisEvidence, a as AxisVerdict, B as BuildEvidenceVectorOptions, k as BuildLoopProvenanceArgs, D as DefaultProductionGateOptions, l as EmitLoopProvenanceArgs, m as EmitLoopProvenanceResult, E as EvidenceVector, b as EvolutionaryDriverOptions, H as HeldOutGateOptions, n as LoopProvenanceBackend, o as LoopProvenanceCandidate, L as LoopProvenanceRecord, O as ObjectiveSource, P as ParetoSignificanceGateOptions, c as PromotionObjective, d as PromotionPolicy, R as RunEvalOptions, e as buildEvidenceVector, q as buildLoopProvenanceRecord, f as composeGate, g as defaultProductionGate, s as emitLoopProvenance, h as evolutionaryDriver, i as heldOutGate, t as loopProvenanceSpans, p as paretoPolicy, j as paretoSignificanceGate, u as provenanceRecordPath, v as provenanceSpansPath, r as runEval, w as surfaceContentHash } from '../provenance-
|
|
7
|
-
import { L as LlmClientOptions } from '../llm-client-
|
|
8
|
-
import {
|
|
9
|
-
import { c as AnalystFinding } from '../types-
|
|
10
|
-
import { a as
|
|
11
|
-
import {
|
|
12
|
-
import { A as AgentEvalError } from '../errors-
|
|
13
|
-
import { a as RunSplitTag, R as RunRecord } from '../run-record-
|
|
2
|
+
import { S as Scenario, M as MutableSurface, b as DispatchContext, a as JudgeConfig, I as ImprovementDriver, q as ProposeContext, m as GenerationRecord, G as Gate, J as JudgeScore, L as LabeledScenarioStore, r as LabeledScenarioWrite, s as LabeledScenarioSampleArgs, t as LabeledScenarioRecord, u as LabelTrust, v as LabeledScenarioSource, g as CampaignResult, i as CodeSurface } from '../types-BU-7W85F.js';
|
|
3
|
+
export { C as CampaignAggregates, d as CampaignArtifactWriter, e as CampaignCellResult, f as CampaignCostMeter, w as CampaignTokenUsage, h as CampaignTraceWriter, D as DispatchFn, j as GateContext, c as GateDecision, k as GateResult, l as GenerationCandidate, x as JudgeAggregate, n as JudgeDimension, o as Mutator, O as OptimizerConfig, P as ParetoParent, y as ProposedCandidate, R as RedactionStatus, z as ScenarioAggregate, p as SessionScript, T as TraceSpan, A as isProposedCandidate, B as labelTrustRank } from '../types-BU-7W85F.js';
|
|
4
|
+
import { b as RunCampaignOptions, c as RunImprovementLoopOptions, C as CampaignStorage } from '../run-improvement-loop-5z_l5zDz.js';
|
|
5
|
+
export { e as GepaDriverConstraints, G as GepaDriverOptions, O as OpenAutoPrOptions, h as OpenAutoPrResult, a as RunImprovementLoopResult, R as RunOptimizationOptions, j as RunOptimizationResult, k as countSentenceEdits, l as defaultRenderDiff, m as extractH2Sections, f as fsCampaignStorage, g as gepaDriver, i as inMemoryCampaignStorage, o as openAutoPr, r as runCampaign, d as runImprovementLoop, n as runOptimization, s as surfaceHash } from '../run-improvement-loop-5z_l5zDz.js';
|
|
6
|
+
export { A as AxisEvidence, a as AxisVerdict, B as BuildEvidenceVectorOptions, k as BuildLoopProvenanceArgs, D as DefaultProductionGateOptions, l as EmitLoopProvenanceArgs, m as EmitLoopProvenanceResult, E as EvidenceVector, b as EvolutionaryDriverOptions, H as HeldOutGateOptions, n as LoopProvenanceBackend, o as LoopProvenanceCandidate, L as LoopProvenanceRecord, O as ObjectiveSource, P as ParetoSignificanceGateOptions, c as PromotionObjective, d as PromotionPolicy, R as RunEvalOptions, e as buildEvidenceVector, q as buildLoopProvenanceRecord, f as composeGate, g as defaultProductionGate, s as emitLoopProvenance, h as evolutionaryDriver, i as heldOutGate, t as loopProvenanceSpans, p as paretoPolicy, j as paretoSignificanceGate, u as provenanceRecordPath, v as provenanceSpansPath, r as runEval, w as surfaceContentHash } from '../provenance-LnqRT0sS.js';
|
|
7
|
+
import { L as LlmClientOptions } from '../llm-client-BeEcAokY.js';
|
|
8
|
+
import { T as TraceAnalystKindSpec } from '../kind-factory-5b7xXXOr.js';
|
|
9
|
+
import { c as AnalystFinding } from '../types-2VVIL04s.js';
|
|
10
|
+
import { S as SignedManifest, A as AgentProfile, B as BackendIntegrityReport, C as CompletionRequirement, R as RuntimeEventLike, a as CompletionVerdict, P as ProducedState, b as CorrectnessChecker } from '../pre-registration-DELOEJ8v.js';
|
|
11
|
+
import { E as EProcessState, a as PairedBootstrapResult } from '../statistics-C7PozGrZ.js';
|
|
12
|
+
import { A as AgentEvalError } from '../errors-CzMUYo7b.js';
|
|
13
|
+
import { a as RunSplitTag, R as RunRecord } from '../run-record-e7vj1uZQ.js';
|
|
14
14
|
import '@ax-llm/ax';
|
|
15
15
|
import '../store-C1YxJDEK.js';
|
|
16
|
-
import '../red-team-
|
|
17
|
-
import '../dataset-
|
|
16
|
+
import '../red-team-BXHil6c8.js';
|
|
17
|
+
import '../dataset-BbGkaN2I.js';
|
|
18
18
|
import '../store-CKUAgsJz.js';
|
|
19
19
|
import '../schema-m0gsnbt3.js';
|
|
20
20
|
import '../pareto-E-pembql.js';
|
|
21
21
|
import '../hosted/index.js';
|
|
22
|
-
import '../insight-report-
|
|
23
|
-
import '../summary-report-
|
|
22
|
+
import '../insight-report-BBwvOh6x.js';
|
|
23
|
+
import '../summary-report-DGmUucwQ.js';
|
|
24
24
|
import '../failure-cluster-CL7IVgkJ.js';
|
|
25
|
-
import '../judge-calibration-
|
|
25
|
+
import '../judge-calibration-0p2QcWNE.js';
|
|
26
26
|
import '../raw-provider-sink-C46HDghv.js';
|
|
27
27
|
import 'zod';
|
|
28
28
|
import '../types-Croy5h7V.js';
|
|
29
29
|
import '@tangle-network/tcloud';
|
|
30
|
+
import '../verdict-C9MlYujm.js';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* @experimental
|
|
@@ -464,6 +465,152 @@ interface TraceAnalystDriverOptions {
|
|
|
464
465
|
/** Wrap agent-eval's trace-analyst registry as an ImprovementDriver (prompt-tier). */
|
|
465
466
|
declare function traceAnalystDriver(opts: TraceAnalystDriverOptions): ImprovementDriver;
|
|
466
467
|
|
|
468
|
+
/**
|
|
469
|
+
* @experimental
|
|
470
|
+
*
|
|
471
|
+
* Anytime-valid sequential promotion gate — an e-process (betting
|
|
472
|
+
* test-martingale, see `eProcess` in `statistics.ts`) over paired
|
|
473
|
+
* per-scenario deltas, so a campaign stops the MOMENT evidence decides
|
|
474
|
+
* instead of burning a fixed-n budget. Decisions remain valid at any
|
|
475
|
+
* data-dependent stopping time (Ville's inequality), which is exactly what
|
|
476
|
+
* fixed-n machinery cannot offer: peeking at a bootstrap CI after every
|
|
477
|
+
* observation and stopping on the first significant peek inflates type-I
|
|
478
|
+
* error far beyond alpha.
|
|
479
|
+
*
|
|
480
|
+
* REPLACES, never layers on, a fixed-n gate. Running `heldoutSignificance`
|
|
481
|
+
* or `paretoSignificanceGate` repeatedly on a growing sample and stopping
|
|
482
|
+
* early is optional stopping no matter how it is dressed up; this gate is
|
|
483
|
+
* the valid way to stop early. Use one or the other per evidence stream.
|
|
484
|
+
*
|
|
485
|
+
* Pre-registration binding: anytime validity holds only for the
|
|
486
|
+
* PRE-REGISTERED statistic. When a `SignedManifest` is bound, the gate takes
|
|
487
|
+
* alpha from `manifest.alpha`, the observation budget from
|
|
488
|
+
* `manifest.preRegisteredN`, orients deltas by `manifest.direction`, and
|
|
489
|
+
* shifts the null boundary by `manifest.minEffect` — re-deciding the same
|
|
490
|
+
* stream under different parameters after seeing data would reopen optional
|
|
491
|
+
* stopping under a fancier name. The manifest's content hash is verified at
|
|
492
|
+
* construction (sync, same `sha256-content` scheme as `signManifest`).
|
|
493
|
+
*
|
|
494
|
+
* Non-iid caveat (stated honestly): the supermartingale guarantee needs each
|
|
495
|
+
* delta's conditional mean under H0 to stay ≤ the null boundary given the
|
|
496
|
+
* past — exchangeable scenario deltas suffice. Scenario streams ordered by
|
|
497
|
+
* difficulty or by scenario family violate this; `decide(ctx)` therefore
|
|
498
|
+
* shuffles the paired deltas with a SEEDED permutation by default (the
|
|
499
|
+
* permutation is data-independent, so bet predictability is preserved).
|
|
500
|
+
* Stratified betting (per-stratum λ) is future work, not implemented here.
|
|
501
|
+
*/
|
|
502
|
+
|
|
503
|
+
type SequentialDecision = 'promote' | 'continue' | 'undecided-at-maxN';
|
|
504
|
+
interface SequentialObservation {
|
|
505
|
+
decision: SequentialDecision;
|
|
506
|
+
/** Current e-value (the betting wealth) against H0. */
|
|
507
|
+
eValue: number;
|
|
508
|
+
/** Paired deltas consumed so far. */
|
|
509
|
+
n: number;
|
|
510
|
+
/** Names the decision basis. For 'undecided-at-maxN' it states explicitly
|
|
511
|
+
* that exhausting the budget is NOT evidence of no effect. */
|
|
512
|
+
reason: string;
|
|
513
|
+
}
|
|
514
|
+
interface SequentialPairedGateOptions {
|
|
515
|
+
/** Type-I budget. With `preRegistration` bound this MUST match
|
|
516
|
+
* `manifest.alpha` (conflict throws). Default 0.05. */
|
|
517
|
+
alpha?: number;
|
|
518
|
+
/** Minimum paired deltas before a promote may fire. The stopping rule is
|
|
519
|
+
* "first n ≥ minN with e-value ≥ 1/alpha" — still a valid stopping time.
|
|
520
|
+
* Default 5. */
|
|
521
|
+
minN?: number;
|
|
522
|
+
/** Pre-registered observation budget. Required unless `preRegistration`
|
|
523
|
+
* supplies it via `preRegisteredN` (conflict throws). */
|
|
524
|
+
maxN?: number;
|
|
525
|
+
/** Bet truncation forwarded to `eProcess`. Default 0.5. */
|
|
526
|
+
maxBet?: number;
|
|
527
|
+
/** Bound on |delta| in the judge's native scale; deltas are mapped to
|
|
528
|
+
* x = (d/scale + 1)/2 ∈ [0,1]. A delta outside ±scale throws (use
|
|
529
|
+
* `detectScale` to pick 1 vs 100 BEFORE streaming). Default 1. */
|
|
530
|
+
scale?: number;
|
|
531
|
+
/** Seed for the data-independent shuffle of paired deltas in `decide(ctx)`
|
|
532
|
+
* (exchangeability guard). Default 1337. */
|
|
533
|
+
shuffleSeed?: number;
|
|
534
|
+
/** Bind the pre-registered hypothesis. Verified (content hash) at
|
|
535
|
+
* construction; alpha/maxN/direction/minEffect come FROM the manifest. */
|
|
536
|
+
preRegistration?: SignedManifest;
|
|
537
|
+
/** Override the gate name in reports. */
|
|
538
|
+
name?: string;
|
|
539
|
+
}
|
|
540
|
+
interface SequentialPairedGate<TArtifact = unknown, TScenario extends Scenario = Scenario> extends Gate<TArtifact, TScenario> {
|
|
541
|
+
/** Streaming entry point: feed one paired per-scenario delta
|
|
542
|
+
* (candidate − baseline, native scale). Each gate instance carries ONE
|
|
543
|
+
* observe-stream; `decide(ctx)` runs on its own fresh stream and never
|
|
544
|
+
* consumes or advances this one. 'promote' is sticky; observing past the
|
|
545
|
+
* pre-registered maxN throws (extending a finished stream after seeing
|
|
546
|
+
* the result reopens optional stopping — start a NEW pre-registered
|
|
547
|
+
* test). */
|
|
548
|
+
observe(delta: number): SequentialObservation;
|
|
549
|
+
/** Read-only snapshot of the observe-stream. */
|
|
550
|
+
state(): EProcessState & {
|
|
551
|
+
decision: SequentialDecision;
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Anytime-valid sequential paired gate. Conforms to the existing `Gate`
|
|
556
|
+
* contract (`decide(ctx)` consumes candidate vs baseline judge scores via
|
|
557
|
+
* `pairHoldout` — same pairing granularity as the fixed-n gates: full cellId,
|
|
558
|
+
* never scenarioId) and adds a streaming `observe(delta)` entry for campaigns
|
|
559
|
+
* that score cells incrementally and want to stop mid-stream.
|
|
560
|
+
*
|
|
561
|
+
* Decision mapping onto the substrate's five-valued `GateDecision`:
|
|
562
|
+
* - 'promote' → 'ship'
|
|
563
|
+
* - 'continue' → 'need_more_work' (stream ended before maxN with
|
|
564
|
+
* the e-value undecided — more reps could decide)
|
|
565
|
+
* - 'undecided-at-maxN' → 'hold', with the reason stating it is NOT
|
|
566
|
+
* evidence of no effect (never a silent default)
|
|
567
|
+
*/
|
|
568
|
+
declare function sequentialPairedGate<TArtifact = unknown, TScenario extends Scenario = Scenario>(options: SequentialPairedGateOptions): SequentialPairedGate<TArtifact, TScenario>;
|
|
569
|
+
interface SequentialDecideOptions {
|
|
570
|
+
/** Type-I budget for the early-stop evidence. Default 0.05. */
|
|
571
|
+
alpha?: number;
|
|
572
|
+
/** Minimum paired deltas before a stop may fire. Default 5. */
|
|
573
|
+
minN?: number;
|
|
574
|
+
/** Bet truncation forwarded to `eProcess`. Default 0.5. */
|
|
575
|
+
maxBet?: number;
|
|
576
|
+
/** Bound on |per-scenario composite delta|. Default 1. */
|
|
577
|
+
scale?: number;
|
|
578
|
+
}
|
|
579
|
+
interface SequentialDecideFn {
|
|
580
|
+
(args: {
|
|
581
|
+
history: GenerationRecord[];
|
|
582
|
+
}): {
|
|
583
|
+
stop: boolean;
|
|
584
|
+
reason?: string;
|
|
585
|
+
};
|
|
586
|
+
/** Read-only snapshot of the accumulated e-process (observability + tests). */
|
|
587
|
+
state(): EProcessState;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* `ImprovementDriver.decide` adapter — stops the optimization loop the moment
|
|
591
|
+
* the e-process decides the loop has produced a real improvement, instead of
|
|
592
|
+
* always running `maxGenerations`.
|
|
593
|
+
*
|
|
594
|
+
* Stream: for each generation g ≥ 1, the per-scenario composite deltas of
|
|
595
|
+
* generation g's top candidate vs the generation-0 top candidate (the
|
|
596
|
+
* incumbent the loop set out to beat), paired by scenarioId. H0: no proposed
|
|
597
|
+
* surface improves any scenario's expected composite over the incumbent —
|
|
598
|
+
* under it every delta has conditional mean ≤ 0 and the e-process is valid.
|
|
599
|
+
* Once wealth ≥ 1/alpha the loop stops and hands the winner to the promotion
|
|
600
|
+
* gate (which re-scores on HELD-OUT data — this adapter only spends the
|
|
601
|
+
* exploration budget, it never promotes).
|
|
602
|
+
*
|
|
603
|
+
* Honesty caveats: (1) the incumbent's scores are measured once and shared
|
|
604
|
+
* across all generations' deltas, so type-I control is exact only insofar as
|
|
605
|
+
* those scores approximate the incumbent's true per-scenario means (more reps
|
|
606
|
+
* → tighter); (2) an UNDECIDED process never stops the loop — absence of a
|
|
607
|
+
* crossing is NOT evidence of no effect, so the loop simply runs its normal
|
|
608
|
+
* course. Calling the adapter repeatedly with a growing history consumes each
|
|
609
|
+
* generation exactly once (re-feeding an already-seen record would double-count
|
|
610
|
+
* evidence).
|
|
611
|
+
*/
|
|
612
|
+
declare function sequentialDecide(options?: SequentialDecideOptions): SequentialDecideFn;
|
|
613
|
+
|
|
467
614
|
/**
|
|
468
615
|
* @experimental
|
|
469
616
|
*
|
|
@@ -1192,4 +1339,4 @@ declare function gitWorktreeAdapter(opts: GitWorktreeAdapterOptions): WorktreeAd
|
|
|
1192
1339
|
* as a ref under the adapter's worktree dir. */
|
|
1193
1340
|
declare function resolveWorktreePath(surface: CodeSurface, worktreeDir?: string): string;
|
|
1194
1341
|
|
|
1195
|
-
export { type AcceptedEdit, type AceDriverOptions, type AnalystArtifact, type AnalystScenario, type ApplySkillPatchResult, type BuildAnalystSurfaceDispatchOptions, type CampaignBreakdown, CampaignResult, CampaignStorage, CodeSurface, type CompareDriversOptions, type DimensionRegression, DispatchContext, type DriverComparison, type DriverEntry, type DriverPairwise, type DriverScore, type FailureModeRecallJudgeOptions, FsLabeledScenarioStore, type FsLabeledScenarioStoreOptions, type GitWorktreeAdapterOptions, type HaloDriverOptions, type HeldoutSignificance, type HeldoutSignificanceOptions, ImprovementDriver, JudgeConfig, JudgeScore, LabelTrust, LabeledScenarioRecord, LabeledScenarioSampleArgs, LabeledScenarioSource, LabeledScenarioStore, LabeledScenarioStoreError, LabeledScenarioWrite, type MemoryCurationDriverOptions, MutableSurface, type OptimizerEntryConfig, type PairedHoldout, type PlaybackContext, type PlaybackDriver, type PlaybackStep, type ProfileDispatchFn, ProfileMatrixError, type ProfileSummary, ProposeContext, type ProposePatchesArgs, type RejectedEdit, RunCampaignOptions, RunImprovementLoopOptions, type RunProfileMatrixOptions, type RunProfileMatrixResult, type RunSkillOptOptions, type RunSkillOptResult, Scenario, type ScenarioRollup, type ScoreboardRenderOptions, type ScoreboardRow, type ScoreboardSummary, type SkillOptDriver, type SkillOptDriverOptions, type SkillOptEpochRecord, type SkillOptEvidence, type SkillPatch, type SkillPatchOp, SkillPatchParseError, type SkillPatchRejection, type TraceAnalystDriverOptions, type UserStory, type UserStoryVerdict, type Worktree, type WorktreeAdapter, WorktreeAdapterError, aceDriver, applySkillPatch, buildAnalystSurfaceDispatch, campaignBreakdown, campaignMeanComposite, compareDrivers, detectScale, dimensionRegressions, failureModeRecallJudge, gepaParetoEntry, gepaReflectionEntry, gitWorktreeAdapter, haloDriver, heldoutSignificance, makePlaybackDispatch, memoryCurationDriver, pairHoldout, parseSkillPatchResponse, patchEditCount, renderScoreboardMarkdown, resolveWorktreePath, runProfileMatrix, runSkillOpt, scoreUserStory, scoreboardSummary, skillOptDriver, skillOptEntry, traceAnalystDriver, userStoryScoreboard };
|
|
1342
|
+
export { type AcceptedEdit, type AceDriverOptions, type AnalystArtifact, type AnalystScenario, type ApplySkillPatchResult, type BuildAnalystSurfaceDispatchOptions, type CampaignBreakdown, CampaignResult, CampaignStorage, CodeSurface, type CompareDriversOptions, type DimensionRegression, DispatchContext, type DriverComparison, type DriverEntry, type DriverPairwise, type DriverScore, type FailureModeRecallJudgeOptions, FsLabeledScenarioStore, type FsLabeledScenarioStoreOptions, Gate, GenerationRecord, type GitWorktreeAdapterOptions, type HaloDriverOptions, type HeldoutSignificance, type HeldoutSignificanceOptions, ImprovementDriver, JudgeConfig, JudgeScore, LabelTrust, LabeledScenarioRecord, LabeledScenarioSampleArgs, LabeledScenarioSource, LabeledScenarioStore, LabeledScenarioStoreError, LabeledScenarioWrite, type MemoryCurationDriverOptions, MutableSurface, type OptimizerEntryConfig, type PairedHoldout, type PlaybackContext, type PlaybackDriver, type PlaybackStep, type ProfileDispatchFn, ProfileMatrixError, type ProfileSummary, ProposeContext, type ProposePatchesArgs, type RejectedEdit, RunCampaignOptions, RunImprovementLoopOptions, type RunProfileMatrixOptions, type RunProfileMatrixResult, type RunSkillOptOptions, type RunSkillOptResult, Scenario, type ScenarioRollup, type ScoreboardRenderOptions, type ScoreboardRow, type ScoreboardSummary, type SequentialDecideFn, type SequentialDecideOptions, type SequentialDecision, type SequentialObservation, type SequentialPairedGate, type SequentialPairedGateOptions, type SkillOptDriver, type SkillOptDriverOptions, type SkillOptEpochRecord, type SkillOptEvidence, type SkillPatch, type SkillPatchOp, SkillPatchParseError, type SkillPatchRejection, type TraceAnalystDriverOptions, type UserStory, type UserStoryVerdict, type Worktree, type WorktreeAdapter, WorktreeAdapterError, aceDriver, applySkillPatch, buildAnalystSurfaceDispatch, campaignBreakdown, campaignMeanComposite, compareDrivers, detectScale, dimensionRegressions, failureModeRecallJudge, gepaParetoEntry, gepaReflectionEntry, gitWorktreeAdapter, haloDriver, heldoutSignificance, makePlaybackDispatch, memoryCurationDriver, pairHoldout, parseSkillPatchResponse, patchEditCount, renderScoreboardMarkdown, resolveWorktreePath, runProfileMatrix, runSkillOpt, scoreUserStory, scoreboardSummary, sequentialDecide, sequentialPairedGate, skillOptDriver, skillOptEntry, traceAnalystDriver, userStoryScoreboard };
|
package/dist/campaign/index.js
CHANGED
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
paretoPolicy,
|
|
11
11
|
paretoSignificanceGate,
|
|
12
12
|
runEval
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-6SOJM3VR.js";
|
|
14
14
|
import {
|
|
15
15
|
agentProfileHash,
|
|
16
16
|
extractProducedState,
|
|
17
17
|
verifyCompletion
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-FIUKOSWI.js";
|
|
19
19
|
import {
|
|
20
20
|
buildLoopProvenanceRecord,
|
|
21
21
|
campaignBreakdown,
|
|
@@ -37,14 +37,14 @@ import {
|
|
|
37
37
|
runOptimization,
|
|
38
38
|
surfaceContentHash,
|
|
39
39
|
surfaceHash
|
|
40
|
-
} from "../chunk-
|
|
40
|
+
} from "../chunk-ZFIBGEOL.js";
|
|
41
41
|
import {
|
|
42
42
|
assertRealBackend,
|
|
43
43
|
fsCampaignStorage,
|
|
44
44
|
inMemoryCampaignStorage,
|
|
45
45
|
runCampaign,
|
|
46
46
|
summarizeBackendIntegrity
|
|
47
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-TWS7AZEY.js";
|
|
48
48
|
import {
|
|
49
49
|
estimateCost,
|
|
50
50
|
isModelPriced
|
|
@@ -53,24 +53,31 @@ import {
|
|
|
53
53
|
AnalystRegistry,
|
|
54
54
|
DEFAULT_TRACE_ANALYST_KINDS,
|
|
55
55
|
createTraceAnalystKind
|
|
56
|
-
} from "../chunk-
|
|
57
|
-
import "../chunk-
|
|
56
|
+
} from "../chunk-D3V5B42D.js";
|
|
57
|
+
import "../chunk-5HRORJQY.js";
|
|
58
58
|
import {
|
|
59
59
|
callLlm
|
|
60
60
|
} from "../chunk-CVVHBFGN.js";
|
|
61
|
+
import "../chunk-45EEMHTC.js";
|
|
61
62
|
import {
|
|
63
|
+
eProcess,
|
|
64
|
+
mulberry32,
|
|
62
65
|
pairedBootstrap
|
|
63
|
-
} from "../chunk-
|
|
66
|
+
} from "../chunk-LMZQ2Z4U.js";
|
|
64
67
|
import "../chunk-GGE4NNQT.js";
|
|
65
68
|
import {
|
|
66
|
-
OtlpFileTraceStore,
|
|
67
69
|
analyzeTraces
|
|
68
|
-
} from "../chunk-
|
|
70
|
+
} from "../chunk-UHMJT4T7.js";
|
|
71
|
+
import {
|
|
72
|
+
OtlpFileTraceStore
|
|
73
|
+
} from "../chunk-QAY5UIJO.js";
|
|
69
74
|
import "../chunk-PC4UYEBM.js";
|
|
70
75
|
import {
|
|
71
76
|
validateRunRecord
|
|
72
77
|
} from "../chunk-KWRRMR3J.js";
|
|
73
|
-
import
|
|
78
|
+
import {
|
|
79
|
+
canonicalize
|
|
80
|
+
} from "../chunk-VSMTAMNK.js";
|
|
74
81
|
import {
|
|
75
82
|
AgentEvalError
|
|
76
83
|
} from "../chunk-3BFEG2F6.js";
|
|
@@ -708,8 +715,274 @@ ${report.slice(0, 800)}`,
|
|
|
708
715
|
});
|
|
709
716
|
}
|
|
710
717
|
|
|
711
|
-
// src/campaign/
|
|
718
|
+
// src/campaign/gates/sequential.ts
|
|
712
719
|
import { createHash } from "crypto";
|
|
720
|
+
function verifyManifestSync(m) {
|
|
721
|
+
if (m.algo !== void 0 && m.algo !== "sha256-content") {
|
|
722
|
+
throw new Error(`sequentialPairedGate: unrecognized manifest hash algo '${m.algo}'`);
|
|
723
|
+
}
|
|
724
|
+
const { contentHash, algo: _algo, ...rest } = m;
|
|
725
|
+
void _algo;
|
|
726
|
+
const bytes = JSON.stringify(canonicalize(rest));
|
|
727
|
+
const hash = createHash("sha256").update(bytes, "utf8").digest("hex");
|
|
728
|
+
return hash === contentHash;
|
|
729
|
+
}
|
|
730
|
+
function resolveConfig(opts) {
|
|
731
|
+
const m = opts.preRegistration;
|
|
732
|
+
let alpha;
|
|
733
|
+
let maxN;
|
|
734
|
+
let direction;
|
|
735
|
+
let minEffect;
|
|
736
|
+
if (m) {
|
|
737
|
+
if (!verifyManifestSync(m)) {
|
|
738
|
+
throw new Error(
|
|
739
|
+
`sequentialPairedGate: pre-registration manifest '${m.id}' content hash mismatch (tampered)`
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
if (opts.alpha !== void 0 && opts.alpha !== m.alpha) {
|
|
743
|
+
throw new Error(
|
|
744
|
+
`sequentialPairedGate: alpha ${opts.alpha} conflicts with pre-registered alpha ${m.alpha} \u2014 the registered statistic is the only one anytime validity covers`
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
if (opts.maxN !== void 0 && opts.maxN !== m.preRegisteredN) {
|
|
748
|
+
throw new Error(
|
|
749
|
+
`sequentialPairedGate: maxN ${opts.maxN} conflicts with pre-registered N ${m.preRegisteredN}`
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
alpha = m.alpha;
|
|
753
|
+
maxN = m.preRegisteredN;
|
|
754
|
+
direction = m.direction;
|
|
755
|
+
minEffect = m.minEffect;
|
|
756
|
+
} else {
|
|
757
|
+
alpha = opts.alpha ?? 0.05;
|
|
758
|
+
if (opts.maxN === void 0) {
|
|
759
|
+
throw new Error(
|
|
760
|
+
"sequentialPairedGate: maxN is required (or bind a preRegistration manifest whose preRegisteredN is the budget) \u2014 an unbounded stream has no pre-registered budget"
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
maxN = opts.maxN;
|
|
764
|
+
direction = "increase";
|
|
765
|
+
minEffect = 0;
|
|
766
|
+
}
|
|
767
|
+
const scale = opts.scale ?? 1;
|
|
768
|
+
if (!Number.isFinite(scale) || scale <= 0) {
|
|
769
|
+
throw new Error(`sequentialPairedGate: scale must be > 0, got ${scale}`);
|
|
770
|
+
}
|
|
771
|
+
if (!Number.isInteger(maxN) || maxN < 1) {
|
|
772
|
+
throw new Error(`sequentialPairedGate: maxN must be a positive integer, got ${maxN}`);
|
|
773
|
+
}
|
|
774
|
+
const minN = opts.minN ?? 5;
|
|
775
|
+
if (!Number.isInteger(minN) || minN < 1 || minN > maxN) {
|
|
776
|
+
throw new Error(
|
|
777
|
+
`sequentialPairedGate: minN must be an integer in [1, maxN=${maxN}], got ${minN}`
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
if (!Number.isFinite(minEffect) || minEffect < 0 || minEffect >= scale) {
|
|
781
|
+
throw new Error(
|
|
782
|
+
`sequentialPairedGate: minEffect must be in [0, scale=${scale}), got ${minEffect}`
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
const nullMean = 0.5 + minEffect / (2 * scale);
|
|
786
|
+
return {
|
|
787
|
+
alpha,
|
|
788
|
+
minN,
|
|
789
|
+
maxN,
|
|
790
|
+
maxBet: opts.maxBet ?? 0.5,
|
|
791
|
+
scale,
|
|
792
|
+
shuffleSeed: opts.shuffleSeed ?? 1337,
|
|
793
|
+
direction,
|
|
794
|
+
nullMean,
|
|
795
|
+
minEffect
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function makeStream(cfg) {
|
|
799
|
+
const proc = eProcess({ alpha: cfg.alpha, maxBet: cfg.maxBet, nullMean: cfg.nullMean });
|
|
800
|
+
const threshold = 1 / cfg.alpha;
|
|
801
|
+
let terminal;
|
|
802
|
+
return {
|
|
803
|
+
observe(delta) {
|
|
804
|
+
if (terminal === "undecided-at-maxN") {
|
|
805
|
+
throw new Error(
|
|
806
|
+
`sequentialPairedGate: pre-registered maxN=${cfg.maxN} exhausted \u2014 extending the stream after seeing the result reopens optional stopping; start a NEW pre-registered test`
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
if (!Number.isFinite(delta) || Math.abs(delta) > cfg.scale) {
|
|
810
|
+
throw new Error(
|
|
811
|
+
`sequentialPairedGate: delta ${delta} outside \xB1scale=${cfg.scale} \u2014 pass the judge's native scale explicitly (detectScale helps pick 1 vs 100)`
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
const d = cfg.direction === "decrease" ? -delta : delta;
|
|
815
|
+
const step = proc.update((d / cfg.scale + 1) / 2);
|
|
816
|
+
if (terminal === void 0 && step.n >= cfg.minN && step.wealth >= threshold) {
|
|
817
|
+
terminal = "promote";
|
|
818
|
+
}
|
|
819
|
+
if (terminal === "promote") {
|
|
820
|
+
return {
|
|
821
|
+
decision: "promote",
|
|
822
|
+
eValue: step.wealth,
|
|
823
|
+
n: step.n,
|
|
824
|
+
reason: `e-value ${step.wealth.toFixed(2)} \u2265 1/\u03B1=${threshold.toFixed(2)} at n=${step.n} (minN=${cfg.minN}): the paired improvement exceeds ${cfg.minEffect} at anytime-valid level \u03B1=${cfg.alpha}`
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
if (step.n >= cfg.maxN) {
|
|
828
|
+
terminal = "undecided-at-maxN";
|
|
829
|
+
return {
|
|
830
|
+
decision: "undecided-at-maxN",
|
|
831
|
+
eValue: step.wealth,
|
|
832
|
+
n: step.n,
|
|
833
|
+
reason: `undecided at pre-registered maxN=${cfg.maxN} (e-value ${step.wealth.toFixed(2)} < 1/\u03B1=${threshold.toFixed(2)}). This is NOT evidence of no effect \u2014 the effect may be real but smaller than this budget can detect; re-register with a larger N to test that`
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
return {
|
|
837
|
+
decision: "continue",
|
|
838
|
+
eValue: step.wealth,
|
|
839
|
+
n: step.n,
|
|
840
|
+
reason: `e-value ${step.wealth.toFixed(2)} < 1/\u03B1=${threshold.toFixed(2)} at n=${step.n}/${cfg.maxN} \u2014 keep observing`
|
|
841
|
+
};
|
|
842
|
+
},
|
|
843
|
+
state() {
|
|
844
|
+
return { ...proc.state(), decision: terminal ?? "continue" };
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
function seededShuffle(items, seed) {
|
|
849
|
+
const rng = mulberry32(seed);
|
|
850
|
+
for (let i = items.length - 1; i > 0; i--) {
|
|
851
|
+
const j = Math.floor(rng() * (i + 1));
|
|
852
|
+
const tmp = items[i];
|
|
853
|
+
items[i] = items[j];
|
|
854
|
+
items[j] = tmp;
|
|
855
|
+
}
|
|
856
|
+
return items;
|
|
857
|
+
}
|
|
858
|
+
function sequentialPairedGate(options) {
|
|
859
|
+
const cfg = resolveConfig(options);
|
|
860
|
+
const name = options.name ?? "sequentialPairedGate";
|
|
861
|
+
const manifest = options.preRegistration;
|
|
862
|
+
const observeStream = makeStream(cfg);
|
|
863
|
+
return {
|
|
864
|
+
name,
|
|
865
|
+
observe(delta) {
|
|
866
|
+
return observeStream.observe(delta);
|
|
867
|
+
},
|
|
868
|
+
state() {
|
|
869
|
+
return observeStream.state();
|
|
870
|
+
},
|
|
871
|
+
async decide(ctx) {
|
|
872
|
+
if (!ctx.baselineJudgeScores) {
|
|
873
|
+
throw new Error(
|
|
874
|
+
`${name}: ctx.baselineJudgeScores is required \u2014 falling back to the candidate's own scores would compare the candidate against itself (delta 0, silent no-op)`
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
const scenarioIds = new Set(ctx.scenarios.map((s) => s.id));
|
|
878
|
+
const paired = pairHoldout(
|
|
879
|
+
ctx.judgeScores,
|
|
880
|
+
ctx.baselineJudgeScores,
|
|
881
|
+
scenarioIds,
|
|
882
|
+
(s) => s.composite
|
|
883
|
+
);
|
|
884
|
+
const deltas = paired.after.map((a, i) => a - paired.before[i]);
|
|
885
|
+
seededShuffle(deltas, cfg.shuffleSeed);
|
|
886
|
+
const stream = makeStream(cfg);
|
|
887
|
+
let last;
|
|
888
|
+
for (const d of deltas) {
|
|
889
|
+
last = stream.observe(d);
|
|
890
|
+
if (last.decision !== "continue") break;
|
|
891
|
+
}
|
|
892
|
+
const detail = {
|
|
893
|
+
...stream.state(),
|
|
894
|
+
minN: cfg.minN,
|
|
895
|
+
maxN: cfg.maxN,
|
|
896
|
+
scale: cfg.scale,
|
|
897
|
+
shuffleSeed: cfg.shuffleSeed,
|
|
898
|
+
direction: cfg.direction,
|
|
899
|
+
minEffect: cfg.minEffect,
|
|
900
|
+
pairedN: deltas.length,
|
|
901
|
+
preRegisteredId: manifest?.id,
|
|
902
|
+
metric: manifest?.metric
|
|
903
|
+
};
|
|
904
|
+
const meanDelta = deltas.length === 0 ? void 0 : deltas.reduce((s, d) => s + d, 0) / deltas.length;
|
|
905
|
+
if (last === void 0) {
|
|
906
|
+
return {
|
|
907
|
+
decision: "need_more_work",
|
|
908
|
+
reasons: [`${name}: no paired holdout observations \u2014 nothing to test`],
|
|
909
|
+
contributingGates: [{ name, passed: false, detail }]
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
const decision = last.decision === "promote" ? "ship" : last.decision === "continue" ? "need_more_work" : "hold";
|
|
913
|
+
return {
|
|
914
|
+
decision,
|
|
915
|
+
reasons: [`${name}: ${last.reason}`],
|
|
916
|
+
contributingGates: [{ name, passed: decision === "ship", detail }],
|
|
917
|
+
delta: meanDelta
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
function sequentialDecide(options = {}) {
|
|
923
|
+
const alpha = options.alpha ?? 0.05;
|
|
924
|
+
const minN = options.minN ?? 5;
|
|
925
|
+
const scale = options.scale ?? 1;
|
|
926
|
+
if (!Number.isFinite(scale) || scale <= 0) {
|
|
927
|
+
throw new Error(`sequentialDecide: scale must be > 0, got ${scale}`);
|
|
928
|
+
}
|
|
929
|
+
const proc = eProcess({ alpha, maxBet: options.maxBet ?? 0.5, nullMean: 0.5 });
|
|
930
|
+
const threshold = 1 / alpha;
|
|
931
|
+
let processedGenerations = 0;
|
|
932
|
+
let reference;
|
|
933
|
+
let stopped;
|
|
934
|
+
const topCandidate = (record) => {
|
|
935
|
+
if (record.candidates.length === 0) {
|
|
936
|
+
throw new Error(
|
|
937
|
+
`sequentialDecide: generation ${record.generationIndex} has no candidates \u2014 cannot extract a top candidate`
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
return record.candidates.reduce((best, c) => c.composite > best.composite ? c : best);
|
|
941
|
+
};
|
|
942
|
+
const decide = ({ history }) => {
|
|
943
|
+
if (stopped) return stopped;
|
|
944
|
+
if (history.length === 0) return { stop: false };
|
|
945
|
+
if (reference === void 0) {
|
|
946
|
+
reference = new Map(
|
|
947
|
+
topCandidate(history[0]).scenarios.map((s) => [s.scenarioId, s.composite])
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
for (let g = Math.max(1, processedGenerations); g < history.length; g++) {
|
|
951
|
+
const top = topCandidate(history[g]);
|
|
952
|
+
const byScenario = new Map(top.scenarios.map((s) => [s.scenarioId, s.composite]));
|
|
953
|
+
for (const [scenarioId, refComposite] of reference) {
|
|
954
|
+
const candComposite = byScenario.get(scenarioId);
|
|
955
|
+
if (candComposite === void 0) {
|
|
956
|
+
throw new Error(
|
|
957
|
+
`sequentialDecide: generation ${history[g].generationIndex} top candidate is missing scenario '${scenarioId}' \u2014 generations must score the same scenario set to pair`
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
const delta = candComposite - refComposite;
|
|
961
|
+
if (!Number.isFinite(delta) || Math.abs(delta) > scale) {
|
|
962
|
+
throw new Error(
|
|
963
|
+
`sequentialDecide: paired delta ${delta} outside \xB1scale=${scale} on scenario '${scenarioId}' \u2014 pass the composite scale explicitly`
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
const step = proc.update((delta / scale + 1) / 2);
|
|
967
|
+
if (step.n >= minN && step.wealth >= threshold) {
|
|
968
|
+
stopped = {
|
|
969
|
+
stop: true,
|
|
970
|
+
reason: `sequential e-process decided at generation ${history[g].generationIndex}: e-value ${step.wealth.toFixed(2)} \u2265 1/\u03B1=${threshold.toFixed(2)} after n=${step.n} paired deltas vs the generation-0 incumbent \u2014 the improvement is real at \u03B1=${alpha}; stop exploring and promote via the gate`
|
|
971
|
+
};
|
|
972
|
+
processedGenerations = history.length;
|
|
973
|
+
return stopped;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
processedGenerations = history.length;
|
|
978
|
+
return { stop: false };
|
|
979
|
+
};
|
|
980
|
+
decide.state = () => proc.state();
|
|
981
|
+
return decide;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// src/campaign/labeled-store/fs-adapter.ts
|
|
985
|
+
import { createHash as createHash2 } from "crypto";
|
|
713
986
|
import { existsSync, mkdirSync, readFileSync, writeFileSync as writeFileSync2 } from "fs";
|
|
714
987
|
import { join as join2 } from "path";
|
|
715
988
|
var LabeledScenarioStoreError = class extends Error {
|
|
@@ -908,7 +1181,7 @@ function matchesFilter(record, args, source) {
|
|
|
908
1181
|
return true;
|
|
909
1182
|
}
|
|
910
1183
|
function sha256(input) {
|
|
911
|
-
return
|
|
1184
|
+
return createHash2("sha256").update(input).digest("hex").slice(0, 16);
|
|
912
1185
|
}
|
|
913
1186
|
function appendLine(path, line) {
|
|
914
1187
|
if (existsSync(path)) {
|
|
@@ -1364,7 +1637,7 @@ function renderScoreboardMarkdown(rows, opts = {}) {
|
|
|
1364
1637
|
}
|
|
1365
1638
|
|
|
1366
1639
|
// src/campaign/presets/run-profile-matrix.ts
|
|
1367
|
-
import { createHash as
|
|
1640
|
+
import { createHash as createHash3 } from "crypto";
|
|
1368
1641
|
import { join as join3 } from "path";
|
|
1369
1642
|
var ProfileMatrixError = class extends AgentEvalError {
|
|
1370
1643
|
constructor(message) {
|
|
@@ -1375,7 +1648,7 @@ function sanitize(id) {
|
|
|
1375
1648
|
return id.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1376
1649
|
}
|
|
1377
1650
|
function sha(input) {
|
|
1378
|
-
return
|
|
1651
|
+
return createHash3("sha256").update(JSON.stringify(input)).digest("hex");
|
|
1379
1652
|
}
|
|
1380
1653
|
function mean2(xs) {
|
|
1381
1654
|
return xs.length === 0 ? 0 : xs.reduce((a, b) => a + b, 0) / xs.length;
|
|
@@ -1700,6 +1973,8 @@ export {
|
|
|
1700
1973
|
runSkillOpt,
|
|
1701
1974
|
scoreUserStory,
|
|
1702
1975
|
scoreboardSummary,
|
|
1976
|
+
sequentialDecide,
|
|
1977
|
+
sequentialPairedGate,
|
|
1703
1978
|
skillOptDriver,
|
|
1704
1979
|
skillOptEntry,
|
|
1705
1980
|
surfaceContentHash,
|