@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,788 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { valueHash } from "../core/index.js";
|
|
4
|
+
import { deriveExperimentSelection, rankCandidates } from "./experiment.js";
|
|
5
|
+
import {
|
|
6
|
+
type ExperimentRun,
|
|
7
|
+
ExperimentRunSchema,
|
|
8
|
+
experimentActiveElapsedMs,
|
|
9
|
+
loadExperimentRun,
|
|
10
|
+
verifyExperimentRunIntegrity,
|
|
11
|
+
} from "./experiment-runs.js";
|
|
12
|
+
|
|
13
|
+
const ExperimentReportSplitSchema = z.enum(["train", "validation", "test"]);
|
|
14
|
+
const OptionalMetricSchema = z.number().finite().nullable();
|
|
15
|
+
|
|
16
|
+
export const ExperimentDecisionReportSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
schemaVersion: z.literal(1),
|
|
19
|
+
experimentDir: z.string(),
|
|
20
|
+
experimentId: z.string(),
|
|
21
|
+
campaignId: z.string(),
|
|
22
|
+
mode: z.enum(["experiment", "optimize"]),
|
|
23
|
+
evaluationKind: z.enum(["agent", "grader"]),
|
|
24
|
+
status: z.enum(["running", "passed", "failed", "aborted"]),
|
|
25
|
+
outcome: z.enum(["promote", "retain", "reject", "error", "incomplete"]),
|
|
26
|
+
error: z.string().nullable(),
|
|
27
|
+
candidateAndAccountingVerified: z.boolean(),
|
|
28
|
+
championCandidateId: z.string().nullable(),
|
|
29
|
+
ranking: z.array(z.string()),
|
|
30
|
+
eligibleCandidateIds: z.array(z.string()),
|
|
31
|
+
source: z
|
|
32
|
+
.object({
|
|
33
|
+
baselineBytes: z.number().int().nonnegative().nullable(),
|
|
34
|
+
championBytes: z.number().int().nonnegative().nullable(),
|
|
35
|
+
deltaBytes: z.number().int().nullable(),
|
|
36
|
+
})
|
|
37
|
+
.strict(),
|
|
38
|
+
gates: z.array(
|
|
39
|
+
z
|
|
40
|
+
.object({
|
|
41
|
+
metric: z.string(),
|
|
42
|
+
profile: z.string().nullable(),
|
|
43
|
+
split: ExperimentReportSplitSchema,
|
|
44
|
+
passed: z.boolean(),
|
|
45
|
+
values: z.array(z.number().finite()),
|
|
46
|
+
interval: z.string().nullable(),
|
|
47
|
+
note: z.string().nullable(),
|
|
48
|
+
})
|
|
49
|
+
.strict(),
|
|
50
|
+
),
|
|
51
|
+
evidence: z.array(
|
|
52
|
+
z
|
|
53
|
+
.object({
|
|
54
|
+
candidateId: z.string(),
|
|
55
|
+
profileId: z.string(),
|
|
56
|
+
split: ExperimentReportSplitSchema,
|
|
57
|
+
repetitions: z.number().int().positive(),
|
|
58
|
+
caseIds: z.array(z.string()),
|
|
59
|
+
passRate: z.number().finite(),
|
|
60
|
+
passRateSamples: z.number().int().nonnegative().nullable(),
|
|
61
|
+
subjectInputTokens: OptionalMetricSchema,
|
|
62
|
+
subjectOutputTokens: OptionalMetricSchema,
|
|
63
|
+
subjectTotalTokens: OptionalMetricSchema,
|
|
64
|
+
subjectTokenSamples: z.number().int().nonnegative().nullable(),
|
|
65
|
+
evaluationTokens: z.number().nonnegative().nullable(),
|
|
66
|
+
meanQuestions: OptionalMetricSchema,
|
|
67
|
+
questionSamples: z.number().int().nonnegative().nullable(),
|
|
68
|
+
meanToolCalls: OptionalMetricSchema,
|
|
69
|
+
toolSamples: z.number().int().nonnegative().nullable(),
|
|
70
|
+
reportedCostUsd: z.number().nonnegative().nullable(),
|
|
71
|
+
unpricedModelCalls: z.number().int().nonnegative().nullable(),
|
|
72
|
+
})
|
|
73
|
+
.strict(),
|
|
74
|
+
),
|
|
75
|
+
deltas: z.array(
|
|
76
|
+
z
|
|
77
|
+
.object({
|
|
78
|
+
profileId: z.string(),
|
|
79
|
+
split: ExperimentReportSplitSchema,
|
|
80
|
+
passRate: OptionalMetricSchema,
|
|
81
|
+
subjectTotalTokens: OptionalMetricSchema,
|
|
82
|
+
meanQuestions: OptionalMetricSchema,
|
|
83
|
+
meanToolCalls: OptionalMetricSchema,
|
|
84
|
+
reportedCostUsd: OptionalMetricSchema,
|
|
85
|
+
})
|
|
86
|
+
.strict(),
|
|
87
|
+
),
|
|
88
|
+
spend: z
|
|
89
|
+
.object({
|
|
90
|
+
candidates: z.number().int().nonnegative(),
|
|
91
|
+
metricCalls: z.number().int().nonnegative(),
|
|
92
|
+
judgeCalls: z.number().int().nonnegative(),
|
|
93
|
+
proposalCalls: z.number().int().nonnegative(),
|
|
94
|
+
totalTokens: z.number().nonnegative(),
|
|
95
|
+
costUsd: z.number().nonnegative(),
|
|
96
|
+
unpricedModelCalls: z.number().int().nonnegative().nullable(),
|
|
97
|
+
activeTimeMs: z.number().nonnegative(),
|
|
98
|
+
})
|
|
99
|
+
.strict(),
|
|
100
|
+
budget: z
|
|
101
|
+
.object({
|
|
102
|
+
maxCandidates: z.number().int().positive(),
|
|
103
|
+
maxMetricCalls: z.number().int().positive(),
|
|
104
|
+
maxJudgeCalls: z.number().int().positive(),
|
|
105
|
+
maxProposalCalls: z.number().int().positive(),
|
|
106
|
+
maxTokens: z.number().int().positive(),
|
|
107
|
+
maxCostUsd: z.number().positive(),
|
|
108
|
+
maxUnpricedModelCalls: z.number().int().nonnegative(),
|
|
109
|
+
maxWallTimeMs: z.number().int().positive(),
|
|
110
|
+
})
|
|
111
|
+
.strict(),
|
|
112
|
+
})
|
|
113
|
+
.strict();
|
|
114
|
+
export type ExperimentDecisionReport = z.infer<typeof ExperimentDecisionReportSchema>;
|
|
115
|
+
|
|
116
|
+
export const VerifiedExperimentDecisionSnapshotSchema = z
|
|
117
|
+
.object({
|
|
118
|
+
experiment: ExperimentRunSchema,
|
|
119
|
+
report: ExperimentDecisionReportSchema,
|
|
120
|
+
})
|
|
121
|
+
.strict();
|
|
122
|
+
export type VerifiedExperimentDecisionSnapshot = z.infer<
|
|
123
|
+
typeof VerifiedExperimentDecisionSnapshotSchema
|
|
124
|
+
>;
|
|
125
|
+
|
|
126
|
+
const concise = (value: number): string =>
|
|
127
|
+
Number.isInteger(value) ? String(value) : value.toFixed(4).replace(/0+$/, "").replace(/\.$/, "");
|
|
128
|
+
|
|
129
|
+
const markdown = (value: string): string =>
|
|
130
|
+
[...value]
|
|
131
|
+
.map((character) => {
|
|
132
|
+
const code = character.codePointAt(0) ?? 0;
|
|
133
|
+
return code <= 0x1f || (code >= 0x7f && code <= 0x9f) ? " " : character;
|
|
134
|
+
})
|
|
135
|
+
.join("")
|
|
136
|
+
.replaceAll("&", "&")
|
|
137
|
+
.replaceAll("<", "<")
|
|
138
|
+
.replaceAll(">", ">")
|
|
139
|
+
.replaceAll("`", "`")
|
|
140
|
+
.replaceAll("!", "!")
|
|
141
|
+
.replaceAll("[", "[")
|
|
142
|
+
.replaceAll("]", "]")
|
|
143
|
+
.replaceAll("(", "(")
|
|
144
|
+
.replaceAll(")", ")")
|
|
145
|
+
.replaceAll("\\", "\")
|
|
146
|
+
.replaceAll("|", "\\|")
|
|
147
|
+
.replace(/\s*\n\s*/g, " ");
|
|
148
|
+
|
|
149
|
+
const intervalText = (
|
|
150
|
+
interval:
|
|
151
|
+
| NonNullable<NonNullable<ExperimentRun["selection"]>["constraints"][number]["interval"]>
|
|
152
|
+
| undefined,
|
|
153
|
+
): string | null => {
|
|
154
|
+
if (!interval) return null;
|
|
155
|
+
const resamples = interval.resamples > 0 ? `, resamples=${interval.resamples}` : "";
|
|
156
|
+
return `${interval.method} ${concise(interval.level * 100)}% ${concise(interval.estimate)} [${concise(interval.lower)}, ${concise(interval.upper)}], n=${interval.n}${resamples}`;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const reportOutcome = (
|
|
160
|
+
experiment: ExperimentRun,
|
|
161
|
+
championId: string | null,
|
|
162
|
+
): ExperimentDecisionReport["outcome"] => {
|
|
163
|
+
if (experiment.status === "passed") return championId === "baseline" ? "retain" : "promote";
|
|
164
|
+
if (experiment.status === "failed" && experiment.errorMessage) return "error";
|
|
165
|
+
if (experiment.status === "failed" && experiment.selection) return "reject";
|
|
166
|
+
if (experiment.status === "failed") return "error";
|
|
167
|
+
return "incomplete";
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
type ExperimentSelection = NonNullable<ExperimentRun["selection"]>;
|
|
171
|
+
type ExperimentCandidate = ExperimentRun["candidates"][number];
|
|
172
|
+
type ExperimentSplit = ExperimentRun["evaluations"][number]["split"];
|
|
173
|
+
|
|
174
|
+
const isCleanExperimentDecision = (experiment: ExperimentRun): boolean =>
|
|
175
|
+
experiment.status === "passed" || (experiment.status === "failed" && !experiment.errorMessage);
|
|
176
|
+
|
|
177
|
+
const verifyIncompleteDecisionHasNoChampion = (experiment: ExperimentRun): void => {
|
|
178
|
+
if (experiment.championCandidateId || experiment.selection?.championCandidateId) {
|
|
179
|
+
throw new Error(`experiment status '${experiment.status}' cannot have a champion`);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const requireCompletedSelection = (experiment: ExperimentRun): ExperimentSelection => {
|
|
184
|
+
const selection = experiment.selection;
|
|
185
|
+
if (!selection) {
|
|
186
|
+
throw new Error(`completed experiment status '${experiment.status}' has no selection`);
|
|
187
|
+
}
|
|
188
|
+
if (!experiment.endedAt) {
|
|
189
|
+
throw new Error(
|
|
190
|
+
`completed experiment status '${experiment.status}' has no completion timestamp`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
if (
|
|
194
|
+
experiment.status === "passed" &&
|
|
195
|
+
(!experiment.championCandidateId || !selection.championCandidateId)
|
|
196
|
+
) {
|
|
197
|
+
throw new Error("passed experiment has no complete champion selection");
|
|
198
|
+
}
|
|
199
|
+
return selection;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const requireCanonicalCandidatePopulation = (experiment: ExperimentRun): ExperimentCandidate => {
|
|
203
|
+
const candidateIds = experiment.candidates.map((candidate) => candidate.id);
|
|
204
|
+
const candidateSet = new Set(candidateIds);
|
|
205
|
+
if (candidateSet.size !== candidateIds.length) {
|
|
206
|
+
throw new Error("experiment candidate IDs must be unique");
|
|
207
|
+
}
|
|
208
|
+
const baseline = experiment.candidates.find((candidate) => candidate.id === "baseline");
|
|
209
|
+
if (!baseline) throw new Error("experiment selection has no baseline candidate");
|
|
210
|
+
return baseline;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const requireCandidateRecords = (
|
|
214
|
+
experiment: ExperimentRun,
|
|
215
|
+
candidateIds: readonly string[],
|
|
216
|
+
kind: "promotion finalist" | "decision candidate",
|
|
217
|
+
): ExperimentCandidate[] =>
|
|
218
|
+
candidateIds.map((candidateId) => {
|
|
219
|
+
const candidate = experiment.candidates.find((entry) => entry.id === candidateId);
|
|
220
|
+
if (!candidate) throw new Error(`${kind} '${candidateId}' has no candidate record`);
|
|
221
|
+
return candidate;
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const requireCompletedEvidence = (
|
|
225
|
+
experiment: ExperimentRun,
|
|
226
|
+
candidateId: string,
|
|
227
|
+
profileId: string,
|
|
228
|
+
split: ExperimentSplit,
|
|
229
|
+
repetitions: number,
|
|
230
|
+
errorMessage: string,
|
|
231
|
+
): void => {
|
|
232
|
+
const evaluation = experiment.evaluations.find(
|
|
233
|
+
(entry) =>
|
|
234
|
+
entry.candidateId === candidateId &&
|
|
235
|
+
entry.profileId === profileId &&
|
|
236
|
+
entry.split === split &&
|
|
237
|
+
entry.repetitions === repetitions,
|
|
238
|
+
);
|
|
239
|
+
if (!evaluation || Object.keys(evaluation.casePassRates).length === 0) {
|
|
240
|
+
throw new Error(errorMessage);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const verifyPromotionFinalistEvidence = (
|
|
245
|
+
experiment: ExperimentRun,
|
|
246
|
+
finalists: readonly ExperimentCandidate[],
|
|
247
|
+
): void => {
|
|
248
|
+
const searchSplits: ExperimentSplit[] = [
|
|
249
|
+
...(experiment.campaignSnapshot.splits.train ? (["train"] as const) : []),
|
|
250
|
+
"validation",
|
|
251
|
+
];
|
|
252
|
+
for (const finalist of finalists) {
|
|
253
|
+
for (const profileId of experiment.campaignSnapshot.profiles) {
|
|
254
|
+
for (const split of searchSplits) {
|
|
255
|
+
requireCompletedEvidence(
|
|
256
|
+
experiment,
|
|
257
|
+
finalist.id,
|
|
258
|
+
profileId,
|
|
259
|
+
split,
|
|
260
|
+
experiment.campaignSnapshot.repetitions.search,
|
|
261
|
+
`optimize experiment finalist '${finalist.id}' lacks search ${split} evidence for profile '${profileId}'`,
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
requireCompletedEvidence(
|
|
265
|
+
experiment,
|
|
266
|
+
finalist.id,
|
|
267
|
+
profileId,
|
|
268
|
+
"validation",
|
|
269
|
+
experiment.campaignSnapshot.repetitions.promotion,
|
|
270
|
+
`optimize experiment finalist '${finalist.id}' lacks promotion evidence for profile '${profileId}'`,
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const requirePromotionFinalists = (
|
|
277
|
+
experiment: ExperimentRun,
|
|
278
|
+
selection: ExperimentSelection,
|
|
279
|
+
baseline: ExperimentCandidate,
|
|
280
|
+
): ExperimentCandidate[] => {
|
|
281
|
+
const optimizer = experiment.campaignSnapshot.optimizer;
|
|
282
|
+
if (!optimizer) throw new Error("optimize experiment has no optimizer snapshot");
|
|
283
|
+
const finalistIds = selection.promotionFinalistCandidateIds;
|
|
284
|
+
if (!finalistIds) {
|
|
285
|
+
throw new Error("optimize experiment selection has no promotion finalist checkpoint");
|
|
286
|
+
}
|
|
287
|
+
const expectedFinalists = 1 + Math.min(optimizer.promotionTopK, experiment.candidates.length - 1);
|
|
288
|
+
if (
|
|
289
|
+
finalistIds[0] !== baseline.id ||
|
|
290
|
+
finalistIds.length !== expectedFinalists ||
|
|
291
|
+
new Set(finalistIds).size !== finalistIds.length
|
|
292
|
+
) {
|
|
293
|
+
throw new Error("optimize experiment has an invalid promotion finalist population");
|
|
294
|
+
}
|
|
295
|
+
return requireCandidateRecords(experiment, finalistIds, "promotion finalist");
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const expectedOptimizationDecisionCandidates = (
|
|
299
|
+
experiment: ExperimentRun,
|
|
300
|
+
selection: ExperimentSelection,
|
|
301
|
+
baseline: ExperimentCandidate,
|
|
302
|
+
): ExperimentCandidate[] => {
|
|
303
|
+
const finalists = requirePromotionFinalists(experiment, selection, baseline);
|
|
304
|
+
verifyPromotionFinalistEvidence(experiment, finalists);
|
|
305
|
+
const promoted =
|
|
306
|
+
rankCandidates(experiment.campaignSnapshot, finalists, experiment, [
|
|
307
|
+
"train",
|
|
308
|
+
"validation",
|
|
309
|
+
])[0] ?? baseline;
|
|
310
|
+
return promoted.id === baseline.id ? [baseline] : [baseline, promoted];
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
const expectedDecisionCandidates = (
|
|
314
|
+
experiment: ExperimentRun,
|
|
315
|
+
selection: ExperimentSelection,
|
|
316
|
+
baseline: ExperimentCandidate,
|
|
317
|
+
): ExperimentCandidate[] => {
|
|
318
|
+
if (experiment.mode === "optimize") {
|
|
319
|
+
return expectedOptimizationDecisionCandidates(experiment, selection, baseline);
|
|
320
|
+
}
|
|
321
|
+
if (selection.promotionFinalistCandidateIds) {
|
|
322
|
+
throw new Error("static experiment selection cannot have promotion finalists");
|
|
323
|
+
}
|
|
324
|
+
return experiment.candidates;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const requireDecisionCandidates = (
|
|
328
|
+
experiment: ExperimentRun,
|
|
329
|
+
selection: ExperimentSelection,
|
|
330
|
+
expectedCandidates: readonly ExperimentCandidate[],
|
|
331
|
+
): { candidates: ExperimentCandidate[]; candidateIds: string[] } => {
|
|
332
|
+
const expectedDecisionCandidateIds = expectedCandidates.map((candidate) => candidate.id);
|
|
333
|
+
const decisionCandidateIds = selection.decisionCandidateIds ?? selection.rankedCandidateIds;
|
|
334
|
+
if (valueHash(decisionCandidateIds) !== valueHash(expectedDecisionCandidateIds)) {
|
|
335
|
+
throw new Error(
|
|
336
|
+
"experiment selection does not use the canonical decision candidate population",
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
const candidateSet = new Set(experiment.candidates.map((candidate) => candidate.id));
|
|
340
|
+
const decisionCandidateSet = new Set(decisionCandidateIds);
|
|
341
|
+
if (
|
|
342
|
+
decisionCandidateIds.length === 0 ||
|
|
343
|
+
decisionCandidateSet.size !== decisionCandidateIds.length ||
|
|
344
|
+
decisionCandidateIds.some((candidateId) => !candidateSet.has(candidateId))
|
|
345
|
+
) {
|
|
346
|
+
throw new Error("experiment selection has an invalid decision candidate population");
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
candidates: requireCandidateRecords(experiment, decisionCandidateIds, "decision candidate"),
|
|
350
|
+
candidateIds: decisionCandidateIds,
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const verifyDecisionCandidateEvidence = (
|
|
355
|
+
experiment: ExperimentRun,
|
|
356
|
+
decisionCandidates: readonly ExperimentCandidate[],
|
|
357
|
+
): void => {
|
|
358
|
+
const requiredSplits: ExperimentSplit[] = [
|
|
359
|
+
...(experiment.campaignSnapshot.splits.train ? ["train" as const] : []),
|
|
360
|
+
"validation",
|
|
361
|
+
...(experiment.campaignSnapshot.splits.test ? ["test" as const] : []),
|
|
362
|
+
];
|
|
363
|
+
for (const candidate of decisionCandidates) {
|
|
364
|
+
for (const profileId of experiment.campaignSnapshot.profiles) {
|
|
365
|
+
for (const split of requiredSplits) {
|
|
366
|
+
const repetitions =
|
|
367
|
+
experiment.mode === "optimize" && split === "train"
|
|
368
|
+
? experiment.campaignSnapshot.repetitions.search
|
|
369
|
+
: experiment.campaignSnapshot.repetitions.promotion;
|
|
370
|
+
requireCompletedEvidence(
|
|
371
|
+
experiment,
|
|
372
|
+
candidate.id,
|
|
373
|
+
profileId,
|
|
374
|
+
split,
|
|
375
|
+
repetitions,
|
|
376
|
+
`experiment selection is missing completed ${split} evidence for candidate '${candidate.id}' profile '${profileId}'`,
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const deriveCanonicalSelection = (
|
|
384
|
+
experiment: ExperimentRun,
|
|
385
|
+
selection: ExperimentSelection,
|
|
386
|
+
decisionCandidates: readonly ExperimentCandidate[],
|
|
387
|
+
): ExperimentSelection =>
|
|
388
|
+
deriveExperimentSelection(experiment.campaignSnapshot, decisionCandidates, experiment, {
|
|
389
|
+
decidedAt: selection.decidedAt,
|
|
390
|
+
...(selection.promotionFinalistCandidateIds
|
|
391
|
+
? { promotionFinalistCandidateIds: selection.promotionFinalistCandidateIds }
|
|
392
|
+
: {}),
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
const verifyRecomputedSelection = (
|
|
396
|
+
experiment: ExperimentRun,
|
|
397
|
+
selection: ExperimentSelection,
|
|
398
|
+
decisionCandidateIds: readonly string[],
|
|
399
|
+
derived: ExperimentSelection,
|
|
400
|
+
): void => {
|
|
401
|
+
const normalizedSelection = { ...selection, decisionCandidateIds };
|
|
402
|
+
if (valueHash(derived) !== valueHash(normalizedSelection)) {
|
|
403
|
+
throw new Error("experiment selection does not match recomputed evaluation evidence");
|
|
404
|
+
}
|
|
405
|
+
const derivedChampionId = derived.championCandidateId;
|
|
406
|
+
if (experiment.status === "passed") {
|
|
407
|
+
if (!experiment.endedAt) {
|
|
408
|
+
throw new Error("passed experiment has no completion timestamp");
|
|
409
|
+
}
|
|
410
|
+
if (
|
|
411
|
+
experiment.championCandidateId !== derivedChampionId ||
|
|
412
|
+
selection.championCandidateId !== derivedChampionId
|
|
413
|
+
) {
|
|
414
|
+
throw new Error("experiment manifest and recomputed selection disagree on the champion");
|
|
415
|
+
}
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (experiment.championCandidateId || selection.championCandidateId || derivedChampionId) {
|
|
419
|
+
throw new Error("failed experiment cannot have an eligible champion");
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
export const verifyExperimentDecisionIntegrity = (experiment: ExperimentRun): void => {
|
|
424
|
+
if (experiment.status === "passed" && experiment.errorMessage) {
|
|
425
|
+
throw new Error("passed experiment cannot retain an execution error");
|
|
426
|
+
}
|
|
427
|
+
if (!isCleanExperimentDecision(experiment)) {
|
|
428
|
+
verifyIncompleteDecisionHasNoChampion(experiment);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const selection = requireCompletedSelection(experiment);
|
|
432
|
+
const baseline = requireCanonicalCandidatePopulation(experiment);
|
|
433
|
+
const expectedCandidates = expectedDecisionCandidates(experiment, selection, baseline);
|
|
434
|
+
const decision = requireDecisionCandidates(experiment, selection, expectedCandidates);
|
|
435
|
+
verifyDecisionCandidateEvidence(experiment, decision.candidates);
|
|
436
|
+
const derived = deriveCanonicalSelection(experiment, selection, decision.candidates);
|
|
437
|
+
verifyRecomputedSelection(experiment, selection, decision.candidateIds, derived);
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
const matchedMetricDelta = (
|
|
441
|
+
before: number | null,
|
|
442
|
+
after: number | null,
|
|
443
|
+
beforeSamples: number | null,
|
|
444
|
+
afterSamples: number | null,
|
|
445
|
+
expectedSamples: number,
|
|
446
|
+
): number | null => {
|
|
447
|
+
if (before === null || after === null) return null;
|
|
448
|
+
if (beforeSamples === null || afterSamples === null) return null;
|
|
449
|
+
if (beforeSamples !== afterSamples) return null;
|
|
450
|
+
if (beforeSamples !== expectedSamples) return null;
|
|
451
|
+
return after - before;
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
const reportedCostDelta = (before: number | null, after: number | null): number | null => {
|
|
455
|
+
if (before === null || after === null) return null;
|
|
456
|
+
return after - before;
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const projectExperimentDecisionReport = (
|
|
460
|
+
experimentDir: string,
|
|
461
|
+
experiment: ExperimentRun,
|
|
462
|
+
candidateAndAccountingVerified: boolean,
|
|
463
|
+
): ExperimentDecisionReport => {
|
|
464
|
+
verifyExperimentDecisionIntegrity(experiment);
|
|
465
|
+
const championId = experiment.championCandidateId ?? null;
|
|
466
|
+
let decisionSelection: ExperimentRun["selection"];
|
|
467
|
+
if (experiment.status === "passed") {
|
|
468
|
+
decisionSelection = experiment.selection;
|
|
469
|
+
} else if (experiment.status === "failed" && !experiment.errorMessage) {
|
|
470
|
+
decisionSelection = experiment.selection;
|
|
471
|
+
}
|
|
472
|
+
const targetId = championId ?? decisionSelection?.rankedCandidateIds[0] ?? "baseline";
|
|
473
|
+
const baseline = experiment.candidates.find((candidate) => candidate.id === "baseline");
|
|
474
|
+
const champion = championId
|
|
475
|
+
? experiment.candidates.find((candidate) => candidate.id === championId)
|
|
476
|
+
: undefined;
|
|
477
|
+
if (experiment.status === "passed" && !baseline) {
|
|
478
|
+
throw new Error("passed experiment has no baseline candidate record");
|
|
479
|
+
}
|
|
480
|
+
if (championId && !champion) {
|
|
481
|
+
throw new Error(`experiment champion '${championId}' has no candidate record`);
|
|
482
|
+
}
|
|
483
|
+
if (experiment.status === "passed" && (!experiment.selection || !championId)) {
|
|
484
|
+
throw new Error("passed experiment has no complete champion selection");
|
|
485
|
+
}
|
|
486
|
+
if (experiment.status !== "passed" && championId) {
|
|
487
|
+
throw new Error(`experiment status '${experiment.status}' cannot have a champion`);
|
|
488
|
+
}
|
|
489
|
+
if (experiment.selection && (experiment.selection.championCandidateId ?? null) !== championId) {
|
|
490
|
+
throw new Error("experiment manifest and selection disagree on the champion");
|
|
491
|
+
}
|
|
492
|
+
const usage = experiment.budgetUsage.usage;
|
|
493
|
+
const subjectMetricPrefix = experiment.evaluationKind === "agent" ? "agent" : "harness";
|
|
494
|
+
const relevantCandidates = new Set(["baseline", ...(championId ? [championId] : [targetId])]);
|
|
495
|
+
const evidenceByScope = new Map<string, ExperimentRun["evaluations"][number]>();
|
|
496
|
+
for (const evaluation of experiment.evaluations) {
|
|
497
|
+
if (!relevantCandidates.has(evaluation.candidateId)) continue;
|
|
498
|
+
const key = `${evaluation.candidateId}:${evaluation.profileId}:${evaluation.split}`;
|
|
499
|
+
const current = evidenceByScope.get(key);
|
|
500
|
+
if (!current || evaluation.repetitions > current.repetitions) {
|
|
501
|
+
evidenceByScope.set(key, evaluation);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const evidence = [...evidenceByScope.values()]
|
|
505
|
+
.sort((left, right) =>
|
|
506
|
+
`${left.candidateId}:${left.profileId}:${left.split}`.localeCompare(
|
|
507
|
+
`${right.candidateId}:${right.profileId}:${right.split}`,
|
|
508
|
+
),
|
|
509
|
+
)
|
|
510
|
+
.map((evaluation) => {
|
|
511
|
+
const evaluationUsage = evaluation.usage;
|
|
512
|
+
const sampleCount = (metric: string): number | null =>
|
|
513
|
+
evaluation.samples?.[metric]?.length ?? null;
|
|
514
|
+
return {
|
|
515
|
+
candidateId: evaluation.candidateId,
|
|
516
|
+
profileId: evaluation.profileId,
|
|
517
|
+
split: evaluation.split,
|
|
518
|
+
repetitions: evaluation.repetitions,
|
|
519
|
+
caseIds: Object.keys(evaluation.casePassRates).sort(),
|
|
520
|
+
passRate: evaluation.passRate,
|
|
521
|
+
passRateSamples: sampleCount("quality.passRate"),
|
|
522
|
+
subjectInputTokens: evaluation.metrics[`${subjectMetricPrefix}.input`] ?? null,
|
|
523
|
+
subjectOutputTokens: evaluation.metrics[`${subjectMetricPrefix}.output`] ?? null,
|
|
524
|
+
subjectTotalTokens: evaluation.metrics[`${subjectMetricPrefix}.total`] ?? null,
|
|
525
|
+
subjectTokenSamples: sampleCount(`${subjectMetricPrefix}.total`),
|
|
526
|
+
evaluationTokens: evaluationUsage
|
|
527
|
+
? evaluationUsage.input +
|
|
528
|
+
evaluationUsage.output +
|
|
529
|
+
evaluationUsage.cacheRead +
|
|
530
|
+
evaluationUsage.cacheCreation
|
|
531
|
+
: null,
|
|
532
|
+
meanQuestions: evaluation.metrics["interrupts.ask"] ?? null,
|
|
533
|
+
questionSamples: sampleCount("interrupts.ask"),
|
|
534
|
+
meanToolCalls: evaluation.metrics.toolCalls ?? null,
|
|
535
|
+
toolSamples: sampleCount("toolCalls"),
|
|
536
|
+
reportedCostUsd: evaluation.costUsd ?? null,
|
|
537
|
+
unpricedModelCalls: evaluation.unpricedModelCalls ?? null,
|
|
538
|
+
};
|
|
539
|
+
});
|
|
540
|
+
const deltas = evidence
|
|
541
|
+
.filter((entry) => championId !== null && entry.candidateId === championId)
|
|
542
|
+
.flatMap((after) => {
|
|
543
|
+
const before = evidence.find(
|
|
544
|
+
(entry) =>
|
|
545
|
+
entry.candidateId === "baseline" &&
|
|
546
|
+
entry.profileId === after.profileId &&
|
|
547
|
+
entry.split === after.split,
|
|
548
|
+
);
|
|
549
|
+
if (!before) return [];
|
|
550
|
+
const scopesMatch =
|
|
551
|
+
before.repetitions === after.repetitions &&
|
|
552
|
+
before.caseIds.join("\n") === after.caseIds.join("\n");
|
|
553
|
+
if (!scopesMatch) return [];
|
|
554
|
+
return [
|
|
555
|
+
{
|
|
556
|
+
profileId: after.profileId,
|
|
557
|
+
split: after.split,
|
|
558
|
+
passRate: matchedMetricDelta(
|
|
559
|
+
before.passRate,
|
|
560
|
+
after.passRate,
|
|
561
|
+
before.passRateSamples,
|
|
562
|
+
after.passRateSamples,
|
|
563
|
+
after.caseIds.length,
|
|
564
|
+
),
|
|
565
|
+
subjectTotalTokens: matchedMetricDelta(
|
|
566
|
+
before.subjectTotalTokens,
|
|
567
|
+
after.subjectTotalTokens,
|
|
568
|
+
before.subjectTokenSamples,
|
|
569
|
+
after.subjectTokenSamples,
|
|
570
|
+
after.caseIds.length,
|
|
571
|
+
),
|
|
572
|
+
meanQuestions: matchedMetricDelta(
|
|
573
|
+
before.meanQuestions,
|
|
574
|
+
after.meanQuestions,
|
|
575
|
+
before.questionSamples,
|
|
576
|
+
after.questionSamples,
|
|
577
|
+
after.caseIds.length,
|
|
578
|
+
),
|
|
579
|
+
meanToolCalls: matchedMetricDelta(
|
|
580
|
+
before.meanToolCalls,
|
|
581
|
+
after.meanToolCalls,
|
|
582
|
+
before.toolSamples,
|
|
583
|
+
after.toolSamples,
|
|
584
|
+
after.caseIds.length,
|
|
585
|
+
),
|
|
586
|
+
reportedCostUsd: reportedCostDelta(before.reportedCostUsd, after.reportedCostUsd),
|
|
587
|
+
},
|
|
588
|
+
];
|
|
589
|
+
});
|
|
590
|
+
return ExperimentDecisionReportSchema.parse({
|
|
591
|
+
schemaVersion: 1,
|
|
592
|
+
experimentDir,
|
|
593
|
+
experimentId: experiment.experimentId,
|
|
594
|
+
campaignId: experiment.campaignId,
|
|
595
|
+
mode: experiment.mode,
|
|
596
|
+
evaluationKind: experiment.evaluationKind,
|
|
597
|
+
status: experiment.status,
|
|
598
|
+
error: experiment.errorMessage ?? null,
|
|
599
|
+
candidateAndAccountingVerified,
|
|
600
|
+
outcome: reportOutcome(experiment, championId),
|
|
601
|
+
championCandidateId: championId,
|
|
602
|
+
ranking: decisionSelection?.rankedCandidateIds ?? [],
|
|
603
|
+
eligibleCandidateIds: decisionSelection?.eligibleCandidateIds ?? [],
|
|
604
|
+
source: {
|
|
605
|
+
baselineBytes: baseline?.sourceBytes ?? null,
|
|
606
|
+
championBytes: champion?.sourceBytes ?? null,
|
|
607
|
+
deltaBytes: baseline && champion ? champion.sourceBytes - baseline.sourceBytes : null,
|
|
608
|
+
},
|
|
609
|
+
gates: (decisionSelection?.constraints ?? [])
|
|
610
|
+
.filter((constraint) => constraint.candidateId === targetId)
|
|
611
|
+
.map((constraint) => ({
|
|
612
|
+
metric: constraint.metric,
|
|
613
|
+
profile: constraint.profile ?? null,
|
|
614
|
+
split: constraint.split,
|
|
615
|
+
passed: constraint.passed,
|
|
616
|
+
values: constraint.values,
|
|
617
|
+
interval: intervalText(constraint.interval),
|
|
618
|
+
note: constraint.note ?? null,
|
|
619
|
+
})),
|
|
620
|
+
evidence,
|
|
621
|
+
deltas,
|
|
622
|
+
spend: {
|
|
623
|
+
candidates: experiment.candidates.length,
|
|
624
|
+
metricCalls: experiment.budgetUsage.metricCalls,
|
|
625
|
+
judgeCalls: experiment.budgetUsage.judgeCalls,
|
|
626
|
+
proposalCalls: experiment.budgetUsage.proposalCalls,
|
|
627
|
+
totalTokens: usage.input + usage.output + usage.cacheRead + usage.cacheCreation,
|
|
628
|
+
costUsd: experiment.budgetUsage.costUsd,
|
|
629
|
+
unpricedModelCalls: experiment.budgetUsage.unpricedModelCalls ?? null,
|
|
630
|
+
activeTimeMs: experimentActiveElapsedMs(experiment),
|
|
631
|
+
},
|
|
632
|
+
budget: {
|
|
633
|
+
maxCandidates: experiment.campaignSnapshot.budget.maxCandidates,
|
|
634
|
+
maxMetricCalls: experiment.campaignSnapshot.budget.maxMetricCalls,
|
|
635
|
+
maxJudgeCalls: experiment.campaignSnapshot.budget.maxJudgeCalls,
|
|
636
|
+
maxProposalCalls: experiment.campaignSnapshot.budget.maxProposalCalls,
|
|
637
|
+
maxTokens: experiment.campaignSnapshot.budget.maxTokens,
|
|
638
|
+
maxCostUsd: experiment.campaignSnapshot.budget.maxCostUsd,
|
|
639
|
+
maxUnpricedModelCalls: experiment.campaignSnapshot.budget.maxUnpricedModelCalls,
|
|
640
|
+
maxWallTimeMs: experiment.campaignSnapshot.budget.maxWallTimeMs,
|
|
641
|
+
},
|
|
642
|
+
});
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
export const createExperimentDecisionReport = (
|
|
646
|
+
experimentDir: string,
|
|
647
|
+
experiment: ExperimentRun,
|
|
648
|
+
): ExperimentDecisionReport => projectExperimentDecisionReport(experimentDir, experiment, false);
|
|
649
|
+
|
|
650
|
+
export const loadVerifiedExperimentDecisionSnapshot = async (
|
|
651
|
+
experimentDir: string,
|
|
652
|
+
): Promise<VerifiedExperimentDecisionSnapshot> => {
|
|
653
|
+
const experiment = await loadExperimentRun(experimentDir);
|
|
654
|
+
if (!experiment) {
|
|
655
|
+
throw new Error(`experiment manifest not found or invalid at ${experimentDir}`);
|
|
656
|
+
}
|
|
657
|
+
await verifyExperimentRunIntegrity(experimentDir, experiment);
|
|
658
|
+
return VerifiedExperimentDecisionSnapshotSchema.parse({
|
|
659
|
+
experiment,
|
|
660
|
+
report: projectExperimentDecisionReport(experimentDir, experiment, true),
|
|
661
|
+
});
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
export const loadExperimentDecisionReport = async (
|
|
665
|
+
experimentDir: string,
|
|
666
|
+
): Promise<ExperimentDecisionReport> =>
|
|
667
|
+
(await loadVerifiedExperimentDecisionSnapshot(experimentDir)).report;
|
|
668
|
+
|
|
669
|
+
const shellQuote = (value: string): string => `'${value.replaceAll("'", "'\\''")}'`;
|
|
670
|
+
const shellPath = (value: string): string => {
|
|
671
|
+
if (
|
|
672
|
+
[...value].some((character) => {
|
|
673
|
+
const code = character.codePointAt(0) ?? 0;
|
|
674
|
+
return code <= 0x1f || (code >= 0x7f && code <= 0x9f);
|
|
675
|
+
})
|
|
676
|
+
) {
|
|
677
|
+
throw new Error("experiment path contains control characters and cannot be rendered safely");
|
|
678
|
+
}
|
|
679
|
+
return shellQuote(value);
|
|
680
|
+
};
|
|
681
|
+
const signed = (value: number, suffix = ""): string =>
|
|
682
|
+
`${value > 0 ? "+" : ""}${concise(value)}${suffix}`;
|
|
683
|
+
|
|
684
|
+
const decisionText = (report: ExperimentDecisionReport): string => {
|
|
685
|
+
switch (report.outcome) {
|
|
686
|
+
case "promote":
|
|
687
|
+
return `Promote \`${markdown(report.championCandidateId ?? "")}\`.`;
|
|
688
|
+
case "retain":
|
|
689
|
+
return "Retain the baseline; no authored candidate earned promotion.";
|
|
690
|
+
case "reject":
|
|
691
|
+
return "Do not promote; the experiment failed its authored gates.";
|
|
692
|
+
case "error":
|
|
693
|
+
return "No promotion decision; experiment execution failed before gate selection.";
|
|
694
|
+
case "incomplete":
|
|
695
|
+
return "No promotion decision is available; the experiment is incomplete.";
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
const optionalNumber = (value: number | null): string => (value === null ? "—" : concise(value));
|
|
700
|
+
|
|
701
|
+
const sourceBytesText = (report: ExperimentDecisionReport): string => {
|
|
702
|
+
const baseline = report.source.baselineBytes ?? "—";
|
|
703
|
+
const champion = report.source.championBytes ?? "—";
|
|
704
|
+
if (report.source.deltaBytes === null) return `${baseline} → ${champion}`;
|
|
705
|
+
const sign = report.source.deltaBytes >= 0 ? "+" : "";
|
|
706
|
+
return `${baseline} → ${champion} (${sign}${report.source.deltaBytes})`;
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
export const formatExperimentDecisionMarkdown = (report: ExperimentDecisionReport): string => {
|
|
710
|
+
const decision = decisionText(report);
|
|
711
|
+
const lines = [
|
|
712
|
+
`# Lux experiment: ${markdown(report.campaignId)}`,
|
|
713
|
+
"",
|
|
714
|
+
`> **Decision:** ${decision}`,
|
|
715
|
+
"",
|
|
716
|
+
`- Experiment: \`${markdown(report.experimentId)}\``,
|
|
717
|
+
`- Mode: \`${report.mode}\``,
|
|
718
|
+
`- Evaluation: \`${report.evaluationKind}\``,
|
|
719
|
+
`- Status: **${report.status.toUpperCase()}**`,
|
|
720
|
+
`- Candidate/accounting integrity: **${report.candidateAndAccountingVerified ? "VERIFIED" : "NOT VERIFIED"}**`,
|
|
721
|
+
`- Champion: ${report.championCandidateId ? `\`${markdown(report.championCandidateId)}\`` : "—"}`,
|
|
722
|
+
`- Ranking: ${report.ranking.map((id) => `\`${markdown(id)}\``).join(" → ") || "—"}`,
|
|
723
|
+
...(report.error ? [`- Error: ${markdown(report.error)}`] : []),
|
|
724
|
+
"",
|
|
725
|
+
"## Promotion gates",
|
|
726
|
+
"",
|
|
727
|
+
];
|
|
728
|
+
if (report.gates.length === 0) {
|
|
729
|
+
lines.push("_No completed promotion gates._");
|
|
730
|
+
} else {
|
|
731
|
+
lines.push(
|
|
732
|
+
"| Result | Metric | Profile | Split | Values | Confidence | Note |",
|
|
733
|
+
"| --- | --- | --- | --- | ---: | --- | --- |",
|
|
734
|
+
...report.gates.map(
|
|
735
|
+
(gate) =>
|
|
736
|
+
`| ${gate.passed ? "PASS" : "FAIL"} | ${markdown(gate.metric)} | ${markdown(gate.profile ?? "all")} | ${gate.split} | ${gate.values.map(concise).join(", ") || "—"} | ${markdown(gate.interval ?? "—")} | ${markdown(gate.note ?? "—")} |`,
|
|
737
|
+
),
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
lines.push("", "## Baseline and decision evidence", "");
|
|
741
|
+
if (report.evidence.length === 0) {
|
|
742
|
+
lines.push("_No completed evaluation evidence._");
|
|
743
|
+
} else {
|
|
744
|
+
lines.push(
|
|
745
|
+
"| Candidate | Profile | Split | Reps | Cases | Pass rate | Pass n | Mean subject input | Mean subject output | Mean subject total | Subject n | Eval tokens | Mean questions | Question n | Mean tools | Tool n | Reported cost | Unpriced |",
|
|
746
|
+
"| --- | --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |",
|
|
747
|
+
...report.evidence.map(
|
|
748
|
+
(entry) =>
|
|
749
|
+
`| ${markdown(entry.candidateId)} | ${markdown(entry.profileId)} | ${entry.split} | ${entry.repetitions} | ${entry.caseIds.length} | ${concise(entry.passRate)} | ${optionalNumber(entry.passRateSamples)} | ${optionalNumber(entry.subjectInputTokens)} | ${optionalNumber(entry.subjectOutputTokens)} | ${optionalNumber(entry.subjectTotalTokens)} | ${optionalNumber(entry.subjectTokenSamples)} | ${optionalNumber(entry.evaluationTokens)} | ${optionalNumber(entry.meanQuestions)} | ${optionalNumber(entry.questionSamples)} | ${optionalNumber(entry.meanToolCalls)} | ${optionalNumber(entry.toolSamples)} | ${entry.reportedCostUsd === null ? "—" : `$${entry.reportedCostUsd.toFixed(4)}`} | ${entry.unpricedModelCalls ?? "—"} |`,
|
|
750
|
+
),
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
lines.push("", "## Change from baseline", "");
|
|
754
|
+
if (report.deltas.length === 0) {
|
|
755
|
+
lines.push("_No matched baseline/champion evidence._");
|
|
756
|
+
} else {
|
|
757
|
+
lines.push(
|
|
758
|
+
"| Profile | Split | Pass rate | Mean subject total | Mean questions | Mean tools | Reported cost |",
|
|
759
|
+
"| --- | --- | ---: | ---: | ---: | ---: | ---: |",
|
|
760
|
+
...report.deltas.map(
|
|
761
|
+
(delta) =>
|
|
762
|
+
`| ${markdown(delta.profileId)} | ${delta.split} | ${delta.passRate === null ? "—" : signed(delta.passRate)} | ${delta.subjectTotalTokens === null ? "—" : signed(delta.subjectTotalTokens)} | ${delta.meanQuestions === null ? "—" : signed(delta.meanQuestions)} | ${delta.meanToolCalls === null ? "—" : signed(delta.meanToolCalls)} | ${delta.reportedCostUsd === null ? "—" : signed(delta.reportedCostUsd, " USD")} |`,
|
|
763
|
+
),
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
lines.push(
|
|
767
|
+
"",
|
|
768
|
+
"## Source and spend",
|
|
769
|
+
"",
|
|
770
|
+
`- Source bytes: ${sourceBytesText(report)}`,
|
|
771
|
+
`- Candidates: ${report.spend.candidates}/${report.budget.maxCandidates}`,
|
|
772
|
+
`- Metric calls: ${report.spend.metricCalls}/${report.budget.maxMetricCalls}`,
|
|
773
|
+
`- Judge calls: ${report.spend.judgeCalls}/${report.budget.maxJudgeCalls}`,
|
|
774
|
+
`- Proposal calls: ${report.spend.proposalCalls}/${report.budget.maxProposalCalls}`,
|
|
775
|
+
`- Tokens: ${report.spend.totalTokens}/${report.budget.maxTokens}`,
|
|
776
|
+
`- Reported cost: $${report.spend.costUsd.toFixed(4)}/$${report.budget.maxCostUsd.toFixed(2)}`,
|
|
777
|
+
`- Unpriced model calls: ${report.spend.unpricedModelCalls ?? "unknown"}/${report.budget.maxUnpricedModelCalls}`,
|
|
778
|
+
`- Active wall time: ${report.spend.activeTimeMs}ms/${report.budget.maxWallTimeMs}ms`,
|
|
779
|
+
"",
|
|
780
|
+
"## Reproduce",
|
|
781
|
+
"",
|
|
782
|
+
` lux view ${shellPath(report.experimentDir)}`,
|
|
783
|
+
...(report.outcome === "promote" ? [` lux apply ${shellPath(report.experimentDir)}`] : []),
|
|
784
|
+
"",
|
|
785
|
+
`Generated from the integrity-checked local experiment record \`${markdown(basename(report.experimentDir))}\`.`,
|
|
786
|
+
);
|
|
787
|
+
return lines.join("\n");
|
|
788
|
+
};
|