@tangle-network/agent-eval 0.119.0 → 0.120.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 (55) hide show
  1. package/CHANGELOG.md +25 -3
  2. package/README.md +0 -26
  3. package/dist/analyst/index.d.ts +30 -39
  4. package/dist/analyst/index.js +9 -5
  5. package/dist/analyst/index.js.map +1 -1
  6. package/dist/benchmarks/index.d.ts +11 -5
  7. package/dist/benchmarks/index.js +7 -7
  8. package/dist/campaign/index.d.ts +121 -66
  9. package/dist/campaign/index.js +26 -10
  10. package/dist/{chunk-RLCJQ6VZ.js → chunk-32BZXMSO.js} +385 -120
  11. package/dist/chunk-32BZXMSO.js.map +1 -0
  12. package/dist/{chunk-XJ7JVCHB.js → chunk-3A246TSA.js} +2 -2
  13. package/dist/{chunk-LMJ2TGWJ.js → chunk-JM2SKQMS.js} +2 -2
  14. package/dist/{chunk-F6YUH3L4.js → chunk-JN2FCO5W.js} +14 -168
  15. package/dist/chunk-JN2FCO5W.js.map +1 -0
  16. package/dist/{chunk-D7AEXSM5.js → chunk-PICTDURQ.js} +2 -2
  17. package/dist/{chunk-6QIM2EAP.js → chunk-PXD6ZFNY.js} +99 -1
  18. package/dist/chunk-PXD6ZFNY.js.map +1 -0
  19. package/dist/{chunk-GERDAIAL.js → chunk-QWMPPZ3X.js} +3 -3
  20. package/dist/{chunk-7A4LIMMY.js → chunk-S5TT5R3L.js} +229 -97
  21. package/dist/chunk-S5TT5R3L.js.map +1 -0
  22. package/dist/{chunk-ZYHJNKI3.js → chunk-ULOKLHIQ.js} +42 -5
  23. package/dist/chunk-ULOKLHIQ.js.map +1 -0
  24. package/dist/{chunk-FIUFRXP3.js → chunk-WW2A73HW.js} +49 -91
  25. package/dist/chunk-WW2A73HW.js.map +1 -0
  26. package/dist/{chunk-PAHNGS65.js → chunk-XDIRG3TO.js} +175 -11
  27. package/dist/chunk-XDIRG3TO.js.map +1 -0
  28. package/dist/contract/index.d.ts +76 -43
  29. package/dist/contract/index.js +596 -32
  30. package/dist/contract/index.js.map +1 -1
  31. package/dist/index.d.ts +92 -75
  32. package/dist/index.js +38 -35
  33. package/dist/index.js.map +1 -1
  34. package/dist/openapi.json +1 -1
  35. package/dist/rl.d.ts +11 -5
  36. package/dist/{run-campaign-OBXSN5WK.js → run-campaign-HNFPJET4.js} +2 -2
  37. package/dist/traces.d.ts +39 -25
  38. package/dist/traces.js +3 -5
  39. package/docs/trace-analysis.md +6 -2
  40. package/package.json +2 -7
  41. package/dist/chunk-6QIM2EAP.js.map +0 -1
  42. package/dist/chunk-7A4LIMMY.js.map +0 -1
  43. package/dist/chunk-F6YUH3L4.js.map +0 -1
  44. package/dist/chunk-FIUFRXP3.js.map +0 -1
  45. package/dist/chunk-PAHNGS65.js.map +0 -1
  46. package/dist/chunk-RLCJQ6VZ.js.map +0 -1
  47. package/dist/chunk-ZYHJNKI3.js.map +0 -1
  48. package/dist/primeintellect/index.d.ts +0 -311
  49. package/dist/primeintellect/index.js +0 -348
  50. package/dist/primeintellect/index.js.map +0 -1
  51. /package/dist/{chunk-XJ7JVCHB.js.map → chunk-3A246TSA.js.map} +0 -0
  52. /package/dist/{chunk-LMJ2TGWJ.js.map → chunk-JM2SKQMS.js.map} +0 -0
  53. /package/dist/{chunk-D7AEXSM5.js.map → chunk-PICTDURQ.js.map} +0 -0
  54. /package/dist/{chunk-GERDAIAL.js.map → chunk-QWMPPZ3X.js.map} +0 -0
  55. /package/dist/{run-campaign-OBXSN5WK.js.map → run-campaign-HNFPJET4.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,29 @@ All notable changes to `@tangle-network/agent-eval` and its sibling `agent-eval-
4
4
 
5
5
  ---
6
6
 
7
+ ## [0.120.0] — 2026-07-14 — exact measured provenance
8
+
9
+ ### Changed
10
+
11
+ - Give each campaign a canonical split digest over the full scenario payload and replicate count, and require the exported benchmark to identify that exact heldout design.
12
+ - Emit self-addressed `tangle.loop-provenance` records from one shared loop-result translator, and derive prompt or code diffs from the exact measured surfaces instead of accepting caller-authored text.
13
+ - Retain one strict hash per scenario so consumers can verify the tested split without persisting customer task payloads.
14
+
15
+ ### Breaking
16
+
17
+ - Require the exact baseline surface and bind portable evidence to every search, winner, heldout, and neutralized campaign; the full decision; the reconstructed receipt ledger; duration; power analysis; and validated candidate history.
18
+ - Require every scored row to link to a successful model receipt; reject contradictory provenance, duplicate scenarios, broken cell identity or pairing, failed judges, and invalid cost, latency, or token measurements before products can publish an improvement proposal.
19
+ - Stop optimization when a proposer returns no candidates, reject empty or non-contiguous generation records, and refuse a shipped no-op.
20
+ - Remove the duplicate worker-record collector and caller-authored diff hook; settled receipts and exact surfaces are now the only evidence path.
21
+ - Remove `@tangle-network/agent-eval/primeintellect`, which generated a legacy single-turn Verifiers package with unsafe substring scoring. Use `@tangle-network/agent-runtime/primeintellect` for task packaging, real runtime execution, and full trace import.
22
+ - Verify the same npm archive implementation used by the release workflow.
23
+
24
+ ## [0.119.1] — 2026-07-14 — portable improvement evidence
25
+
26
+ ### Added
27
+
28
+ - `measuredComparisonFromSelfImproveResult()` converts paired held-out quality, cost, latency, uncertainty, power, decision, and provenance into the shared `AgentImprovementMeasuredComparison` contract.
29
+
7
30
  ## [0.119.0] — 2026-07-14 — chained, metered trace analysis
8
31
 
9
32
  ### Added
@@ -121,8 +144,7 @@ All notable changes to `@tangle-network/agent-eval` and its sibling `agent-eval-
121
144
  - `runOptimization({ promoteTopK })` accepts only `1`; multiple concurrent incumbents were never represented by the optimizer state and now fail before dispatch.
122
145
  - `ScoredSurfaceOutcome` requires `split: 'search'` and the actual `generation` that measured the surface.
123
146
  - `llmPolicyEditProposer()` requires explicit raw-score objectives and `PolicyEditFindingInput` rows whose source is either an exact measured surface-generation pair or an explicitly global finding.
124
- - `LoopProvenanceRecord.schema` is now `tangle.loop-provenance.v3`.
125
- Consumers of v2 records must migrate to the v3 baseline score, parent chain, coverage, eligibility, and exact surface fields; no compatibility shim is provided.
147
+ - Loop provenance preserves complete candidate measurement lineage: baseline score, parent chain, coverage, eligibility, and exact surface fields.
126
148
 
127
149
  ## [0.115.3] — 2026-07-12 — fail-closed structured output parsing
128
150
 
@@ -186,7 +208,7 @@ Existing consumers do not need to update unless they want the new statistic.
186
208
  - `CodeSurface` is now a finalized, content-addressed code candidate.
187
209
  `gitWorktreeAdapter.finalize()` records exact base/candidate commits, the final tree, and the SHA-256 + byte length of the raw binary Git patch; `surfaceHash` and `surfaceContentHash` no longer use filesystem paths.
188
210
  Binary-patch generation runs against an isolated bare repository with fixed diff options, config, attributes, compression, and locale, so ambient repository, global, system, or environment settings cannot change the digest for identical trees.
189
- - `LoopProvenanceRecord.schema` is now `tangle.loop-provenance.v2`, distinguishing records that use content-addressed code-surface hashes from v1 records whose code hashes included mutable paths.
211
+ - Code-surface provenance now uses content-addressed hashes instead of mutable paths.
190
212
  - `resolveWorktreePath()` now verifies the candidate before returning its checkout.
191
213
  Dirty or ignored files, moved refs, missing objects, wrong trees, raw byte or executable-mode mismatches, external symlinks, submodules, and patch-byte mismatches fail instead of being evaluated under stale identity.
192
214
  Raw file hashing bypasses Git clean/smudge filters so repository configuration cannot hide different executable bytes.
package/README.md CHANGED
@@ -95,31 +95,6 @@ const traceRuns = fromOtelSpans({ spans: yourOtelSpans })
95
95
  await analyzeRuns({ runs: [...runs, ...traceRuns], raterScores })
96
96
  ```
97
97
 
98
- ### 4. Export to PrimeIntellect
99
-
100
- Use this when you want PrimeIntellect Verifiers to run or train against tasks produced by Tangle evals, runtime runs, or knowledge runs.
101
-
102
- ```ts
103
- import {
104
- primeIntellectRowsFromRunRecords,
105
- writePrimeIntellectEnvironmentPackage,
106
- } from '@tangle-network/agent-eval/primeintellect'
107
-
108
- const rows = primeIntellectRowsFromRunRecords({
109
- records, // RunRecord[] with scenarioId
110
- scenarios, // prompts plus answer or requiredSubstrings
111
- })
112
-
113
- await writePrimeIntellectEnvironmentPackage('prime-envs/refund-policy', {
114
- name: 'refund-policy',
115
- rows,
116
- runRecords: records,
117
- })
118
- ```
119
-
120
- The generated package contains `load_environment()`, `data/dataset.jsonl`, `data/run_records.jsonl`, and a manifest.
121
- Run it with `uv run vf-eval refund-policy` or upload it with `prime env push`.
122
-
123
98
  ---
124
99
 
125
100
  ## Core concepts
@@ -149,7 +124,6 @@ Each example: `README.md` + a single `index.ts` runnable via `pnpm tsx`. Prints
149
124
  |---|---|
150
125
  | `…/contract` | **The headline, frozen surface — new code starts here.** `defineAgentEval`, `selfImprove`, `analyzeRuns`, `runEval`, `runCampaign`, `runImprovementLoop`, `diffRuns`; intake adapters (`fromFeedbackTable`, `fromOtelSpans`); proposers (`gepaProposer`, `evolutionaryProposer`); gates (`defaultProductionGate`, `heldOutGate`, `paretoSignificanceGate`, `neutralizationGate`, `composeGate`); the deployment-outcome store; storage; and the five core types `Scenario` / `Dispatch` / `JudgeConfig` / `SurfaceProposer` / `Gate`. |
151
126
  | `…/hosted` | `createHostedClient` / `hostedClientFromEnv` + the wire types to ship eval-run events + trace spans to a hosted orchestrator (ours or your own implementation of the spec) |
152
- | `…/primeintellect` | Export validated `RunRecord`s plus scenario prompts into a PrimeIntellect Verifiers package: Python `load_environment()`, `data/dataset.jsonl`, `data/run_records.jsonl`, and export manifest |
153
127
  | `…/adapters/otel` | `createOtelBridge` — forwards OpenTelemetry-shape spans into the hosted-tier ingest, no `@opentelemetry/*` dependency |
154
128
  | `…/adapters/langchain` | Wrap any LangChain `Runnable` as a `Dispatch` (or `JudgeConfig`), no `@langchain/core` peer dep |
155
129
  | `…/adapters/http` | `httpDispatch` + `runDispatchServer` — run a campaign's worker on another machine (multi-region, remote worker execution) |
@@ -1,5 +1,5 @@
1
1
  import { TCloud } from '@tangle-network/tcloud';
2
- import { AxAIService, AxFunction } from '@ax-llm/ax';
2
+ import { AxAIArgs, AxAIService, AxFunction } from '@ax-llm/ax';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -1706,6 +1706,8 @@ interface AnalystCost {
1706
1706
  est_usd_per_run?: number;
1707
1707
  /** Models the analyst expects to use (informational). */
1708
1708
  models?: string[];
1709
+ /** Maximum post-cancellation wait for provider usage. Model analysts default to 5 seconds. */
1710
+ settlement_timeout_ms?: number;
1709
1711
  }
