@tangle-network/agent-eval 0.117.0 → 0.118.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 (143) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/analyst/index.d.ts +2772 -21
  3. package/dist/analyst/index.js +7 -6
  4. package/dist/analyst/index.js.map +1 -1
  5. package/dist/belief-state/index.d.ts +706 -10
  6. package/dist/belief-state/index.js +2 -1
  7. package/dist/belief-state/index.js.map +1 -1
  8. package/dist/benchmarks/index.d.ts +958 -14
  9. package/dist/benchmarks/index.js +12 -10
  10. package/dist/builder-eval/index.d.ts +449 -4
  11. package/dist/builder-eval/index.js +4 -3
  12. package/dist/builder-eval/index.js.map +1 -1
  13. package/dist/campaign/index.d.ts +4276 -74
  14. package/dist/campaign/index.js +12 -10
  15. package/dist/{chunk-VF3XSYTI.js → chunk-33JA4TFA.js} +6 -6
  16. package/dist/{chunk-4JLWXDYA.js → chunk-3EHHMC6E.js} +2 -2
  17. package/dist/{chunk-CCZIVI3F.js → chunk-BFW56GTT.js} +2 -2
  18. package/dist/{chunk-YZPO4UHR.js → chunk-DP3BBMYJ.js} +100 -143
  19. package/dist/chunk-DP3BBMYJ.js.map +1 -0
  20. package/dist/{chunk-E4BUPP7Z.js → chunk-HKUCJ437.js} +38 -66
  21. package/dist/chunk-HKUCJ437.js.map +1 -0
  22. package/dist/{chunk-HZHNRYHK.js → chunk-K6N6XJJX.js} +2 -2
  23. package/dist/chunk-KSDQVPLR.js +286 -0
  24. package/dist/chunk-KSDQVPLR.js.map +1 -0
  25. package/dist/chunk-MA6HLL3S.js +65 -0
  26. package/dist/chunk-MA6HLL3S.js.map +1 -0
  27. package/dist/{chunk-MGEHEHSN.js → chunk-OIIMMLRB.js} +11 -11
  28. package/dist/{chunk-DXZRATT5.js → chunk-OYZAPX5G.js} +3 -3
  29. package/dist/chunk-PXE2VKMX.js +140 -0
  30. package/dist/chunk-PXE2VKMX.js.map +1 -0
  31. package/dist/{chunk-ZUXV7UWZ.js → chunk-Q442S5AS.js} +73 -19
  32. package/dist/{chunk-ZUXV7UWZ.js.map → chunk-Q442S5AS.js.map} +1 -1
  33. package/dist/{chunk-ODVOOEWQ.js → chunk-QBRSJK47.js} +2 -2
  34. package/dist/{chunk-S2F4J57L.js → chunk-QKEGNI5B.js} +77 -32
  35. package/dist/chunk-QKEGNI5B.js.map +1 -0
  36. package/dist/{chunk-5UF54T55.js → chunk-S3UZOQ5Y.js} +34 -7
  37. package/dist/chunk-S3UZOQ5Y.js.map +1 -0
  38. package/dist/{chunk-FQNLDL4D.js → chunk-SVH2ANFD.js} +136 -4
  39. package/dist/chunk-SVH2ANFD.js.map +1 -0
  40. package/dist/{chunk-GQCZRZ7L.js → chunk-U5CHZ5M3.js} +9 -9
  41. package/dist/{chunk-TVVP3ZZQ.js → chunk-VQMK5FMP.js} +2 -1
  42. package/dist/{chunk-TVVP3ZZQ.js.map → chunk-VQMK5FMP.js.map} +1 -1
  43. package/dist/chunk-WDHBCA3M.js +31 -0
  44. package/dist/chunk-WDHBCA3M.js.map +1 -0
  45. package/dist/{chunk-HQPHZGL6.js → chunk-YLMUS4MM.js} +9 -9
  46. package/dist/{chunk-LQUTGLOZ.js → chunk-ZET2UAYW.js} +15 -65
  47. package/dist/chunk-ZET2UAYW.js.map +1 -0
  48. package/dist/contract/index.d.ts +4012 -38
  49. package/dist/contract/index.js +56 -29
  50. package/dist/contract/index.js.map +1 -1
  51. package/dist/control.d.ts +1013 -9
  52. package/dist/control.js +4 -3
  53. package/dist/fuzz.d.ts +194 -4
  54. package/dist/fuzz.js +3 -3
  55. package/dist/hosted/index.d.ts +498 -17
  56. package/dist/index.d.ts +10982 -1286
  57. package/dist/index.js +97 -80
  58. package/dist/index.js.map +1 -1
  59. package/dist/matrix/index.d.ts +139 -4
  60. package/dist/meta-eval/index.d.ts +862 -15
  61. package/dist/meta-eval/index.js +2 -1
  62. package/dist/meta-eval/index.js.map +1 -1
  63. package/dist/multishot/index.d.ts +214 -14
  64. package/dist/openapi.json +1 -1
  65. package/dist/pipelines/index.d.ts +392 -7
  66. package/dist/pipelines/index.js +5 -3
  67. package/dist/pipelines/index.js.map +1 -1
  68. package/dist/reporting.d.ts +1277 -17
  69. package/dist/rl.d.ts +2359 -28
  70. package/dist/rl.js +6 -5
  71. package/dist/rl.js.map +1 -1
  72. package/dist/storyboard/index.d.ts +86 -1
  73. package/dist/trace-attributes.d.ts +16 -0
  74. package/dist/trace-attributes.js +32 -0
  75. package/dist/trace-attributes.js.map +1 -0
  76. package/dist/traces.d.ts +1970 -697
  77. package/dist/traces.js +49 -32
  78. package/dist/wire/index.d.ts +655 -9
  79. package/docs/insight-report.md +44 -0
  80. package/package.json +9 -3
  81. package/dist/adversarial-B7loGVVX.d.ts +0 -19
  82. package/dist/analyst-C8HHvfJp.d.ts +0 -88
  83. package/dist/analyze-runs--2x39HZ7.d.ts +0 -81
  84. package/dist/baseline-DKq3gJpP.d.ts +0 -141
  85. package/dist/calibration-C8MTS7cw.d.ts +0 -101
  86. package/dist/chunk-5UF54T55.js.map +0 -1
  87. package/dist/chunk-E4BUPP7Z.js.map +0 -1
  88. package/dist/chunk-FQNLDL4D.js.map +0 -1
  89. package/dist/chunk-LQUTGLOZ.js.map +0 -1
  90. package/dist/chunk-S2F4J57L.js.map +0 -1
  91. package/dist/chunk-YZPO4UHR.js.map +0 -1
  92. package/dist/code-agent-session-CjZsVd19.d.ts +0 -87
  93. package/dist/control-6vuGfmDH.d.ts +0 -258
  94. package/dist/cost-ledger-DWy3XdJc.d.ts +0 -183
  95. package/dist/dataset-NENEzRgk.d.ts +0 -115
  96. package/dist/default-registry-DaK8b3fv.d.ts +0 -155
  97. package/dist/emitter-CjD7vUwv.d.ts +0 -122
  98. package/dist/errors-oeQrLqXC.d.ts +0 -74
  99. package/dist/failure-cluster-DOAcSJ87.d.ts +0 -76
  100. package/dist/feedback-trajectory-BUnM58xL.d.ts +0 -348
  101. package/dist/gepa-eESocoDi.d.ts +0 -642
  102. package/dist/index-PdX4VnPA.d.ts +0 -423
  103. package/dist/insight-report-DY4nDW9Q.d.ts +0 -310
  104. package/dist/integrity-DqlBiLyK.d.ts +0 -81
  105. package/dist/judge-calibration-7C-IDmKr.d.ts +0 -145
  106. package/dist/kind-factory-ClZmO25A.d.ts +0 -171
  107. package/dist/llm-client-qoDd18Qz.d.ts +0 -289
  108. package/dist/multi-layer-verifier-BsqKuLyN.d.ts +0 -150
  109. package/dist/off-policy-DiwuKKg7.d.ts +0 -132
  110. package/dist/outcome-store-rnXLEqSn.d.ts +0 -63
  111. package/dist/policy-edit-wG9uFEFm.d.ts +0 -455
  112. package/dist/pre-registration-BWQhJ3vz.d.ts +0 -761
  113. package/dist/provenance-DpjwyseI.d.ts +0 -541
  114. package/dist/query-CF7PG61p.d.ts +0 -35
  115. package/dist/raw-provider-sink-C46HDghv.d.ts +0 -132
  116. package/dist/release-report-C8G2i5Xi.d.ts +0 -236
  117. package/dist/researcher-C8XyxQsu.d.ts +0 -387
  118. package/dist/rubric-predictive-validity-p49lLVrE.d.ts +0 -105
  119. package/dist/run-record-BDH49H2E.d.ts +0 -360
  120. package/dist/runtime-trajectory-DGBIUt4B.d.ts +0 -49
  121. package/dist/schema-B3Q3l9Z_.d.ts +0 -201
  122. package/dist/semantic-concept-judge-CXnPEJbf.d.ts +0 -723
  123. package/dist/sequential-5iSVfzl2.d.ts +0 -139
  124. package/dist/series-convergence-D5OWMBg6.d.ts +0 -33
  125. package/dist/statistics-KUnG73jH.d.ts +0 -494
  126. package/dist/storage-DrX3v_5B.d.ts +0 -50
  127. package/dist/store-C1YxJDEK.d.ts +0 -248
  128. package/dist/store-DGqD0Pyo.d.ts +0 -116
  129. package/dist/summary-report-C5bKFfm-.d.ts +0 -445
  130. package/dist/test-graded-scenario-B0ybnPY7.d.ts +0 -166
  131. package/dist/types-BSw1rOUB.d.ts +0 -634
  132. package/dist/types-BUxNaJ8c.d.ts +0 -108
  133. package/dist/types-BkfcQnxV.d.ts +0 -313
  134. package/dist/verdict-C9MlYujm.d.ts +0 -35
  135. /package/dist/{chunk-VF3XSYTI.js.map → chunk-33JA4TFA.js.map} +0 -0
  136. /package/dist/{chunk-4JLWXDYA.js.map → chunk-3EHHMC6E.js.map} +0 -0
  137. /package/dist/{chunk-CCZIVI3F.js.map → chunk-BFW56GTT.js.map} +0 -0
  138. /package/dist/{chunk-HZHNRYHK.js.map → chunk-K6N6XJJX.js.map} +0 -0
  139. /package/dist/{chunk-MGEHEHSN.js.map → chunk-OIIMMLRB.js.map} +0 -0
  140. /package/dist/{chunk-DXZRATT5.js.map → chunk-OYZAPX5G.js.map} +0 -0
  141. /package/dist/{chunk-ODVOOEWQ.js.map → chunk-QBRSJK47.js.map} +0 -0
  142. /package/dist/{chunk-GQCZRZ7L.js.map → chunk-U5CHZ5M3.js.map} +0 -0
  143. /package/dist/{chunk-HQPHZGL6.js.map → chunk-YLMUS4MM.js.map} +0 -0
