@tangle-network/agent-eval 0.118.3 → 0.119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +26 -0
- package/dist/analyst/index.d.ts +143 -21
- package/dist/analyst/index.js +44 -10
- package/dist/analyst/index.js.map +1 -1
- package/dist/benchmarks/index.d.ts +50 -40
- package/dist/benchmarks/index.js +6 -6
- package/dist/campaign/index.d.ts +231 -156
- package/dist/campaign/index.js +5 -5
- package/dist/{chunk-JTMFT5QZ.js → chunk-4I2E3LLO.js} +2 -2
- package/dist/{chunk-VNLWDTDA.js → chunk-7A4LIMMY.js} +845 -252
- package/dist/chunk-7A4LIMMY.js.map +1 -0
- package/dist/{chunk-KK2O4VWA.js → chunk-D7AEXSM5.js} +2 -2
- package/dist/{chunk-EKHHBKS6.js → chunk-F6YUH3L4.js} +39 -28
- package/dist/{chunk-EKHHBKS6.js.map → chunk-F6YUH3L4.js.map} +1 -1
- package/dist/{chunk-267UCQWI.js → chunk-GERDAIAL.js} +2 -2
- package/dist/{chunk-267UCQWI.js.map → chunk-GERDAIAL.js.map} +1 -1
- package/dist/{chunk-MLHRFWQK.js → chunk-JHOJHHU7.js} +85 -16
- package/dist/chunk-JHOJHHU7.js.map +1 -0
- package/dist/{chunk-F5A4GDQW.js → chunk-LMJ2TGWJ.js} +3 -15
- package/dist/chunk-LMJ2TGWJ.js.map +1 -0
- package/dist/{chunk-EGNRE7VA.js → chunk-PAHNGS65.js} +2 -2
- package/dist/{chunk-QWRLW4CT.js → chunk-RLCJQ6VZ.js} +5 -5
- package/dist/{chunk-7V3QDWNL.js → chunk-XJ7JVCHB.js} +2 -2
- package/dist/cli.js +2 -2
- package/dist/contract/index.d.ts +257 -160
- package/dist/contract/index.js +6 -6
- package/dist/fuzz.d.ts +19 -1
- package/dist/fuzz.js +1 -1
- package/dist/index.d.ts +154 -48
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/primeintellect/index.d.ts +311 -0
- package/dist/primeintellect/index.js +348 -0
- package/dist/primeintellect/index.js.map +1 -0
- package/dist/rl.d.ts +4 -0
- package/dist/{run-campaign-DWC67KJP.js → run-campaign-OBXSN5WK.js} +3 -3
- package/dist/wire/index.d.ts +19 -1
- package/dist/wire/index.js +2 -2
- package/package.json +6 -1
- package/dist/chunk-F5A4GDQW.js.map +0 -1
- package/dist/chunk-MLHRFWQK.js.map +0 -1
- package/dist/chunk-VNLWDTDA.js.map +0 -1
- /package/dist/{chunk-JTMFT5QZ.js.map → chunk-4I2E3LLO.js.map} +0 -0
- /package/dist/{chunk-KK2O4VWA.js.map → chunk-D7AEXSM5.js.map} +0 -0
- /package/dist/{chunk-EGNRE7VA.js.map → chunk-PAHNGS65.js.map} +0 -0
- /package/dist/{chunk-QWRLW4CT.js.map → chunk-RLCJQ6VZ.js.map} +0 -0
- /package/dist/{chunk-7V3QDWNL.js.map → chunk-XJ7JVCHB.js.map} +0 -0
- /package/dist/{run-campaign-DWC67KJP.js.map → run-campaign-OBXSN5WK.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,27 @@ All notable changes to `@tangle-network/agent-eval` and its sibling `agent-eval-
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [0.119.0] — 2026-07-14 — chained, metered trace analysis
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Trace analysts can consume findings produced earlier in the same ordered run and emit multiple evidence citations without changing the original singular-citation callback API.
|
|
12
|
+
- Analyst summaries report provider calls, input, output, reasoning, cache-read, cache-write, dollar provenance, and known partial spend independently of finding count.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- All Ax analyst calls reserve spend before dispatch, disable hidden provider retries, honor cancellation, wait a bounded time for late receipts, and preserve known charges when token usage is unavailable.
|
|
17
|
+
- Trace-analysis proposers record each model call directly in the campaign cost ledger instead of replacing them with one estimated wrapper receipt.
|
|
18
|
+
- Direct Gemini 3 analysis keeps its output limit without sending Ax's incompatible thinking-level option.
|
|
19
|
+
- Recovery findings pass through the same subject, evidence, and post-processing rules as primary findings, and malformed recovery calls fail visibly.
|
|
20
|
+
- Budget allocation rejects invalid values and cannot exceed the remaining run budget or regain spend through malformed finding metadata.
|
|
21
|
+
|
|
22
|
+
### Breaking
|
|
23
|
+
|
|
24
|
+
- `SemanticConceptJudgeAdapterOpts.options` no longer accepts `costLedger` or `signal`; remove those fields because `AnalystRegistry` now supplies the run budget and cancellation signal and records the resulting usage.
|
|
25
|
+
- `createTraceAnalystKind()` now requires `model` when passed an externally constructed Ax service; supply the service's model explicitly or construct it with `createAnalystAi()` so the model can be recovered safely.
|
|
26
|
+
- `TraceAnalystGolden.expected` now uses `CanonicalRawAnalystFinding` with an `evidence` array; migrate singular `evidence_uri` and `evidence_excerpt` fields into the first array entry.
|
|
27
|
+
|
|
7
28
|
## [0.118.2] — 2026-07-13 — interoperable contracts and trace accounting
|
|
8
29
|
|
|
9
30
|
### Fixed
|
package/README.md
CHANGED
|
@@ -95,6 +95,31 @@ 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
|
+
|
|
98
123
|
---
|
|
99
124
|
|
|
100
125
|
## Core concepts
|
|
@@ -124,6 +149,7 @@ Each example: `README.md` + a single `index.ts` runnable via `pnpm tsx`. Prints
|
|
|
124
149
|
|---|---|
|
|
125
150
|
| `…/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`. |
|
|
126
151
|
| `…/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 |
|
|
127
153
|
| `…/adapters/otel` | `createOtelBridge` — forwards OpenTelemetry-shape spans into the hosted-tier ingest, no `@opentelemetry/*` dependency |
|
|
128
154
|
| `…/adapters/langchain` | Wrap any LangChain `Runnable` as a `Dispatch` (or `JudgeConfig`), no `@langchain/core` peer dep |
|
|
129
155
|
| `…/adapters/http` | `httpDispatch` + `runDispatchServer` — run a campaign's worker on another machine (multi-region, remote worker execution) |
|
package/dist/analyst/index.d.ts
CHANGED
|
@@ -800,8 +800,14 @@ declare class RunCritic {
|
|
|
800
800
|
type CostChannel = 'agent' | 'judge' | 'verifier' | 'analyst' | 'driver' | (string & {});
|
|
801
801
|
interface CostUsage {
|
|
802
802
|
inputTokens: number;
|
|
803
|
+
/** Includes reasoning tokens when the provider bills them as output. */
|
|
803
804
|
outputTokens: number;
|
|
805
|
+
/** Reasoning-token subset of outputTokens, when reported. */
|
|
806
|
+
reasoningTokens?: number;
|
|
807
|
+
/** Prompt tokens served from a provider cache. */
|
|
804
808
|
cachedTokens?: number;
|
|
809
|
+
/** Prompt tokens written into a provider cache. */
|
|
810
|
+
cacheWriteTokens?: number;
|
|
805
811
|
}
|
|
806
812
|
interface CostCallBase {
|
|
807
813
|
callId: string;
|
|
@@ -868,7 +874,9 @@ interface ChannelRollup {
|
|
|
868
874
|
calls: number;
|
|
869
875
|
inputTokens: number;
|
|
870
876
|
outputTokens: number;
|
|
877
|
+
reasoningTokens?: number;
|
|
871
878
|
cachedTokens: number;
|
|
879
|
+
cacheWriteTokens?: number;
|
|
872
880
|
costUsd: number;
|
|
873
881
|
unpricedCalls: number;
|
|
874
882
|
unknownUsageCalls: number;
|
|
@@ -880,7 +888,9 @@ interface CostLedgerSummary {
|
|
|
880
888
|
reservedCostUsd: number;
|
|
881
889
|
inputTokens: number;
|
|
882
890
|
outputTokens: number;
|
|
891
|
+
reasoningTokens?: number;
|
|
883
892
|
cachedTokens: number;
|
|
893
|
+
cacheWriteTokens?: number;
|
|
884
894
|
totalCostUsd: number;
|
|
885
895
|
byChannel: ChannelRollup[];
|
|
886
896
|
unpricedModels: string[];
|
|
@@ -894,6 +904,10 @@ interface CostLedgerFilter {
|
|
|
894
904
|
phase?: string;
|
|
895
905
|
tags?: Record<string, string>;
|
|
896
906
|
}
|
|
907
|
+
interface CostLedgerWaitOptions {
|
|
908
|
+
/** Maximum time to wait for active provider calls. Default 5 seconds. */
|
|
909
|
+
timeoutMs?: number;
|
|
910
|
+
}
|
|
897
911
|
/** Append-only storage. `append` must atomically reject stale revisions. */
|
|
898
912
|
interface CostLedgerPersistence {
|
|
899
913
|
read(): {
|
|
@@ -913,6 +927,7 @@ declare class CostLedger {
|
|
|
913
927
|
private readonly records;
|
|
914
928
|
private readonly activeCallIds;
|
|
915
929
|
private readonly lateCallIds;
|
|
930
|
+
private readonly idleWaiters;
|
|
916
931
|
private completedTasks;
|
|
917
932
|
private revision;
|
|
918
933
|
private costLimitPersisted;
|
|
@@ -920,6 +935,8 @@ declare class CostLedger {
|
|
|
920
935
|
private readonly persistence?;
|
|
921
936
|
constructor(input?: number | CostLedgerOptions);
|
|
922
937
|
runPaidCall<T>(input: RunPaidCallInput<T>): Promise<PaidCallResult<T>>;
|
|
938
|
+
/** Wait until every call started by this ledger has produced a durable outcome. */
|
|
939
|
+
waitForIdle(options?: CostLedgerWaitOptions): Promise<boolean>;
|
|
923
940
|
/** Settle a call left pending by a crashed process after reconciling with the provider. */
|
|
924
941
|
reconcile(callId: string, observed: CostReceiptInput, options?: {
|
|
925
942
|
error?: string;
|
|
@@ -930,6 +947,7 @@ declare class CostLedger {
|
|
|
930
947
|
costPerCompletedTask(): number | null;
|
|
931
948
|
private execute;
|
|
932
949
|
private captureLateOutcome;
|
|
950
|
+
private releaseActiveCall;
|
|
933
951
|
private commitOutcome;
|
|
934
952
|
private captureFailure;
|
|
935
953
|
private commitReceipt;
|
|
@@ -945,7 +963,7 @@ declare class CostLedger {
|
|
|
945
963
|
* Keeping callback contracts structural lets those subpaths compose while the
|
|
946
964
|
* concrete {@link CostLedger} retains its private durable state.
|
|
947
965
|
*/
|
|
948
|
-
type CostLedgerHandle = Pick<CostLedger, keyof CostLedger
|
|
966
|
+
type CostLedgerHandle = Pick<CostLedger, Exclude<keyof CostLedger, 'waitForIdle'>> & Partial<Pick<CostLedger, 'waitForIdle'>>;
|
|
949
967
|
|
|
950
968
|
/**
|
|
951
969
|
* LLM client with graceful degrade.
|
|
@@ -1715,6 +1733,10 @@ interface AnalystContext {
|
|
|
1715
1733
|
deadlineMs?: number;
|
|
1716
1734
|
/** Per-analyst USD budget. Analysts MAY check before issuing LLM calls. */
|
|
1717
1735
|
budgetUsd?: number;
|
|
1736
|
+
/** Shared paid-call account when the analyst runs inside a larger campaign. */
|
|
1737
|
+
costLedger?: CostLedgerHandle;
|
|
1738
|
+
/** Attribution phase used when writing to the shared paid-call account. */
|
|
1739
|
+
costPhase?: string;
|
|
1718
1740
|
/**
|
|
1719
1741
|
* Shared chat client. Analysts that call an LLM go through this so
|
|
1720
1742
|
* the operator picks transport (sandbox-sdk | router | cli-bridge |
|
|
@@ -1732,6 +1754,18 @@ interface AnalystContext {
|
|
|
1732
1754
|
* filter. Empty / absent means no cross-run context.
|
|
1733
1755
|
*/
|
|
1734
1756
|
priorFindings?: ReadonlyArray<AnalystFinding>;
|
|
1757
|
+
/**
|
|
1758
|
+
* Findings emitted by analysts that completed earlier in this registry run.
|
|
1759
|
+
* This is separate from `priorFindings`: upstream findings are dependency
|
|
1760
|
+
* context for the current pass, while prior findings are cross-run memory.
|
|
1761
|
+
* The registry populates this only when `RegistryRunOpts.chainFindings` is on.
|
|
1762
|
+
*/
|
|
1763
|
+
upstreamFindings?: ReadonlyArray<AnalystFinding>;
|
|
1764
|
+
/**
|
|
1765
|
+
* Report metered work independently of findings. This keeps an empty finding
|
|
1766
|
+
* set from erasing token/cost telemetry. Multiple receipts are accumulated.
|
|
1767
|
+
*/
|
|
1768
|
+
recordUsage?: (receipt: AnalystUsageReceipt) => void;
|
|
1735
1769
|
/** Free-form runtime tags (env, host, op). Findings can echo these into metadata. */
|
|
1736
1770
|
tags?: Record<string, string>;
|
|
1737
1771
|
/** Logger callback — analysts SHOULD prefer this over console.* for testability. */
|
|
@@ -1757,6 +1791,17 @@ interface Analyst<TInput = unknown> {
|
|
|
1757
1791
|
readonly version: string;
|
|
1758
1792
|
analyze(input: TInput, ctx: AnalystContext): Promise<AnalystFinding[]>;
|
|
1759
1793
|
}
|
|
1794
|
+
/** Metered work performed by one analyst call. */
|
|
1795
|
+
interface AnalystUsageReceipt {
|
|
1796
|
+
/** Number of model-usage records observed at the provider boundary. */
|
|
1797
|
+
calls: number | null;
|
|
1798
|
+
/** Null when the provider did not return token accounting. */
|
|
1799
|
+
tokens: RunTokenUsage | null;
|
|
1800
|
+
/** Observed, estimated, or explicitly uncaptured dollar cost. */
|
|
1801
|
+
cost: RunCostProvenance;
|
|
1802
|
+
/** Known lower bound when one or more calls have uncaptured cost. */
|
|
1803
|
+
knownCostUsd?: number;
|
|
1804
|
+
}
|
|
1760
1805
|
/**
|
|
1761
1806
|
* Compute the stable finding_id from the identity-defining fields.
|
|
1762
1807
|
* Default implementation hashes {analyst_id, area, subject, normalized claim}.
|
|
@@ -1789,6 +1834,12 @@ interface AnalystRunSummary {
|
|
|
1789
1834
|
findings_count: number;
|
|
1790
1835
|
latency_ms: number;
|
|
1791
1836
|
cost_usd: number;
|
|
1837
|
+
/**
|
|
1838
|
+
* Additive receipt for model usage. Registry-produced summaries populate it
|
|
1839
|
+
* even when the analyst emits no findings. `cost_usd` remains the legacy
|
|
1840
|
+
* numeric field; inspect `usage.cost` before treating zero as observed.
|
|
1841
|
+
*/
|
|
1842
|
+
usage?: AnalystUsageReceipt;
|
|
1792
1843
|
/** When `status='failed'`: the error class + message, never the full stack. */
|
|
1793
1844
|
error?: {
|
|
1794
1845
|
class: string;
|
|
@@ -1804,6 +1855,11 @@ interface AnalystRunResult {
|
|
|
1804
1855
|
per_analyst: AnalystRunSummary[];
|
|
1805
1856
|
/** Total LLM cost in USD across all analysts in this registry.run(). */
|
|
1806
1857
|
total_cost_usd: number;
|
|
1858
|
+
/**
|
|
1859
|
+
* Provenance for `total_cost_usd`. When uncaptured, the numeric field is only
|
|
1860
|
+
* the known subtotal and must not be treated as the run's total spend.
|
|
1861
|
+
*/
|
|
1862
|
+
total_cost_provenance?: RunCostProvenance;
|
|
1807
1863
|
}
|
|
1808
1864
|
/**
|
|
1809
1865
|
* Events emitted by `AnalystRegistry.runStream(...)` in real time as
|
|
@@ -1896,7 +1952,10 @@ declare function createJudgeAdapter(opts: JudgeAdapterOpts): Analyst<JudgeInput>
|
|
|
1896
1952
|
interface SemanticConceptJudgeAdapterOpts {
|
|
1897
1953
|
id?: string;
|
|
1898
1954
|
area?: string;
|
|
1899
|
-
|
|
1955
|
+
/** Registry context owns cancellation and the per-analyst cost ledger. */
|
|
1956
|
+
options?: Omit<SemanticConceptJudgeOptions, 'costLedger' | 'signal'>;
|
|
1957
|
+
/** Maximum post-cancellation wait for a provider receipt. Default 5 seconds. */
|
|
1958
|
+
settlementTimeoutMs?: number;
|
|
1900
1959
|
}
|
|
1901
1960
|
declare function createSemanticConceptJudgeAdapter(opts?: SemanticConceptJudgeAdapterOpts): Analyst<SemanticConceptJudgeInput>;
|
|
1902
1961
|
|
|
@@ -2016,7 +2075,15 @@ declare function behavioralAnalyst(): Analyst<TraceAnalysisStore>;
|
|
|
2016
2075
|
*/
|
|
2017
2076
|
|
|
2018
2077
|
declare const ANALYST_SEVERITIES: readonly ["critical", "high", "medium", "low", "info"];
|
|
2078
|
+
declare const RawAnalystEvidenceSchema: z.ZodObject<{
|
|
2079
|
+
uri: z.ZodString;
|
|
2080
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
2081
|
+
}, z.core.$strict>;
|
|
2082
|
+
type RawAnalystEvidence = z.infer<typeof RawAnalystEvidenceSchema>;
|
|
2083
|
+
/** Original public schema retained for stored rows and callback contracts. */
|
|
2019
2084
|
declare const RawAnalystFindingSchema: z.ZodObject<{
|
|
2085
|
+
evidence_uri: z.ZodString;
|
|
2086
|
+
evidence_excerpt: z.ZodOptional<z.ZodString>;
|
|
2020
2087
|
severity: z.ZodEnum<{
|
|
2021
2088
|
critical: "critical";
|
|
2022
2089
|
info: "info";
|
|
@@ -2026,25 +2093,53 @@ declare const RawAnalystFindingSchema: z.ZodObject<{
|
|
|
2026
2093
|
}>;
|
|
2027
2094
|
claim: z.ZodString;
|
|
2028
2095
|
subject: z.ZodOptional<z.ZodString>;
|
|
2029
|
-
evidence_uri: z.ZodString;
|
|
2030
|
-
evidence_excerpt: z.ZodOptional<z.ZodString>;
|
|
2031
2096
|
confidence: z.ZodNumber;
|
|
2032
2097
|
rationale: z.ZodOptional<z.ZodString>;
|
|
2033
2098
|
recommended_action: z.ZodOptional<z.ZodString>;
|
|
2034
2099
|
}, z.core.$strict>;
|
|
2035
2100
|
type RawAnalystFinding = z.infer<typeof RawAnalystFindingSchema>;
|
|
2101
|
+
/**
|
|
2102
|
+
* Canonical plural-evidence contract. The preprocessor accepts the original
|
|
2103
|
+
* `evidence_uri` / `evidence_excerpt` pair and normalizes it into one evidence
|
|
2104
|
+
* item so persisted rows and older model fixtures remain readable. New output
|
|
2105
|
+
* always receives the plural shape.
|
|
2106
|
+
*/
|
|
2107
|
+
declare const CanonicalRawAnalystFindingSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
2108
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
2109
|
+
uri: z.ZodString;
|
|
2110
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
2111
|
+
}, z.core.$strict>>;
|
|
2112
|
+
severity: z.ZodEnum<{
|
|
2113
|
+
critical: "critical";
|
|
2114
|
+
info: "info";
|
|
2115
|
+
low: "low";
|
|
2116
|
+
high: "high";
|
|
2117
|
+
medium: "medium";
|
|
2118
|
+
}>;
|
|
2119
|
+
claim: z.ZodString;
|
|
2120
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
2121
|
+
confidence: z.ZodNumber;
|
|
2122
|
+
rationale: z.ZodOptional<z.ZodString>;
|
|
2123
|
+
recommended_action: z.ZodOptional<z.ZodString>;
|
|
2124
|
+
}, z.core.$strict>>;
|
|
2125
|
+
type CanonicalRawAnalystFinding = z.infer<typeof CanonicalRawAnalystFindingSchema>;
|
|
2036
2126
|
/**
|
|
2037
2127
|
* Description embedded into the actor prompt so the LLM knows what
|
|
2038
2128
|
* shape to emit. Kept here so kinds share one source of truth rather
|
|
2039
2129
|
* than restating the schema in every prompt.
|
|
2040
2130
|
*/
|
|
2041
|
-
declare const RAW_FINDING_SCHEMA_PROMPT = "Each finding MUST be a JSON object with
|
|
2131
|
+
declare const RAW_FINDING_SCHEMA_PROMPT = "Each finding MUST be a strict JSON object with:\n - severity: \"critical\" | \"high\" | \"medium\" | \"low\" | \"info\"\n - claim: one-sentence statement (max 2000 chars)\n - subject?: one exact subject form listed by this kind; omit rather than guess\n - evidence: REQUIRED non-empty array of {\"uri\": string, \"excerpt\"?: string}. Use real identifiers with span://, event://, artifact://, metric://, or finding://. Include a short exact quote in excerpt when available. If nothing is citable, do not emit the finding.\n - confidence: number 0..1 (0.9+ exact evidence; 0.6-0.8 inferred pattern; <0.5 speculative)\n - rationale?: one or two reasoning sentences\n - recommended_action?: concrete imperative change; omit for descriptive findings\n\nUnknown fields are rejected. Do not emit area; the factory assigns it. Emit [] when there are no findings. Never fabricate evidence.";
|
|
2132
|
+
/** Convert canonical raw citations into the public finding evidence envelope. */
|
|
2133
|
+
declare function evidenceRefsFromRawFinding(finding: CanonicalRawAnalystFinding): EvidenceRef[];
|
|
2042
2134
|
/**
|
|
2043
|
-
* Validate
|
|
2044
|
-
*
|
|
2045
|
-
*
|
|
2135
|
+
* Validate the original singular-evidence shape. This public parser retains
|
|
2136
|
+
* its pre-canonicalization result type so existing callback code and stored
|
|
2137
|
+
* rows continue to receive exactly the object accepted by
|
|
2138
|
+
* {@link RawAnalystFindingSchema}.
|
|
2046
2139
|
*/
|
|
2047
2140
|
declare function parseRawFinding(row: unknown, log?: (msg: string, fields?: Record<string, unknown>) => void): RawAnalystFinding | null;
|
|
2141
|
+
/** Validate model output and normalize original singular citations. */
|
|
2142
|
+
declare function parseCanonicalRawFinding(row: unknown, log?: (msg: string, fields?: Record<string, unknown>) => void): CanonicalRawAnalystFinding | null;
|
|
2048
2143
|
|
|
2049
2144
|
/**
|
|
2050
2145
|
* Analyst-kind factory — the typed way to define trace analysts.
|
|
@@ -2052,9 +2147,9 @@ declare function parseRawFinding(row: unknown, log?: (msg: string, fields?: Reco
|
|
|
2052
2147
|
* A "kind" is a specialized analyst whose actor prompt, tool subset,
|
|
2053
2148
|
* and Ax recursion config target one failure-mode lens (failure-mode
|
|
2054
2149
|
* classification, knowledge gap discovery, knowledge poisoning, recursive
|
|
2055
|
-
* self-improvement, ...). Kinds emit findings in the typed
|
|
2056
|
-
* shape via a JSON-array Ax output; the factory
|
|
2057
|
-
* Zod and lifts it into `AnalystFinding[]
|
|
2150
|
+
* self-improvement, ...). Kinds emit findings in the typed
|
|
2151
|
+
* `CanonicalRawAnalystFinding` shape via a JSON-array Ax output; the factory
|
|
2152
|
+
* validates each row with Zod and lifts it into `AnalystFinding[]`.
|
|
2058
2153
|
*
|
|
2059
2154
|
* Composition rules:
|
|
2060
2155
|
* - Each kind owns its actor description. No generic "answer this
|
|
@@ -2100,10 +2195,14 @@ interface TraceAnalystKindSpec {
|
|
|
2100
2195
|
maxTurns?: number;
|
|
2101
2196
|
/** Runtime char cap. Default 6000. */
|
|
2102
2197
|
maxRuntimeChars?: number;
|
|
2198
|
+
/** Maximum output tokens for every actor, responder, and recursive model call. Default 4096. */
|
|
2199
|
+
maxOutputTokens?: number;
|
|
2103
2200
|
/** Cost classification surfaced in `registry.list()` and budget enforcement. */
|
|
2104
2201
|
cost: AnalystCost;
|
|
2105
2202
|
/** Per-finding-row hook — kinds may reject / rewrite before lifting. */
|
|
2106
2203
|
postProcess?: (row: RawAnalystFinding, ctx: AnalystContext) => RawAnalystFinding | null;
|
|
2204
|
+
/** Minimum citations per finding. Default 1; rows below it are rejected. */
|
|
2205
|
+
minimumEvidenceCitations?: number;
|
|
2107
2206
|
/** Optional optimizer hook — populated when a kind wants to fit its prompt against labeled examples. */
|
|
2108
2207
|
goldens?: TraceAnalystGolden[];
|
|
2109
2208
|
}
|
|
@@ -2115,12 +2214,12 @@ interface TraceAnalystKindSpec {
|
|
|
2115
2214
|
*/
|
|
2116
2215
|
interface TraceAnalystGolden {
|
|
2117
2216
|
question: string;
|
|
2118
|
-
expected: ReadonlyArray<Omit<
|
|
2217
|
+
expected: ReadonlyArray<Omit<CanonicalRawAnalystFinding, 'confidence'>>;
|
|
2119
2218
|
}
|
|
2120
2219
|
interface CreateTraceAnalystKindOpts {
|
|
2121
2220
|
/** AxAIService bound at registration time. */
|
|
2122
2221
|
ai: AxAIService;
|
|
2123
|
-
/**
|
|
2222
|
+
/** Required unless `ai` was created by {@link createAnalystAi}. */
|
|
2124
2223
|
model?: string;
|
|
2125
2224
|
/** Override the spec's `version` (e.g. when an optimizer has fitted a new prompt). */
|
|
2126
2225
|
versionSuffix?: string;
|
|
@@ -2137,6 +2236,8 @@ interface CreateTraceAnalystKindOpts {
|
|
|
2137
2236
|
model?: string;
|
|
2138
2237
|
fetchImpl?: typeof fetch;
|
|
2139
2238
|
};
|
|
2239
|
+
/** Maximum post-cancellation wait for a provider receipt. Default 5 seconds. */
|
|
2240
|
+
settlementTimeoutMs?: number;
|
|
2140
2241
|
}
|
|
2141
2242
|
/**
|
|
2142
2243
|
* Build an `Analyst<TraceAnalysisStore>` from a kind spec.
|
|
@@ -2162,6 +2263,8 @@ declare function createTraceAnalystKind(spec: TraceAnalystKindSpec, opts: Create
|
|
|
2162
2263
|
* prompts (e.g. specialized analysts living outside the default kinds).
|
|
2163
2264
|
*/
|
|
2164
2265
|
declare function renderPriorFindings(prior: AnalystContext['priorFindings']): string;
|
|
2266
|
+
/** Render findings produced earlier in this same registry run. */
|
|
2267
|
+
declare function renderUpstreamFindings(upstream: AnalystContext['upstreamFindings']): string;
|
|
2165
2268
|
|
|
2166
2269
|
/**
|
|
2167
2270
|
* AnalystRegistry — orchestrate N analysts against one run.
|
|
@@ -2218,7 +2321,8 @@ interface BudgetPolicy {
|
|
|
2218
2321
|
/**
|
|
2219
2322
|
* Custom allocator — receives the analyst, remaining/total budget, and
|
|
2220
2323
|
* the count of analysts that will run. Returns the per-analyst budget
|
|
2221
|
-
* (or undefined
|
|
2324
|
+
* (or undefined only when the run has no overall cap). Overrides weights
|
|
2325
|
+
* when set.
|
|
2222
2326
|
*/
|
|
2223
2327
|
allocate?: (args: {
|
|
2224
2328
|
analyst: Analyst;
|
|
@@ -2248,6 +2352,10 @@ interface RegistryRunOpts {
|
|
|
2248
2352
|
timeoutMs?: number;
|
|
2249
2353
|
/** Abort signal — forwarded into every analyst's context. */
|
|
2250
2354
|
signal?: AbortSignal;
|
|
2355
|
+
/** Shared paid-call account forwarded to every analyst. */
|
|
2356
|
+
costLedger?: CostLedgerHandle;
|
|
2357
|
+
/** Attribution phase for calls written to `costLedger`. */
|
|
2358
|
+
costPhase?: string;
|
|
2251
2359
|
/** Tags echoed into AnalystContext.tags — useful for tracking environment/version in findings. */
|
|
2252
2360
|
tags?: Record<string, string>;
|
|
2253
2361
|
/**
|
|
@@ -2255,10 +2363,16 @@ interface RegistryRunOpts {
|
|
|
2255
2363
|
* analyst via `ctx.priorFindings`. The registry forwards the slice
|
|
2256
2364
|
* whose `analyst_id` matches each registered analyst so a kind sees
|
|
2257
2365
|
* only its own history. Pass `{ '*': findings }` to broadcast to
|
|
2258
|
-
* every analyst (useful
|
|
2259
|
-
*
|
|
2366
|
+
* every analyst (useful when several kinds share the same historical
|
|
2367
|
+
* context). For findings from this run, use `chainFindings` instead.
|
|
2260
2368
|
*/
|
|
2261
2369
|
priorFindings?: ReadonlyArray<AnalystFinding> | Record<string, ReadonlyArray<AnalystFinding>>;
|
|
2370
|
+
/**
|
|
2371
|
+
* Pass findings produced earlier in this registry run to each later analyst
|
|
2372
|
+
* via `ctx.upstreamFindings`. Registration order is dependency order.
|
|
2373
|
+
* Disabled by default because independent analyst suites must opt in.
|
|
2374
|
+
*/
|
|
2375
|
+
chainFindings?: boolean;
|
|
2262
2376
|
}
|
|
2263
2377
|
declare class AnalystRegistry {
|
|
2264
2378
|
private readonly analysts;
|
|
@@ -2302,7 +2416,7 @@ declare class AnalystRegistry {
|
|
|
2302
2416
|
interface DefaultAnalystRegistryOptions {
|
|
2303
2417
|
/** Ax service for the agentic RLM kinds. Omit → only the deterministic analyst. */
|
|
2304
2418
|
ai?: AxAIService;
|
|
2305
|
-
/**
|
|
2419
|
+
/** Required unless `ai` was created by `createAnalystAi`. */
|
|
2306
2420
|
model?: string;
|
|
2307
2421
|
/** Which agentic kinds to register when `ai` is present. Default = the shipped suite. */
|
|
2308
2422
|
kinds?: readonly TraceAnalystKindSpec[];
|
|
@@ -2661,8 +2775,8 @@ declare const KNOWLEDGE_POISONING_KIND_SPEC: TraceAnalystKindSpec;
|
|
|
2661
2775
|
* The four kinds chain: failure-mode classifies; knowledge-gap and
|
|
2662
2776
|
* knowledge-poisoning explain *why* in two orthogonal ways; improvement
|
|
2663
2777
|
* proposes concrete edits. Register all four against the same trace
|
|
2664
|
-
* store
|
|
2665
|
-
*
|
|
2778
|
+
* store in this order and run the registry with `chainFindings: true`
|
|
2779
|
+
* to pass each completed kind's findings to the kinds that follow it.
|
|
2666
2780
|
*/
|
|
2667
2781
|
|
|
2668
2782
|
/**
|
|
@@ -2778,7 +2892,7 @@ declare function coerceJson(text: string): unknown;
|
|
|
2778
2892
|
* Coerce arbitrary actor/structurer output into an array of candidate finding
|
|
2779
2893
|
* rows: a JSON string → parse; a single object → 1-element array; an array →
|
|
2780
2894
|
* as-is; anything else → []. Callers still run each row through Zod
|
|
2781
|
-
* (`
|
|
2895
|
+
* (`parseCanonicalRawFinding`) — this only fixes the SHAPE, never invents fields.
|
|
2782
2896
|
*/
|
|
2783
2897
|
declare function coerceToFindingRows(raw: unknown): unknown[];
|
|
2784
2898
|
|
|
@@ -2950,9 +3064,17 @@ interface StructureFindingsOptions {
|
|
|
2950
3064
|
/** Optional ledger for direct use. */
|
|
2951
3065
|
costLedger?: CostLedgerHandle;
|
|
2952
3066
|
costPhase?: string;
|
|
3067
|
+
costTags?: Record<string, string>;
|
|
2953
3068
|
maxTokens?: number;
|
|
3069
|
+
signal?: AbortSignal;
|
|
2954
3070
|
/** Max reask attempts after a zero/invalid extraction. Default 1. */
|
|
2955
3071
|
maxReasks?: number;
|
|
3072
|
+
/** Apply the caller's normal finding rules before a recovered row is lifted. */
|
|
3073
|
+
processRow?: (row: RawAnalystFinding) => RawAnalystFinding | null;
|
|
3074
|
+
/** Apply canonical multi-citation rules after any original callback. */
|
|
3075
|
+
processCanonicalRow?: (row: CanonicalRawAnalystFinding) => CanonicalRawAnalystFinding | null;
|
|
3076
|
+
/** Provenance copied onto every recovered finding. */
|
|
3077
|
+
findingMetadata?: Record<string, unknown>;
|
|
2956
3078
|
/** Test seam: inject a fetch (no network in unit tests). */
|
|
2957
3079
|
fetchImpl?: LlmClientOptions['fetch'];
|
|
2958
3080
|
}
|
|
@@ -2995,4 +3117,4 @@ type TraceToolGroupName =
|
|
|
2995
3117
|
*/
|
|
2996
3118
|
declare function buildTraceToolsForGroup(group: TraceToolGroupName, store: TraceAnalysisStore): AxFunction[];
|
|
2997
3119
|
|
|
2998
|
-
export { ANALYST_SEVERITIES, type Analyst, type AnalystContext, type AnalystCost, type AnalystFinding, type AnalystHooks, type AnalystInputKind, AnalystRegistry, type AnalystRegistryOptions, type AnalystRequirements, type AnalystRunEvent, type AnalystRunInputs, type AnalystRunResult, type AnalystRunSummary, type AnalystSeverity, type BudgetPolicy, type ChatCallOpts, type ChatClient, type ChatRequest, type ChatResponse, type ChatTransport, type CliBridgeTransportOpts, type CreateAnalystAiConfig, type CreateChatClientOpts, type CreateTraceAnalystKindOpts, DEFAULT_TRACE_ANALYST_KINDS, type DefaultAnalystRegistryOptions, type DiffPolicy, type DirectProviderTransportOpts, type EvidenceRef, FAILURE_MODE_KIND_SPEC, FINDING_SUBJECT_GRAMMAR_PROMPT, FINDING_SUBJECT_KINDS, FINDING_SUBJECT_SYNTAX, type FindingSubject, type FindingSubjectKind, FindingSubjectStringSchema, type FindingToPolicyEditOptions, type FindingsDiff, FindingsStore, IMPROVEMENT_KIND_SPEC, type JudgeAdapterOpts, KIND_EXPECTED_SUBJECTS, KNOWLEDGE_GAP_KIND_SPEC, KNOWLEDGE_POISONING_KIND_SPEC, type MockTransportOpts, POLICY_EDIT_AXES, POLICY_EDIT_CANDIDATE_RECORD_SCHEMA, POLICY_EDIT_TARGET_SURFACES, type PersistedFinding, type PolicyEdit, type PolicyEditAdmission, type PolicyEditAdmissionOptions, type PolicyEditAxis, type PolicyEditCandidateRecord, type PolicyEditChange, type PolicyEditExpectedGain, type PolicyEditGainDirection, type PolicyEditGainUnit, type PolicyEditInit, type PolicyEditRisk, type PolicyEditSchemaVersion, type PolicyEditSource, type PolicyEditTarget, type PolicyEditTargetSurface, PolicyEditValidationError, RAW_FINDING_SCHEMA_PROMPT, type RawAnalystFinding, RawAnalystFindingSchema, type RegistryRunOpts, type RouterTransportOpts, type RunCriticAdapterOpts, SKILL_USAGE_ANALYST, type SandboxSdkTransportOpts, type SemanticConceptJudgeAdapterOpts, SkillUsageAnalyst, type SkillUsageRecord, type SkillUsageReport, type SkillUsageScanConfig, type StructureFindingsOptions, type StructureFindingsResult, type TraceAnalystGolden, type TraceAnalystKindSpec, type TraceToolGroupName, type VerifierAdapterOpts, admitPolicyEdit, applyPolicyEditToSurface, assertNoJudgeVerdict, behavioralAnalyst, buildDefaultAnalystRegistry, buildSkillUsageReport, buildTraceToolsForGroup, coerceJson, coerceToFindingRows, computeFindingId, computePolicyEditId, createAnalystAi, createChatClient, createJudgeAdapter, createRunCriticAdapter, createSemanticConceptJudgeAdapter, createTraceAnalystKind, createVerifierAdapter, defaultIsMaterial, deriveEfficiencyFindings, diffFindings, emitSkillUsageFindings, findingSubjectGrammarPromptFor, isJudgeVerdict, isPolicyEdit, isTraceObservable, liftSeverity, makeFinding, makePolicyEdit, makePolicyEditCandidateRecord, parseFindingSubject, parseRawFinding, policyEditFromFinding, policyEditsFromFindings, renderFindingSubject, renderPriorFindings, scorePolicyEditReadiness, stripCodeFences, structureFindings, validatePolicyEdit, validatePolicyEditCandidateRecord };
|
|
3120
|
+
export { ANALYST_SEVERITIES, type Analyst, type AnalystContext, type AnalystCost, type AnalystFinding, type AnalystHooks, type AnalystInputKind, AnalystRegistry, type AnalystRegistryOptions, type AnalystRequirements, type AnalystRunEvent, type AnalystRunInputs, type AnalystRunResult, type AnalystRunSummary, type AnalystSeverity, type AnalystUsageReceipt, type BudgetPolicy, type CanonicalRawAnalystFinding, CanonicalRawAnalystFindingSchema, type ChatCallOpts, type ChatClient, type ChatRequest, type ChatResponse, type ChatTransport, type CliBridgeTransportOpts, type CreateAnalystAiConfig, type CreateChatClientOpts, type CreateTraceAnalystKindOpts, DEFAULT_TRACE_ANALYST_KINDS, type DefaultAnalystRegistryOptions, type DiffPolicy, type DirectProviderTransportOpts, type EvidenceRef, FAILURE_MODE_KIND_SPEC, FINDING_SUBJECT_GRAMMAR_PROMPT, FINDING_SUBJECT_KINDS, FINDING_SUBJECT_SYNTAX, type FindingSubject, type FindingSubjectKind, FindingSubjectStringSchema, type FindingToPolicyEditOptions, type FindingsDiff, FindingsStore, IMPROVEMENT_KIND_SPEC, type JudgeAdapterOpts, KIND_EXPECTED_SUBJECTS, KNOWLEDGE_GAP_KIND_SPEC, KNOWLEDGE_POISONING_KIND_SPEC, type MockTransportOpts, POLICY_EDIT_AXES, POLICY_EDIT_CANDIDATE_RECORD_SCHEMA, POLICY_EDIT_TARGET_SURFACES, type PersistedFinding, type PolicyEdit, type PolicyEditAdmission, type PolicyEditAdmissionOptions, type PolicyEditAxis, type PolicyEditCandidateRecord, type PolicyEditChange, type PolicyEditExpectedGain, type PolicyEditGainDirection, type PolicyEditGainUnit, type PolicyEditInit, type PolicyEditRisk, type PolicyEditSchemaVersion, type PolicyEditSource, type PolicyEditTarget, type PolicyEditTargetSurface, PolicyEditValidationError, RAW_FINDING_SCHEMA_PROMPT, type RawAnalystEvidence, RawAnalystEvidenceSchema, type RawAnalystFinding, RawAnalystFindingSchema, type RegistryRunOpts, type RouterTransportOpts, type RunCriticAdapterOpts, SKILL_USAGE_ANALYST, type SandboxSdkTransportOpts, type SemanticConceptJudgeAdapterOpts, SkillUsageAnalyst, type SkillUsageRecord, type SkillUsageReport, type SkillUsageScanConfig, type StructureFindingsOptions, type StructureFindingsResult, type TraceAnalystGolden, type TraceAnalystKindSpec, type TraceToolGroupName, type VerifierAdapterOpts, admitPolicyEdit, applyPolicyEditToSurface, assertNoJudgeVerdict, behavioralAnalyst, buildDefaultAnalystRegistry, buildSkillUsageReport, buildTraceToolsForGroup, coerceJson, coerceToFindingRows, computeFindingId, computePolicyEditId, createAnalystAi, createChatClient, createJudgeAdapter, createRunCriticAdapter, createSemanticConceptJudgeAdapter, createTraceAnalystKind, createVerifierAdapter, defaultIsMaterial, deriveEfficiencyFindings, diffFindings, emitSkillUsageFindings, evidenceRefsFromRawFinding, findingSubjectGrammarPromptFor, isJudgeVerdict, isPolicyEdit, isTraceObservable, liftSeverity, makeFinding, makePolicyEdit, makePolicyEditCandidateRecord, parseCanonicalRawFinding, parseFindingSubject, parseRawFinding, policyEditFromFinding, policyEditsFromFindings, renderFindingSubject, renderPriorFindings, renderUpstreamFindings, scorePolicyEditReadiness, stripCodeFences, structureFindings, validatePolicyEdit, validatePolicyEditCandidateRecord };
|
package/dist/analyst/index.js
CHANGED
|
@@ -5,23 +5,23 @@ import {
|
|
|
5
5
|
SKILL_USAGE_ANALYST,
|
|
6
6
|
SkillUsageAnalyst,
|
|
7
7
|
buildSkillUsageReport,
|
|
8
|
-
createAnalystAi,
|
|
9
8
|
defaultIsMaterial,
|
|
10
9
|
diffFindings,
|
|
11
10
|
emitSkillUsageFindings,
|
|
12
11
|
runSemanticConceptJudge
|
|
13
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-LMJ2TGWJ.js";
|
|
14
13
|
import {
|
|
15
14
|
behavioralAnalyst,
|
|
16
15
|
buildDefaultAnalystRegistry,
|
|
17
16
|
createChatClient,
|
|
18
17
|
deriveEfficiencyFindings
|
|
19
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-GERDAIAL.js";
|
|
20
19
|
import "../chunk-HHWE3POT.js";
|
|
21
20
|
import "../chunk-3YYRZDON.js";
|
|
22
21
|
import {
|
|
23
22
|
ANALYST_SEVERITIES,
|
|
24
23
|
AnalystRegistry,
|
|
24
|
+
CanonicalRawAnalystFindingSchema,
|
|
25
25
|
DEFAULT_TRACE_ANALYST_KINDS,
|
|
26
26
|
FAILURE_MODE_KIND_SPEC,
|
|
27
27
|
FINDING_SUBJECT_GRAMMAR_PROMPT,
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
POLICY_EDIT_TARGET_SURFACES,
|
|
38
38
|
PolicyEditValidationError,
|
|
39
39
|
RAW_FINDING_SCHEMA_PROMPT,
|
|
40
|
+
RawAnalystEvidenceSchema,
|
|
40
41
|
RawAnalystFindingSchema,
|
|
41
42
|
admitPolicyEdit,
|
|
42
43
|
applyPolicyEditToSurface,
|
|
@@ -46,7 +47,9 @@ import {
|
|
|
46
47
|
coerceToFindingRows,
|
|
47
48
|
computeFindingId,
|
|
48
49
|
computePolicyEditId,
|
|
50
|
+
createAnalystAi,
|
|
49
51
|
createTraceAnalystKind,
|
|
52
|
+
evidenceRefsFromRawFinding,
|
|
50
53
|
findingSubjectGrammarPromptFor,
|
|
51
54
|
isJudgeVerdict,
|
|
52
55
|
isPolicyEdit,
|
|
@@ -54,20 +57,26 @@ import {
|
|
|
54
57
|
makeFinding,
|
|
55
58
|
makePolicyEdit,
|
|
56
59
|
makePolicyEditCandidateRecord,
|
|
60
|
+
parseCanonicalRawFinding,
|
|
57
61
|
parseFindingSubject,
|
|
58
62
|
parseRawFinding,
|
|
59
63
|
policyEditFromFinding,
|
|
60
64
|
policyEditsFromFindings,
|
|
61
65
|
renderFindingSubject,
|
|
62
66
|
renderPriorFindings,
|
|
67
|
+
renderUpstreamFindings,
|
|
63
68
|
scorePolicyEditReadiness,
|
|
69
|
+
settleUsageReceiptFromCostLedger,
|
|
64
70
|
stripCodeFences,
|
|
65
71
|
structureFindings,
|
|
66
72
|
validatePolicyEdit,
|
|
67
|
-
validatePolicyEditCandidateRecord
|
|
68
|
-
|
|
73
|
+
validatePolicyEditCandidateRecord,
|
|
74
|
+
validateUsageSettlementTimeout
|
|
75
|
+
} from "../chunk-7A4LIMMY.js";
|
|
69
76
|
import "../chunk-NJC7U437.js";
|
|
70
|
-
import
|
|
77
|
+
import {
|
|
78
|
+
CostLedger
|
|
79
|
+
} from "../chunk-JHOJHHU7.js";
|
|
71
80
|
import "../chunk-VI2UW6B6.js";
|
|
72
81
|
import "../chunk-6QIM2EAP.js";
|
|
73
82
|
import "../chunk-PC4UYEBM.js";
|
|
@@ -250,14 +259,35 @@ function liftJudgeScore(analyst_id, area, s) {
|
|
|
250
259
|
function createSemanticConceptJudgeAdapter(opts = {}) {
|
|
251
260
|
const id = opts.id ?? "semantic-concept-judge";
|
|
252
261
|
const area = opts.area ?? "concept-coverage";
|
|
262
|
+
const settlementTimeoutMs = validateUsageSettlementTimeout(opts.settlementTimeoutMs);
|
|
253
263
|
return {
|
|
254
264
|
id,
|
|
255
265
|
description: "Runs the semantic-concept judge and surfaces missing / weak concepts as findings.",
|
|
256
266
|
inputKind: "custom",
|
|
257
267
|
cost: { kind: "llm", models: opts.options?.model ? [opts.options.model] : void 0 },
|
|
258
268
|
version: `${SEMANTIC_CONCEPT_JUDGE_VERSION}-adapter-${ADAPTER_REV}`,
|
|
259
|
-
async analyze(input) {
|
|
260
|
-
const
|
|
269
|
+
async analyze(input, ctx) {
|
|
270
|
+
const costLedger = new CostLedger(ctx.budgetUsd);
|
|
271
|
+
let result;
|
|
272
|
+
try {
|
|
273
|
+
result = await runSemanticConceptJudge(input, {
|
|
274
|
+
...opts.options,
|
|
275
|
+
costLedger,
|
|
276
|
+
signal: ctx.signal
|
|
277
|
+
});
|
|
278
|
+
} finally {
|
|
279
|
+
const usage = await settleUsageReceiptFromCostLedger(costLedger, {
|
|
280
|
+
channel: "judge",
|
|
281
|
+
timeoutMs: settlementTimeoutMs
|
|
282
|
+
});
|
|
283
|
+
if (!usage.settled) {
|
|
284
|
+
ctx.log?.("semantic-concept judge provider settlement timed out", {
|
|
285
|
+
pending_calls: usage.pendingCalls,
|
|
286
|
+
timeout_ms: settlementTimeoutMs
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
ctx.recordUsage?.(usage.receipt);
|
|
290
|
+
}
|
|
261
291
|
if (!result.available) {
|
|
262
292
|
return [
|
|
263
293
|
makeFinding({
|
|
@@ -288,8 +318,7 @@ function createSemanticConceptJudgeAdapter(opts = {}) {
|
|
|
288
318
|
metadata: {
|
|
289
319
|
concept: f.concept,
|
|
290
320
|
present: f.present,
|
|
291
|
-
score_10: f.score
|
|
292
|
-
cost_usd: result.costUsd ?? void 0
|
|
321
|
+
score_10: f.score
|
|
293
322
|
}
|
|
294
323
|
})
|
|
295
324
|
);
|
|
@@ -301,6 +330,7 @@ function createSemanticConceptJudgeAdapter(opts = {}) {
|
|
|
301
330
|
export {
|
|
302
331
|
ANALYST_SEVERITIES,
|
|
303
332
|
AnalystRegistry,
|
|
333
|
+
CanonicalRawAnalystFindingSchema,
|
|
304
334
|
DEFAULT_TRACE_ANALYST_KINDS,
|
|
305
335
|
FAILURE_MODE_KIND_SPEC,
|
|
306
336
|
FINDING_SUBJECT_GRAMMAR_PROMPT,
|
|
@@ -317,6 +347,7 @@ export {
|
|
|
317
347
|
POLICY_EDIT_TARGET_SURFACES,
|
|
318
348
|
PolicyEditValidationError,
|
|
319
349
|
RAW_FINDING_SCHEMA_PROMPT,
|
|
350
|
+
RawAnalystEvidenceSchema,
|
|
320
351
|
RawAnalystFindingSchema,
|
|
321
352
|
SKILL_USAGE_ANALYST,
|
|
322
353
|
SkillUsageAnalyst,
|
|
@@ -342,6 +373,7 @@ export {
|
|
|
342
373
|
deriveEfficiencyFindings,
|
|
343
374
|
diffFindings,
|
|
344
375
|
emitSkillUsageFindings,
|
|
376
|
+
evidenceRefsFromRawFinding,
|
|
345
377
|
findingSubjectGrammarPromptFor,
|
|
346
378
|
isJudgeVerdict,
|
|
347
379
|
isPolicyEdit,
|
|
@@ -350,12 +382,14 @@ export {
|
|
|
350
382
|
makeFinding,
|
|
351
383
|
makePolicyEdit,
|
|
352
384
|
makePolicyEditCandidateRecord,
|
|
385
|
+
parseCanonicalRawFinding,
|
|
353
386
|
parseFindingSubject,
|
|
354
387
|
parseRawFinding,
|
|
355
388
|
policyEditFromFinding,
|
|
356
389
|
policyEditsFromFindings,
|
|
357
390
|
renderFindingSubject,
|
|
358
391
|
renderPriorFindings,
|
|
392
|
+
renderUpstreamFindings,
|
|
359
393
|
scorePolicyEditReadiness,
|
|
360
394
|
stripCodeFences,
|
|
361
395
|
structureFindings,
|