1710
1712
  interface AnalystRequirements {
1711
1713
  /** Min number of shots / samples the analyst needs to produce signal. */
@@ -1729,7 +1731,7 @@ interface AnalystContext {
1729
1731
  runId: string;
1730
1732
  /** Stable correlation id so logs from a single registry.run() share a tag. */
1731
1733
  correlationId: string;
1732
- /** Wall-clock deadline (epoch ms). Analysts SHOULD honor for graceful cancel. */
1734
+ /** Enforced wall-clock deadline (epoch ms). */
1733
1735
  deadlineMs?: number;
1734
1736
  /** Per-analyst USD budget. Analysts MAY check before issuing LLM calls. */
1735
1737
  budgetUsd?: number;
@@ -1965,11 +1967,13 @@ interface CreateAnalystAiConfig {
1965
1967
  apiKey: string;
1966
1968
  /** OpenAI-compatible base URL — e.g. `https://router.tangle.tools/v1` or a
1967
1969
  * cli-bridge loopback. */
1968
- baseUrl: string;
1969
- /** Model id forwarded to the analyst actor + responder. */
1970
+ baseUrl?: string;
1971
+ /** Additional headers required by the gateway, such as tenant or execution policy. */
1972
+ headers?: Record<string, string>;
1973
+ /** Model id forwarded to analyst calls. */
1970
1974
  model: string;
1971
1975
  /** Ax provider name. Defaults to the OpenAI-compatible client. */
1972
- provider?: 'openai' | 'anthropic';
1976
+ provider?: AxAIArgs<unknown>['name'];
1973
1977
  }
1974
1978
  /**
1975
1979
  * Construct the `AxAIService` an analyst kind calls through
@@ -2145,8 +2149,8 @@ declare function parseCanonicalRawFinding(row: unknown, log?: (msg: string, fiel
2145
2149
  * Analyst-kind factory — the typed way to define trace analysts.
2146
2150
  *
2147
2151
  * A "kind" is a specialized analyst whose actor prompt, tool subset,
2148
- * and Ax recursion config target one failure-mode lens (failure-mode
2149
- * classification, knowledge gap discovery, knowledge poisoning, recursive
2152
+ * and bounded Ax subqueries target one failure-mode lens (failure-mode
2153
+ * classification, knowledge gap discovery, knowledge poisoning,
2150
2154
  * self-improvement, ...). Kinds emit findings in the typed
2151
2155
  * `CanonicalRawAnalystFinding` shape via a JSON-array Ax output; the factory
2152
2156
  * validates each row with Zod and lifts it into `AnalystFinding[]`.
@@ -2157,12 +2161,11 @@ declare function parseCanonicalRawFinding(row: unknown, log?: (msg: string, fiel
2157
2161
  * - Each kind picks a narrow tool subset from `ANALYST_TOOL_GROUPS`.
2158
2162
  * A kind that never needs full-trace dumps can drop `viewTrace` /
2159
2163
  * `viewSpans` and stay cheap.
2160
- * - Each kind declares its recursion + parallelism budget. Discovery-
2161
- * heavy kinds (failure-mode) get higher `maxDepth`; lens kinds
2162
- * (poisoning) usually stay at 0 since they have a tighter brief.
2164
+ * - Each kind declares its subquery + parallelism budget. Discovery-heavy
2165
+ * kinds can fan out more bounded semantic questions than narrow lenses.
2163
2166
  *
2164
2167
  * Optimizer hook: kinds may declare `goldens` — labeled examples used
2165
- * by `AxMiPRO` / `AxBootstrapFewShot` / `AxGEPA` to fit the actor
2168
+ * by `AxBootstrapFewShot` / `AxGEPA` to fit the actor
2166
2169
  * description programmatically. Stored on the kind, not the registry,
2167
2170
  * because the right metric is kind-specific.
2168
2171
  */
@@ -2182,20 +2185,18 @@ interface TraceAnalystKindSpec {
2182
2185
  version: string;
2183
2186
  /** Actor system prompt. Must instruct the LLM to emit `findings` per the schema. */
2184
2187
  actorDescription: string;
2185
- /** Responder system prompt; falls back to a minimal "format the findings" instruction. */
2186
- responderDescription?: string;
2187
2188
  /** Tool functions the actor may call. Pick narrow subsets via `ANALYST_TOOL_GROUPS`. */
2188
2189
  buildTools: (store: TraceAnalysisStore) => AxFunction[];
2189
- /** Recursion budget. `maxDepth: 0` disables subagents. */
2190
- recursion?: {
2191
- maxDepth: number;
2192
- maxParallelSubagents?: number;
2190
+ /** Bounded semantic subqueries. `maxCalls: 0` disables model fan-out. */
2191
+ subqueries?: {
2192
+ maxCalls: number;
2193
+ maxParallel?: number;
2193
2194
  };
2194
2195
  /** Actor turn cap. Default 12. */
2195
2196
  maxTurns?: number;
2196
2197
  /** Runtime char cap. Default 6000. */
2197
2198
  maxRuntimeChars?: number;
2198
- /** Maximum output tokens for every actor, responder, and recursive model call. Default 4096. */
2199
+ /** Maximum output tokens for every actor and subquery model call. Default 4096. */
2199
2200
  maxOutputTokens?: number;
2200
2201
  /** Cost classification surfaced in `registry.list()` and budget enforcement. */
2201
2202
  cost: AnalystCost;
@@ -2348,7 +2349,7 @@ interface RegistryRunOpts {
2348
2349
  skip?: string[];
2349
2350
  /** Budget policy — totalUsd + optional weights/allocator. Falls back to options.defaultBudget. */
2350
2351
  budget?: BudgetPolicy;
2351
- /** Wall-clock cap. Analysts SHOULD honor `ctx.deadlineMs`. */
2352
+ /** Active-work cap for the complete registry run. Model receipt settlement may follow. */
2352
2353
  timeoutMs?: number;
2353
2354
  /** Abort signal — forwarded into every analyst's context. */
2354
2355
  signal?: AbortSignal;
@@ -2684,19 +2685,14 @@ declare function diffFindings(previous: PersistedFinding[], current: PersistedFi
2684
2685
  * findings. The actor's job is *taxonomy + evidence*, not fix-design —
2685
2686
  * that's the improvement-analyst's job.
2686
2687
  *
2687
- * Recursion is deep (`maxDepth: 3`) because real failure-mode
2688
- * discovery is genuinely tree-shaped: the actor splits the dataset
2689
- * into candidate clusters, each cluster spawns a focused investigator
2690
- * that drills into representative traces, and a deeply-recursed
2691
- * investigator may itself split a confounded mode into two sub-modes.
2692
- * Each level fans out 4-way, so the analyst can investigate up to
2693
- * ~16 leaf clusters before hitting the depth ceiling.
2688
+ * Eight bounded model subqueries let the actor compare candidate
2689
+ * clusters in parallel after it has loaded representative evidence.
2694
2690
  */
2695
2691
 
2696
2692
  declare const FAILURE_MODE_KIND_SPEC: TraceAnalystKindSpec;
2697
2693
 
2698
2694
  /**
2699
- * Improvement analyst — actionable, recursive self-improvement findings.
2695
+ * Improvement analyst — actionable self-improvement findings.
2700
2696
  *
2701
2697
  * Brief: read findings from upstream analysts (failure-mode,
2702
2698
  * knowledge-gap, knowledge-poisoning) AND the trace dataset itself,
@@ -2706,14 +2702,11 @@ declare const FAILURE_MODE_KIND_SPEC: TraceAnalystKindSpec;
2706
2702
  * finding is one proposed edit with the locus, the diff, and the
2707
2703
  * expected effect.
2708
2704
  *
2709
- * This is the recursive-self-improvement loop's last mile: the prior
2705
+ * This is the self-improvement loop's last mile: the prior
2710
2706
  * kinds describe *what's wrong*; this kind describes *what to change*.
2711
2707
  *
2712
- * Recursion is deep (`maxDepth: 3`) because real improvement proposals
2713
- * are competitive: for each failure-mode there are usually 2-3 viable
2714
- * fix directions (tighten prompt vs add tool vs adjust scaffolding),
2715
- * and the actor should explore each with a focused subagent before
2716
- * picking the highest-leverage one to recommend.
2708
+ * Eight bounded model subqueries let the actor compare competing fix
2709
+ * directions over the same cited evidence before recommending one.
2717
2710
  */
2718
2711
 
2719
2712
  declare const IMPROVEMENT_KIND_SPEC: TraceAnalystKindSpec;
@@ -2740,8 +2733,8 @@ declare const IMPROVEMENT_KIND_SPEC: TraceAnalystKindSpec;
2740
2733
  * knowledge-gap names the *information* whose absence (or staleness)
2741
2734
  * caused the break. One failure-mode often maps to several gaps.
2742
2735
  *
2743
- * Recursion (`maxDepth: 2`) is enough to fan out one subagent per
2744
- * candidate gap-source layer; each subagent runs a focused detection.
2736
+ * Five bounded model subqueries let the actor compare candidate gaps
2737
+ * across source layers after it has loaded the relevant excerpts.
2745
2738
  */
2746
2739
 
2747
2740
  declare const KNOWLEDGE_GAP_KIND_SPEC: TraceAnalystKindSpec;
@@ -2760,10 +2753,8 @@ declare const KNOWLEDGE_GAP_KIND_SPEC: TraceAnalystKindSpec;
2760
2753
  * surface as questions / self-correction; poisonings surface as
2761
2754
  * confident-but-wrong actions that downstream evidence contradicts.
2762
2755
  *
2763
- * Recursion is moderate (`maxDepth: 2`) because each candidate
2764
- * poisoning typically needs two sub-investigations: one to confirm
2765
- * the agent acted on the false belief, one to confirm the belief
2766
- * itself is actually false in ground truth.
2756
+ * Eight bounded model subqueries let the actor independently assess
2757
+ * the action and contradiction excerpts for candidate poisonings.
2767
2758
  */
2768
2759
 
2769
2760
  declare const KNOWLEDGE_POISONING_KIND_SPEC: TraceAnalystKindSpec;
@@ -9,13 +9,13 @@ import {
9
9
  diffFindings,
10
10
  emitSkillUsageFindings,
11
11
  runSemanticConceptJudge
12
- } from "../chunk-LMJ2TGWJ.js";
12
+ } from "../chunk-JM2SKQMS.js";
13
13
  import {
14
14
  behavioralAnalyst,
15
15
  buildDefaultAnalystRegistry,
16
16
  createChatClient,
17
17
  deriveEfficiencyFindings
18
- } from "../chunk-GERDAIAL.js";
18
+ } from "../chunk-QWMPPZ3X.js";
19
19
  import "../chunk-HHWE3POT.js";
20
20
  import "../chunk-3YYRZDON.js";
21
21
  import {
@@ -72,13 +72,13 @@ import {
72
72
  validatePolicyEdit,
73
73
  validatePolicyEditCandidateRecord,
74
74
  validateUsageSettlementTimeout
75
- } from "../chunk-7A4LIMMY.js";
75
+ } from "../chunk-S5TT5R3L.js";
76
76
  import "../chunk-NJC7U437.js";
77
77
  import {
78
78
  CostLedger
79
79
  } from "../chunk-JHOJHHU7.js";
80
80
  import "../chunk-VI2UW6B6.js";
81
- import "../chunk-6QIM2EAP.js";
81
+ import "../chunk-PXD6ZFNY.js";
82
82
  import "../chunk-PC4UYEBM.js";
83
83
  import "../chunk-XJYR7XFV.js";
84
84
  import "../chunk-VSMTAMNK.js";
@@ -264,7 +264,11 @@ function createSemanticConceptJudgeAdapter(opts = {}) {
264
264
  id,
265
265
  description: "Runs the semantic-concept judge and surfaces missing / weak concepts as findings.",
266
266
  inputKind: "custom",
267
- cost: { kind: "llm", models: opts.options?.model ? [opts.options.model] : void 0 },
267
+ cost: {
268
+ kind: "llm",
269
+ models: opts.options?.model ? [opts.options.model] : void 0,
270
+ settlement_timeout_ms: settlementTimeoutMs
271
+ },
268
272
  version: `${SEMANTIC_CONCEPT_JUDGE_VERSION}-adapter-${ADAPTER_REV}`,
269
273
  async analyze(input, ctx) {
270
274
  const costLedger = new CostLedger(ctx.budgetUsd);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/analyst/adapters.ts"],"sourcesContent":["/**\n * Adapter factories — lift each existing agent-eval primitive into the\n * Analyst contract without re-implementing it.\n *\n * Five primitives, five factories. Each one:\n * - Builds an Analyst with a stable id (caller chooses; defaults\n * given), a sensible default `inputKind`, a version derived from\n * the wrapped primitive's version + an adapter revision, and an\n * `analyze()` that calls the primitive and lifts its output to\n * AnalystFinding[] using `makeFinding()`.\n * - Maps severities: the existing `Severity` ('critical' | 'major' |\n * 'minor' | 'info') projects onto AnalystSeverity ('critical' |\n * 'high' | 'medium' | 'low' | 'info'); 'major' → 'high', 'minor' →\n * 'medium'. Domain analysts that want finer-grained mapping override.\n *\n * Adapters never own state. Calling the same factory twice with the\n * same primitive instance is safe.\n */\n\nimport { CostLedger } from '../cost-ledger'\nimport type {\n Finding as LayerFinding,\n Severity as LayerSeverity,\n MultiLayerVerifier,\n VerifyOptions,\n} from '../multi-layer-verifier'\nimport { RunCritic, type RunTrace } from '../run-critic'\nimport {\n runSemanticConceptJudge,\n SEMANTIC_CONCEPT_JUDGE_VERSION,\n type SemanticConceptJudgeInput,\n type SemanticConceptJudgeOptions,\n type SemanticConceptJudgeResult,\n} from '../semantic-concept-judge'\nimport type { JudgeFn, JudgeInput, JudgeScore, TCloud } from '../types'\nimport type { Analyst, AnalystFinding, AnalystSeverity } from './types'\nimport { makeFinding } from './types'\nimport { settleUsageReceiptFromCostLedger, validateUsageSettlementTimeout } from './usage-receipt'\n\nconst ADAPTER_REV = '1'\n\n// ── Severity bridges ───────────────────────────────────────────────\n\nexport function liftSeverity(s: LayerSeverity): AnalystSeverity {\n switch (s) {\n case 'critical':\n return 'critical'\n case 'major':\n return 'high'\n case 'minor':\n return 'medium'\n case 'info':\n return 'info'\n }\n}\n\n// ── 1. MultiLayerVerifier → Analyst ─────────────────────────────────\n\nexport interface VerifierAdapterOpts<Env> {\n id?: string\n area?: string\n verifier: MultiLayerVerifier<Env>\n /**\n * The verifier expects an `env` per run. Adapters take it from\n * `AnalystRunInputs.custom[<id>]` via the registry's 'custom' routing.\n */\n options?: Omit<VerifyOptions<Env>, 'env'>\n}\n\nexport function createVerifierAdapter<Env>(opts: VerifierAdapterOpts<Env>): Analyst<Env> {\n const id = opts.id ?? 'multi-layer-verifier'\n const area = opts.area ?? 'verification'\n return {\n id,\n description:\n \"Runs a MultiLayerVerifier and lifts each layer's findings into the analyst envelope.\",\n inputKind: 'custom',\n cost: { kind: 'deterministic' },\n version: `verifier-${ADAPTER_REV}`,\n async analyze(env, ctx) {\n const report = await opts.verifier.run({ env, ...opts.options })\n const out: AnalystFinding[] = []\n for (const layer of report.layers) {\n for (const finding of layer.findings) {\n out.push(liftLayerFinding(id, area, layer.layer, finding))\n }\n // Layer-level signal: a failed/error layer is itself a finding\n // even if it didn't emit per-finding rows.\n if (layer.status === 'fail' || layer.status === 'error' || layer.status === 'timeout') {\n out.push(\n makeFinding({\n analyst_id: id,\n area,\n subject: layer.layer,\n claim: `layer \"${layer.layer}\" ${layer.status}: ${layer.reason ?? 'no reason given'}`,\n severity:\n layer.status === 'error' ? 'high' : layer.status === 'timeout' ? 'medium' : 'high',\n confidence: 1,\n evidence_refs: [],\n metadata: {\n layer_status: layer.status,\n duration_ms: layer.durationMs,\n score: layer.score,\n diagnostics: layer.diagnostics,\n },\n }),\n )\n }\n }\n ctx.log?.('verifier complete', {\n layers: report.layers.length,\n blended: report.blendedScore,\n all_pass: report.allPass,\n })\n return out\n },\n }\n}\n\nfunction liftLayerFinding(\n analyst_id: string,\n area: string,\n layer: string,\n f: LayerFinding,\n): AnalystFinding {\n return makeFinding({\n analyst_id,\n area,\n subject: f.layer ?? layer,\n claim: f.message,\n severity: liftSeverity(f.severity),\n confidence: 0.85,\n evidence_refs: f.evidence\n ? [{ kind: 'artifact', uri: 'inline:evidence', excerpt: f.evidence }]\n : [],\n metadata: f.detail,\n })\n}\n\n// ── 2. RunCritic → Analyst ──────────────────────────────────────────\n\nexport interface RunCriticAdapterOpts {\n id?: string\n area?: string\n critic?: RunCritic\n /** Optional threshold below which a dimension is reported as a finding. Default 0.5. */\n threshold?: number\n}\n\nexport function createRunCriticAdapter(opts: RunCriticAdapterOpts = {}): Analyst<RunTrace> {\n const id = opts.id ?? 'run-critic'\n const area = opts.area ?? 'run-quality'\n const critic = opts.critic ?? new RunCritic()\n const threshold = opts.threshold ?? 0.5\n return {\n id,\n description:\n 'Scores a single run across success / grounding / drift / tool-quality and surfaces below-threshold dimensions.',\n inputKind: 'custom',\n cost: { kind: 'deterministic' },\n version: `run-critic-${ADAPTER_REV}`,\n async analyze(trace) {\n const score = critic.scoreTrace(trace)\n const out: AnalystFinding[] = []\n const dims: Array<[keyof typeof score, AnalystSeverity, string]> = [\n ['success', 'critical', 'run did not complete successfully'],\n ['goalProgress', 'high', 'goal progress is low'],\n ['repoGroundedness', 'high', 'output is poorly grounded in the repository'],\n ['toolUseQuality', 'medium', 'tool use quality is low'],\n ['patchQuality', 'medium', 'no real patch/edit evidence'],\n ['testReality', 'high', 'no real test/build evidence'],\n ['finalGate', 'critical', 'final gate is blocking'],\n ]\n for (const [dim, sev, msg] of dims) {\n const value = score[dim] as number\n if (typeof value === 'number' && value < threshold) {\n out.push(\n makeFinding({\n analyst_id: id,\n area,\n subject: dim,\n claim: msg,\n rationale: `${dim}=${value.toFixed(2)} below threshold ${threshold}`,\n severity: sev,\n confidence: 1,\n evidence_refs: [],\n metadata: { dimension: dim, value, threshold, run_id: trace.run.runId },\n }),\n )\n }\n }\n // Drift penalty is high → surface as a finding (inverse threshold).\n if (score.driftPenalty > 1 - threshold) {\n out.push(\n makeFinding({\n analyst_id: id,\n area,\n subject: 'drift',\n claim: 'agent output drifted from repository signal',\n rationale: `driftPenalty=${score.driftPenalty.toFixed(2)}`,\n severity: 'medium',\n confidence: 0.9,\n evidence_refs: [],\n metadata: { drift_penalty: score.driftPenalty, notes: score.notes },\n }),\n )\n }\n return out\n },\n }\n}\n\n// ── 3. JudgeFn → Analyst ────────────────────────────────────────────\n\nexport interface JudgeAdapterOpts {\n id?: string\n area?: string\n judge: JudgeFn\n /** TCloud handle the JudgeFn calls. */\n tcloud: TCloud\n /** Optional cost classification — most judges call an LLM. */\n cost?: Analyst['cost']\n /** Optional threshold below which a JudgeScore becomes a finding. Default 6 (on 0-10 scale). */\n threshold?: number\n}\n\nexport function createJudgeAdapter(opts: JudgeAdapterOpts): Analyst<JudgeInput> {\n const id = opts.id ?? 'judge'\n const area = opts.area ?? 'judge'\n const threshold = opts.threshold ?? 6\n return {\n id,\n description:\n 'Wraps an agent-eval JudgeFn into an analyst; below-threshold dimensions surface as findings.',\n inputKind: 'judge-input',\n cost: opts.cost ?? { kind: 'llm' },\n version: `judge-${ADAPTER_REV}`,\n async analyze(input) {\n const scores = await opts.judge(opts.tcloud, input)\n return scores\n .filter((s) => normalize10(s.score) < threshold)\n .map((s) => liftJudgeScore(id, area, s))\n },\n }\n}\n\nfunction normalize10(s: number): number {\n // JudgeScore convention is 0-10 but some judges emit 0-1. Coerce to 0-10.\n return s <= 1 ? s * 10 : s\n}\n\nfunction liftJudgeScore(analyst_id: string, area: string, s: JudgeScore): AnalystFinding {\n const score10 = normalize10(s.score)\n const severity: AnalystSeverity =\n score10 < 3 ? 'critical' : score10 < 5 ? 'high' : score10 < 7 ? 'medium' : 'low'\n return makeFinding({\n analyst_id,\n area,\n subject: s.dimension,\n claim: `${s.judgeName}/${s.dimension} scored ${score10.toFixed(1)}/10`,\n rationale: s.reasoning,\n severity,\n confidence: 0.8,\n evidence_refs: s.evidence\n ? [{ kind: 'artifact', uri: 'inline:evidence', excerpt: s.evidence }]\n : [],\n // Provenance: this finding IS a judge verdict (an acceptance score), not an\n // observation of behavior. The steer firewall (assertNoJudgeVerdict) rejects\n // it from steering — even when it cites an artifact above — because letting a\n // verdict steer the next attempt is the held-out judge leaking into the loop.\n derived_from_judge: true,\n metadata: { judge_name: s.judgeName, dimension: s.dimension, score_10: score10 },\n })\n}\n\n// ── 4. SemanticConceptJudge → Analyst ──────────────────────────────\n\nexport interface SemanticConceptJudgeAdapterOpts {\n id?: string\n area?: string\n /** Registry context owns cancellation and the per-analyst cost ledger. */\n options?: Omit<SemanticConceptJudgeOptions, 'costLedger' | 'signal'>\n /** Maximum post-cancellation wait for a provider receipt. Default 5 seconds. */\n settlementTimeoutMs?: number\n}\n\nexport function createSemanticConceptJudgeAdapter(\n opts: SemanticConceptJudgeAdapterOpts = {},\n): Analyst<SemanticConceptJudgeInput> {\n const id = opts.id ?? 'semantic-concept-judge'\n const area = opts.area ?? 'concept-coverage'\n const settlementTimeoutMs = validateUsageSettlementTimeout(opts.settlementTimeoutMs)\n return {\n id,\n description:\n 'Runs the semantic-concept judge and surfaces missing / weak concepts as findings.',\n inputKind: 'custom',\n cost: { kind: 'llm', models: opts.options?.model ? [opts.options.model] : undefined },\n version: `${SEMANTIC_CONCEPT_JUDGE_VERSION}-adapter-${ADAPTER_REV}`,\n async analyze(input, ctx) {\n const costLedger = new CostLedger(ctx.budgetUsd)\n let result: SemanticConceptJudgeResult\n try {\n result = await runSemanticConceptJudge(input, {\n ...opts.options,\n costLedger,\n signal: ctx.signal,\n })\n } finally {\n const usage = await settleUsageReceiptFromCostLedger(costLedger, {\n channel: 'judge',\n timeoutMs: settlementTimeoutMs,\n })\n if (!usage.settled) {\n ctx.log?.('semantic-concept judge provider settlement timed out', {\n pending_calls: usage.pendingCalls,\n timeout_ms: settlementTimeoutMs,\n })\n }\n ctx.recordUsage?.(usage.receipt)\n }\n if (!result.available) {\n return [\n makeFinding({\n analyst_id: id,\n area,\n claim: 'semantic-concept judge unavailable',\n rationale: result.error,\n severity: 'info',\n confidence: 1,\n evidence_refs: [],\n metadata: { reason: result.error },\n }),\n ]\n }\n const out: AnalystFinding[] = []\n for (const f of result.findings) {\n // Only surface gaps: missing concepts or low scores. Concepts at\n // 7+/10 with present=true are not findings — they're successes.\n if (f.present && f.score >= 7) continue\n out.push(\n makeFinding({\n analyst_id: id,\n area,\n subject: f.concept,\n claim: f.present\n ? `concept \"${f.concept}\" is weak (${f.score}/10)`\n : `concept \"${f.concept}\" is missing`,\n rationale: f.evidence,\n severity: liftSeverity(f.severity),\n confidence: 0.85,\n evidence_refs: [{ kind: 'artifact', uri: 'inline:evidence', excerpt: f.evidence }],\n metadata: {\n concept: f.concept,\n present: f.present,\n score_10: f.score,\n },\n }),\n )\n }\n return out\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,cAAc;AAIb,SAAS,aAAa,GAAmC;AAC9D,UAAQ,GAAG;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAeO,SAAS,sBAA2B,MAA8C;AACvF,QAAM,KAAK,KAAK,MAAM;AACtB,QAAM,OAAO,KAAK,QAAQ;AAC1B,SAAO;AAAA,IACL;AAAA,IACA,aACE;AAAA,IACF,WAAW;AAAA,IACX,MAAM,EAAE,MAAM,gBAAgB;AAAA,IAC9B,SAAS,YAAY,WAAW;AAAA,IAChC,MAAM,QAAQ,KAAK,KAAK;AACtB,YAAM,SAAS,MAAM,KAAK,SAAS,IAAI,EAAE,KAAK,GAAG,KAAK,QAAQ,CAAC;AAC/D,YAAM,MAAwB,CAAC;AAC/B,iBAAW,SAAS,OAAO,QAAQ;AACjC,mBAAW,WAAW,MAAM,UAAU;AACpC,cAAI,KAAK,iBAAiB,IAAI,MAAM,MAAM,OAAO,OAAO,CAAC;AAAA,QAC3D;AAGA,YAAI,MAAM,WAAW,UAAU,MAAM,WAAW,WAAW,MAAM,WAAW,WAAW;AACrF,cAAI;AAAA,YACF,YAAY;AAAA,cACV,YAAY;AAAA,cACZ;AAAA,cACA,SAAS,M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AK,SAC1C,YAAY,EAAE,OAAO;AAAA,YACzB,WAAW,EAAE;AAAA,YACb,UAAU,aAAa,EAAE,QAAQ;AAAA,YACjC,YAAY;AAAA,YACZ,eAAe,CAAC,EAAE,MAAM,YAAY,KAAK,mBAAmB,SAAS,EAAE,SAAS,CAAC;AAAA,YACjF,UAAU;AAAA,cACR,SAAS,EAAE;AAAA,cACX,SAAS,EAAE;AAAA,cACX,UAAU,EAAE;AAAA,YACd;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/analyst/adapters.ts"],"sourcesContent":["/**\n * Adapter factories — lift each existing agent-eval primitive into the\n * Analyst contract without re-implementing it.\n *\n * Five primitives, five factories. Each one:\n * - Builds an Analyst with a stable id (caller chooses; defaults\n * given), a sensible default `inputKind`, a version derived from\n * the wrapped primitive's version + an adapter revision, and an\n * `analyze()` that calls the primitive and lifts its output to\n * AnalystFinding[] using `makeFinding()`.\n * - Maps severities: the existing `Severity` ('critical' | 'major' |\n * 'minor' | 'info') projects onto AnalystSeverity ('critical' |\n * 'high' | 'medium' | 'low' | 'info'); 'major' → 'high', 'minor' →\n * 'medium'. Domain analysts that want finer-grained mapping override.\n *\n * Adapters never own state. Calling the same factory twice with the\n * same primitive instance is safe.\n */\n\nimport { CostLedger } from '../cost-ledger'\nimport type {\n Finding as LayerFinding,\n Severity as LayerSeverity,\n MultiLayerVerifier,\n VerifyOptions,\n} from '../multi-layer-verifier'\nimport { RunCritic, type RunTrace } from '../run-critic'\nimport {\n runSemanticConceptJudge,\n SEMANTIC_CONCEPT_JUDGE_VERSION,\n type SemanticConceptJudgeInput,\n type SemanticConceptJudgeOptions,\n type SemanticConceptJudgeResult,\n} from '../semantic-concept-judge'\nimport type { JudgeFn, JudgeInput, JudgeScore, TCloud } from '../types'\nimport type { Analyst, AnalystFinding, AnalystSeverity } from './types'\nimport { makeFinding } from './types'\nimport { settleUsageReceiptFromCostLedger, validateUsageSettlementTimeout } from './usage-receipt'\n\nconst ADAPTER_REV = '1'\n\n// ── Severity bridges ───────────────────────────────────────────────\n\nexport function liftSeverity(s: LayerSeverity): AnalystSeverity {\n switch (s) {\n case 'critical':\n return 'critical'\n case 'major':\n return 'high'\n case 'minor':\n return 'medium'\n case 'info':\n return 'info'\n }\n}\n\n// ── 1. MultiLayerVerifier → Analyst ─────────────────────────────────\n\nexport interface VerifierAdapterOpts<Env> {\n id?: string\n area?: string\n verifier: MultiLayerVerifier<Env>\n /**\n * The verifier expects an `env` per run. Adapters take it from\n * `AnalystRunInputs.custom[<id>]` via the registry's 'custom' routing.\n */\n options?: Omit<VerifyOptions<Env>, 'env'>\n}\n\nexport function createVerifierAdapter<Env>(opts: VerifierAdapterOpts<Env>): Analyst<Env> {\n const id = opts.id ?? 'multi-layer-verifier'\n const area = opts.area ?? 'verification'\n return {\n id,\n description:\n \"Runs a MultiLayerVerifier and lifts each layer's findings into the analyst envelope.\",\n inputKind: 'custom',\n cost: { kind: 'deterministic' },\n version: `verifier-${ADAPTER_REV}`,\n async analyze(env, ctx) {\n const report = await opts.verifier.run({ env, ...opts.options })\n const out: AnalystFinding[] = []\n for (const layer of report.layers) {\n for (const finding of layer.findings) {\n out.push(liftLayerFinding(id, area, layer.layer, finding))\n }\n // Layer-level signal: a failed/error layer is itself a finding\n // even if it didn't emit per-finding rows.\n if (layer.status === 'fail' || layer.status === 'error' || layer.status === 'timeout') {\n out.push(\n makeFinding({\n analyst_id: id,\n area,\n subject: layer.layer,\n claim: `layer \"${layer.layer}\" ${layer.status}: ${layer.reason ?? 'no reason given'}`,\n severity:\n layer.status === 'error' ? 'high' : layer.status === 'timeout' ? 'medium' : 'high',\n confidence: 1,\n evidence_refs: [],\n metadata: {\n layer_status: layer.status,\n duration_ms: layer.durationMs,\n score: layer.score,\n diagnostics: layer.diagnostics,\n },\n }),\n )\n }\n }\n ctx.log?.('verifier complete', {\n layers: report.layers.length,\n blended: report.blendedScore,\n all_pass: report.allPass,\n })\n return out\n },\n }\n}\n\nfunction liftLayerFinding(\n analyst_id: string,\n area: string,\n layer: string,\n f: LayerFinding,\n): AnalystFinding {\n return makeFinding({\n analyst_id,\n area,\n subject: f.layer ?? layer,\n claim: f.message,\n severity: liftSeverity(f.severity),\n confidence: 0.85,\n evidence_refs: f.evidence\n ? [{ kind: 'artifact', uri: 'inline:evidence', excerpt: f.evidence }]\n : [],\n metadata: f.detail,\n })\n}\n\n// ── 2. RunCritic → Analyst ──────────────────────────────────────────\n\nexport interface RunCriticAdapterOpts {\n id?: string\n area?: string\n critic?: RunCritic\n /** Optional threshold below which a dimension is reported as a finding. Default 0.5. */\n threshold?: number\n}\n\nexport function createRunCriticAdapter(opts: RunCriticAdapterOpts = {}): Analyst<RunTrace> {\n const id = opts.id ?? 'run-critic'\n const area = opts.area ?? 'run-quality'\n const critic = opts.critic ?? new RunCritic()\n const threshold = opts.threshold ?? 0.5\n return {\n id,\n description:\n 'Scores a single run across success / grounding / drift / tool-quality and surfaces below-threshold dimensions.',\n inputKind: 'custom',\n cost: { kind: 'deterministic' },\n version: `run-critic-${ADAPTER_REV}`,\n async analyze(trace) {\n const score = critic.scoreTrace(trace)\n const out: AnalystFinding[] = []\n const dims: Array<[keyof typeof score, AnalystSeverity, string]> = [\n ['success', 'critical', 'run did not complete successfully'],\n ['goalProgress', 'high', 'goal progress is low'],\n ['repoGroundedness', 'high', 'output is poorly grounded in the repository'],\n ['toolUseQuality', 'medium', 'tool use quality is low'],\n ['patchQuality', 'medium', 'no real patch/edit evidence'],\n ['testReality', 'high', 'no real test/build evidence'],\n ['finalGate', 'critical', 'final gate is blocking'],\n ]\n for (const [dim, sev, msg] of dims) {\n const value = score[dim] as number\n if (typeof value === 'number' && value < threshold) {\n out.push(\n makeFinding({\n analyst_id: id,\n area,\n subject: dim,\n claim: msg,\n rationale: `${dim}=${value.toFixed(2)} below threshold ${threshold}`,\n severity: sev,\n confidence: 1,\n evidence_refs: [],\n metadata: { dimension: dim, value, threshold, run_id: trace.run.runId },\n }),\n )\n }\n }\n // Drift penalty is high → surface as a finding (inverse threshold).\n if (score.driftPenalty > 1 - threshold) {\n out.push(\n makeFinding({\n analyst_id: id,\n area,\n subject: 'drift',\n claim: 'agent output drifted from repository signal',\n rationale: `driftPenalty=${score.driftPenalty.toFixed(2)}`,\n severity: 'medium',\n confidence: 0.9,\n evidence_refs: [],\n metadata: { drift_penalty: score.driftPenalty, notes: score.notes },\n }),\n )\n }\n return out\n },\n }\n}\n\n// ── 3. JudgeFn → Analyst ────────────────────────────────────────────\n\nexport interface JudgeAdapterOpts {\n id?: string\n area?: string\n judge: JudgeFn\n /** TCloud handle the JudgeFn calls. */\n tcloud: TCloud\n /** Optional cost classification — most judges call an LLM. */\n cost?: Analyst['cost']\n /** Optional threshold below which a JudgeScore becomes a finding. Default 6 (on 0-10 scale). */\n threshold?: number\n}\n\nexport function createJudgeAdapter(opts: JudgeAdapterOpts): Analyst<JudgeInput> {\n const id = opts.id ?? 'judge'\n const area = opts.area ?? 'judge'\n const threshold = opts.threshold ?? 6\n return {\n id,\n description:\n 'Wraps an agent-eval JudgeFn into an analyst; below-threshold dimensions surface as findings.',\n inputKind: 'judge-input',\n cost: opts.cost ?? { kind: 'llm' },\n version: `judge-${ADAPTER_REV}`,\n async analyze(input) {\n const scores = await opts.judge(opts.tcloud, input)\n return scores\n .filter((s) => normalize10(s.score) < threshold)\n .map((s) => liftJudgeScore(id, area, s))\n },\n }\n}\n\nfunction normalize10(s: number): number {\n // JudgeScore convention is 0-10 but some judges emit 0-1. Coerce to 0-10.\n return s <= 1 ? s * 10 : s\n}\n\nfunction liftJudgeScore(analyst_id: string, area: string, s: JudgeScore): AnalystFinding {\n const score10 = normalize10(s.score)\n const severity: AnalystSeverity =\n score10 < 3 ? 'critical' : score10 < 5 ? 'high' : score10 < 7 ? 'medium' : 'low'\n return makeFinding({\n analyst_id,\n area,\n subject: s.dimension,\n claim: `${s.judgeName}/${s.dimension} scored ${score10.toFixed(1)}/10`,\n rationale: s.reasoning,\n severity,\n confidence: 0.8,\n evidence_refs: s.evidence\n ? [{ kind: 'artifact', uri: 'inline:evidence', excerpt: s.evidence }]\n : [],\n // Provenance: this finding IS a judge verdict (an acceptance score), not an\n // observation of behavior. The steer firewall (assertNoJudgeVerdict) rejects\n // it from steering — even when it cites an artifact above — because letting a\n // verdict steer the next attempt is the held-out judge leaking into the loop.\n derived_from_judge: true,\n metadata: { judge_name: s.judgeName, dimension: s.dimension, score_10: score10 },\n })\n}\n\n// ── 4. SemanticConceptJudge → Analyst ──────────────────────────────\n\nexport interface SemanticConceptJudgeAdapterOpts {\n id?: string\n area?: string\n /** Registry context owns cancellation and the per-analyst cost ledger. */\n options?: Omit<SemanticConceptJudgeOptions, 'costLedger' | 'signal'>\n /** Maximum post-cancellation wait for a provider receipt. Default 5 seconds. */\n settlementTimeoutMs?: number\n}\n\nexport function createSemanticConceptJudgeAdapter(\n opts: SemanticConceptJudgeAdapterOpts = {},\n): Analyst<SemanticConceptJudgeInput> {\n const id = opts.id ?? 'semantic-concept-judge'\n const area = opts.area ?? 'concept-coverage'\n const settlementTimeoutMs = validateUsageSettlementTimeout(opts.settlementTimeoutMs)\n return {\n id,\n description:\n 'Runs the semantic-concept judge and surfaces missing / weak concepts as findings.',\n inputKind: 'custom',\n cost: {\n kind: 'llm',\n models: opts.options?.model ? [opts.options.model] : undefined,\n settlement_timeout_ms: settlementTimeoutMs,\n },\n version: `${SEMANTIC_CONCEPT_JUDGE_VERSION}-adapter-${ADAPTER_REV}`,\n async analyze(input, ctx) {\n const costLedger = new CostLedger(ctx.budgetUsd)\n let result: SemanticConceptJudgeResult\n try {\n result = await runSemanticConceptJudge(input, {\n ...opts.options,\n costLedger,\n signal: ctx.signal,\n })\n } finally {\n const usage = await settleUsageReceiptFromCostLedger(costLedger, {\n channel: 'judge',\n timeoutMs: settlementTimeoutMs,\n })\n if (!usage.settled) {\n ctx.log?.('semantic-concept judge provider settlement timed out', {\n pending_calls: usage.pendingCalls,\n timeout_ms: settlementTimeoutMs,\n })\n }\n ctx.recordUsage?.(usage.receipt)\n }\n if (!result.available) {\n return [\n makeFinding({\n analyst_id: id,\n area,\n claim: 'semantic-concept judge unavailable',\n rationale: result.error,\n severity: 'info',\n confidence: 1,\n evidence_refs: [],\n metadata: { reason: result.error },\n }),\n ]\n }\n const out: AnalystFinding[] = []\n for (const f of result.findings) {\n // Only surface gaps: missing concepts or low scores. Concepts at\n // 7+/10 with present=true are not findings — they're successes.\n if (f.present && f.score >= 7) continue\n out.push(\n makeFinding({\n analyst_id: id,\n area,\n subject: f.concept,\n claim: f.present\n ? `concept \"${f.concept}\" is weak (${f.score}/10)`\n : `concept \"${f.concept}\" is missing`,\n rationale: f.evidence,\n severity: liftSeverity(f.severity),\n confidence: 0.85,\n evidence_refs: [{ kind: 'artifact', uri: 'inline:evidence', excerpt: f.evidence }],\n metadata: {\n concept: f.concept,\n present: f.present,\n score_10: f.score,\n },\n }),\n )\n }\n return out\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,cAAc;AAIb,SAAS,aAAa,GAAmC;AAC9D,UAAQ,GAAG;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAeO,SAAS,sBAA2B,MAA8C;AACvF,QAAM,KAAK,KAAK,MAAM;AACtB,QAAM,OAAO,KAAK,QAAQ;AAC1B,SAAO;AAAA,IACL;AAAA,IACA,aACE;AAAA,IACF,WAAW;AAAA,IACX,MAAM,EAAE,MAAM,gBAAgB;AAAA,IAC9B,SAAS,YAAY,WAAW;AAAA,IAChC,MAAM,QAAQ,KAAK,KAAK;AACtB,YAAM,SAAS,MAAM,KAAK,SAAS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OAAO;AAAA,YAClB,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,eAAe,CAAC;AAAA,YAChB,UAAU,EAAE,QAAQ,OAAO,MAAM;AAAA,UACnC,CAAC;AAAA,QACH;AAAA,MACF;AACA,YAAM,MAAwB,CAAC;AAC/B,iBAAW,KAAK,OAAO,UAAU;AAG/B,YAAI,EAAE,WAAW,EAAE,SAAS,EAAG;AAC/B,YAAI;AAAA,UACF,YAAY;AAAA,YACV,YAAY;AAAA,YACZ;AAAA,YACA,SAAS,EAAE;AAAA,YACX,OAAO,EAAE,UACL,YAAY,EAAE,OAAO,cAAc,EAAE,KAAK,SAC1C,YAAY,EAAE,OAAO;AAAA,YACzB,WAAW,EAAE;AAAA,YACb,UAAU,aAAa,EAAE,QAAQ;AAAA,YACjC,YAAY;AAAA,YACZ,eAAe,CAAC,EAAE,MAAM,YAAY,KAAK,mBAAmB,SAAS,EAAE,SAAS,CAAC;AAAA,YACjF,UAAU;AAAA,cACR,SAAS,EAAE;AAAA,cACX,SAAS,EAAE;AAAA,cACX,UAAU,EAAE;AAAA,YACd;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -356,6 +356,10 @@ interface Scenario {
356
356
  kind: string;
357
357
  tags?: string[];
358
358
  }
359
+ /** Redacted identity of a complete scenario payload retained in campaign results. */
360
+ interface CampaignScenarioIdentity extends Pick<Scenario, 'id' | 'kind'> {
361
+ scenarioDigest: `sha256:${string}`;
362
+ }
359
363
  /** Context handed to every dispatch invocation. Scoped — every
360
364
  * trace/span carries the cellId, every artifact write lands under the cell's
361
365
  * artifact root, the cost meter accumulates per cell. */
@@ -564,7 +568,11 @@ interface CampaignAggregates {
564
568
  interface CampaignResult<TArtifact = unknown, TScenario extends Scenario = Scenario> {
565
569
  /** sha256(scenarios, judges, dispatch source ref, optimizer config, seed). Stable identity for reruns. */
566
570
  manifestHash: string;
571
+ /** Canonical identity of the exact scenario payloads and replicate count. */
572
+ splitDigest: `sha256:${string}`;
567
573
  seed: number;
574
+ /** Replicates designed for every scenario in this campaign. */
575
+ reps: number;
568
576
  startedAt: string;
569
577
  endedAt: string;
570
578
  durationMs: number;
@@ -578,11 +586,9 @@ interface CampaignResult<TArtifact = unknown, TScenario extends Scenario = Scena
578
586
  prUrl?: string;
579
587
  runDir: string;
580
588
  artifactsByPath: Record<string, string>;
581
- /** Substrate strips the input scenarios to id+kind for the result manifest;
582
- * consumers needing full payload look it up via the original input. The
583
- * type parameter `TScenario` is propagated for downstream consumers that
584
- * want narrowed types when extending `CampaignResult`. */
585
- scenarios: Array<Pick<TScenario, 'id' | 'kind'>>;
589
+ /** Redacted identities that let consumers verify the exact scenario payloads
590
+ * without retaining customer task content in the result. */
591
+ scenarios: Array<CampaignScenarioIdentity & Pick<TScenario, 'id' | 'kind'>>;
586
592
  }
587
593
 
588
594
  /**
@@ -16,20 +16,20 @@ import {
16
16
  routing_exports,
17
17
  runBenchmarkAdapter,
18
18
  summarizeBenchmarkCampaign
19
- } from "../chunk-D7AEXSM5.js";
20
- import "../chunk-F6YUH3L4.js";
21
- import "../chunk-RLCJQ6VZ.js";
22
- import "../chunk-PAHNGS65.js";
19
+ } from "../chunk-PICTDURQ.js";
20
+ import "../chunk-JN2FCO5W.js";
21
+ import "../chunk-32BZXMSO.js";
22
+ import "../chunk-XDIRG3TO.js";
23
23
  import "../chunk-3YYRZDON.js";
24
- import "../chunk-7A4LIMMY.js";
24
+ import "../chunk-S5TT5R3L.js";
25
25
  import "../chunk-ARU2PZFM.js";
26
26
  import "../chunk-NJC7U437.js";
27
27
  import "../chunk-PJQFMIOX.js";
28
28
  import "../chunk-JHOJHHU7.js";
29
29
  import "../chunk-VI2UW6B6.js";
30
- import "../chunk-FIUFRXP3.js";
30
+ import "../chunk-WW2A73HW.js";
31
31
  import "../chunk-GGE4NNQT.js";
32
- import "../chunk-6QIM2EAP.js";
32
+ import "../chunk-PXD6ZFNY.js";
33
33
  import "../chunk-PC4UYEBM.js";
34
34
  import "../chunk-S3UZOQ5Y.js";
35
35
  import "../chunk-MA6HLL3S.js";