@prismatic-io/lux 0.0.1
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/LICENSE +21 -0
- package/lib/answerers/claude-code/index.d.ts +17 -0
- package/lib/answerers/claude-code/index.d.ts.map +1 -0
- package/lib/answerers/claude-code/index.js +280 -0
- package/lib/answerers/claude-code/index.js.map +1 -0
- package/lib/answerers/persona/index.d.ts +40 -0
- package/lib/answerers/persona/index.d.ts.map +1 -0
- package/lib/answerers/persona/index.js +265 -0
- package/lib/answerers/persona/index.js.map +1 -0
- package/lib/answerers/scripted/index.d.ts +8 -0
- package/lib/answerers/scripted/index.d.ts.map +1 -0
- package/lib/answerers/scripted/index.js +163 -0
- package/lib/answerers/scripted/index.js.map +1 -0
- package/lib/answerers/shared.d.ts +13 -0
- package/lib/answerers/shared.d.ts.map +1 -0
- package/lib/answerers/shared.js +17 -0
- package/lib/answerers/shared.js.map +1 -0
- package/lib/answerers/terminal/index.d.ts +9 -0
- package/lib/answerers/terminal/index.d.ts.map +1 -0
- package/lib/answerers/terminal/index.js +97 -0
- package/lib/answerers/terminal/index.js.map +1 -0
- package/lib/assertions/core/command-exits-zero.d.ts +21 -0
- package/lib/assertions/core/command-exits-zero.d.ts.map +1 -0
- package/lib/assertions/core/command-exits-zero.js +87 -0
- package/lib/assertions/core/command-exits-zero.js.map +1 -0
- package/lib/assertions/core/event-checks.d.ts +57 -0
- package/lib/assertions/core/event-checks.d.ts.map +1 -0
- package/lib/assertions/core/event-checks.js +123 -0
- package/lib/assertions/core/event-checks.js.map +1 -0
- package/lib/assertions/core/file-checks.d.ts +103 -0
- package/lib/assertions/core/file-checks.d.ts.map +1 -0
- package/lib/assertions/core/file-checks.js +288 -0
- package/lib/assertions/core/file-checks.js.map +1 -0
- package/lib/assertions/core/helpers.d.ts +66 -0
- package/lib/assertions/core/helpers.d.ts.map +1 -0
- package/lib/assertions/core/helpers.js +170 -0
- package/lib/assertions/core/helpers.js.map +1 -0
- package/lib/assertions/core/index.d.ts +15 -0
- package/lib/assertions/core/index.d.ts.map +1 -0
- package/lib/assertions/core/index.js +56 -0
- package/lib/assertions/core/index.js.map +1 -0
- package/lib/assertions/core/json-pointer-equals.d.ts +19 -0
- package/lib/assertions/core/json-pointer-equals.d.ts.map +1 -0
- package/lib/assertions/core/json-pointer-equals.js +71 -0
- package/lib/assertions/core/json-pointer-equals.js.map +1 -0
- package/lib/assertions/core/output-checks.d.ts +46 -0
- package/lib/assertions/core/output-checks.d.ts.map +1 -0
- package/lib/assertions/core/output-checks.js +121 -0
- package/lib/assertions/core/output-checks.js.map +1 -0
- package/lib/assertions/core/predicate.d.ts +14 -0
- package/lib/assertions/core/predicate.d.ts.map +1 -0
- package/lib/assertions/core/predicate.js +55 -0
- package/lib/assertions/core/predicate.js.map +1 -0
- package/lib/assertions/core/resource-checks.d.ts +71 -0
- package/lib/assertions/core/resource-checks.d.ts.map +1 -0
- package/lib/assertions/core/resource-checks.js +159 -0
- package/lib/assertions/core/resource-checks.js.map +1 -0
- package/lib/assertions/core/safe-regex.d.ts +23 -0
- package/lib/assertions/core/safe-regex.d.ts.map +1 -0
- package/lib/assertions/core/safe-regex.js +102 -0
- package/lib/assertions/core/safe-regex.js.map +1 -0
- package/lib/assertions/core/tool-called-with.d.ts +21 -0
- package/lib/assertions/core/tool-called-with.d.ts.map +1 -0
- package/lib/assertions/core/tool-called-with.js +69 -0
- package/lib/assertions/core/tool-called-with.js.map +1 -0
- package/lib/assertions/core/tool-calls.d.ts +22 -0
- package/lib/assertions/core/tool-calls.d.ts.map +1 -0
- package/lib/assertions/core/tool-calls.js +17 -0
- package/lib/assertions/core/tool-calls.js.map +1 -0
- package/lib/assertions/core/tool-invocation.d.ts +36 -0
- package/lib/assertions/core/tool-invocation.d.ts.map +1 -0
- package/lib/assertions/core/tool-invocation.js +170 -0
- package/lib/assertions/core/tool-invocation.js.map +1 -0
- package/lib/assertions/core/tool-result-checks.d.ts +59 -0
- package/lib/assertions/core/tool-result-checks.d.ts.map +1 -0
- package/lib/assertions/core/tool-result-checks.js +193 -0
- package/lib/assertions/core/tool-result-checks.js.map +1 -0
- package/lib/assertions/mcp/discovery-checks.d.ts +36 -0
- package/lib/assertions/mcp/discovery-checks.d.ts.map +1 -0
- package/lib/assertions/mcp/discovery-checks.js +122 -0
- package/lib/assertions/mcp/discovery-checks.js.map +1 -0
- package/lib/assertions/mcp/index.d.ts +10 -0
- package/lib/assertions/mcp/index.d.ts.map +1 -0
- package/lib/assertions/mcp/index.js +25 -0
- package/lib/assertions/mcp/index.js.map +1 -0
- package/lib/assertions/rubric/index.d.ts +104 -0
- package/lib/assertions/rubric/index.d.ts.map +1 -0
- package/lib/assertions/rubric/index.js +191 -0
- package/lib/assertions/rubric/index.js.map +1 -0
- package/lib/assertions/rubric/internal.d.ts +14 -0
- package/lib/assertions/rubric/internal.d.ts.map +1 -0
- package/lib/assertions/rubric/internal.js +335 -0
- package/lib/assertions/rubric/internal.js.map +1 -0
- package/lib/authoring.d.ts +3 -0
- package/lib/authoring.d.ts.map +1 -0
- package/lib/authoring.js +3 -0
- package/lib/authoring.js.map +1 -0
- package/lib/cli/bin.d.ts +3 -0
- package/lib/cli/bin.d.ts.map +1 -0
- package/lib/cli/bin.js +15 -0
- package/lib/cli/bin.js.map +1 -0
- package/lib/cli/command-runtime.d.ts +5 -0
- package/lib/cli/command-runtime.d.ts.map +1 -0
- package/lib/cli/command-runtime.js +30 -0
- package/lib/cli/command-runtime.js.map +1 -0
- package/lib/cli/init.d.ts +21 -0
- package/lib/cli/init.d.ts.map +1 -0
- package/lib/cli/init.js +340 -0
- package/lib/cli/init.js.map +1 -0
- package/lib/cli/program.d.ts +22 -0
- package/lib/cli/program.d.ts.map +1 -0
- package/lib/cli/program.js +757 -0
- package/lib/cli/program.js.map +1 -0
- package/lib/cli/render/format.d.ts +14 -0
- package/lib/cli/render/format.d.ts.map +1 -0
- package/lib/cli/render/format.js +71 -0
- package/lib/cli/render/format.js.map +1 -0
- package/lib/cli/render/reporter.d.ts +73 -0
- package/lib/cli/render/reporter.d.ts.map +1 -0
- package/lib/cli/render/reporter.js +519 -0
- package/lib/cli/render/reporter.js.map +1 -0
- package/lib/cli/render/tty.d.ts +77 -0
- package/lib/cli/render/tty.d.ts.map +1 -0
- package/lib/cli/render/tty.js +283 -0
- package/lib/cli/render/tty.js.map +1 -0
- package/lib/cli/run-options.d.ts +27 -0
- package/lib/cli/run-options.d.ts.map +1 -0
- package/lib/cli/run-options.js +58 -0
- package/lib/cli/run-options.js.map +1 -0
- package/lib/cli/skills.d.ts +38 -0
- package/lib/cli/skills.d.ts.map +1 -0
- package/lib/cli/skills.js +84 -0
- package/lib/cli/skills.js.map +1 -0
- package/lib/core/annotation.d.ts +56 -0
- package/lib/core/annotation.d.ts.map +1 -0
- package/lib/core/annotation.js +92 -0
- package/lib/core/annotation.js.map +1 -0
- package/lib/core/answerer.d.ts +68 -0
- package/lib/core/answerer.d.ts.map +1 -0
- package/lib/core/answerer.js +17 -0
- package/lib/core/answerer.js.map +1 -0
- package/lib/core/artifact-evidence.d.ts +50 -0
- package/lib/core/artifact-evidence.d.ts.map +1 -0
- package/lib/core/artifact-evidence.js +185 -0
- package/lib/core/artifact-evidence.js.map +1 -0
- package/lib/core/artifact-snapshot.d.ts +37 -0
- package/lib/core/artifact-snapshot.d.ts.map +1 -0
- package/lib/core/artifact-snapshot.js +339 -0
- package/lib/core/artifact-snapshot.js.map +1 -0
- package/lib/core/assertion.d.ts +129 -0
- package/lib/core/assertion.d.ts.map +1 -0
- package/lib/core/assertion.js +75 -0
- package/lib/core/assertion.js.map +1 -0
- package/lib/core/case.d.ts +79 -0
- package/lib/core/case.d.ts.map +1 -0
- package/lib/core/case.js +90 -0
- package/lib/core/case.js.map +1 -0
- package/lib/core/conversation-turn.d.ts +23 -0
- package/lib/core/conversation-turn.d.ts.map +1 -0
- package/lib/core/conversation-turn.js +31 -0
- package/lib/core/conversation-turn.js.map +1 -0
- package/lib/core/driver.d.ts +64 -0
- package/lib/core/driver.d.ts.map +1 -0
- package/lib/core/driver.js +18 -0
- package/lib/core/driver.js.map +1 -0
- package/lib/core/emitter.d.ts +20 -0
- package/lib/core/emitter.d.ts.map +1 -0
- package/lib/core/emitter.js +34 -0
- package/lib/core/emitter.js.map +1 -0
- package/lib/core/events.d.ts +202 -0
- package/lib/core/events.d.ts.map +1 -0
- package/lib/core/events.js +107 -0
- package/lib/core/events.js.map +1 -0
- package/lib/core/exec.d.ts +82 -0
- package/lib/core/exec.d.ts.map +1 -0
- package/lib/core/exec.js +168 -0
- package/lib/core/exec.js.map +1 -0
- package/lib/core/experiment.d.ts +285 -0
- package/lib/core/experiment.d.ts.map +1 -0
- package/lib/core/experiment.js +389 -0
- package/lib/core/experiment.js.map +1 -0
- package/lib/core/glob.d.ts +3 -0
- package/lib/core/glob.d.ts.map +1 -0
- package/lib/core/glob.js +32 -0
- package/lib/core/glob.js.map +1 -0
- package/lib/core/hash.d.ts +8 -0
- package/lib/core/hash.d.ts.map +1 -0
- package/lib/core/hash.js +214 -0
- package/lib/core/hash.js.map +1 -0
- package/lib/core/index.d.ts +29 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +29 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/lifecycle-fixtures.d.ts +20 -0
- package/lib/core/lifecycle-fixtures.d.ts.map +1 -0
- package/lib/core/lifecycle-fixtures.js +109 -0
- package/lib/core/lifecycle-fixtures.js.map +1 -0
- package/lib/core/lifecycle-hooks.d.ts +52 -0
- package/lib/core/lifecycle-hooks.d.ts.map +1 -0
- package/lib/core/lifecycle-hooks.js +42 -0
- package/lib/core/lifecycle-hooks.js.map +1 -0
- package/lib/core/mcp-events.d.ts +44 -0
- package/lib/core/mcp-events.d.ts.map +1 -0
- package/lib/core/mcp-events.js +23 -0
- package/lib/core/mcp-events.js.map +1 -0
- package/lib/core/model-cli.d.ts +57 -0
- package/lib/core/model-cli.d.ts.map +1 -0
- package/lib/core/model-cli.js +237 -0
- package/lib/core/model-cli.js.map +1 -0
- package/lib/core/observer.d.ts +31 -0
- package/lib/core/observer.d.ts.map +1 -0
- package/lib/core/observer.js +25 -0
- package/lib/core/observer.js.map +1 -0
- package/lib/core/platform-process.d.ts +33 -0
- package/lib/core/platform-process.d.ts.map +1 -0
- package/lib/core/platform-process.js +214 -0
- package/lib/core/platform-process.js.map +1 -0
- package/lib/core/registry.d.ts +22 -0
- package/lib/core/registry.d.ts.map +1 -0
- package/lib/core/registry.js +45 -0
- package/lib/core/registry.js.map +1 -0
- package/lib/core/rubric.d.ts +18 -0
- package/lib/core/rubric.d.ts.map +1 -0
- package/lib/core/rubric.js +49 -0
- package/lib/core/rubric.js.map +1 -0
- package/lib/core/run.d.ts +419 -0
- package/lib/core/run.d.ts.map +1 -0
- package/lib/core/run.js +126 -0
- package/lib/core/run.js.map +1 -0
- package/lib/core/statistics.d.ts +39 -0
- package/lib/core/statistics.d.ts.map +1 -0
- package/lib/core/statistics.js +163 -0
- package/lib/core/statistics.js.map +1 -0
- package/lib/core/subject.d.ts +4 -0
- package/lib/core/subject.d.ts.map +1 -0
- package/lib/core/subject.js +46 -0
- package/lib/core/subject.js.map +1 -0
- package/lib/core/tool-events.d.ts +69 -0
- package/lib/core/tool-events.d.ts.map +1 -0
- package/lib/core/tool-events.js +242 -0
- package/lib/core/tool-events.js.map +1 -0
- package/lib/core/usage.d.ts +78 -0
- package/lib/core/usage.d.ts.map +1 -0
- package/lib/core/usage.js +104 -0
- package/lib/core/usage.js.map +1 -0
- package/lib/core/wire.d.ts +83 -0
- package/lib/core/wire.d.ts.map +1 -0
- package/lib/core/wire.js +101 -0
- package/lib/core/wire.js.map +1 -0
- package/lib/core/zod.d.ts +10 -0
- package/lib/core/zod.d.ts.map +1 -0
- package/lib/core/zod.js +18 -0
- package/lib/core/zod.js.map +1 -0
- package/lib/drivers/claude-code/index.d.ts +55 -0
- package/lib/drivers/claude-code/index.d.ts.map +1 -0
- package/lib/drivers/claude-code/index.js +779 -0
- package/lib/drivers/claude-code/index.js.map +1 -0
- package/lib/drivers/claude-code/parse-events.d.ts +46 -0
- package/lib/drivers/claude-code/parse-events.d.ts.map +1 -0
- package/lib/drivers/claude-code/parse-events.js +387 -0
- package/lib/drivers/claude-code/parse-events.js.map +1 -0
- package/lib/drivers/codex/app-events.d.ts +16 -0
- package/lib/drivers/codex/app-events.d.ts.map +1 -0
- package/lib/drivers/codex/app-events.js +184 -0
- package/lib/drivers/codex/app-events.js.map +1 -0
- package/lib/drivers/codex/config.d.ts +55 -0
- package/lib/drivers/codex/config.d.ts.map +1 -0
- package/lib/drivers/codex/config.js +125 -0
- package/lib/drivers/codex/config.js.map +1 -0
- package/lib/drivers/codex/index.d.ts +8 -0
- package/lib/drivers/codex/index.d.ts.map +1 -0
- package/lib/drivers/codex/index.js +904 -0
- package/lib/drivers/codex/index.js.map +1 -0
- package/lib/drivers/mcp/index.d.ts +52 -0
- package/lib/drivers/mcp/index.d.ts.map +1 -0
- package/lib/drivers/mcp/index.js +282 -0
- package/lib/drivers/mcp/index.js.map +1 -0
- package/lib/drivers/mcp/transport.d.ts +50 -0
- package/lib/drivers/mcp/transport.d.ts.map +1 -0
- package/lib/drivers/mcp/transport.js +190 -0
- package/lib/drivers/mcp/transport.js.map +1 -0
- package/lib/drivers/shared/artifacts.d.ts +4 -0
- package/lib/drivers/shared/artifacts.d.ts.map +1 -0
- package/lib/drivers/shared/artifacts.js +81 -0
- package/lib/drivers/shared/artifacts.js.map +1 -0
- package/lib/drivers/shared/secure-copy.d.ts +2 -0
- package/lib/drivers/shared/secure-copy.d.ts.map +1 -0
- package/lib/drivers/shared/secure-copy.js +35 -0
- package/lib/drivers/shared/secure-copy.js.map +1 -0
- package/lib/drivers/subprocess/index.d.ts +24 -0
- package/lib/drivers/subprocess/index.d.ts.map +1 -0
- package/lib/drivers/subprocess/index.js +451 -0
- package/lib/drivers/subprocess/index.js.map +1 -0
- package/lib/index.d.ts +40 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +48 -0
- package/lib/index.js.map +1 -0
- package/lib/optimization/reflective.d.ts +27 -0
- package/lib/optimization/reflective.d.ts.map +1 -0
- package/lib/optimization/reflective.js +257 -0
- package/lib/optimization/reflective.js.map +1 -0
- package/lib/orchestrator/annotation-loader.d.ts +65 -0
- package/lib/orchestrator/annotation-loader.d.ts.map +1 -0
- package/lib/orchestrator/annotation-loader.js +73 -0
- package/lib/orchestrator/annotation-loader.js.map +1 -0
- package/lib/orchestrator/annotation-store.d.ts +3 -0
- package/lib/orchestrator/annotation-store.d.ts.map +1 -0
- package/lib/orchestrator/annotation-store.js +100 -0
- package/lib/orchestrator/annotation-store.js.map +1 -0
- package/lib/orchestrator/authored-dependencies.d.ts +3 -0
- package/lib/orchestrator/authored-dependencies.d.ts.map +1 -0
- package/lib/orchestrator/authored-dependencies.js +146 -0
- package/lib/orchestrator/authored-dependencies.js.map +1 -0
- package/lib/orchestrator/campaign-lifecycle.d.ts +105 -0
- package/lib/orchestrator/campaign-lifecycle.d.ts.map +1 -0
- package/lib/orchestrator/campaign-lifecycle.js +141 -0
- package/lib/orchestrator/campaign-lifecycle.js.map +1 -0
- package/lib/orchestrator/candidate-integrity.d.ts +4 -0
- package/lib/orchestrator/candidate-integrity.d.ts.map +1 -0
- package/lib/orchestrator/candidate-integrity.js +14 -0
- package/lib/orchestrator/candidate-integrity.js.map +1 -0
- package/lib/orchestrator/candidates.d.ts +13 -0
- package/lib/orchestrator/candidates.d.ts.map +1 -0
- package/lib/orchestrator/candidates.js +577 -0
- package/lib/orchestrator/candidates.js.map +1 -0
- package/lib/orchestrator/compare.d.ts +80 -0
- package/lib/orchestrator/compare.d.ts.map +1 -0
- package/lib/orchestrator/compare.js +270 -0
- package/lib/orchestrator/compare.js.map +1 -0
- package/lib/orchestrator/comparison-identity.d.ts +10 -0
- package/lib/orchestrator/comparison-identity.d.ts.map +1 -0
- package/lib/orchestrator/comparison-identity.js +39 -0
- package/lib/orchestrator/comparison-identity.js.map +1 -0
- package/lib/orchestrator/config.d.ts +121 -0
- package/lib/orchestrator/config.d.ts.map +1 -0
- package/lib/orchestrator/config.js +176 -0
- package/lib/orchestrator/config.js.map +1 -0
- package/lib/orchestrator/content-bound-json.d.ts +5 -0
- package/lib/orchestrator/content-bound-json.d.ts.map +1 -0
- package/lib/orchestrator/content-bound-json.js +59 -0
- package/lib/orchestrator/content-bound-json.js.map +1 -0
- package/lib/orchestrator/discover.d.ts +45 -0
- package/lib/orchestrator/discover.d.ts.map +1 -0
- package/lib/orchestrator/discover.js +98 -0
- package/lib/orchestrator/discover.js.map +1 -0
- package/lib/orchestrator/doctor.d.ts +141 -0
- package/lib/orchestrator/doctor.d.ts.map +1 -0
- package/lib/orchestrator/doctor.js +525 -0
- package/lib/orchestrator/doctor.js.map +1 -0
- package/lib/orchestrator/driver-session.d.ts +177 -0
- package/lib/orchestrator/driver-session.d.ts.map +1 -0
- package/lib/orchestrator/driver-session.js +396 -0
- package/lib/orchestrator/driver-session.js.map +1 -0
- package/lib/orchestrator/evaluator-identity.d.ts +7 -0
- package/lib/orchestrator/evaluator-identity.d.ts.map +1 -0
- package/lib/orchestrator/evaluator-identity.js +42 -0
- package/lib/orchestrator/evaluator-identity.js.map +1 -0
- package/lib/orchestrator/experiment-budget.d.ts +11 -0
- package/lib/orchestrator/experiment-budget.d.ts.map +1 -0
- package/lib/orchestrator/experiment-budget.js +51 -0
- package/lib/orchestrator/experiment-budget.js.map +1 -0
- package/lib/orchestrator/experiment-context.d.ts +43 -0
- package/lib/orchestrator/experiment-context.d.ts.map +1 -0
- package/lib/orchestrator/experiment-context.js +9 -0
- package/lib/orchestrator/experiment-context.js.map +1 -0
- package/lib/orchestrator/experiment-contracts.d.ts +290 -0
- package/lib/orchestrator/experiment-contracts.d.ts.map +1 -0
- package/lib/orchestrator/experiment-contracts.js +38 -0
- package/lib/orchestrator/experiment-contracts.js.map +1 -0
- package/lib/orchestrator/experiment-corpus.d.ts +21 -0
- package/lib/orchestrator/experiment-corpus.d.ts.map +1 -0
- package/lib/orchestrator/experiment-corpus.js +276 -0
- package/lib/orchestrator/experiment-corpus.js.map +1 -0
- package/lib/orchestrator/experiment-evaluation.d.ts +44 -0
- package/lib/orchestrator/experiment-evaluation.d.ts.map +1 -0
- package/lib/orchestrator/experiment-evaluation.js +542 -0
- package/lib/orchestrator/experiment-evaluation.js.map +1 -0
- package/lib/orchestrator/experiment-finish.d.ts +6 -0
- package/lib/orchestrator/experiment-finish.d.ts.map +1 -0
- package/lib/orchestrator/experiment-finish.js +19 -0
- package/lib/orchestrator/experiment-finish.js.map +1 -0
- package/lib/orchestrator/experiment-identity.d.ts +6 -0
- package/lib/orchestrator/experiment-identity.d.ts.map +1 -0
- package/lib/orchestrator/experiment-identity.js +257 -0
- package/lib/orchestrator/experiment-identity.js.map +1 -0
- package/lib/orchestrator/experiment-loader.d.ts +175 -0
- package/lib/orchestrator/experiment-loader.d.ts.map +1 -0
- package/lib/orchestrator/experiment-loader.js +77 -0
- package/lib/orchestrator/experiment-loader.js.map +1 -0
- package/lib/orchestrator/experiment-report.d.ts +450 -0
- package/lib/orchestrator/experiment-report.d.ts.map +1 -0
- package/lib/orchestrator/experiment-report.js +570 -0
- package/lib/orchestrator/experiment-report.js.map +1 -0
- package/lib/orchestrator/experiment-runs.d.ts +379 -0
- package/lib/orchestrator/experiment-runs.d.ts.map +1 -0
- package/lib/orchestrator/experiment-runs.js +796 -0
- package/lib/orchestrator/experiment-runs.js.map +1 -0
- package/lib/orchestrator/experiment-runtime-identity.d.ts +41 -0
- package/lib/orchestrator/experiment-runtime-identity.d.ts.map +1 -0
- package/lib/orchestrator/experiment-runtime-identity.js +411 -0
- package/lib/orchestrator/experiment-runtime-identity.js.map +1 -0
- package/lib/orchestrator/experiment-selection.d.ts +25 -0
- package/lib/orchestrator/experiment-selection.d.ts.map +1 -0
- package/lib/orchestrator/experiment-selection.js +286 -0
- package/lib/orchestrator/experiment-selection.js.map +1 -0
- package/lib/orchestrator/experiment.d.ts +11 -0
- package/lib/orchestrator/experiment.d.ts.map +1 -0
- package/lib/orchestrator/experiment.js +639 -0
- package/lib/orchestrator/experiment.js.map +1 -0
- package/lib/orchestrator/fixture-identity.d.ts +7 -0
- package/lib/orchestrator/fixture-identity.d.ts.map +1 -0
- package/lib/orchestrator/fixture-identity.js +55 -0
- package/lib/orchestrator/fixture-identity.js.map +1 -0
- package/lib/orchestrator/fs-read.d.ts +19 -0
- package/lib/orchestrator/fs-read.d.ts.map +1 -0
- package/lib/orchestrator/fs-read.js +113 -0
- package/lib/orchestrator/fs-read.js.map +1 -0
- package/lib/orchestrator/grader-experiment.d.ts +190 -0
- package/lib/orchestrator/grader-experiment.d.ts.map +1 -0
- package/lib/orchestrator/grader-experiment.js +579 -0
- package/lib/orchestrator/grader-experiment.js.map +1 -0
- package/lib/orchestrator/grading.d.ts +31 -0
- package/lib/orchestrator/grading.d.ts.map +1 -0
- package/lib/orchestrator/grading.js +186 -0
- package/lib/orchestrator/grading.js.map +1 -0
- package/lib/orchestrator/index.d.ts +22 -0
- package/lib/orchestrator/index.d.ts.map +1 -0
- package/lib/orchestrator/index.js +30 -0
- package/lib/orchestrator/index.js.map +1 -0
- package/lib/orchestrator/lifecycle-hook-execution.d.ts +4 -0
- package/lib/orchestrator/lifecycle-hook-execution.d.ts.map +1 -0
- package/lib/orchestrator/lifecycle-hook-execution.js +67 -0
- package/lib/orchestrator/lifecycle-hook-execution.js.map +1 -0
- package/lib/orchestrator/list-runs.d.ts +33 -0
- package/lib/orchestrator/list-runs.d.ts.map +1 -0
- package/lib/orchestrator/list-runs.js +308 -0
- package/lib/orchestrator/list-runs.js.map +1 -0
- package/lib/orchestrator/loader.d.ts +3 -0
- package/lib/orchestrator/loader.d.ts.map +1 -0
- package/lib/orchestrator/loader.js +17 -0
- package/lib/orchestrator/loader.js.map +1 -0
- package/lib/orchestrator/optimization-lifecycle.d.ts +12 -0
- package/lib/orchestrator/optimization-lifecycle.d.ts.map +1 -0
- package/lib/orchestrator/optimization-lifecycle.js +92 -0
- package/lib/orchestrator/optimization-lifecycle.js.map +1 -0
- package/lib/orchestrator/orchestrator.d.ts +144 -0
- package/lib/orchestrator/orchestrator.d.ts.map +1 -0
- package/lib/orchestrator/orchestrator.js +632 -0
- package/lib/orchestrator/orchestrator.js.map +1 -0
- package/lib/orchestrator/owned-lock.d.ts +17 -0
- package/lib/orchestrator/owned-lock.d.ts.map +1 -0
- package/lib/orchestrator/owned-lock.js +149 -0
- package/lib/orchestrator/owned-lock.js.map +1 -0
- package/lib/orchestrator/package-version.d.ts +2 -0
- package/lib/orchestrator/package-version.d.ts.map +1 -0
- package/lib/orchestrator/package-version.js +4 -0
- package/lib/orchestrator/package-version.js.map +1 -0
- package/lib/orchestrator/provenance.d.ts +5 -0
- package/lib/orchestrator/provenance.d.ts.map +1 -0
- package/lib/orchestrator/provenance.js +137 -0
- package/lib/orchestrator/provenance.js.map +1 -0
- package/lib/orchestrator/regrade.d.ts +80 -0
- package/lib/orchestrator/regrade.d.ts.map +1 -0
- package/lib/orchestrator/regrade.js +433 -0
- package/lib/orchestrator/regrade.js.map +1 -0
- package/lib/orchestrator/rubric-loader.d.ts +7 -0
- package/lib/orchestrator/rubric-loader.d.ts.map +1 -0
- package/lib/orchestrator/rubric-loader.js +65 -0
- package/lib/orchestrator/rubric-loader.js.map +1 -0
- package/lib/orchestrator/run-dir.d.ts +40 -0
- package/lib/orchestrator/run-dir.d.ts.map +1 -0
- package/lib/orchestrator/run-dir.js +161 -0
- package/lib/orchestrator/run-dir.js.map +1 -0
- package/lib/orchestrator/run-execution.d.ts +30 -0
- package/lib/orchestrator/run-execution.d.ts.map +1 -0
- package/lib/orchestrator/run-execution.js +531 -0
- package/lib/orchestrator/run-execution.js.map +1 -0
- package/lib/orchestrator/run-lifecycle.d.ts +115 -0
- package/lib/orchestrator/run-lifecycle.d.ts.map +1 -0
- package/lib/orchestrator/run-lifecycle.js +136 -0
- package/lib/orchestrator/run-lifecycle.js.map +1 -0
- package/lib/orchestrator/suite-compare.d.ts +76 -0
- package/lib/orchestrator/suite-compare.d.ts.map +1 -0
- package/lib/orchestrator/suite-compare.js +159 -0
- package/lib/orchestrator/suite-compare.js.map +1 -0
- package/lib/orchestrator/suite-lifecycle.d.ts +157 -0
- package/lib/orchestrator/suite-lifecycle.d.ts.map +1 -0
- package/lib/orchestrator/suite-lifecycle.js +253 -0
- package/lib/orchestrator/suite-lifecycle.js.map +1 -0
- package/lib/orchestrator/suite-runs.d.ts +91 -0
- package/lib/orchestrator/suite-runs.d.ts.map +1 -0
- package/lib/orchestrator/suite-runs.js +157 -0
- package/lib/orchestrator/suite-runs.js.map +1 -0
- package/lib/orchestrator/suite-summary.d.ts +109 -0
- package/lib/orchestrator/suite-summary.d.ts.map +1 -0
- package/lib/orchestrator/suite-summary.js +213 -0
- package/lib/orchestrator/suite-summary.js.map +1 -0
- package/lib/orchestrator/trace-limits.d.ts +20 -0
- package/lib/orchestrator/trace-limits.d.ts.map +1 -0
- package/lib/orchestrator/trace-limits.js +28 -0
- package/lib/orchestrator/trace-limits.js.map +1 -0
- package/lib/orchestrator/validate-plugin-config.d.ts +10 -0
- package/lib/orchestrator/validate-plugin-config.d.ts.map +1 -0
- package/lib/orchestrator/validate-plugin-config.js +26 -0
- package/lib/orchestrator/validate-plugin-config.js.map +1 -0
- package/package.json +84 -0
- package/skills/lux/SKILL.md +85 -0
- package/skills/lux/references/cli.md +102 -0
- package/skills/lux/references/eval-authoring.md +105 -0
- package/skills/lux-answerer/SKILL.md +169 -0
- package/src/answerers/claude-code/index.ts +342 -0
- package/src/answerers/persona/index.ts +327 -0
- package/src/answerers/scripted/index.ts +186 -0
- package/src/answerers/shared.ts +23 -0
- package/src/answerers/terminal/index.ts +117 -0
- package/src/assertions/core/command-exits-zero.ts +94 -0
- package/src/assertions/core/event-checks.ts +138 -0
- package/src/assertions/core/file-checks.ts +336 -0
- package/src/assertions/core/helpers.ts +203 -0
- package/src/assertions/core/index.ts +80 -0
- package/src/assertions/core/json-pointer-equals.ts +84 -0
- package/src/assertions/core/output-checks.ts +134 -0
- package/src/assertions/core/predicate.ts +67 -0
- package/src/assertions/core/resource-checks.ts +180 -0
- package/src/assertions/core/safe-regex.ts +196 -0
- package/src/assertions/core/tool-called-with.ts +68 -0
- package/src/assertions/core/tool-calls.ts +28 -0
- package/src/assertions/core/tool-invocation.ts +198 -0
- package/src/assertions/core/tool-result-checks.ts +211 -0
- package/src/assertions/mcp/discovery-checks.ts +139 -0
- package/src/assertions/mcp/index.ts +37 -0
- package/src/assertions/rubric/index.ts +258 -0
- package/src/assertions/rubric/internal.ts +367 -0
- package/src/authoring.ts +2 -0
- package/src/cli/bin.ts +14 -0
- package/src/cli/command-runtime.ts +34 -0
- package/src/cli/init.ts +410 -0
- package/src/cli/program.ts +992 -0
- package/src/cli/render/format.ts +69 -0
- package/src/cli/render/reporter.ts +643 -0
- package/src/cli/render/tty.ts +314 -0
- package/src/cli/run-options.ts +82 -0
- package/src/cli/skills.ts +129 -0
- package/src/core/annotation.ts +104 -0
- package/src/core/answerer.ts +75 -0
- package/src/core/artifact-evidence.ts +249 -0
- package/src/core/artifact-snapshot.ts +429 -0
- package/src/core/assertion.ts +156 -0
- package/src/core/case.ts +103 -0
- package/src/core/conversation-turn.ts +47 -0
- package/src/core/driver.ts +75 -0
- package/src/core/emitter.ts +38 -0
- package/src/core/events.ts +135 -0
- package/src/core/exec.ts +263 -0
- package/src/core/experiment.ts +467 -0
- package/src/core/glob.ts +31 -0
- package/src/core/hash.ts +237 -0
- package/src/core/index.ts +28 -0
- package/src/core/lifecycle-fixtures.ts +145 -0
- package/src/core/lifecycle-hooks.ts +101 -0
- package/src/core/mcp-events.ts +57 -0
- package/src/core/model-cli.ts +271 -0
- package/src/core/observer.ts +50 -0
- package/src/core/platform-process.ts +284 -0
- package/src/core/registry.ts +57 -0
- package/src/core/rubric.ts +52 -0
- package/src/core/run.ts +144 -0
- package/src/core/statistics.ts +194 -0
- package/src/core/subject.ts +50 -0
- package/src/core/tool-events.ts +292 -0
- package/src/core/usage.ts +123 -0
- package/src/core/wire.ts +135 -0
- package/src/core/zod.ts +20 -0
- package/src/drivers/claude-code/index.ts +866 -0
- package/src/drivers/claude-code/parse-events.ts +464 -0
- package/src/drivers/codex/app-events.ts +218 -0
- package/src/drivers/codex/config.ts +128 -0
- package/src/drivers/codex/index.ts +995 -0
- package/src/drivers/mcp/index.ts +351 -0
- package/src/drivers/mcp/transport.ts +222 -0
- package/src/drivers/shared/artifacts.ts +86 -0
- package/src/drivers/shared/secure-copy.ts +40 -0
- package/src/drivers/subprocess/index.ts +490 -0
- package/src/index.ts +594 -0
- package/src/optimization/reflective.ts +319 -0
- package/src/orchestrator/annotation-loader.ts +97 -0
- package/src/orchestrator/annotation-store.ts +112 -0
- package/src/orchestrator/authored-dependencies.ts +193 -0
- package/src/orchestrator/campaign-lifecycle.ts +181 -0
- package/src/orchestrator/candidate-integrity.ts +18 -0
- package/src/orchestrator/candidates.ts +683 -0
- package/src/orchestrator/compare.ts +358 -0
- package/src/orchestrator/comparison-identity.ts +45 -0
- package/src/orchestrator/config.ts +205 -0
- package/src/orchestrator/content-bound-json.ts +71 -0
- package/src/orchestrator/discover.ts +132 -0
- package/src/orchestrator/doctor.ts +781 -0
- package/src/orchestrator/driver-session.ts +507 -0
- package/src/orchestrator/evaluator-identity.ts +45 -0
- package/src/orchestrator/experiment-budget.ts +61 -0
- package/src/orchestrator/experiment-context.ts +41 -0
- package/src/orchestrator/experiment-contracts.ts +43 -0
- package/src/orchestrator/experiment-corpus.ts +416 -0
- package/src/orchestrator/experiment-evaluation.ts +749 -0
- package/src/orchestrator/experiment-finish.ts +33 -0
- package/src/orchestrator/experiment-identity.ts +356 -0
- package/src/orchestrator/experiment-loader.ts +105 -0
- package/src/orchestrator/experiment-report.ts +788 -0
- package/src/orchestrator/experiment-runs.ts +960 -0
- package/src/orchestrator/experiment-runtime-identity.ts +465 -0
- package/src/orchestrator/experiment-selection.ts +467 -0
- package/src/orchestrator/experiment.ts +991 -0
- package/src/orchestrator/fixture-identity.ts +67 -0
- package/src/orchestrator/fs-read.ts +126 -0
- package/src/orchestrator/grader-experiment.ts +856 -0
- package/src/orchestrator/grading.ts +260 -0
- package/src/orchestrator/index.ts +186 -0
- package/src/orchestrator/lifecycle-hook-execution.ts +90 -0
- package/src/orchestrator/list-runs.ts +384 -0
- package/src/orchestrator/loader.ts +19 -0
- package/src/orchestrator/optimization-lifecycle.ts +126 -0
- package/src/orchestrator/orchestrator.ts +919 -0
- package/src/orchestrator/owned-lock.ts +147 -0
- package/src/orchestrator/package-version.ts +5 -0
- package/src/orchestrator/provenance.ts +140 -0
- package/src/orchestrator/regrade.ts +580 -0
- package/src/orchestrator/rubric-loader.ts +74 -0
- package/src/orchestrator/run-dir.ts +209 -0
- package/src/orchestrator/run-execution.ts +694 -0
- package/src/orchestrator/run-lifecycle.ts +174 -0
- package/src/orchestrator/suite-compare.ts +195 -0
- package/src/orchestrator/suite-lifecycle.ts +335 -0
- package/src/orchestrator/suite-runs.ts +202 -0
- package/src/orchestrator/suite-summary.ts +276 -0
- package/src/orchestrator/trace-limits.ts +65 -0
- package/src/orchestrator/validate-plugin-config.ts +34 -0
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import {
|
|
5
|
+
createRubricAssertion,
|
|
6
|
+
RubricModelAccountingDetailSchema,
|
|
7
|
+
} from "../assertions/rubric/index.js";
|
|
8
|
+
import {
|
|
9
|
+
type Candidate,
|
|
10
|
+
type CandidateEvaluation,
|
|
11
|
+
type ExperimentSelector,
|
|
12
|
+
emptyUsage,
|
|
13
|
+
type GraderAnnotation,
|
|
14
|
+
type GradingReport,
|
|
15
|
+
GradingReportSchema,
|
|
16
|
+
sumUsage,
|
|
17
|
+
TokenUsageSchema,
|
|
18
|
+
totalTokens,
|
|
19
|
+
valueHash,
|
|
20
|
+
} from "../core/index.js";
|
|
21
|
+
import { selectGraderAnnotations } from "./annotation-loader.js";
|
|
22
|
+
import { buildRegistryFromConfig } from "./config.js";
|
|
23
|
+
import {
|
|
24
|
+
readContentBoundJson,
|
|
25
|
+
retireContentBoundJson,
|
|
26
|
+
writeContentBoundJson,
|
|
27
|
+
} from "./content-bound-json.js";
|
|
28
|
+
import type { CampaignExecutionOptions } from "./experiment.js";
|
|
29
|
+
import type { OpenedExperimentRun } from "./experiment-runs.js";
|
|
30
|
+
import { gradeRun } from "./grading.js";
|
|
31
|
+
import { loadFrozenRegradableRun, releaseFrozenRegradableRun } from "./regrade.js";
|
|
32
|
+
import { loadRubricDefinition } from "./rubric-loader.js";
|
|
33
|
+
|
|
34
|
+
const GraderJudgmentSchema = z.object({
|
|
35
|
+
key: z.string(),
|
|
36
|
+
kind: z.enum(["case-pass", "case-score", "assertion-pass", "assertion-score"]),
|
|
37
|
+
expected: z.union([z.boolean(), z.number()]),
|
|
38
|
+
actual: z.union([z.boolean(), z.number()]).nullable(),
|
|
39
|
+
matched: z.boolean(),
|
|
40
|
+
absoluteError: z.exactOptional(z.number()),
|
|
41
|
+
});
|
|
42
|
+
export type GraderJudgment = z.infer<typeof GraderJudgmentSchema>;
|
|
43
|
+
|
|
44
|
+
const GraderEvidenceItemSchema = z.object({
|
|
45
|
+
annotationId: z.string(),
|
|
46
|
+
repetition: z.number().int().positive(),
|
|
47
|
+
runDir: z.string(),
|
|
48
|
+
rubricPath: z.string(),
|
|
49
|
+
feedback: z.exactOptional(z.string()),
|
|
50
|
+
judgments: z.array(GraderJudgmentSchema),
|
|
51
|
+
report: GradingReportSchema,
|
|
52
|
+
durationMs: z.number().nonnegative(),
|
|
53
|
+
usage: TokenUsageSchema,
|
|
54
|
+
costUsd: z.number().nonnegative(),
|
|
55
|
+
unpricedModelCalls: z.number().int().nonnegative(),
|
|
56
|
+
});
|
|
57
|
+
type GraderEvidenceItem = z.infer<typeof GraderEvidenceItemSchema>;
|
|
58
|
+
|
|
59
|
+
const GraderEvaluationUnitSchema = z
|
|
60
|
+
.object({
|
|
61
|
+
schemaVersion: z.literal(1),
|
|
62
|
+
unitId: z.string(),
|
|
63
|
+
candidateId: z.string(),
|
|
64
|
+
profileId: z.string(),
|
|
65
|
+
split: z.enum(["train", "validation", "test"]),
|
|
66
|
+
repetitions: z.number().int().positive(),
|
|
67
|
+
annotationsHash: z.string(),
|
|
68
|
+
annotationId: z.string(),
|
|
69
|
+
repetition: z.number().int().positive(),
|
|
70
|
+
item: GraderEvidenceItemSchema,
|
|
71
|
+
})
|
|
72
|
+
.strict();
|
|
73
|
+
type GraderEvaluationUnit = z.infer<typeof GraderEvaluationUnitSchema>;
|
|
74
|
+
|
|
75
|
+
export const GraderEvaluationEvidenceSchema = z.object({
|
|
76
|
+
schemaVersion: z.literal(1),
|
|
77
|
+
candidateId: z.string(),
|
|
78
|
+
profileId: z.string(),
|
|
79
|
+
split: z.enum(["train", "validation", "test"]),
|
|
80
|
+
repetitions: z.number().int().positive(),
|
|
81
|
+
annotationsHash: z.string(),
|
|
82
|
+
generatedAt: z.string(),
|
|
83
|
+
metrics: z.record(z.string(), z.number()),
|
|
84
|
+
samples: z.record(z.string(), z.array(z.number())),
|
|
85
|
+
items: z.array(GraderEvidenceItemSchema),
|
|
86
|
+
});
|
|
87
|
+
export type GraderEvaluationEvidence = z.infer<typeof GraderEvaluationEvidenceSchema>;
|
|
88
|
+
|
|
89
|
+
const assertionOperationalError = (
|
|
90
|
+
entry: GradingReport["assertions"][number] | undefined,
|
|
91
|
+
): boolean => {
|
|
92
|
+
if (!entry) return false;
|
|
93
|
+
if (entry.errorMessage) return true;
|
|
94
|
+
const detail = RubricModelAccountingDetailSchema.safeParse(entry.detail);
|
|
95
|
+
return detail.success && detail.data.graderError !== undefined;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const assertionModelAccounting = (
|
|
99
|
+
assertion: GradingReport["assertions"][number],
|
|
100
|
+
): { attempts: number; costUsd: number; unpricedModelCalls: number } => {
|
|
101
|
+
const detail = RubricModelAccountingDetailSchema.safeParse(assertion.detail);
|
|
102
|
+
if (!detail.success) {
|
|
103
|
+
return { attempts: 0, costUsd: 0, unpricedModelCalls: 0 };
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
attempts: detail.data.attempts,
|
|
107
|
+
costUsd: detail.data.costUsd,
|
|
108
|
+
unpricedModelCalls: detail.data.unpricedAttempts,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const compareGraderAnnotation = (
|
|
113
|
+
annotation: GraderAnnotation,
|
|
114
|
+
report: GradingReport,
|
|
115
|
+
scoreTolerance: number,
|
|
116
|
+
): GraderJudgment[] => {
|
|
117
|
+
const judgments: GraderJudgment[] = [];
|
|
118
|
+
const reportFailed = report.assertions.some(assertionOperationalError);
|
|
119
|
+
if (annotation.expected.casePassed !== undefined) {
|
|
120
|
+
const actual = reportFailed ? null : report.casePassed;
|
|
121
|
+
judgments.push({
|
|
122
|
+
key: "case",
|
|
123
|
+
kind: "case-pass",
|
|
124
|
+
expected: annotation.expected.casePassed,
|
|
125
|
+
actual,
|
|
126
|
+
matched: actual === annotation.expected.casePassed,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (annotation.expected.caseScore !== undefined) {
|
|
130
|
+
const actual = reportFailed ? null : report.caseScore;
|
|
131
|
+
const absoluteError = actual === null ? 1 : Math.abs(actual - annotation.expected.caseScore);
|
|
132
|
+
judgments.push({
|
|
133
|
+
key: "case",
|
|
134
|
+
kind: "case-score",
|
|
135
|
+
expected: annotation.expected.caseScore,
|
|
136
|
+
actual,
|
|
137
|
+
matched: actual !== null && absoluteError <= scoreTolerance,
|
|
138
|
+
absoluteError,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const entries = new Map(
|
|
142
|
+
report.assertions.flatMap((entry) => (entry.id ? [[entry.id, entry] as const] : [])),
|
|
143
|
+
);
|
|
144
|
+
for (const [assertionId, expected] of Object.entries(annotation.expected.assertions)) {
|
|
145
|
+
const entry = entries.get(assertionId);
|
|
146
|
+
const actual = assertionOperationalError(entry) ? undefined : entry;
|
|
147
|
+
judgments.push({
|
|
148
|
+
key: assertionId,
|
|
149
|
+
kind: "assertion-pass",
|
|
150
|
+
expected: expected.passed,
|
|
151
|
+
actual: actual?.passed ?? null,
|
|
152
|
+
matched: actual?.passed === expected.passed,
|
|
153
|
+
});
|
|
154
|
+
if (expected.score !== undefined) {
|
|
155
|
+
const absoluteError = actual ? Math.abs(actual.score - expected.score) : 1;
|
|
156
|
+
judgments.push({
|
|
157
|
+
key: assertionId,
|
|
158
|
+
kind: "assertion-score",
|
|
159
|
+
expected: expected.score,
|
|
160
|
+
actual: actual?.score ?? null,
|
|
161
|
+
matched: actual !== undefined && absoluteError <= scoreTolerance,
|
|
162
|
+
absoluteError,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return judgments;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const ratio = (numerator: number, denominator: number, empty: number): number =>
|
|
170
|
+
denominator === 0 ? empty : numerator / denominator;
|
|
171
|
+
|
|
172
|
+
const addSample = (samples: Record<string, number[]>, name: string, value: number): void => {
|
|
173
|
+
if (!Number.isFinite(value)) return;
|
|
174
|
+
const values = samples[name] ?? [];
|
|
175
|
+
values.push(value);
|
|
176
|
+
samples[name] = values;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const mean = (values: readonly number[], empty = 0): number =>
|
|
180
|
+
values.length === 0 ? empty : values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
181
|
+
|
|
182
|
+
type GraderEvidenceCounts = {
|
|
183
|
+
truePositive: number;
|
|
184
|
+
falsePositive: number;
|
|
185
|
+
falseNegative: number;
|
|
186
|
+
positiveLabels: number;
|
|
187
|
+
negativeLabels: number;
|
|
188
|
+
abstentions: number;
|
|
189
|
+
passJudgments: number;
|
|
190
|
+
scoreJudgments: number;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const collectGraderEvidence = (
|
|
194
|
+
items: readonly GraderEvidenceItem[],
|
|
195
|
+
): {
|
|
196
|
+
byAnnotation: Map<string, z.infer<typeof GraderJudgmentSchema>[]>;
|
|
197
|
+
itemsByAnnotation: Map<string, GraderEvidenceItem[]>;
|
|
198
|
+
counts: GraderEvidenceCounts;
|
|
199
|
+
} => {
|
|
200
|
+
const byAnnotation = new Map<string, z.infer<typeof GraderJudgmentSchema>[]>();
|
|
201
|
+
const itemsByAnnotation = new Map<string, GraderEvidenceItem[]>();
|
|
202
|
+
const counts: GraderEvidenceCounts = {
|
|
203
|
+
truePositive: 0,
|
|
204
|
+
falsePositive: 0,
|
|
205
|
+
falseNegative: 0,
|
|
206
|
+
positiveLabels: 0,
|
|
207
|
+
negativeLabels: 0,
|
|
208
|
+
abstentions: 0,
|
|
209
|
+
passJudgments: 0,
|
|
210
|
+
scoreJudgments: 0,
|
|
211
|
+
};
|
|
212
|
+
for (const item of items) {
|
|
213
|
+
const annotationJudgments = byAnnotation.get(item.annotationId) ?? [];
|
|
214
|
+
annotationJudgments.push(...item.judgments);
|
|
215
|
+
byAnnotation.set(item.annotationId, annotationJudgments);
|
|
216
|
+
const annotationItems = itemsByAnnotation.get(item.annotationId) ?? [];
|
|
217
|
+
annotationItems.push(item);
|
|
218
|
+
itemsByAnnotation.set(item.annotationId, annotationItems);
|
|
219
|
+
for (const judgment of item.judgments) {
|
|
220
|
+
if (judgment.absoluteError !== undefined) counts.scoreJudgments++;
|
|
221
|
+
if (!judgment.kind.endsWith("-pass") || typeof judgment.expected !== "boolean") continue;
|
|
222
|
+
counts.passJudgments++;
|
|
223
|
+
if (judgment.expected) counts.positiveLabels++;
|
|
224
|
+
else counts.negativeLabels++;
|
|
225
|
+
if (judgment.actual === null) counts.abstentions++;
|
|
226
|
+
else if (judgment.expected && judgment.actual) counts.truePositive++;
|
|
227
|
+
else if (!judgment.expected && judgment.actual) counts.falsePositive++;
|
|
228
|
+
else if (judgment.expected && !judgment.actual) counts.falseNegative++;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return { byAnnotation, itemsByAnnotation, counts };
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export const summarizeGraderEvidence = (
|
|
235
|
+
items: readonly z.infer<typeof GraderEvidenceItemSchema>[],
|
|
236
|
+
candidate: Candidate,
|
|
237
|
+
): { metrics: Record<string, number>; samples: Record<string, number[]> } => {
|
|
238
|
+
const samples: Record<string, number[]> = {};
|
|
239
|
+
const { byAnnotation, itemsByAnnotation, counts } = collectGraderEvidence(items);
|
|
240
|
+
let caseJudgmentCount = 0;
|
|
241
|
+
let assertionJudgmentCount = 0;
|
|
242
|
+
for (const [annotationId, judgments] of byAnnotation) {
|
|
243
|
+
const annotationItems = itemsByAnnotation.get(annotationId) ?? [];
|
|
244
|
+
addSample(samples, "phase.gradingMs", mean(annotationItems.map((item) => item.durationMs)));
|
|
245
|
+
addSample(samples, "harness.input", mean(annotationItems.map((item) => item.usage.input)));
|
|
246
|
+
addSample(samples, "harness.output", mean(annotationItems.map((item) => item.usage.output)));
|
|
247
|
+
addSample(
|
|
248
|
+
samples,
|
|
249
|
+
"harness.cacheRead",
|
|
250
|
+
mean(annotationItems.map((item) => item.usage.cacheRead)),
|
|
251
|
+
);
|
|
252
|
+
addSample(
|
|
253
|
+
samples,
|
|
254
|
+
"harness.cacheCreation",
|
|
255
|
+
mean(annotationItems.map((item) => item.usage.cacheCreation)),
|
|
256
|
+
);
|
|
257
|
+
addSample(
|
|
258
|
+
samples,
|
|
259
|
+
"harness.total",
|
|
260
|
+
mean(annotationItems.map((item) => totalTokens(item.usage))),
|
|
261
|
+
);
|
|
262
|
+
const allAgreement = mean(judgments.map((judgment) => (judgment.matched ? 1 : 0)));
|
|
263
|
+
addSample(samples, "quality.passRate", allAgreement);
|
|
264
|
+
addSample(samples, "grader.agreement", allAgreement);
|
|
265
|
+
const caseJudgments = judgments.filter((judgment) => judgment.kind.startsWith("case"));
|
|
266
|
+
if (caseJudgments.length > 0) {
|
|
267
|
+
caseJudgmentCount += caseJudgments.length;
|
|
268
|
+
addSample(
|
|
269
|
+
samples,
|
|
270
|
+
"grader.caseAgreement",
|
|
271
|
+
mean(caseJudgments.map((judgment) => (judgment.matched ? 1 : 0))),
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
const assertionJudgments = judgments.filter((judgment) =>
|
|
275
|
+
judgment.kind.startsWith("assertion"),
|
|
276
|
+
);
|
|
277
|
+
if (assertionJudgments.length > 0) {
|
|
278
|
+
assertionJudgmentCount += assertionJudgments.length;
|
|
279
|
+
addSample(
|
|
280
|
+
samples,
|
|
281
|
+
"grader.assertionAgreement",
|
|
282
|
+
mean(assertionJudgments.map((judgment) => (judgment.matched ? 1 : 0))),
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
const passes = judgments.filter(
|
|
286
|
+
(judgment) => judgment.kind.endsWith("-pass") && typeof judgment.expected === "boolean",
|
|
287
|
+
);
|
|
288
|
+
const scoreErrors = judgments.flatMap((judgment) =>
|
|
289
|
+
judgment.absoluteError === undefined ? [] : [judgment.absoluteError],
|
|
290
|
+
);
|
|
291
|
+
if (scoreErrors.length > 0) {
|
|
292
|
+
addSample(samples, "grader.scoreAbsoluteError", mean(scoreErrors));
|
|
293
|
+
addSample(samples, "grader.scoreMae", mean(scoreErrors));
|
|
294
|
+
}
|
|
295
|
+
const positive = passes.filter((judgment) => judgment.expected === true);
|
|
296
|
+
const negative = passes.filter((judgment) => judgment.expected === false);
|
|
297
|
+
const coveredPositive = positive.filter((judgment) => judgment.actual !== null);
|
|
298
|
+
const coveredNegative = negative.filter((judgment) => judgment.actual !== null);
|
|
299
|
+
if (coveredPositive.length > 0) {
|
|
300
|
+
addSample(
|
|
301
|
+
samples,
|
|
302
|
+
"grader.macroFalseNegativeRate",
|
|
303
|
+
coveredPositive.filter((judgment) => judgment.actual === false).length /
|
|
304
|
+
coveredPositive.length,
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
if (coveredNegative.length > 0) {
|
|
308
|
+
addSample(
|
|
309
|
+
samples,
|
|
310
|
+
"grader.macroFalsePositiveRate",
|
|
311
|
+
coveredNegative.filter((judgment) => judgment.actual === true).length /
|
|
312
|
+
coveredNegative.length,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
if (passes.length > 0) {
|
|
316
|
+
addSample(
|
|
317
|
+
samples,
|
|
318
|
+
"grader.coverage",
|
|
319
|
+
passes.filter((judgment) => judgment.actual !== null).length / passes.length,
|
|
320
|
+
);
|
|
321
|
+
addSample(
|
|
322
|
+
samples,
|
|
323
|
+
"grader.abstentionRate",
|
|
324
|
+
passes.filter((judgment) => judgment.actual === null).length / passes.length,
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
const precision = ratio(
|
|
329
|
+
counts.truePositive,
|
|
330
|
+
counts.truePositive + counts.falsePositive,
|
|
331
|
+
Number.NaN,
|
|
332
|
+
);
|
|
333
|
+
const recall = ratio(counts.truePositive, counts.truePositive + counts.falseNegative, Number.NaN);
|
|
334
|
+
const metrics: Record<string, number> = {
|
|
335
|
+
"quality.passRate": mean(samples["quality.passRate"] ?? []),
|
|
336
|
+
"grader.agreement": mean(samples["grader.agreement"] ?? []),
|
|
337
|
+
"grader.labels": byAnnotation.size,
|
|
338
|
+
"grader.judgments": items.reduce((total, item) => total + item.judgments.length, 0),
|
|
339
|
+
"grader.passJudgments": counts.passJudgments,
|
|
340
|
+
"grader.caseJudgments": caseJudgmentCount,
|
|
341
|
+
"grader.assertionJudgments": assertionJudgmentCount,
|
|
342
|
+
"grader.scoreJudgments": counts.scoreJudgments,
|
|
343
|
+
"grader.positiveLabels": counts.positiveLabels,
|
|
344
|
+
"grader.negativeLabels": counts.negativeLabels,
|
|
345
|
+
"grader.abstentions": counts.abstentions,
|
|
346
|
+
"subject.bytes": candidate.sourceBytes,
|
|
347
|
+
};
|
|
348
|
+
const addMetric = (name: string, value: number | undefined): void => {
|
|
349
|
+
if (value !== undefined && Number.isFinite(value)) metrics[name] = value;
|
|
350
|
+
};
|
|
351
|
+
addMetric(
|
|
352
|
+
"grader.caseAgreement",
|
|
353
|
+
samples["grader.caseAgreement"] ? mean(samples["grader.caseAgreement"]) : undefined,
|
|
354
|
+
);
|
|
355
|
+
addMetric(
|
|
356
|
+
"grader.assertionAgreement",
|
|
357
|
+
samples["grader.assertionAgreement"] ? mean(samples["grader.assertionAgreement"]) : undefined,
|
|
358
|
+
);
|
|
359
|
+
addMetric("grader.microPrecision", precision);
|
|
360
|
+
addMetric("grader.microRecall", recall);
|
|
361
|
+
let microF1: number | undefined;
|
|
362
|
+
if (Number.isFinite(precision) && Number.isFinite(recall)) {
|
|
363
|
+
microF1 = precision + recall === 0 ? 0 : (2 * precision * recall) / (precision + recall);
|
|
364
|
+
}
|
|
365
|
+
addMetric("grader.microF1", microF1);
|
|
366
|
+
addMetric(
|
|
367
|
+
"grader.macroFalsePositiveRate",
|
|
368
|
+
samples["grader.macroFalsePositiveRate"]
|
|
369
|
+
? mean(samples["grader.macroFalsePositiveRate"])
|
|
370
|
+
: undefined,
|
|
371
|
+
);
|
|
372
|
+
addMetric(
|
|
373
|
+
"grader.macroFalseNegativeRate",
|
|
374
|
+
samples["grader.macroFalseNegativeRate"]
|
|
375
|
+
? mean(samples["grader.macroFalseNegativeRate"])
|
|
376
|
+
: undefined,
|
|
377
|
+
);
|
|
378
|
+
addMetric(
|
|
379
|
+
"grader.coverage",
|
|
380
|
+
samples["grader.coverage"] ? mean(samples["grader.coverage"]) : undefined,
|
|
381
|
+
);
|
|
382
|
+
addMetric(
|
|
383
|
+
"grader.abstentionRate",
|
|
384
|
+
samples["grader.abstentionRate"] ? mean(samples["grader.abstentionRate"]) : undefined,
|
|
385
|
+
);
|
|
386
|
+
addMetric(
|
|
387
|
+
"grader.scoreMae",
|
|
388
|
+
samples["grader.scoreMae"] ? mean(samples["grader.scoreMae"]) : undefined,
|
|
389
|
+
);
|
|
390
|
+
for (const [name, values] of Object.entries(samples)) {
|
|
391
|
+
if (!(name in metrics)) metrics[name] = mean(values);
|
|
392
|
+
}
|
|
393
|
+
return { metrics, samples };
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
const graderEvidencePath = (
|
|
397
|
+
experiment: OpenedExperimentRun,
|
|
398
|
+
identityInput: Pick<
|
|
399
|
+
GraderEvaluationEvidence,
|
|
400
|
+
"candidateId" | "profileId" | "split" | "repetitions" | "annotationsHash"
|
|
401
|
+
>,
|
|
402
|
+
): string => {
|
|
403
|
+
const directory = join(experiment.path, "grader-evaluations");
|
|
404
|
+
const identity = valueHash({
|
|
405
|
+
candidateId: identityInput.candidateId,
|
|
406
|
+
profileId: identityInput.profileId,
|
|
407
|
+
split: identityInput.split,
|
|
408
|
+
repetitions: identityInput.repetitions,
|
|
409
|
+
annotationsHash: identityInput.annotationsHash,
|
|
410
|
+
}).slice(0, 20);
|
|
411
|
+
return join(directory, `${identityInput.candidateId}-${identity}.json`);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const graderUnitId = (input: {
|
|
415
|
+
candidateId: string;
|
|
416
|
+
profileId: string;
|
|
417
|
+
split: "train" | "validation" | "test";
|
|
418
|
+
repetitions: number;
|
|
419
|
+
annotationsHash: string;
|
|
420
|
+
annotationId: string;
|
|
421
|
+
repetition: number;
|
|
422
|
+
}): string => `grader-${valueHash(input).slice(0, 32)}`;
|
|
423
|
+
|
|
424
|
+
const graderUnitPath = (experiment: OpenedExperimentRun, unitId: string): string =>
|
|
425
|
+
join(experiment.path, "evaluation-units", `${unitId}.json`);
|
|
426
|
+
|
|
427
|
+
const itemAccounting = (): Pick<
|
|
428
|
+
CandidateEvaluation,
|
|
429
|
+
"metricCalls" | "judgeCalls" | "unpricedModelCalls" | "usage" | "costUsd"
|
|
430
|
+
> => ({
|
|
431
|
+
metricCalls: 1,
|
|
432
|
+
judgeCalls: 0,
|
|
433
|
+
usage: emptyUsage(),
|
|
434
|
+
costUsd: 0,
|
|
435
|
+
unpricedModelCalls: 0,
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
const evaluationFromEvidence = (
|
|
439
|
+
experiment: OpenedExperimentRun,
|
|
440
|
+
evidencePath: string,
|
|
441
|
+
evidence: GraderEvaluationEvidence,
|
|
442
|
+
): CandidateEvaluation & { evidencePath: string } => {
|
|
443
|
+
const byAnnotation = new Map<string, number[]>();
|
|
444
|
+
for (const item of evidence.items) {
|
|
445
|
+
const values = byAnnotation.get(item.annotationId) ?? [];
|
|
446
|
+
values.push(...item.judgments.map((judgment) => (judgment.matched ? 1 : 0)));
|
|
447
|
+
byAnnotation.set(item.annotationId, values);
|
|
448
|
+
}
|
|
449
|
+
const failedCases: CandidateEvaluation["failedCases"] = evidence.items.flatMap((item) => {
|
|
450
|
+
const mismatches = item.judgments.filter((judgment) => !judgment.matched);
|
|
451
|
+
if (mismatches.length === 0) return [];
|
|
452
|
+
const feedback = mismatches.map(
|
|
453
|
+
(judgment) =>
|
|
454
|
+
`${judgment.key} ${judgment.kind}: expected ${String(judgment.expected)}, got ${String(judgment.actual)}`,
|
|
455
|
+
);
|
|
456
|
+
if (item.feedback) feedback.unshift(`human feedback: ${item.feedback}`);
|
|
457
|
+
for (const judgment of mismatches) {
|
|
458
|
+
if (!judgment.kind.startsWith("assertion")) continue;
|
|
459
|
+
const comment = item.report.assertions.find((entry) => entry.id === judgment.key)?.comment;
|
|
460
|
+
if (comment) feedback.push(`grader comment for ${judgment.key}: ${comment}`);
|
|
461
|
+
}
|
|
462
|
+
return [
|
|
463
|
+
{
|
|
464
|
+
caseId: `${item.annotationId} #${item.repetition}`,
|
|
465
|
+
score: mean(item.judgments.map((judgment) => (judgment.matched ? 1 : 0))),
|
|
466
|
+
feedback,
|
|
467
|
+
},
|
|
468
|
+
];
|
|
469
|
+
});
|
|
470
|
+
return {
|
|
471
|
+
profileId: evidence.profileId,
|
|
472
|
+
split: evidence.split,
|
|
473
|
+
evidencePath: relative(experiment.path, evidencePath),
|
|
474
|
+
passRate: evidence.metrics["quality.passRate"] ?? 0,
|
|
475
|
+
casePassRates: Object.fromEntries([...byAnnotation].map(([id, values]) => [id, mean(values)])),
|
|
476
|
+
metrics: evidence.metrics,
|
|
477
|
+
samples: evidence.samples,
|
|
478
|
+
metricCalls: evidence.items.length,
|
|
479
|
+
judgeCalls: evidence.items.reduce(
|
|
480
|
+
(total, item) =>
|
|
481
|
+
total +
|
|
482
|
+
item.report.assertions.reduce(
|
|
483
|
+
(assertionTotal, assertion) =>
|
|
484
|
+
assertionTotal + assertionModelAccounting(assertion).attempts,
|
|
485
|
+
0,
|
|
486
|
+
),
|
|
487
|
+
0,
|
|
488
|
+
),
|
|
489
|
+
usage: sumUsage(evidence.items.map((item) => item.usage)),
|
|
490
|
+
costUsd: evidence.items.reduce((total, item) => total + item.costUsd, 0),
|
|
491
|
+
unpricedModelCalls: evidence.items.reduce((total, item) => total + item.unpricedModelCalls, 0),
|
|
492
|
+
failedCases,
|
|
493
|
+
};
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
const candidateRubricPath = (materializedRoot: string, rubricPath: string): string => {
|
|
497
|
+
const root = resolve(materializedRoot);
|
|
498
|
+
const path = resolve(root, rubricPath);
|
|
499
|
+
if (path !== root && !path.startsWith(`${root}${sep}`)) {
|
|
500
|
+
throw new Error(`grader rubric path escapes candidate root: ${rubricPath}`);
|
|
501
|
+
}
|
|
502
|
+
return path;
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
const assertionIds = (rubric: Awaited<ReturnType<typeof loadRubricDefinition>>): string[] =>
|
|
506
|
+
rubric.assertions.map((assertion) => assertion.id ?? "").sort();
|
|
507
|
+
|
|
508
|
+
const assertEvidenceIdentity = (
|
|
509
|
+
evidence: GraderEvaluationEvidence,
|
|
510
|
+
expected: {
|
|
511
|
+
candidateId: string;
|
|
512
|
+
profileId: string;
|
|
513
|
+
split: "train" | "validation" | "test";
|
|
514
|
+
repetitions: number;
|
|
515
|
+
annotationsHash: string;
|
|
516
|
+
},
|
|
517
|
+
path: string,
|
|
518
|
+
): void => {
|
|
519
|
+
if (
|
|
520
|
+
evidence.candidateId !== expected.candidateId ||
|
|
521
|
+
evidence.profileId !== expected.profileId ||
|
|
522
|
+
evidence.split !== expected.split ||
|
|
523
|
+
evidence.repetitions !== expected.repetitions ||
|
|
524
|
+
evidence.annotationsHash !== expected.annotationsHash
|
|
525
|
+
) {
|
|
526
|
+
throw new Error(`cached grader evidence failed its identity check: ${path}`);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
const assertUnitIdentity = (
|
|
531
|
+
unit: GraderEvaluationUnit,
|
|
532
|
+
expected: Omit<GraderEvaluationUnit, "schemaVersion" | "item">,
|
|
533
|
+
path: string,
|
|
534
|
+
): void => {
|
|
535
|
+
if (
|
|
536
|
+
unit.unitId !== expected.unitId ||
|
|
537
|
+
unit.candidateId !== expected.candidateId ||
|
|
538
|
+
unit.profileId !== expected.profileId ||
|
|
539
|
+
unit.split !== expected.split ||
|
|
540
|
+
unit.repetitions !== expected.repetitions ||
|
|
541
|
+
unit.annotationsHash !== expected.annotationsHash ||
|
|
542
|
+
unit.annotationId !== expected.annotationId ||
|
|
543
|
+
unit.repetition !== expected.repetition
|
|
544
|
+
) {
|
|
545
|
+
throw new Error(`grader evaluation unit failed its identity check: ${path}`);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
const throwIfExperimentAborted = (signal: AbortSignal | undefined): void => {
|
|
550
|
+
if (!signal?.aborted) return;
|
|
551
|
+
throw signal.reason instanceof Error ? signal.reason : new Error("experiment aborted");
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
const validateCandidateRubricIds = (
|
|
555
|
+
rubricPath: string,
|
|
556
|
+
baselineIds: readonly string[],
|
|
557
|
+
candidateIds: readonly string[],
|
|
558
|
+
allowedAdditions: ReadonlySet<string>,
|
|
559
|
+
): void => {
|
|
560
|
+
const missingBaseline = baselineIds.filter((id) => !candidateIds.includes(id));
|
|
561
|
+
const unlabeledAdditions = candidateIds.filter(
|
|
562
|
+
(id) => !baselineIds.includes(id) && !allowedAdditions.has(id),
|
|
563
|
+
);
|
|
564
|
+
if (missingBaseline.length === 0 && unlabeledAdditions.length === 0) return;
|
|
565
|
+
throw new Error(
|
|
566
|
+
`rubric '${rubricPath}' must preserve baseline IDs and may add only explicitly allowed IDs` +
|
|
567
|
+
`${missingBaseline.length > 0 ? `; missing: ${missingBaseline.join(", ")}` : ""}` +
|
|
568
|
+
`${unlabeledAdditions.length > 0 ? `; unlabeled additions: ${unlabeledAdditions.join(", ")}` : ""}`,
|
|
569
|
+
);
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
export const evaluateGraderCandidate = async (options: {
|
|
573
|
+
execution: CampaignExecutionOptions;
|
|
574
|
+
experiment: OpenedExperimentRun;
|
|
575
|
+
candidate: Candidate;
|
|
576
|
+
materializedRoot: string;
|
|
577
|
+
profileId: string;
|
|
578
|
+
split: "train" | "validation" | "test";
|
|
579
|
+
selector: ExperimentSelector;
|
|
580
|
+
repetitions: number;
|
|
581
|
+
preflightUnit: (maximumJudgeCalls: number) => void;
|
|
582
|
+
recordUnit: (
|
|
583
|
+
unitId: string,
|
|
584
|
+
accounting: Pick<
|
|
585
|
+
CandidateEvaluation,
|
|
586
|
+
"metricCalls" | "judgeCalls" | "unpricedModelCalls" | "usage" | "costUsd"
|
|
587
|
+
>,
|
|
588
|
+
) => Promise<void>;
|
|
589
|
+
recordAttempt: (
|
|
590
|
+
attemptId: string,
|
|
591
|
+
accounting: Pick<
|
|
592
|
+
CandidateEvaluation,
|
|
593
|
+
"metricCalls" | "judgeCalls" | "unpricedModelCalls" | "usage" | "costUsd"
|
|
594
|
+
>,
|
|
595
|
+
) => Promise<void>;
|
|
596
|
+
recordAssertion: (
|
|
597
|
+
assertionId: string,
|
|
598
|
+
accounting: Pick<
|
|
599
|
+
CandidateEvaluation,
|
|
600
|
+
"metricCalls" | "judgeCalls" | "unpricedModelCalls" | "usage" | "costUsd"
|
|
601
|
+
>,
|
|
602
|
+
) => Promise<void>;
|
|
603
|
+
recordModelAttemptStart: (kind: "judge") => string | Promise<string>;
|
|
604
|
+
completeModelAttempts: (attemptIds: readonly string[]) => void | Promise<void>;
|
|
605
|
+
verifyExecutionIdentity: () => Promise<void>;
|
|
606
|
+
}): Promise<CandidateEvaluation & { evidencePath: string }> => {
|
|
607
|
+
const { execution, experiment, candidate, profileId, split, repetitions } = options;
|
|
608
|
+
const annotations = execution.loaded.graderAnnotations;
|
|
609
|
+
if (!annotations || execution.loaded.campaign.evaluation.kind !== "grader") {
|
|
610
|
+
throw new Error("grader experiment is missing its loaded annotation dataset");
|
|
611
|
+
}
|
|
612
|
+
const evaluationHash = experiment.manifest.evaluationHash;
|
|
613
|
+
if (!evaluationHash) throw new Error("grader experiment has no evaluation identity");
|
|
614
|
+
const selected = selectGraderAnnotations(annotations.annotations, options.selector);
|
|
615
|
+
if (selected.length === 0) {
|
|
616
|
+
throw new Error(
|
|
617
|
+
`experiment '${execution.loaded.campaign.id}' ${split} selector matched no labels`,
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
const profile = execution.config.profiles?.[profileId];
|
|
621
|
+
if (!profile) throw new Error(`experiment profile '${profileId}' is not configured`);
|
|
622
|
+
const expectedEvidencePath = graderEvidencePath(experiment, {
|
|
623
|
+
candidateId: candidate.id,
|
|
624
|
+
profileId,
|
|
625
|
+
split,
|
|
626
|
+
repetitions,
|
|
627
|
+
annotationsHash: annotations.hash,
|
|
628
|
+
});
|
|
629
|
+
let cachedEvidence = await readContentBoundJson(
|
|
630
|
+
expectedEvidencePath,
|
|
631
|
+
GraderEvaluationEvidenceSchema,
|
|
632
|
+
evaluationHash,
|
|
633
|
+
);
|
|
634
|
+
if (cachedEvidence) {
|
|
635
|
+
assertEvidenceIdentity(
|
|
636
|
+
cachedEvidence,
|
|
637
|
+
{
|
|
638
|
+
candidateId: candidate.id,
|
|
639
|
+
profileId,
|
|
640
|
+
split,
|
|
641
|
+
repetitions,
|
|
642
|
+
annotationsHash: annotations.hash,
|
|
643
|
+
},
|
|
644
|
+
expectedEvidencePath,
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
const harness = profile.harness ?? execution.config.harness;
|
|
648
|
+
const registry = buildRegistryFromConfig({
|
|
649
|
+
...execution.config,
|
|
650
|
+
...(harness ? { harness } : {}),
|
|
651
|
+
}).withAssertion(createRubricAssertion(harness));
|
|
652
|
+
const items: GraderEvidenceItem[] = [];
|
|
653
|
+
for (const annotation of selected) {
|
|
654
|
+
const rubric = await loadRubricDefinition(
|
|
655
|
+
candidateRubricPath(options.materializedRoot, annotation.rubricPath),
|
|
656
|
+
);
|
|
657
|
+
const baselineRubric = await loadRubricDefinition(
|
|
658
|
+
candidateRubricPath(execution.loaded.subjectRoot, annotation.rubricPath),
|
|
659
|
+
);
|
|
660
|
+
const baselineIds = assertionIds(baselineRubric);
|
|
661
|
+
const candidateIds = assertionIds(rubric);
|
|
662
|
+
const allowedAdditions = new Set(
|
|
663
|
+
execution.loaded.campaign.evaluation.allowedAssertionAdditions[annotation.rubricPath] ?? [],
|
|
664
|
+
);
|
|
665
|
+
validateCandidateRubricIds(annotation.rubricPath, baselineIds, candidateIds, allowedAdditions);
|
|
666
|
+
const persistedRun = await loadFrozenRegradableRun(annotation.runDir);
|
|
667
|
+
try {
|
|
668
|
+
if (rubric.id !== persistedRun.case.id) {
|
|
669
|
+
throw new Error(
|
|
670
|
+
`rubric '${annotation.rubricPath}' id '${rubric.id}' does not match persisted case '${persistedRun.case.id}'`,
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
for (let repetition = 1; repetition <= repetitions; repetition++) {
|
|
674
|
+
const unitId = graderUnitId({
|
|
675
|
+
candidateId: candidate.id,
|
|
676
|
+
profileId,
|
|
677
|
+
split,
|
|
678
|
+
repetitions,
|
|
679
|
+
annotationsHash: annotations.hash,
|
|
680
|
+
annotationId: annotation.id,
|
|
681
|
+
repetition,
|
|
682
|
+
});
|
|
683
|
+
const unitPath = graderUnitPath(experiment, unitId);
|
|
684
|
+
const existing = await readContentBoundJson(
|
|
685
|
+
unitPath,
|
|
686
|
+
GraderEvaluationUnitSchema,
|
|
687
|
+
evaluationHash,
|
|
688
|
+
);
|
|
689
|
+
if (existing) {
|
|
690
|
+
assertUnitIdentity(
|
|
691
|
+
existing,
|
|
692
|
+
{
|
|
693
|
+
unitId,
|
|
694
|
+
candidateId: candidate.id,
|
|
695
|
+
profileId,
|
|
696
|
+
split,
|
|
697
|
+
repetitions,
|
|
698
|
+
annotationsHash: annotations.hash,
|
|
699
|
+
annotationId: annotation.id,
|
|
700
|
+
repetition,
|
|
701
|
+
},
|
|
702
|
+
unitPath,
|
|
703
|
+
);
|
|
704
|
+
await options.recordUnit(unitId, { ...itemAccounting(), metricCalls: 0 });
|
|
705
|
+
throwIfExperimentAborted(execution.abortSignal);
|
|
706
|
+
items.push(existing.item);
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (cachedEvidence) {
|
|
710
|
+
await retireContentBoundJson(expectedEvidencePath);
|
|
711
|
+
cachedEvidence = null;
|
|
712
|
+
}
|
|
713
|
+
options.preflightUnit(rubric.assertions.length * 2);
|
|
714
|
+
const run = {
|
|
715
|
+
...persistedRun,
|
|
716
|
+
case: { ...persistedRun.case, assertions: rubric.assertions },
|
|
717
|
+
};
|
|
718
|
+
const startedAt = Date.now();
|
|
719
|
+
const assertionAttemptId = randomUUID();
|
|
720
|
+
await options.recordAttempt(
|
|
721
|
+
`grader-metric-attempt-${unitId}-${assertionAttemptId}`,
|
|
722
|
+
itemAccounting(),
|
|
723
|
+
);
|
|
724
|
+
let report: GradingReport;
|
|
725
|
+
try {
|
|
726
|
+
report = await gradeRun(
|
|
727
|
+
run,
|
|
728
|
+
registry,
|
|
729
|
+
undefined,
|
|
730
|
+
execution.abortSignal,
|
|
731
|
+
async (assertion, index) => {
|
|
732
|
+
const accounting = assertionModelAccounting(assertion);
|
|
733
|
+
let unpricedModelCalls = accounting.unpricedModelCalls;
|
|
734
|
+
if (unpricedModelCalls === 0 && accounting.attempts === 0 && assertion.usage) {
|
|
735
|
+
unpricedModelCalls = 1;
|
|
736
|
+
}
|
|
737
|
+
await options.recordAssertion(
|
|
738
|
+
`grader-judge-${unitId}-${assertionAttemptId}-${index}`,
|
|
739
|
+
{
|
|
740
|
+
metricCalls: 0,
|
|
741
|
+
// Provider-attempt starts journal judgeCalls before spend.
|
|
742
|
+
judgeCalls: 0,
|
|
743
|
+
usage: assertion.usage ?? emptyUsage(),
|
|
744
|
+
costUsd: accounting.costUsd,
|
|
745
|
+
unpricedModelCalls,
|
|
746
|
+
},
|
|
747
|
+
);
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
start: options.recordModelAttemptStart,
|
|
751
|
+
complete: options.completeModelAttempts,
|
|
752
|
+
},
|
|
753
|
+
);
|
|
754
|
+
const failedAssertion = report.assertions.find(assertionOperationalError);
|
|
755
|
+
if (report.incomplete?.phase === "grading" || failedAssertion) {
|
|
756
|
+
throw new Error(
|
|
757
|
+
failedAssertion?.errorMessage ??
|
|
758
|
+
failedAssertion?.comment ??
|
|
759
|
+
"grader assertion could not produce a judgment",
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
} catch (error) {
|
|
763
|
+
await options.recordUnit(`grader-attempt-${unitId}-${assertionAttemptId}`, {
|
|
764
|
+
...itemAccounting(),
|
|
765
|
+
metricCalls: 0,
|
|
766
|
+
});
|
|
767
|
+
throw error;
|
|
768
|
+
}
|
|
769
|
+
const usage = sumUsage(
|
|
770
|
+
report.assertions.flatMap((assertion) => (assertion.usage ? [assertion.usage] : [])),
|
|
771
|
+
);
|
|
772
|
+
const costUsd = report.assertions.reduce(
|
|
773
|
+
(total, assertion) => total + assertionModelAccounting(assertion).costUsd,
|
|
774
|
+
0,
|
|
775
|
+
);
|
|
776
|
+
const unpricedModelCalls = report.assertions.reduce(
|
|
777
|
+
(total, assertion) => total + assertionModelAccounting(assertion).unpricedModelCalls,
|
|
778
|
+
0,
|
|
779
|
+
);
|
|
780
|
+
const item: GraderEvidenceItem = {
|
|
781
|
+
annotationId: annotation.id,
|
|
782
|
+
repetition,
|
|
783
|
+
runDir: annotation.runDir,
|
|
784
|
+
rubricPath: annotation.rubricPath,
|
|
785
|
+
...(annotation.feedback ? { feedback: annotation.feedback } : {}),
|
|
786
|
+
judgments: compareGraderAnnotation(
|
|
787
|
+
annotation,
|
|
788
|
+
report,
|
|
789
|
+
execution.loaded.campaign.evaluation.scoreTolerance,
|
|
790
|
+
),
|
|
791
|
+
report,
|
|
792
|
+
durationMs: Date.now() - startedAt,
|
|
793
|
+
usage,
|
|
794
|
+
costUsd,
|
|
795
|
+
unpricedModelCalls,
|
|
796
|
+
};
|
|
797
|
+
if (execution.abortSignal?.aborted) {
|
|
798
|
+
await options.recordUnit(`grader-attempt-${unitId}-${startedAt}`, {
|
|
799
|
+
...itemAccounting(),
|
|
800
|
+
metricCalls: 0,
|
|
801
|
+
});
|
|
802
|
+
throwIfExperimentAborted(execution.abortSignal);
|
|
803
|
+
}
|
|
804
|
+
const unit: GraderEvaluationUnit = {
|
|
805
|
+
schemaVersion: 1,
|
|
806
|
+
unitId,
|
|
807
|
+
candidateId: candidate.id,
|
|
808
|
+
profileId,
|
|
809
|
+
split,
|
|
810
|
+
repetitions,
|
|
811
|
+
annotationsHash: annotations.hash,
|
|
812
|
+
annotationId: annotation.id,
|
|
813
|
+
repetition,
|
|
814
|
+
item,
|
|
815
|
+
};
|
|
816
|
+
await options.verifyExecutionIdentity();
|
|
817
|
+
await writeContentBoundJson(unitPath, unit, evaluationHash, async () => {
|
|
818
|
+
await options.recordUnit(unitId, { ...itemAccounting(), metricCalls: 0 });
|
|
819
|
+
await options.verifyExecutionIdentity();
|
|
820
|
+
});
|
|
821
|
+
throwIfExperimentAborted(execution.abortSignal);
|
|
822
|
+
items.push(item);
|
|
823
|
+
}
|
|
824
|
+
} finally {
|
|
825
|
+
await releaseFrozenRegradableRun(persistedRun);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
const { metrics, samples } = summarizeGraderEvidence(items, candidate);
|
|
829
|
+
if (cachedEvidence) {
|
|
830
|
+
const recomputed = { ...cachedEvidence, metrics, samples, items };
|
|
831
|
+
if (valueHash(cachedEvidence) !== valueHash(recomputed)) {
|
|
832
|
+
throw new Error("cached grader evidence does not match its verified evaluation units");
|
|
833
|
+
}
|
|
834
|
+
return evaluationFromEvidence(experiment, expectedEvidencePath, cachedEvidence);
|
|
835
|
+
}
|
|
836
|
+
const evidence: GraderEvaluationEvidence = {
|
|
837
|
+
schemaVersion: 1,
|
|
838
|
+
candidateId: candidate.id,
|
|
839
|
+
profileId,
|
|
840
|
+
split,
|
|
841
|
+
repetitions,
|
|
842
|
+
annotationsHash: annotations.hash,
|
|
843
|
+
generatedAt: new Date().toISOString(),
|
|
844
|
+
metrics,
|
|
845
|
+
samples,
|
|
846
|
+
items,
|
|
847
|
+
};
|
|
848
|
+
await options.verifyExecutionIdentity();
|
|
849
|
+
await writeContentBoundJson(
|
|
850
|
+
expectedEvidencePath,
|
|
851
|
+
evidence,
|
|
852
|
+
evaluationHash,
|
|
853
|
+
options.verifyExecutionIdentity,
|
|
854
|
+
);
|
|
855
|
+
return evaluationFromEvidence(experiment, expectedEvidencePath, evidence);
|
|
856
|
+
};
|