@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.
Files changed (140) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/adapters/http.d.ts +3 -3
  3. package/dist/adapters/langchain.d.ts +3 -3
  4. package/dist/adapters/otel.d.ts +6 -6
  5. package/dist/adversarial-DIVcDoI_.d.ts +88 -0
  6. package/dist/analyst/index.d.ts +11 -10
  7. package/dist/analyst/index.js +13 -8
  8. package/dist/analyst/index.js.map +1 -1
  9. package/dist/analyze-runs-DwCEkpO_.d.ts +81 -0
  10. package/dist/belief-state/index.d.ts +4 -4
  11. package/dist/belief-state/index.js +1 -1
  12. package/dist/benchmarks/index.d.ts +3 -3
  13. package/dist/campaign/index.d.ts +165 -18
  14. package/dist/campaign/index.js +289 -14
  15. package/dist/campaign/index.js.map +1 -1
  16. package/dist/chunk-45EEMHTC.js +35 -0
  17. package/dist/chunk-45EEMHTC.js.map +1 -0
  18. package/dist/{chunk-FZWAFVAA.js → chunk-4FBZZIYD.js} +2 -2
  19. package/dist/{chunk-YV7J7X5N.js → chunk-5HRORJQY.js} +22 -12
  20. package/dist/chunk-5HRORJQY.js.map +1 -0
  21. package/dist/{chunk-OTYQPHPL.js → chunk-6SOJM3VR.js} +5 -5
  22. package/dist/chunk-BOD4O7OF.js +40 -0
  23. package/dist/chunk-BOD4O7OF.js.map +1 -0
  24. package/dist/{chunk-Z7VFTS2J.js → chunk-CY6U5S3X.js} +2 -2
  25. package/dist/{chunk-VIDQF3F5.js → chunk-D3V5B42D.js} +5 -34
  26. package/dist/chunk-D3V5B42D.js.map +1 -0
  27. package/dist/{chunk-YGYXHNAQ.js → chunk-FIUKOSWI.js} +21 -8
  28. package/dist/chunk-FIUKOSWI.js.map +1 -0
  29. package/dist/{chunk-WJL2NJXN.js → chunk-GSH6QNNS.js} +2 -2
  30. package/dist/{chunk-RBNA5AZT.js → chunk-L3JOU6XM.js} +2 -2
  31. package/dist/{chunk-IDVBLYCY.js → chunk-LMZQ2Z4U.js} +56 -2
  32. package/dist/{chunk-IDVBLYCY.js.map → chunk-LMZQ2Z4U.js.map} +1 -1
  33. package/dist/{chunk-VUINJM5M.js → chunk-QAY5UIJO.js} +2 -193
  34. package/dist/chunk-QAY5UIJO.js.map +1 -0
  35. package/dist/{chunk-P2J6SOXT.js → chunk-QG2OVF2D.js} +5 -3
  36. package/dist/{chunk-P2J6SOXT.js.map → chunk-QG2OVF2D.js.map} +1 -1
  37. package/dist/chunk-REVYNR6C.js +100 -0
  38. package/dist/chunk-REVYNR6C.js.map +1 -0
  39. package/dist/chunk-STGVSCDH.js +202 -0
  40. package/dist/chunk-STGVSCDH.js.map +1 -0
  41. package/dist/{chunk-ZZ2HOPME.js → chunk-TWS7AZEY.js} +2 -2
  42. package/dist/chunk-UHMJT4T7.js +200 -0
  43. package/dist/chunk-UHMJT4T7.js.map +1 -0
  44. package/dist/chunk-UMMZHCPB.js +190 -0
  45. package/dist/chunk-UMMZHCPB.js.map +1 -0
  46. package/dist/chunk-VZSRQ272.js +149 -0
  47. package/dist/chunk-VZSRQ272.js.map +1 -0
  48. package/dist/{chunk-L5G7OUKD.js → chunk-XY4DDNEG.js} +8 -190
  49. package/dist/chunk-XY4DDNEG.js.map +1 -0
  50. package/dist/chunk-Y47J2LJ3.js +859 -0
  51. package/dist/chunk-Y47J2LJ3.js.map +1 -0
  52. package/dist/{chunk-BABOZOSN.js → chunk-ZFIBGEOL.js} +3 -3
  53. package/dist/chunk-ZFIBGEOL.js.map +1 -0
  54. package/dist/{code-agent-session-BRXmavYv.d.ts → code-agent-session-BO8nCnv3.d.ts} +1 -1
  55. package/dist/contract/index.d.ts +24 -95
  56. package/dist/contract/index.js +25 -764
  57. package/dist/contract/index.js.map +1 -1
  58. package/dist/{control-GeE8OhpN.d.ts → control-_Qb7skHX.d.ts} +2 -2
  59. package/dist/control.d.ts +5 -5
  60. package/dist/corpus-BoR-041R.d.ts +560 -0
  61. package/dist/cost-ledger-DuSqlw5B.d.ts +113 -0
  62. package/dist/counterfactual-Dwibr5IW.d.ts +85 -0
  63. package/dist/{dataset-B2kL-fSM.d.ts → dataset-BbGkaN2I.d.ts} +1 -1
  64. package/dist/{registry-DrEQ3Luj.d.ts → default-registry-zoGHUQEH.d.ts} +29 -2
  65. package/dist/diagnose.d.ts +251 -0
  66. package/dist/diagnose.js +381 -0
  67. package/dist/diagnose.js.map +1 -0
  68. package/dist/{errors-Dwqw-T_m.d.ts → errors-CzMUYo7b.d.ts} +1 -1
  69. package/dist/{feedback-trajectory-B3rErRsh.d.ts → feedback-trajectory-D9OVLrg9.d.ts} +1 -1
  70. package/dist/fuzz.d.ts +484 -0
  71. package/dist/fuzz.js +613 -0
  72. package/dist/fuzz.js.map +1 -0
  73. package/dist/governance/index.d.ts +4 -4
  74. package/dist/hosted/index.d.ts +6 -6
  75. package/dist/{index-DE3RXAXD.d.ts → index-Bx3gZ8xl.d.ts} +1 -1
  76. package/dist/index.d.ts +718 -455
  77. package/dist/index.js +1604 -793
  78. package/dist/index.js.map +1 -1
  79. package/dist/{insight-report-3ADTfClO.d.ts → insight-report-BBwvOh6x.d.ts} +2 -2
  80. package/dist/{integrity-CJzrpUua.d.ts → integrity-VJ9A7aST.d.ts} +1 -1
  81. package/dist/{judge-calibration-DilmB3Ml.d.ts → judge-calibration-0p2QcWNE.d.ts} +1 -1
  82. package/dist/{kind-factory-CVecZZG_.d.ts → kind-factory-5b7xXXOr.d.ts} +2 -2
  83. package/dist/{llm-client-CuUg2Mn3.d.ts → llm-client-BeEcAokY.d.ts} +1 -1
  84. package/dist/matrix/index.d.ts +2 -2
  85. package/dist/meta-eval/index.d.ts +177 -3
  86. package/dist/meta-eval/index.js +260 -1
  87. package/dist/meta-eval/index.js.map +1 -1
  88. package/dist/{multi-layer-verifier-DlWCXuxL.d.ts → multi-layer-verifier-DUZXrPDA.d.ts} +7 -1
  89. package/dist/multishot/index.d.ts +25 -11
  90. package/dist/multishot/index.js +36 -7
  91. package/dist/multishot/index.js.map +1 -1
  92. package/dist/openapi.json +1 -1
  93. package/dist/perf/index.d.ts +123 -0
  94. package/dist/perf/index.js +18 -0
  95. package/dist/pipelines/index.js +2 -2
  96. package/dist/{agent-profile-D0PBIWlV.d.ts → pre-registration-DELOEJ8v.d.ts} +144 -4
  97. package/dist/{provenance-DPpNIOJD.d.ts → provenance-LnqRT0sS.d.ts} +5 -5
  98. package/dist/{red-team-DW9Ca_tj.d.ts → red-team-BXHil6c8.d.ts} +1 -1
  99. package/dist/{release-report-hlNtD12q.d.ts → release-report-euXIV_Sk.d.ts} +3 -3
  100. package/dist/reporting.d.ts +8 -8
  101. package/dist/reporting.js +3 -3
  102. package/dist/{researcher-BLPHBbNV.d.ts → researcher-DE6Gpnb4.d.ts} +4 -4
  103. package/dist/rl.d.ts +194 -656
  104. package/dist/rl.js +231 -149
  105. package/dist/rl.js.map +1 -1
  106. package/dist/{rubric-predictive-validity-CnEl9Jc8.d.ts → rubric-predictive-validity-Cy_W-hWZ.d.ts} +1 -1
  107. package/dist/{run-campaign-4Y5V5CN3.js → run-campaign-RDGAM5KJ.js} +3 -3
  108. package/dist/run-campaign-RDGAM5KJ.js.map +1 -0
  109. package/dist/{run-improvement-loop-CNqQckTj.d.ts → run-improvement-loop-5z_l5zDz.d.ts} +2 -2
  110. package/dist/{run-record-De9VarXR.d.ts → run-record-e7vj1uZQ.d.ts} +1 -1
  111. package/dist/{runtime-trajectory-BLRiaifm.d.ts → runtime-trajectory-BDgfGZSr.d.ts} +1 -1
  112. package/dist/{semantic-concept-judge-DIEgr_6v.d.ts → semantic-concept-judge-Dn8Z6KEG.d.ts} +5 -31
  113. package/dist/series-convergence-D5OWMBg6.d.ts +33 -0
  114. package/dist/{statistics-CnC1FMbx.d.ts → statistics-C7PozGrZ.d.ts} +71 -2
  115. package/dist/{summary-report-Db0dDSWP.d.ts → summary-report-DGmUucwQ.d.ts} +1 -1
  116. package/dist/traces.d.ts +3 -3
  117. package/dist/traces.js +8 -6
  118. package/dist/{types-Cu3u_x59.d.ts → types-2VVIL04s.d.ts} +2 -2
  119. package/dist/{types-D7lLRYe9.d.ts → types-BU-7W85F.d.ts} +21 -1
  120. package/dist/{types-CqPax19X.d.ts → types-mn5Aqk7x.d.ts} +1 -1
  121. package/dist/{verdict-CeEgtjyI.d.ts → verdict-C9MlYujm.d.ts} +3 -0
  122. package/dist/wire/index.d.ts +3 -3
  123. package/dist/workflow/index.d.ts +12 -11
  124. package/dist/workflow/index.js +1 -1
  125. package/package.json +16 -1
  126. package/dist/chunk-BABOZOSN.js.map +0 -1
  127. package/dist/chunk-L5G7OUKD.js.map +0 -1
  128. package/dist/chunk-SHTXZ4O2.js +0 -113
  129. package/dist/chunk-SHTXZ4O2.js.map +0 -1
  130. package/dist/chunk-VIDQF3F5.js.map +0 -1
  131. package/dist/chunk-VUINJM5M.js.map +0 -1
  132. package/dist/chunk-YGYXHNAQ.js.map +0 -1
  133. package/dist/chunk-YV7J7X5N.js.map +0 -1
  134. /package/dist/{chunk-FZWAFVAA.js.map → chunk-4FBZZIYD.js.map} +0 -0
  135. /package/dist/{chunk-OTYQPHPL.js.map → chunk-6SOJM3VR.js.map} +0 -0
  136. /package/dist/{chunk-Z7VFTS2J.js.map → chunk-CY6U5S3X.js.map} +0 -0
  137. /package/dist/{chunk-WJL2NJXN.js.map → chunk-GSH6QNNS.js.map} +0 -0
  138. /package/dist/{chunk-RBNA5AZT.js.map → chunk-L3JOU6XM.js.map} +0 -0
  139. /package/dist/{chunk-ZZ2HOPME.js.map → chunk-TWS7AZEY.js.map} +0 -0
  140. /package/dist/{run-campaign-4Y5V5CN3.js.map → perf/index.js.map} +0 -0