@@ -1,723 +0,0 @@
1
- import { AxAIService } from '@ax-llm/ax';
2
- import { z } from 'zod';
3
- import { c as AnalystFinding, A as Analyst, a as AnalystContext } from './policy-edit-wG9uFEFm.js';
4
- import { T as TraceAnalystKindSpec } from './kind-factory-ClZmO25A.js';
5
- import { a as TraceAnalystSpan } from './store-C1YxJDEK.js';
6
- import { R as Run, S as Span, e as TraceEvent, A as Artifact, B as BudgetLedgerEntry } from './schema-B3Q3l9Z_.js';
7
- import { T as TraceStore } from './store-DGqD0Pyo.js';
8
- import { C as CostLedger } from './cost-ledger-DWy3XdJc.js';
9
- import { a as LlmClientOptions } from './llm-client-qoDd18Qz.js';
10
- import { S as Severity } from './multi-layer-verifier-BsqKuLyN.js';
11
-
12
- interface CreateAnalystAiConfig {
13
- /** OpenAI-compatible API key forwarded as `Authorization: Bearer`.
14
- * cli-bridge ignores the value on loopback but Ax requires a non-empty string. */
15
- apiKey: string;
16
- /** OpenAI-compatible base URL — e.g. `https://router.tangle.tools/v1` or a
17
- * cli-bridge loopback. */
18
- baseUrl: string;
19
- /** Model id forwarded to the analyst actor + responder. */
20
- model: string;
21
- /** Ax provider name. Defaults to the OpenAI-compatible client. */
22
- provider?: 'openai' | 'anthropic';
23
- }
24
- /**
25
- * Construct the `AxAIService` an analyst kind calls through
26
- * (`createTraceAnalystKind({ ai })`).
27
- *
28
- * Ax's `ai()` pins `config.model` to the OpenAI catalog enum, but every
29
- * OpenAI-compatible router an analyst points at (router.tangle.tools,
30
- * cli-bridge) accepts arbitrary model ids (claude-code/sonnet, openai/gpt-5.4,
31
- * …). Consumers were each re-rolling `ai({ name, apiKey, apiURL, config })`
32
- * behind an `as (a: any) => any` cast to dodge the enum; this is the one
33
- * canonical constructor so they don't have to — and don't take a direct
34
- * `@ax-llm/ax` dependency for it.
35
- */
36
- declare function createAnalystAi(config: CreateAnalystAiConfig): AxAIService;
37
-
38
- /**
39
- * Typed `FindingSubject` — the canonical grammar every analyst kind emits.
40
- *
41
- * Background: kind actor prompts have always documented a subject grammar
42
- * (e.g. `system-prompt:<section>`, `agent-knowledge:wiki:<slug>`) but the
43
- * LLM was unconstrained — it could emit `subject: "fix the prompt"`
44
- * (prose) and downstream adapters routed on `startsWith(...)` would
45
- * silently skip it. Every per-vertical `ImprovementAdapter` had a
46
- * routing table that mostly caught nothing.
47
- *
48
- * This module fixes that:
49
- * - `parseFindingSubject(raw)` — returns the typed `FindingSubject`
50
- * when `raw` matches the grammar, else `null`. Used at the
51
- * `RawAnalystFindingSchema` boundary so malformed subjects are
52
- * rejected loudly instead of silently lifted into the registry.
53
- * - `FindingSubjectKind` — the union of valid locus categories. Each
54
- * variant carries the typed components downstream adapters resolve
55
- * against the agent's surface manifest (no string parsing in the
56
- * adapter).
57
- * - `FINDING_SUBJECT_GRAMMAR_PROMPT` — single source of truth for the
58
- * grammar string embedded in kind actor prompts. Drift between
59
- * prompt and parser is impossible if every kind imports this.
60
- *
61
- * The grammar is intentionally NARROW — only loci the substrate's
62
- * default `ImprovementAdapter` / `KnowledgeAdapter` can act on. A
63
- * finding with a subject outside this set fails the parser; the kind
64
- * author either extends the grammar here (and adds adapter routing)
65
- * or rephrases the prompt to map onto an existing variant.
66
- *
67
- * `failure-mode` is the one exception — its subjects are free-form
68
- * cluster labels, not loci. The schema preserves them as
69
- * `{ kind: 'cluster', label }` and the adapters skip them (cluster
70
- * findings are evidence, not actionable mutations).
71
- */
72
-
73
- /**
74
- * Discriminated union of every locus the substrate can route findings to.
75
- *
76
- * Adapters narrow on `kind` and use the typed components (no string
77
- * parsing). Adding a variant here REQUIRES updating the parser, the
78
- * grammar prompt, and at least one adapter — by design.
79
- */
80
- type FindingSubject = {
81
- kind: 'knowledge.wiki';
82
- slug: string;
83
- heading?: string;
84
- } | {
85
- kind: 'knowledge.claim';
86
- topic: string;
87
- } | {
88
- kind: 'knowledge.raw';
89
- sourceId: string;
90
- } | {
91
- kind: 'knowledge.stale';
92
- slug: string;
93
- } | {
94
- kind: 'system-prompt';
95
- section: string;
96
- } | {
97
- kind: 'skill';
98
- name: string;
99
- } | {
100
- kind: 'tool-doc';
101
- tool: string;
102
- aspect?: string;
103
- } | {
104
- kind: 'new-tool';
105
- name: string;
106
- } | {
107
- kind: 'mcp';
108
- server: string;
109
- tool?: string;
110
- } | {
111
- kind: 'hook';
112
- name: string;
113
- } | {
114
- kind: 'subagent';
115
- name: string;
116
- } | {
117
- kind: 'workflow';
118
- name: string;
119
- } | {
120
- kind: 'rollout-policy';
121
- field: string;
122
- } | {
123
- kind: 'agent-profile';
124
- field: string;
125
- } | {
126
- kind: 'code';
127
- path: string;
128
- } | {
129
- kind: 'rag';
130
- corpus: string;
131
- docId: string;
132
- } | {
133
- kind: 'memory';
134
- key: string;
135
- } | {
136
- kind: 'scaffolding';
137
- concern: string;
138
- } | {
139
- kind: 'output-schema';
140
- field: string;
141
- } | {
142
- kind: 'websearch.outdated';
143
- topic: string;
144
- } | {
145
- kind: 'prior-run-summary';
146
- topic: string;
147
- } | {
148
- kind: 'cluster';
149
- label: string;
150
- };
151
- type FindingSubjectKind = FindingSubject['kind'];
152
- declare const FINDING_SUBJECT_KINDS: ReadonlyArray<FindingSubjectKind>;
153
- /**
154
- * Parse a raw subject string emitted by an analyst kind's actor.
155
- *
156
- * Returns the typed `FindingSubject` when `raw` matches the grammar,
157
- * else `null`. Callers use the `null` return as a signal to either
158
- * (a) reject the finding at parse time (kinds that emit typed loci —
159
- * knowledge-gap, improvement, knowledge-poisoning) or (b) lift it as
160
- * a cluster label (failure-mode).
161
- *
162
- * Slugs are constrained to `[a-z0-9-]+` (lowercase kebab) to keep file
163
- * paths sane downstream. Topics / keys / sections allow any non-empty
164
- * string (free-form for the LLM's voice) but get trimmed.
165
- *
166
- * Empty / whitespace-only inputs return `null`. `undefined` returns
167
- * `null`. Both are surfaced by the caller as a rejected subject.
168
- */
169
- declare function parseFindingSubject(raw: string | null | undefined): FindingSubject | null;
170
- /**
171
- * Render the parsed subject back to its canonical string form. Inverse
172
- * of `parseFindingSubject`; useful when the substrate constructs new
173
- * findings programmatically (e.g. for tests, replays, or
174
- * `id_basis` carry-forward).
175
- */
176
- declare function renderFindingSubject(s: FindingSubject): string;
177
- /**
178
- * The grammar text embedded into kind actor prompts. Kinds opt into
179
- * the subset of variants they emit (e.g. `improvement` excludes the
180
- * cluster variant; `failure-mode` includes ONLY the cluster variant).
181
- *
182
- * Drift between prompt and parser is impossible: every kind imports
183
- * this constant + the matching `expects` set, and the unit tests below
184
- * lock the table to the parser.
185
- */
186
- declare const FINDING_SUBJECT_SYNTAX: Readonly<Record<FindingSubjectKind, string>>;
187
- declare const FINDING_SUBJECT_GRAMMAR_PROMPT: string;
188
- /**
189
- * The variants each kind is allowed to emit. Used at the kind factory
190
- * boundary so a knowledge-gap finding can't sneak in a `system-prompt:*`
191
- * subject (the improvement-analyst's job) and vice versa.
192
- *
193
- * `failure-mode` is restricted to `cluster` — the only kind that emits
194
- * a non-locus subject.
195
- */
196
- declare const KIND_EXPECTED_SUBJECTS: Record<string, ReadonlyArray<FindingSubjectKind>>;
197
- /** Render only the subject forms one analyst kind is permitted to emit. */
198
- declare function findingSubjectGrammarPromptFor(kindId: string): string;
199
- /**
200
- * Zod schema that validates a raw subject string and returns the parsed
201
- * `FindingSubject`. Embedded in `RawAnalystFindingSchema` via
202
- * `transform`, so `subject` arrives at the kind factory either as a
203
- * typed locus or as a parse error attached to a single Zod issue.
204
- *
205
- * Optionality is preserved: subjects ARE optional on the wire (some
206
- * findings are descriptive, not actionable). When present, they MUST
207
- * parse — emitting a malformed subject is a contract violation, not a
208
- * soft signal.
209
- */
210
- declare const FindingSubjectStringSchema: z.ZodString;
211
-
212
- /**
213
- * FindingsStore — durable persistence for AnalystFinding rows + a diff
214
- * helper so we can answer "what changed since the last run?" without
215
- * recomputing analysts.
216
- *
217
- * On-disk shape is JSONL: one finding per line, append-only, locked via
218
- * LockedJsonlAppender. Operators get crash-safety (no partial JSON),
219
- * cheap reads (sequential parse), and trivial backup (rsync the file).
220
- *
221
- * Reads are non-locking: a reader sees a consistent snapshot of all
222
- * fully-written lines and skips an incomplete trailing line if the
223
- * writer is mid-append. Cross-process locking is intentionally out of
224
- * scope (see locked-jsonl-appender.ts).
225
- *
226
- * The store is run-scoped: callers pass `runId` on append and on load,
227
- * which keeps multi-run files cleanly partitioned. The `diffFindings`
228
- * helper compares two run-id sets using stable `finding_id` semantics —
229
- * the diff is the cross-run signal the regression dashboard renders.
230
- */
231
-
232
- /**
233
- * One persisted row. We attach `run_id` on disk so a single file can
234
- * hold multiple runs and the diff helper can query without re-walking
235
- * separate files.
236
- */
237
- interface PersistedFinding extends AnalystFinding {
238
- run_id: string;
239
- }
240
- declare class FindingsStore {
241
- readonly path: string;
242
- private readonly appender;
243
- constructor(path: string);
244
- append(runId: string, findings: AnalystFinding[]): Promise<void>;
245
- /** Load every persisted finding. Discards malformed trailing lines silently. */
246
- loadAll(): PersistedFinding[];
247
- /** Filter to a single run. */
248
- loadRun(runId: string): PersistedFinding[];
249
- }
250
- interface FindingsDiff {
251
- /** New finding ids in `current` that weren't in `previous`. */
252
- appeared: PersistedFinding[];
253
- /** Finding ids in `previous` that aren't in `current`. */
254
- disappeared: PersistedFinding[];
255
- /** Same finding id present in both runs and unchanged per the materiality test. */
256
- persisted: PersistedFinding[];
257
- /**
258
- * Same finding id in both runs but at least one non-identity field
259
- * shifted per `DiffPolicy.isMaterial`. Reported as [previous, current].
260
- */
261
- changed: Array<{
262
- previous: PersistedFinding;
263
- current: PersistedFinding;
264
- }>;
265
- }
266
- interface DiffPolicy {
267
- /**
268
- * Predicate that decides whether two findings (same finding_id) count
269
- * as a material change. Defaults to {@link defaultIsMaterial}: severity
270
- * shift, confidence Δ > 0.05, or evidence count change. Compliance /
271
- * perf consumers MAY supply a stricter predicate (e.g. rationale text
272
- * diff, metric Δ thresholds).
273
- */
274
- isMaterial?: (previous: AnalystFinding, current: AnalystFinding) => boolean;
275
- }
276
- /**
277
- * Default materiality test. Deliberately narrow so LLM-reword churn
278
- * doesn't flood the diff. Stricter tests are opt-in via DiffPolicy.
279
- */
280
- declare function defaultIsMaterial(a: AnalystFinding, b: AnalystFinding): boolean;
281
- /**
282
- * Diff two findings sets by stable finding_id. Callers typically load
283
- * the two run-id slices from the same store and pass them in.
284
- */
285
- declare function diffFindings(previous: PersistedFinding[], current: PersistedFinding[], policy?: DiffPolicy): FindingsDiff;
286
-
287
- /**
288
- * Failure-mode analyst — classifies what went wrong and why.
289
- *
290
- * Brief: read the trace dataset, identify the top failure modes across
291
- * runs, classify each with severity + evidence, and surface them as
292
- * findings. The actor's job is *taxonomy + evidence*, not fix-design —
293
- * that's the improvement-analyst's job.
294
- *
295
- * Recursion is deep (`maxDepth: 3`) because real failure-mode
296
- * discovery is genuinely tree-shaped: the actor splits the dataset
297
- * into candidate clusters, each cluster spawns a focused investigator
298
- * that drills into representative traces, and a deeply-recursed
299
- * investigator may itself split a confounded mode into two sub-modes.
300
- * Each level fans out 4-way, so the analyst can investigate up to
301
- * ~16 leaf clusters before hitting the depth ceiling.
302
- */
303
-
304
- declare const FAILURE_MODE_KIND_SPEC: TraceAnalystKindSpec;
305
-
306
- /**
307
- * Improvement analyst — actionable, recursive self-improvement findings.
308
- *
309
- * Brief: read findings from upstream analysts (failure-mode,
310
- * knowledge-gap, knowledge-poisoning) AND the trace dataset itself,
311
- * then propose **concrete edits** to the agent's runtime: prompt
312
- * additions, RAG documents to ingest, tool descriptions to rewrite,
313
- * scaffolding changes to make, memory entries to invalidate. Each
314
- * finding is one proposed edit with the locus, the diff, and the
315
- * expected effect.
316
- *
317
- * This is the recursive-self-improvement loop's last mile: the prior
318
- * kinds describe *what's wrong*; this kind describes *what to change*.
319
- *
320
- * Recursion is deep (`maxDepth: 3`) because real improvement proposals
321
- * are competitive: for each failure-mode there are usually 2-3 viable
322
- * fix directions (tighten prompt vs add tool vs adjust scaffolding),
323
- * and the actor should explore each with a focused subagent before
324
- * picking the highest-leverage one to recommend.
325
- */
326
-
327
- declare const IMPROVEMENT_KIND_SPEC: TraceAnalystKindSpec;
328
-
329
- /**
330
- * Knowledge-gap analyst — what did the agent NOT know that it needed?
331
- *
332
- * Brief: find moments in the trace where the agent had to guess, ask
333
- * the user to fill in context, recover from a wrong assumption, or
334
- * loop on a retrieval. Each finding names a *missing or outdated piece
335
- * of knowledge* the agent's curated knowledge base should have held —
336
- * or a downstream lookup (web, docs, tool description) that surfaced
337
- * stale or outdated information.
338
- *
339
- * The primary expected store is `@tangle-network/agent-knowledge`: a
340
- * Karpathy-style wiki the agent maintains with raw ↔ curated pages,
341
- * source anchors, and claim/relation triples. A gap is anything the
342
- * agent had to discover at run-time that should already have lived
343
- * there. Secondary loci: web-search results that returned outdated
344
- * pages, tool descriptions that omitted critical behavior, system-
345
- * prompt sections that didn't cover the case.
346
- *
347
- * Distinct from failure-mode: failure-mode classifies *how* it broke;
348
- * knowledge-gap names the *information* whose absence (or staleness)
349
- * caused the break. One failure-mode often maps to several gaps.
350
- *
351
- * Recursion (`maxDepth: 2`) is enough to fan out one subagent per
352
- * candidate gap-source layer; each subagent runs a focused detection.
353
- */
354
-
355
- declare const KNOWLEDGE_GAP_KIND_SPEC: TraceAnalystKindSpec;
356
-
357
- /**
358
- * Knowledge-poisoning analyst — what FALSE information misled the agent?
359
- *
360
- * Brief: find moments where the agent acted on information that was
361
- * *wrong* — stale memory, RAG documents that contradicted ground truth,
362
- * tool descriptions that lied about return shapes, system-prompt
363
- * instructions that no longer matched reality, prior-run summaries that
364
- * cached a wrong decision.
365
- *
366
- * Distinct from knowledge-gap: a gap is "the agent didn't know X"; a
367
- * poisoning is "the agent confidently used X, but X was wrong." Gaps
368
- * surface as questions / self-correction; poisonings surface as
369
- * confident-but-wrong actions that downstream evidence contradicts.
370
- *
371
- * Recursion is moderate (`maxDepth: 2`) because each candidate
372
- * poisoning typically needs two sub-investigations: one to confirm
373
- * the agent acted on the false belief, one to confirm the belief
374
- * itself is actually false in ground truth.
375
- */
376
-
377
- declare const KNOWLEDGE_POISONING_KIND_SPEC: TraceAnalystKindSpec;
378
-
379
- /**
380
- * Default analyst kinds focused on agent failure + recursive
381
- * self-improvement.
382
- *
383
- * The four kinds chain: failure-mode classifies; knowledge-gap and
384
- * knowledge-poisoning explain *why* in two orthogonal ways; improvement
385
- * proposes concrete edits. Register all four against the same trace
386
- * store and the registry runs them in dependency order if the operator
387
- * pipes findings between them.
388
- */
389
-
390
- /**
391
- * The default kind suite. Order is the run order operators should
392
- * use: failure-mode first (no upstream deps), gap + poisoning next
393
- * (both depend on failures), improvement last (chains all three).
394
- */
395
- declare const DEFAULT_TRACE_ANALYST_KINDS: readonly TraceAnalystKindSpec[];
396
-
397
- /**
398
- * Skill-usage analyst — a DETERMINISTIC `Analyst` over a Claude/Codex skill
399
- * library + its trace corpus. Unlike the trace-store kinds (failure-mode,
400
- * improvement, ...) this kind calls no LLM: it mines real usage and skill
401
- * structure and emits findings by rule.
402
- *
403
- * It exists because the naive "Skill-tool invocation count" lies low — it
404
- * misses orchestrated sub-dispatch (a leaf skill run BY /pursue or /governor
405
- * logs under the parent), slash-command entry, local-script bypass, and
406
- * on-disk artifacts. The 2026-05-30 skill audit found 39/53 skills at zero
407
- * direct invocations, yet only one was a genuine cut: the rest were
408
- * measurement-invisible or discovery-limited. This analyst encodes that
409
- * lesson as a multi-signal usage model so a cheap repeatable pass can keep
410
- * the library honest, and so the expensive audit workflow's verdicts can
411
- * GEPA-distill it toward agreement (see `gold/skill-verdicts.gold.jsonl`).
412
- *
413
- * Report-building (`buildSkillUsageReport`, an fs scan) is separated from
414
- * finding emission (`SkillUsageAnalyst.analyze`, pure) so the slow scan runs
415
- * once at the registry boundary and the rule logic stays unit-testable.
416
- */
417
-
418
- type SkillKind = 'public' | 'private';
419
- /** One skill's multi-signal usage + structure. All counts are deterministic. */
420
- interface SkillUsageRecord {
421
- name: string;
422
- kind: SkillKind;
423
- /** Absolute path to the skill's SKILL.md. */
424
- path: string;
425
- lines: number;
426
- /** `"skill":"<name>"` Skill-tool invocations across the trace corpus. */
427
- directInvocations: number;
428
- /** `<command-name>/<name>` slash invocations across the trace corpus. */
429
- slashInvocations: number;
430
- /** Sibling skills whose SKILL.md dispatches to this one (`/<name>`). Proxy
431
- * for orchestrated sub-dispatch the per-skill counter cannot see. */
432
- inboundRefs: number;
433
- /** On-disk artifacts attributable to the skill (e.g. `.evolve/<name>/**`). */
434
- artifactCount: number;
435
- /** Tangle-private reference count in the body (leak signal for public skills). */
436
- tanglePrivateRefs: number;
437
- hasReferencesDir: boolean;
438
- hasEvalsDir: boolean;
439
- /** Body mentions `skill-runs.jsonl` (visible to /reflect + /governor). */
440
- logsRuns: boolean;
441
- /** Description carries an explicit `Triggers:` clause / trigger phrases. */
442
- hasTriggerPhrases: boolean;
443
- }
444
- interface SkillUsageReport {
445
- generatedFromTraces: number;
446
- records: SkillUsageRecord[];
447
- }
448
- interface SkillUsageScanConfig {
449
- /** Dirs holding `*.jsonl` transcripts (Claude `~/.claude/projects`, Codex sessions). */
450
- transcriptDirs: string[];
451
- /** Skill roots to scan; each dir directly under `root` with a `SKILL.md` is a skill. */
452
- skillRoots: {
453
- root: string;
454
- kind: SkillKind;
455
- }[];
456
- /** Roots scanned for `<root>/.evolve/<skill>` artifact dirs. */
457
- artifactRoots?: string[];
458
- /** Token-prefixed mappings: skill name → extra artifact subpaths under an artifactRoot
459
- * (e.g. reflect → `.evolve/reflections`). Catches non-eponymous artifact dirs. */
460
- artifactAliases?: Record<string, string[]>;
461
- /** Cap files read per transcript dir (bounds a huge corpus); 0 = unbounded. */
462
- maxTranscriptsPerDir?: number;
463
- }
464
- /** Scan the corpus + skill roots into a {@link SkillUsageReport}. Deterministic. */
465
- declare function buildSkillUsageReport(config: SkillUsageScanConfig): SkillUsageReport;
466
- /** Pure rule pass over a report → findings. Exported for direct/unit use. */
467
- declare function emitSkillUsageFindings(report: SkillUsageReport, producedAt: string): AnalystFinding[];
468
- declare class SkillUsageAnalyst implements Analyst<SkillUsageReport> {
469
- readonly id = "skill-usage";
470
- readonly description = "Deterministic multi-signal skill-usage analysis: flags dead skills, measurement-invisible (orchestrated) usage, discovery gaps, public-repo leaks, bloat, missing evals, and missing run-logging.";
471
- readonly inputKind: "custom";
472
- readonly cost: {
473
- kind: "deterministic";
474
- est_usd_per_run: number;
475
- };
476
- readonly version = "1.0.0";
477
- analyze(input: SkillUsageReport, ctx: AnalystContext): Promise<AnalystFinding[]>;
478
- }
479
- declare const SKILL_USAGE_ANALYST: SkillUsageAnalyst;
480
-
481
- /**
482
- * Deterministic behavioral metrics over OTLP spans — pure arithmetic, no LLM.
483
- *
484
- * These are the model-independent multiplier: the four trace-quality signals a
485
- * tolerant analyzer (e.g. HALO) re-derives per run inside the model — token
486
- * growth, output decay, tool monoculture, missing self-verification — computed
487
- * here once, in TypeScript, with zero model judgment. A finding that falls out
488
- * of arithmetic is trivially model-agnostic and cannot hallucinate the trend.
489
- *
490
- * General, not trace-specific: the detectors key off token trajectories and
491
- * tool usage present in any agentic OTLP trace, not any one benchmark.
492
- */
493
-
494
- type SuboptimalCode = 'monotonic-input-growth' | 'output-length-decay' | 'single-tool-dependency' | 'no-self-verification';
495
- interface SuboptimalSignal {
496
- code: SuboptimalCode;
497
- severity: 'high' | 'medium' | 'low';
498
- /** Human-readable claim, with the backing numbers inlined. */
499
- detail: string;
500
- /** The exact figures the detector fired on — auditable, no model in the loop. */
501
- evidence: Record<string, number | string | boolean>;
502
- }
503
- interface BehavioralMetrics {
504
- /** The only trace represented by these metrics; null when spans are empty. */
505
- traceId: string | null;
506
- llmCallCount: number;
507
- /** Causally serial LLM timelines. Parallel branches are never joined. */
508
- tokenSequences: BehavioralTokenSequence[];
509
- /** Token values from the longest serial timeline, retained for convenience. */
510
- inputTokenTrajectory: number[];
511
- outputTokenTrajectory: number[];
512
- toolHistogram: Record<string, number>;
513
- totalToolCalls: number;
514
- distinctTools: number;
515
- /** distinct/total tool calls; 1.0 when there are no tool calls. */
516
- toolDiversityRatio: number;
517
- hasSelfVerification: boolean;
518
- signals: SuboptimalSignal[];
519
- }
520
- interface BehavioralTokenSequence {
521
- scopeId: string;
522
- spanIds: string[];
523
- inputTokenTrajectory: Array<number | null>;
524
- outputTokenTrajectory: Array<number | null>;
525
- }
526
- /**
527
- * Reduce a span list to behavioral metrics + fired suboptimality signals.
528
- * Pure + deterministic: same spans → same output, on any machine, no model.
529
- */
530
- declare function computeTraceMetrics(spans: readonly TraceAnalystSpan[]): BehavioralMetrics;
531
-
532
- interface RunScore {
533
- success: number;
534
- goalProgress: number;
535
- repoGroundedness: number;
536
- driftPenalty: number;
537
- toolUseQuality: number;
538
- patchQuality: number;
539
- testReality: number;
540
- finalGate: number;
541
- reviewerBlockers: number;
542
- costUsd: number;
543
- wallSeconds: number;
544
- notes?: string[];
545
- }
546
- interface RunScoreWeights {
547
- success: number;
548
- goalProgress: number;
549
- repoGroundedness: number;
550
- driftPenalty: number;
551
- toolUseQuality: number;
552
- patchQuality: number;
553
- testReality: number;
554
- finalGate: number;
555
- reviewerBlockers: number;
556
- costUsd: number;
557
- wallSeconds: number;
558
- }
559
- declare const DEFAULT_RUN_SCORE_WEIGHTS: RunScoreWeights;
560
- declare function aggregateRunScore(score: RunScore, weights?: Partial<RunScoreWeights>): number;
561
- declare function clamp01(value: number): number;
562
-
563
- interface RunTrace {
564
- run: Run;
565
- spans: Span[];
566
- events: TraceEvent[];
567
- artifacts: Artifact[];
568
- budget: BudgetLedgerEntry[];
569
- }
570
- interface RunCriticOptions {
571
- weights?: Partial<RunScoreWeights>;
572
- driftPatterns?: RegExp[];
573
- }
574
- declare class RunCritic {
575
- private readonly weights?;
576
- private readonly driftPatterns;
577
- constructor(options?: RunCriticOptions);
578
- score(store: TraceStore, runId: string): Promise<RunScore>;
579
- scoreTrace(trace: RunTrace): RunScore;
580
- rank(score: RunScore): number;
581
- private isDrift;
582
- }
583
-
584
- /**
585
- * Semantic concept judge — "does the built artifact actually implement
586
- * the features the user asked for?"
587
- *
588
- * Distinct from the domain/code/coherence judges in `judges.ts`:
589
- * - those judges score free-form conversational agent outputs along
590
- * quality dimensions (accuracy, depth, etc.)
591
- * - this judge scores a *built artifact* (served HTML + source files)
592
- * against an explicit list of expected concepts, returning per-concept
593
- * {present, score 0-10, evidence, severity}.
594
- *
595
- * The judge is strict about distinguishing (a) a working implementation
596
- * from (b) a keyword-present stub. "// TODO: mint button" is NOT present.
597
- * Only real, functional, wired-up code counts.
598
- *
599
- * Use via {@link createSemanticConceptJudge} or directly via
600
- * {@link runSemanticConceptJudge}. Soft-fails (available=false) on LLM
601
- * or JSON-parse errors so the caller can treat that as "layer skipped"
602
- * rather than "layer failed" in a multi-layer pipeline.
603
- */
604
-
605
- /**
606
- * Implementation complexity class for weighted scoring.
607
- *
608
- * - `render` (default): the concept is a UI surface that displays static
609
- * data — render a list, show a counter, lay out a button. Single-file
610
- * work, no external integration.
611
- * - `integrate`: the concept requires wiring a real external system —
612
- * wallet connect (wagmi + RainbowKit + chain config), payment provider
613
- * (Stripe Elements + intent + webhook), an API client with auth.
614
- * Multi-file, library-knowledge, runtime correctness matters.
615
- * - `compute`: the concept requires algorithmic work — solver, simulator,
616
- * constraint propagation, ML inference. Correctness > UI polish.
617
- *
618
- * Default weights (when applied via `weightConcepts: 'complexity'`):
619
- * render=1.0, integrate=2.0, compute=2.5
620
- *
621
- * Cross-vertical scoring without complexity weighting silently inflates
622
- * the rate of UI-heavy verticals (healthcare, fintech dashboards) vs
623
- * integration-heavy verticals (DeFi, wallets) — all concepts treated
624
- * equally even though the agent does 2-3x the work for `integrate`.
625
- */
626
- type ConceptComplexity = 'render' | 'integrate' | 'compute';
627
- interface ConceptSpec {
628
- name: string;
629
- /** Short hints that help the judge; not used for matching. */
630
- keywords?: string[];
631
- /** Optional explicit weight; default 1.0. Overrides complexity-derived weight. */
632
- weight?: number;
633
- /** Implementation complexity class. Default `render`. */
634
- complexity?: ConceptComplexity;
635
- }
636
- interface ConceptFinding {
637
- concept: string;
638
- present: boolean;
639
- /** 0..10. 10 = production-ready; 7 = functional thin; 4 = partial; 0 = absent. */
640
- score: number;
641
- evidence: string;
642
- severity: Severity;
643
- }
644
- interface SemanticConceptJudgeInput {
645
- /** Full natural-language prompt the agent was handed. */
646
- userRequest: string;
647
- /** Rendered HTML the preview returns (UI artifacts). Optional. */
648
- servedHtml?: string;
649
- /** Top-level source files from the agent's workdir. */
650
- sourceFiles: Array<{
651
- path: string;
652
- content: string;
653
- }>;
654
- /** The expected concept list. */
655
- expectedConcepts: ConceptSpec[];
656
- /** Free-form metadata (id, difficulty) to inject into the prompt. */
657
- artifactLabel?: string;
658
- artifactDescription?: string;
659
- }
660
- interface SemanticConceptJudgeResult {
661
- kind: 'semantic-concept';
662
- version: string;
663
- /** Normalized 0..1 score — mean of per-concept scores / 10. */
664
- score: number;
665
- presentCount: number;
666
- totalCount: number;
667
- findings: ConceptFinding[];
668
- summary: string;
669
- durationMs: number;
670
- costUsd: number | null;
671
- /** False on LLM/JSON error — treat as "skipped / unable to judge" in pipelines. */
672
- available: boolean;
673
- error?: string;
674
- }
675
- /**
676
- * Score-aggregation strategy. `mean` averages 0-10 scores uniformly.
677
- * `complexity` applies the default weight table (render=1, integrate=2,
678
- * compute=2.5) unless a concept has an explicit `weight`. `explicit`
679
- * honors only `weight` (defaulting to 1 for unspecified).
680
- */
681
- type ConceptWeightStrategy = 'mean' | 'complexity' | 'explicit';
682
- declare const DEFAULT_COMPLEXITY_WEIGHTS: Record<ConceptComplexity, number>;
683
- interface SemanticConceptJudgeOptions {
684
- /** Model id to call. Default 'claude-sonnet-4-6' via agent-eval defaults. */
685
- model?: string;
686
- /** Per-call timeout. Default 300s. */
687
- timeoutMs?: number;
688
- /** Provider-enforced output limit. Default 16000. */
689
- maxTokens?: number;
690
- /** Pipeline budget for the prompt (source blob truncation). Default 45000. */
691
- maxSourceChars?: number;
692
- /** Per-file cap before inclusion. Default 20000. */
693
- maxPerFileChars?: number;
694
- /** HTML cap. Default 30000. */
695
- maxHtmlChars?: number;
696
- /** LlmClient config (baseUrl, apiKey, authHeader, …). */
697
- llm?: LlmClientOptions;
698
- costLedger?: CostLedger;
699
- costPhase?: string;
700
- signal?: AbortSignal;
701
- /**
702
- * Score aggregation strategy. Default `mean` — uniform average across
703
- * concepts. Cross-vertical comparisons should use `complexity` to
704
- * neutralize the integrate-vs-render asymmetry.
705
- */
706
- weightConcepts?: ConceptWeightStrategy;
707
- /** Override the default complexity → weight table. */
708
- complexityWeights?: Partial<Record<ConceptComplexity, number>>;
709
- }
710
- declare const SEMANTIC_CONCEPT_JUDGE_VERSION = "semantic-concept-judge-v1-2026-04-24";
711
- /**
712
- * Run the semantic concept judge. Soft-fails to available=false on
713
- * LLM/JSON errors — callers in a MultiLayerVerifier pipeline can treat
714
- * that as "skip" rather than "fail."
715
- */
716
- declare function runSemanticConceptJudge(input: SemanticConceptJudgeInput, options?: SemanticConceptJudgeOptions): Promise<SemanticConceptJudgeResult>;
717
- /**
718
- * Factory: pin LLM options once, return a closure that accepts inputs.
719
- * Convenient for pipelines that want to share a single LlmClient config.
720
- */
721
- declare function createSemanticConceptJudge(options?: SemanticConceptJudgeOptions): (input: SemanticConceptJudgeInput) => Promise<SemanticConceptJudgeResult>;
722
-
723
- export { runSemanticConceptJudge as $, type RunScore as A, type BehavioralMetrics as B, type CreateAnalystAiConfig as C, DEFAULT_TRACE_ANALYST_KINDS as D, type RunScoreWeights as E, FAILURE_MODE_KIND_SPEC as F, type BehavioralTokenSequence as G, type ConceptComplexity as H, IMPROVEMENT_KIND_SPEC as I, type ConceptFinding as J, KIND_EXPECTED_SUBJECTS as K, type ConceptSpec as L, type ConceptWeightStrategy as M, DEFAULT_COMPLEXITY_WEIGHTS as N, DEFAULT_RUN_SCORE_WEIGHTS as O, type PersistedFinding as P, type RunCriticOptions as Q, RunCritic as R, type SemanticConceptJudgeOptions as S, SEMANTIC_CONCEPT_JUDGE_VERSION as T, type SemanticConceptJudgeResult as U, type SuboptimalCode as V, type SuboptimalSignal as W, aggregateRunScore as X, clamp01 as Y, computeTraceMetrics as Z, createSemanticConceptJudge as _, type RunTrace as a, type SemanticConceptJudgeInput as b, type DiffPolicy as c, FINDING_SUBJECT_GRAMMAR_PROMPT as d, FINDING_SUBJECT_KINDS as e, FINDING_SUBJECT_SYNTAX as f, type FindingSubject as g, type FindingSubjectKind as h, FindingSubjectStringSchema as i, type FindingsDiff as j, FindingsStore as k, KNOWLEDGE_GAP_KIND_SPEC as l, KNOWLEDGE_POISONING_KIND_SPEC as m, SKILL_USAGE_ANALYST as n, SkillUsageAnalyst as o, type SkillUsageRecord as p, type SkillUsageReport as q, type SkillUsageScanConfig as r, buildSkillUsageReport as s, createAnalystAi as t, defaultIsMaterial as u, diffFindings as v, emitSkillUsageFindings as w, findingSubjectGrammarPromptFor as x, parseFindingSubject as y, renderFindingSubject as z };