package/dist/fuzz.d.ts ADDED
@@ -0,0 +1,484 @@
1
+ import { C as CostLedger, a as CostChannel } from './cost-ledger-DuSqlw5B.js';
2
+ import { D as DefaultVerdict } from './verdict-C9MlYujm.js';
3
+ import { A as AdversarialMutation } from './adversarial-DIVcDoI_.js';
4
+
5
+ /**
6
+ * Behavior-space exploration — types.
7
+ *
8
+ * One engine searches a space of inputs against a target, scores each run with a
9
+ * multi-objective verdict, keeps a quality-diversity archive, and admits only
10
+ * findings that pass the validity gates. Adversarial fuzzing is the headline
11
+ * preset (`fuzzAgent`); swapping the `Objective` re-points the same engine at
12
+ * novelty search, curriculum growth, or user-simulation.
13
+ *
14
+ * Two kinds of coordinates, deliberately distinct:
15
+ * - INPUT axes (`space.axes`) are the stratification plan — enumerable up front,
16
+ * so allocation and the coverage denominator (planned vs covered) are honest.
17
+ * - MEASURED descriptors (`descriptor(scenario, ev)`) are read off the rollout —
18
+ * they bin the archive by what the agent DID, and never inflate the coverage
19
+ * denominator (a behavior you haven't seen yet is not a planned cell).
20
+ *
21
+ * An `Evaluation` IS a `DefaultVerdict` — same spine as judges and verifiers,
22
+ * never a parallel score shape.
23
+ */
24
+
25
+ /** One input axis of the stratification plan (e.g. matterType, difficulty, personaRigor). */
26
+ interface SpaceAxis {
27
+ name: string;
28
+ values: string[];
29
+ }
30
+ /** The input space to stratify. Cells are the cartesian product of the axes. */
31
+ interface BehaviorSpace {
32
+ axes: SpaceAxis[];
33
+ }
34
+ /** One input cell: a coordinate in the stratification plan. */
35
+ interface Cell {
36
+ /** Stable id, e.g. `matterType=nda|difficulty=hard`. */
37
+ id: string;
38
+ coords: Record<string, string>;
39
+ }
40
+ /**
41
+ * The outcome of running the target against one scenario: a `DefaultVerdict`
42
+ * (`valid`, headline `score` in [0,1], per-dimension `scores`, `notes`) plus the
43
+ * fields exploration needs. Keep `scores` populated — the coverage map surfaces
44
+ * WHICH dimension is weak only when evaluations carry it.
45
+ */
46
+ interface Evaluation extends DefaultVerdict {
47
+ /** Measured behavior coordinates (e.g. `{ outcome: 'refused' }`). Bins the archive. */
48
+ descriptor?: Record<string, string>;
49
+ /** Surfaced output — drives exemplars + minimization. */
50
+ output?: string;
51
+ /** RunRecord id when the target persisted a trace. */
52
+ runId?: string;
53
+ /** Structured labels, e.g. failure classes (`hallucination`, `refusal`). */
54
+ labels?: string[];
55
+ }
56
+ /** Run the target against one scenario in a cell. */
57
+ type Evaluator<S> = (scenario: S, cell: Cell) => Promise<Evaluation>;
58
+ /** Context a proposer sees — prior elites + findings let a skill-backed proposer steer. */
59
+ interface ProposeContext<S> {
60
+ cell: Cell;
61
+ seeds: S[];
62
+ /** Current archive elites whose input cell matches. */
63
+ elites: S[];
64
+ /** Verified findings so far (read-only) — probe new gaps, not re-found ones. */
65
+ findings: ReadonlyArray<Finding<S>>;
66
+ /** How many candidates to propose. */
67
+ count: number;
68
+ rng: () => number;
69
+ }
70
+ /**
71
+ * Produces candidate scenarios for a cell. A plain function — `mutationProposer`
72
+ * builds one from mutation operators; an agent running a generator skill IS one
73
+ * (`(ctx) => dispatchToSkill(ctx)`), no wrapper needed.
74
+ */
75
+ type Proposer<S> = (ctx: ProposeContext<S>) => Promise<S[]> | S[];
76
+ /**
77
+ * What "interesting" means. `interest` in [0,1]; a candidate is notable (gate-
78
+ * checked, reported) when `interest >= threshold`. `adversarialObjective` (low
79
+ * score is interesting) and `noveltyObjective` (far from the archive) ship.
80
+ */
81
+ interface Objective {
82
+ kind: string;
83
+ interest(ev: Evaluation, ctx: ObjectiveContext): number;
84
+ /** Default 0.5. */
85
+ threshold?: number;
86
+ }
87
+ interface ObjectiveContext {
88
+ archiveScores: number[];
89
+ archiveDescriptors: Array<Record<string, string> | undefined>;
90
+ }
91
+ /**
92
+ * Validity gates — the moat. A notable candidate is admitted ONLY when it is a
93
+ * fair, answerable task (`isValid`) AND reproduces under a meaning-preserving
94
+ * rephrase (`isUncontaminated`). Pass-through by default (testable without an
95
+ * LLM); live wiring supplies real gates.
96
+ */
97
+ interface ValidityGates<S> {
98
+ isValid?: (scenario: S, ev: Evaluation, cell: Cell) => boolean | Promise<boolean>;
99
+ isUncontaminated?: (scenario: S, ev: Evaluation, cell: Cell) => boolean | Promise<boolean>;
100
+ }
101
+ /** A gate-verified, minimized finding — the unit the capsule reports. */
102
+ interface Finding<S> {
103
+ id: string;
104
+ cell: Cell;
105
+ scenario: S;
106
+ /** The minimized trigger (== `scenario` when no minimizer is supplied). */
107
+ minimized: S;
108
+ /** Legible text of the minimized trigger, when `scenarioText` is supplied. */
109
+ text?: string;
110
+ /** The full multi-objective verdict. */
111
+ evaluation: Evaluation;
112
+ /** The objective's interest score that flagged it. */
113
+ interest: number;
114
+ /** Which objective flagged it. */
115
+ objective: string;
116
+ }
117
+ /** An archive elite — the most interesting scenario seen for one bin. */
118
+ interface ArchiveEntry<S> {
119
+ /** Input cell + measured descriptor coords combined, e.g. `difficulty=hard|outcome=refused`. */
120
+ binId: string;
121
+ cell: Cell;
122
+ scenario: S;
123
+ evaluation: Evaluation;
124
+ interest: number;
125
+ }
126
+ /** Per-INPUT-cell coverage — the planned-vs-covered map. */
127
+ interface CoverageCell {
128
+ cell: Cell;
129
+ runs: number;
130
+ /** Mean headline score in [0,1]; `null` when the cell was never run (honestly uncovered). */
131
+ robustness: number | null;
132
+ /** Fraction of runs the objective flagged as notable. */
133
+ findingRate: number;
134
+ /** Mean per-dimension scores — surfaces WHICH dimension is weak. */
135
+ dimensions: Record<string, number>;
136
+ }
137
+ /** The artifact every exploration produces. */
138
+ interface CapsuleData<S> {
139
+ target: string;
140
+ objective: string;
141
+ /** Stamped by the caller — the engine stays clock-free and deterministic. */
142
+ generatedAt?: string;
143
+ coverage: CoverageCell[];
144
+ /** Verified findings, sorted by descending interest. */
145
+ findings: Finding<S>[];
146
+ /** QD archive elites (binned by input × measured coords). */
147
+ archive: ArchiveEntry<S>[];
148
+ /** Post-harden lift, filled by a second pass after an improvement. */
149
+ lift?: {
150
+ before: number;
151
+ after: number;
152
+ verdict: string;
153
+ };
154
+ stats: {
155
+ totalRuns: number;
156
+ /** Input-cell denominator — the stratification plan. */
157
+ cellsTotal: number;
158
+ cellsCovered: number;
159
+ /** Distinct measured-descriptor bins observed (never part of the denominator). */
160
+ behaviorBinsObserved: number;
161
+ candidateFindings: number;
162
+ verifiedFindings: number;
163
+ meanRobustness: number;
164
+ /** Known dollars spent on this exploration's runs. Present only when cost
165
+ * tracking was wired (`costOf`) — absent means "not tracked", never $0. */
166
+ costUsd?: number;
167
+ /** Runs whose cost was unknown (`costOf` returned null) — counted apart,
168
+ * never folded into `costUsd` as a fabricated $0. */
169
+ costUnknownRuns?: number;
170
+ };
171
+ }
172
+ /**
173
+ * Known cost of one evaluated run. `model` attributes the spend in the ledger's
174
+ * per-model rollup; absent, the entry is labeled `unattributed` (the dollars are
175
+ * real either way — recorded as `actualCostUsd`, never an estimate).
176
+ */
177
+ interface RunCost {
178
+ usd: number;
179
+ model?: string;
180
+ }
181
+ type ExploreEvent<S> = {
182
+ type: 'cell-allocated';
183
+ cell: Cell;
184
+ count: number;
185
+ } | {
186
+ type: 'evaluated';
187
+ cell: Cell;
188
+ scenario: S;
189
+ evaluation: Evaluation;
190
+ } | {
191
+ type: 'finding';
192
+ finding: Finding<S>;
193
+ } | {
194
+ type: 'round';
195
+ runsUsed: number;
196
+ budget: number;
197
+ };
198
+ interface ExploreOptions<S> {
199
+ /** Name of the target under exploration — labels the capsule. */
200
+ target: string;
201
+ /** The input stratification plan. */
202
+ space: BehaviorSpace;
203
+ /** Candidate generator. */
204
+ proposer: Proposer<S>;
205
+ /** Runs the target → multi-objective `Evaluation`. */
206
+ evaluate: Evaluator<S>;
207
+ /** Seed corpus per cell. */
208
+ seedsFor: (cell: Cell) => S[] | Promise<S[]>;
209
+ /** Stable id for a scenario (dedup + lineage). */
210
+ scenarioId: (scenario: S) => string;
211
+ /** Human-legible text — drives capsule exemplars. */
212
+ scenarioText?: (scenario: S) => string;
213
+ /** Measured behavior coords appended to the archive bin. Default: input cell only. */
214
+ descriptor?: (scenario: S, ev: Evaluation) => Record<string, string>;
215
+ /** What "interesting" means. Default: `adversarialObjective(0.5)`. */
216
+ objective?: Objective;
217
+ /** Validity gates. Default pass-through. */
218
+ gates?: ValidityGates<S>;
219
+ /** Budget steering across input cells. `variance` chases uncertainty; `uniform` is the unsteered ablation baseline. Default `variance`. */
220
+ allocation?: 'variance' | 'uniform';
221
+ /** Total target evaluations. */
222
+ budget: number;
223
+ /** Minimum evaluations per input cell before steering. Default 2. */
224
+ floorPerCell?: number;
225
+ /** Shrink a notable scenario to its minimal trigger. Default: identity. */
226
+ minimize?: (scenario: S, evaluate: Evaluator<S>, cell: Cell) => Promise<S> | S;
227
+ /** Max concurrent `evaluate` calls. Default 1. */
228
+ concurrency?: number;
229
+ /** Cooperative cancellation. */
230
+ signal?: AbortSignal;
231
+ /** Progress stream. */
232
+ onProgress?: (event: ExploreEvent<S>) => void;
233
+ /** Deterministic seed. Default 1. */
234
+ seed?: number;
235
+ /**
236
+ * Cost of one evaluated run — consumer-supplied; the explorer cannot know
237
+ * token usage. Return null when the cost is unknown: the run is COUNTED in
238
+ * `stats.costUnknownRuns`, never folded into the total as $0. Required by
239
+ * every other cost option (`costBudgetUsd` / `ledger` / `onCost`).
240
+ */
241
+ costOf?: (scenario: S, cell: Cell, ev: Evaluation) => RunCost | null;
242
+ /**
243
+ * Hard dollar ceiling on accumulated KNOWN cost (same semantics as the
244
+ * control-runtime `budget.maxCostUsd`: nonnegative finite, the session stops
245
+ * once spent ≥ ceiling; no new evaluation starts after that). Unknown-cost
246
+ * runs do not consume budget — they are reported separately, so the ceiling
247
+ * is honest about what it can see.
248
+ */
249
+ costBudgetUsd?: number;
250
+ /**
251
+ * Sink for per-run cost entries — each known `costOf` result is recorded
252
+ * with channel 'agent' and `actualCostUsd` (token axes are zero: the
253
+ * explorer only sees dollars). Pass the program's shared `CostLedger` so
254
+ * `costReport` stamps fuzz spend alongside judge/analyst spend.
255
+ */
256
+ ledger?: CostLedger;
257
+ /** Observer fired for every known-cost run recorded. */
258
+ onCost?: (entry: {
259
+ usd: number;
260
+ channel: CostChannel;
261
+ }) => void;
262
+ }
263
+
264
+ /**
265
+ * Input-space tiling + coverage projection.
266
+ *
267
+ * Cells are the cartesian product of the input axes — the stratification plan,
268
+ * enumerable up front so the planned-vs-covered denominator is honest. Coverage
269
+ * is projected from the evaluation log: per cell, mean headline robustness, the
270
+ * mean of each scored dimension (so the map shows WHICH dimension is weak), and
271
+ * the rate at which the active objective flagged a candidate.
272
+ */
273
+
274
+ /** One recorded evaluation — the unit coverage and the capsule are built from. */
275
+ interface EvalRecord {
276
+ cell: Cell;
277
+ ev: Evaluation;
278
+ /** The objective's interest score for this evaluation. */
279
+ interest: number;
280
+ }
281
+ /** Enumerate every input cell (cartesian product of the axes), in stable order. */
282
+ declare function enumerateCells(space: BehaviorSpace): Cell[];
283
+ /** Deterministic id for a coordinate map, e.g. `matterType=nda|difficulty=hard`. */
284
+ declare function cellId(space: BehaviorSpace, coords: Record<string, string>): string;
285
+ /**
286
+ * Project the evaluation log into the per-input-cell coverage map. A cell with
287
+ * no evaluations reports `robustness: null` (honestly uncovered), never 0.
288
+ */
289
+ declare function buildCoverage(cells: Cell[], log: EvalRecord[], threshold: number): CoverageCell[];
290
+
291
+ /**
292
+ * The capsule — the artifact every exploration produces.
293
+ *
294
+ * `buildCapsule` assembles coverage + verified findings + the QD archive into a
295
+ * pure `CapsuleData` (no clock, no I/O — deterministic and snapshot-testable).
296
+ * `renderCapsuleHtml` turns it into a standalone page: the input-cell heat-map
297
+ * (planned vs covered), per-dimension weakness chips, and the minimized finding
298
+ * exemplars. One artifact — the hardening map and the shareable proof object.
299
+ */
300
+
301
+ interface BuildCapsuleInput<S> {
302
+ target: string;
303
+ objective: string;
304
+ cells: Cell[];
305
+ log: EvalRecord[];
306
+ /** The objective's notable threshold — drives findingRate. */
307
+ threshold: number;
308
+ archive: ArchiveEntry<S>[];
309
+ findings: Finding<S>[];
310
+ candidateFindings: number;
311
+ runsUsed: number;
312
+ /** Known-dollar / unknown-run split — present only when cost tracking was
313
+ * wired; the capsule never fabricates a $0 total. */
314
+ cost?: {
315
+ costUsd: number;
316
+ costUnknownRuns: number;
317
+ };
318
+ }
319
+ declare function buildCapsule<S>(input: BuildCapsuleInput<S>): CapsuleData<S>;
320
+ interface RenderCapsuleOptions {
321
+ /** Max finding exemplars to show. Default 8. */
322
+ maxFindings?: number;
323
+ /** ISO timestamp to stamp into the page (keeps the pure capsule clock-free). */
324
+ generatedAt?: string;
325
+ }
326
+ /** Render a self-contained HTML capsule — heat-map + per-dimension chips + verified findings. */
327
+ declare function renderCapsuleHtml<S>(capsule: CapsuleData<S>, opts?: RenderCapsuleOptions): string;
328
+
329
+ /**
330
+ * The exploration engine — a stateful session over a behavior space.
331
+ *
332
+ * Each `step()`: allocate budget across INPUT cells (floor first, then variance
333
+ * steering toward the least-certain cells), propose candidates (the proposer
334
+ * reads current elites + findings, so the search deepens generationally),
335
+ * evaluate with bounded concurrency, archive the most interesting scenario per
336
+ * input×measured bin, and admit notable candidates that pass the validity gates.
337
+ * `run()` loops to budget. `coverage()`/`findings()`/`capsule()` read live state —
338
+ * the surface `makeExploreTools` exposes so an agent can drive the session.
339
+ *
340
+ * One evaluation log (`EvalRecord[]`) is the source of truth; allocation
341
+ * observations and coverage are projections of it.
342
+ */
343
+
344
+ declare class BehaviorExplorer<S> {
345
+ private readonly opts;
346
+ private readonly cells;
347
+ private readonly cellById;
348
+ private readonly objective;
349
+ private readonly threshold;
350
+ private readonly floorPerCell;
351
+ private readonly perRoundBudget;
352
+ /** The single evaluation log — coverage + allocation are projections of it. */
353
+ private readonly log;
354
+ /** binId (input × measured coords) → the most interesting entry seen. */
355
+ private readonly archiveByBin;
356
+ private readonly _findings;
357
+ private runsUsed;
358
+ private candidateFindings;
359
+ private rngState;
360
+ /** Accumulated KNOWN dollars — unknown-cost runs never inflate it. */
361
+ private spentKnownUsd;
362
+ private costUnknownRuns;
363
+ constructor(opts: ExploreOptions<S>);
364
+ private rng;
365
+ private binId;
366
+ private allocate;
367
+ private objectiveContext;
368
+ /** Mirrors control-runtime: stop once accumulated KNOWN cost ≥ the ceiling. */
369
+ private costExhausted;
370
+ /** Fold one run's cost in: null counts as unknown (never $0); a known cost
371
+ * accrues toward the budget, lands in the ledger, and fires `onCost`. */
372
+ private recordRunCost;
373
+ /** Elites whose INPUT cell matches — what the proposer mutates/deepens from. */
374
+ private elitesFor;
375
+ /** One allocate → propose → evaluate → gate → archive round. */
376
+ step(): Promise<{
377
+ runs: number;
378
+ findings: Finding<S>[];
379
+ }>;
380
+ /** Loop `step()` until the run or dollar budget is spent, the signal aborts,
381
+ * or no progress is made. */
382
+ run(): Promise<CapsuleData<S>>;
383
+ coverage(): CoverageCell[];
384
+ findings(): Finding<S>[];
385
+ capsule(): CapsuleData<S>;
386
+ }
387
+
388
+ /**
389
+ * `fuzzAgent` — the adversarial batch preset over `BehaviorExplorer`.
390
+ *
391
+ * One call: explore the space to budget with the adversarial objective and
392
+ * return the capsule. For agent-driven, incremental, or multi-objective use,
393
+ * construct a `BehaviorExplorer` and drive it via `makeExploreTools`.
394
+ */
395
+
396
+ type FuzzAgentOptions<S> = Omit<ExploreOptions<S>, 'objective'> & {
397
+ /** Score strictly below this is a candidate failure. Default 0.5. */
398
+ failureThreshold?: number;
399
+ };
400
+ declare function fuzzAgent<S>(opts: FuzzAgentOptions<S>): Promise<{
401
+ capsule: CapsuleData<S>;
402
+ }>;
403
+
404
+ /**
405
+ * Validity gates — what separates a fuzzer from a slop generator.
406
+ *
407
+ * A notable candidate is admitted only when it is fair and reproducible. None of
408
+ * these are on by default: the live wiring opts in, so reported findings carry
409
+ * their proof.
410
+ */
411
+
412
+ /** Combine gate sets; a candidate must pass every gate in every set. */
413
+ declare function composeGates<S>(...sets: Array<ValidityGates<S> | undefined>): ValidityGates<S>;
414
+ /**
415
+ * Reproducibility gate. Re-run the target on a meaning-preserving rephrase of the
416
+ * flagged scenario; keep the finding only when the rephrase ALSO scores below the
417
+ * threshold. A finding that flips under a cosmetic rewrite was keyed to surface
418
+ * form, not the task — a false signal we must not report. Costs one extra
419
+ * evaluation per candidate (candidates are rare, so cheap).
420
+ */
421
+ declare function perturbationStabilityGate<S>(opts: {
422
+ evaluate: Evaluator<S>;
423
+ /** Produce a semantic-preserving rephrase. Return null to skip (treated as pass). */
424
+ perturb: (scenario: S) => S | null;
425
+ /** Score strictly below this still counts as failing. Default 0.5. */
426
+ failureThreshold?: number;
427
+ }): ValidityGates<S>;
428
+ /**
429
+ * Severity-floor gate. Reject borderline candidates whose score sits in a band
430
+ * just under the threshold — judge noise, not a real defect.
431
+ */
432
+ declare function severityFloorGate<S>(opts: {
433
+ failureThreshold?: number;
434
+ margin?: number;
435
+ }): ValidityGates<S>;
436
+
437
+ /**
438
+ * Shipped policies for the exploration engine.
439
+ *
440
+ * `Proposer` is a plain function type — an agent running a generator skill IS a
441
+ * proposer (`(ctx) => dispatchToSkill(ctx)`), no wrapper needed. `mutationProposer`
442
+ * builds the deterministic, LLM-free one from mutation operators. Objectives are
443
+ * interfaces because the engine reads `kind` + `threshold` off them.
444
+ */
445
+
446
+ /**
447
+ * Perturbation-based search: apply the cell's mutation operators to the current
448
+ * elites + seeds, deduping by id. Elites first — mutating the most interesting
449
+ * scenario found so far is what makes the search deepen across rounds.
450
+ */
451
+ declare function mutationProposer<S>(opts: {
452
+ mutationsFor: (cell: Cell) => AdversarialMutation<S>[];
453
+ scenarioId: (s: S) => string;
454
+ }): Proposer<S>;
455
+ /** Adversarial: a low headline score is interesting — find where the agent fails. */
456
+ declare function adversarialObjective(threshold?: number): Objective;
457
+ /**
458
+ * Novelty: interesting when far from the archive in score AND measured behavior
459
+ * descriptor — quality-diversity's diversity pressure; drives corpus growth
460
+ * rather than re-finding the same hole.
461
+ */
462
+ declare function noveltyObjective(threshold?: number): Objective;
463
+
464
+ /**
465
+ * Agent-drivable surface over a live exploration session.
466
+ *
467
+ * Framework-neutral tool defs ({name, description, parameters: JSON Schema,
468
+ * handler}) so the on-demand agent — not a batch script — drives the search:
469
+ * step it, read coverage, inspect findings, render the capsule. Transport
470
+ * encodings (OpenAI function shape, MCP) are one-line mappings the host owns.
471
+ */
472
+
473
+ interface ExploreToolDef {
474
+ name: string;
475
+ description: string;
476
+ /** JSON Schema (draft-07+) for the arguments. */
477
+ parameters: Record<string, unknown>;
478
+ handler: (args: unknown, ctx?: {
479
+ signal?: AbortSignal;
480
+ }) => Promise<unknown>;
481
+ }
482
+ declare function makeExploreTools<S>(explorer: BehaviorExplorer<S>): ExploreToolDef[];
483
+
484
+ export { type ArchiveEntry, BehaviorExplorer, type BehaviorSpace, type BuildCapsuleInput, type CapsuleData, type Cell, type CoverageCell, type EvalRecord, type Evaluation, type Evaluator, type ExploreEvent, type ExploreOptions, type ExploreToolDef, type Finding, type FuzzAgentOptions, type Objective, type ObjectiveContext, type ProposeContext, type Proposer, type RenderCapsuleOptions, type RunCost, type SpaceAxis, type ValidityGates, adversarialObjective, buildCapsule, buildCoverage, cellId, composeGates, enumerateCells, fuzzAgent, makeExploreTools, mutationProposer, noveltyObjective, perturbationStabilityGate, renderCapsuleHtml, severityFloorGate };