@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,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Optimizer } from "../core/index.js";
|
|
3
|
+
export declare const ReflectiveOptimizerConfigSchema: z.ZodObject<{
|
|
4
|
+
provider: z.ZodDefault<z.ZodEnum<{
|
|
5
|
+
"claude-code": "claude-code";
|
|
6
|
+
codex: "codex";
|
|
7
|
+
}>>;
|
|
8
|
+
model: z.ZodOptional<z.ZodString>;
|
|
9
|
+
command: z.ZodOptional<z.ZodString>;
|
|
10
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
11
|
+
high: "high";
|
|
12
|
+
low: "low";
|
|
13
|
+
medium: "medium";
|
|
14
|
+
minimal: "minimal";
|
|
15
|
+
none: "none";
|
|
16
|
+
xhigh: "xhigh";
|
|
17
|
+
}>>;
|
|
18
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
19
|
+
maxComponentChars: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
maxAlternativeChars: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
maxFeedbackChars: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
maxPromptChars: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
proposalsPerIteration: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export type ReflectiveOptimizerConfig = z.infer<typeof ReflectiveOptimizerConfigSchema>;
|
|
26
|
+
export declare const createReflectiveOptimizer: (rawConfig?: unknown) => Optimizer;
|
|
27
|
+
//# sourceMappingURL=reflective.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflective.d.ts","sourceRoot":"","sources":["../../src/optimization/reflective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAML,KAAK,SAAS,EAGf,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;kBAcjC,CAAC;AACZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAkSxF,eAAO,MAAM,yBAAyB,eAAe,OAAO,KAAQ,SACG,CAAC"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defaultHarnessModel, emptyUsage, ModelCliProviderSchema, ReasoningEffortSchema, runTextModel, } from "../core/index.js";
|
|
3
|
+
export const ReflectiveOptimizerConfigSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
provider: ModelCliProviderSchema.default("claude-code"),
|
|
6
|
+
model: z.string().optional(),
|
|
7
|
+
command: z.string().optional(),
|
|
8
|
+
reasoningEffort: ReasoningEffortSchema.optional(),
|
|
9
|
+
timeoutMs: z.number().int().positive().default(180_000),
|
|
10
|
+
maxComponentChars: z.number().int().positive().default(80_000),
|
|
11
|
+
maxAlternativeChars: z.number().int().positive().default(40_000),
|
|
12
|
+
maxFeedbackChars: z.number().int().positive().default(50_000),
|
|
13
|
+
/** Hard cap for the complete serialized optimizer prompt. */
|
|
14
|
+
maxPromptChars: z.number().int().min(5_000).max(500_000).default(120_000),
|
|
15
|
+
proposalsPerIteration: z.number().int().min(1).max(4).default(1),
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
const ProposalResponseSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
proposals: z.array(z
|
|
21
|
+
.object({
|
|
22
|
+
rationale: z.string().optional(),
|
|
23
|
+
updates: z.record(z.string(), z.string()),
|
|
24
|
+
})
|
|
25
|
+
.strict()),
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
const parseResponse = (text) => {
|
|
29
|
+
const direct = (() => {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(text);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
37
|
+
const directResult = ProposalResponseSchema.safeParse(direct);
|
|
38
|
+
if (directResult.success)
|
|
39
|
+
return directResult.data;
|
|
40
|
+
const fenced = /```(?:json)?\s*([\s\S]*?)```/i.exec(text)?.[1];
|
|
41
|
+
if (!fenced)
|
|
42
|
+
return null;
|
|
43
|
+
try {
|
|
44
|
+
const parsed = ProposalResponseSchema.safeParse(JSON.parse(fenced));
|
|
45
|
+
return parsed.success ? parsed.data : null;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const boundedComponents = (components, budget) => {
|
|
52
|
+
const out = {};
|
|
53
|
+
const omitted = [];
|
|
54
|
+
let used = 0;
|
|
55
|
+
for (const [path, content] of Object.entries(components).sort(([a], [b]) => a.localeCompare(b))) {
|
|
56
|
+
const serializedChars = JSON.stringify({ [path]: content }).length;
|
|
57
|
+
if (serializedChars > budget - used) {
|
|
58
|
+
omitted.push(path);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
out[path] = content;
|
|
62
|
+
used += serializedChars;
|
|
63
|
+
}
|
|
64
|
+
return { complete: out, omitted };
|
|
65
|
+
};
|
|
66
|
+
const boundedRecord = (input, budget) => {
|
|
67
|
+
const complete = {};
|
|
68
|
+
let used = 0;
|
|
69
|
+
let omitted = 0;
|
|
70
|
+
for (const [key, value] of Object.entries(input).sort(([a], [b]) => a.localeCompare(b))) {
|
|
71
|
+
const size = JSON.stringify({ [key]: value }).length;
|
|
72
|
+
if (used + size > budget) {
|
|
73
|
+
omitted++;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
complete[key] = value;
|
|
77
|
+
used += size;
|
|
78
|
+
}
|
|
79
|
+
return { complete, omitted };
|
|
80
|
+
};
|
|
81
|
+
const boundedResults = (observations, budget, includeMetrics) => {
|
|
82
|
+
const results = [];
|
|
83
|
+
for (const observation of observations) {
|
|
84
|
+
const share = Math.max(100, Math.floor(budget / Math.max(1, observations.length)));
|
|
85
|
+
const casePassRates = boundedRecord(observation.casePassRates, Math.floor(share * 0.55));
|
|
86
|
+
const metrics = boundedRecord(includeMetrics ? observation.metrics : {}, Math.floor(share * 0.3));
|
|
87
|
+
const next = {
|
|
88
|
+
profile: observation.profileId.slice(0, 200),
|
|
89
|
+
split: observation.split,
|
|
90
|
+
passRate: observation.passRate,
|
|
91
|
+
casePassRates: casePassRates.complete,
|
|
92
|
+
omittedCasePassRates: casePassRates.omitted,
|
|
93
|
+
...(includeMetrics ? { metrics: metrics.complete, omittedMetrics: metrics.omitted } : {}),
|
|
94
|
+
};
|
|
95
|
+
if (JSON.stringify([...results, next]).length > budget)
|
|
96
|
+
break;
|
|
97
|
+
results.push(next);
|
|
98
|
+
}
|
|
99
|
+
return { results, omitted: observations.length - results.length };
|
|
100
|
+
};
|
|
101
|
+
const boundedFeedback = (observations, budget) => {
|
|
102
|
+
const failures = observations.flatMap((observation) => observation.failedCases.map((failure) => ({
|
|
103
|
+
profile: observation.profileId,
|
|
104
|
+
split: observation.split,
|
|
105
|
+
caseId: failure.caseId,
|
|
106
|
+
score: failure.score,
|
|
107
|
+
feedback: failure.feedback,
|
|
108
|
+
})));
|
|
109
|
+
const included = [];
|
|
110
|
+
for (const failure of failures) {
|
|
111
|
+
const next = [...included, failure];
|
|
112
|
+
if (JSON.stringify(next).length > budget)
|
|
113
|
+
break;
|
|
114
|
+
included.push(failure);
|
|
115
|
+
}
|
|
116
|
+
return { failures: included, omitted: failures.length - included.length };
|
|
117
|
+
};
|
|
118
|
+
const systemPrompt = (kind) => `You improve text components of a
|
|
119
|
+
${kind === "grader" ? "grading system from disagreements with human expert labels" : "coding-agent system from evaluation results"}.
|
|
120
|
+
Propose the smallest changes that fix recurring failures while preserving successful behavior
|
|
121
|
+
and reducing instruction/context size where possible.
|
|
122
|
+
|
|
123
|
+
Return only JSON:
|
|
124
|
+
{"proposals":[{"rationale":"short explanation","updates":{"relative/path":"complete new file contents"}}]}
|
|
125
|
+
|
|
126
|
+
Rules:
|
|
127
|
+
- Update only paths present in the supplied components.
|
|
128
|
+
- Each update value is the complete replacement file, never a patch.
|
|
129
|
+
- ${kind === "grader"
|
|
130
|
+
? "Align rubric criteria, evidence bounds, thresholds, and weights to the human labels. Do not make a grader merely more lenient or leak annotation text, IDs, or expected labels into it."
|
|
131
|
+
: "Do not weaken tests, graders, safety rules, or required user-owned decisions."}
|
|
132
|
+
- Prefer deletion, routing, explicit compact contracts, and mechanical checks over added prose.
|
|
133
|
+
- Do not mention the evaluation cases in the proposed component text.
|
|
134
|
+
${kind === "grader" ? "- Preserve stable assertion IDs so labels and historical grades remain comparable." : ""}`;
|
|
135
|
+
const optimizerPrompt = (input, config) => {
|
|
136
|
+
const cap = config.maxPromptChars;
|
|
137
|
+
const currentComponents = boundedComponents(input.candidate.components, Math.min(config.maxComponentChars, Math.floor(cap * 0.45)));
|
|
138
|
+
const resultBudget = Math.floor(cap * 0.12);
|
|
139
|
+
const currentResults = boundedResults(input.observations, resultBudget, true);
|
|
140
|
+
const objectives = JSON.stringify(input.campaign.objectives).length <= Math.floor(cap * 0.08)
|
|
141
|
+
? input.campaign.objectives
|
|
142
|
+
: {
|
|
143
|
+
omitted: true,
|
|
144
|
+
constraints: input.campaign.objectives.constraints.length,
|
|
145
|
+
minimize: input.campaign.objectives.minimize.length,
|
|
146
|
+
};
|
|
147
|
+
const alternatives = (input.alternatives ?? []).slice(0, 2).map((candidate) => {
|
|
148
|
+
const observations = input.alternativeObservations?.[candidate.id] ?? [];
|
|
149
|
+
return {
|
|
150
|
+
id: candidate.id.slice(0, 200),
|
|
151
|
+
sourceBytes: candidate.sourceBytes,
|
|
152
|
+
trainResults: boundedResults(observations, Math.floor((cap * 0.08) / Math.max(1, input.alternatives?.length ?? 1)), false),
|
|
153
|
+
componentView: boundedComponents(candidate.components, Math.min(Math.floor(config.maxAlternativeChars / Math.max(1, input.alternatives?.length ?? 1)), Math.floor((cap * 0.08) / Math.max(1, input.alternatives?.length ?? 1)))),
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
const payload = {
|
|
157
|
+
campaign: {
|
|
158
|
+
id: input.campaign.id.slice(0, 200),
|
|
159
|
+
objectives,
|
|
160
|
+
remainingCandidates: input.remainingCandidates,
|
|
161
|
+
},
|
|
162
|
+
currentCandidate: {
|
|
163
|
+
id: input.candidate.id.slice(0, 200),
|
|
164
|
+
sourceBytes: input.candidate.sourceBytes,
|
|
165
|
+
trainResults: currentResults,
|
|
166
|
+
components: currentComponents.complete,
|
|
167
|
+
omittedComponents: currentComponents.omitted,
|
|
168
|
+
},
|
|
169
|
+
frontierAlternatives: alternatives,
|
|
170
|
+
omittedFrontierAlternatives: Math.max(0, (input.alternatives?.length ?? 0) - alternatives.length),
|
|
171
|
+
failedEvaluations: boundedFeedback(input.observations, Math.min(config.maxFeedbackChars, Math.floor(cap * 0.12))),
|
|
172
|
+
proposalCount: Math.min(config.proposalsPerIteration, input.remainingCandidates),
|
|
173
|
+
};
|
|
174
|
+
let prompt = JSON.stringify(payload, null, 2);
|
|
175
|
+
if (prompt.length > cap) {
|
|
176
|
+
// Preserve valid JSON and the component visibility contract while
|
|
177
|
+
// shedding reproducibly ordered context from least essential sections.
|
|
178
|
+
payload.frontierAlternatives = [];
|
|
179
|
+
payload.omittedFrontierAlternatives = input.alternatives?.length ?? 0;
|
|
180
|
+
payload.failedEvaluations = { failures: [], omitted: input.observations.length };
|
|
181
|
+
payload.campaign.objectives = {
|
|
182
|
+
omitted: true,
|
|
183
|
+
constraints: input.campaign.objectives.constraints.length,
|
|
184
|
+
minimize: input.campaign.objectives.minimize.length,
|
|
185
|
+
};
|
|
186
|
+
payload.currentCandidate.trainResults = {
|
|
187
|
+
results: [],
|
|
188
|
+
omitted: input.observations.length,
|
|
189
|
+
};
|
|
190
|
+
prompt = JSON.stringify(payload, null, 2);
|
|
191
|
+
}
|
|
192
|
+
while (prompt.length > cap) {
|
|
193
|
+
const paths = Object.keys(currentComponents.complete).sort();
|
|
194
|
+
const path = paths.at(-1);
|
|
195
|
+
if (!path)
|
|
196
|
+
break;
|
|
197
|
+
delete currentComponents.complete[path];
|
|
198
|
+
currentComponents.omitted.push(path);
|
|
199
|
+
prompt = JSON.stringify(payload, null, 2);
|
|
200
|
+
}
|
|
201
|
+
if (prompt.length > cap) {
|
|
202
|
+
throw new Error(`reflective optimizer prompt metadata exceeds maxPromptChars=${cap}`);
|
|
203
|
+
}
|
|
204
|
+
return { prompt, visibleComponents: new Set(Object.keys(currentComponents.complete)) };
|
|
205
|
+
};
|
|
206
|
+
const reflectiveOptimizer = (config) => ({
|
|
207
|
+
propose: async (input) => {
|
|
208
|
+
const model = config.model ?? defaultHarnessModel(config.provider);
|
|
209
|
+
const builtPrompt = optimizerPrompt(input, config);
|
|
210
|
+
let response;
|
|
211
|
+
try {
|
|
212
|
+
await input.recordModelAttemptStart?.("proposal");
|
|
213
|
+
response = await runTextModel({
|
|
214
|
+
provider: config.provider,
|
|
215
|
+
model,
|
|
216
|
+
command: config.command,
|
|
217
|
+
reasoningEffort: config.reasoningEffort,
|
|
218
|
+
timeoutMs: config.timeoutMs,
|
|
219
|
+
system: systemPrompt(input.campaign.evaluation.kind),
|
|
220
|
+
signal: input.abortSignal,
|
|
221
|
+
prompt: builtPrompt.prompt,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
// A failed provider call has unknown usage/price. The campaign ledger
|
|
226
|
+
// must still consume one explicit unpriced call.
|
|
227
|
+
await input.recordModelCall?.({ usage: emptyUsage() });
|
|
228
|
+
await input.completeModelAttempts?.();
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
await input.recordModelCall?.({
|
|
232
|
+
usage: response.usage,
|
|
233
|
+
...(response.costUsd !== undefined ? { costUsd: response.costUsd } : {}),
|
|
234
|
+
});
|
|
235
|
+
await input.completeModelAttempts?.();
|
|
236
|
+
const parsed = parseResponse(response.text);
|
|
237
|
+
if (!parsed) {
|
|
238
|
+
throw new Error(`reflective optimizer returned invalid JSON: ${response.text.slice(0, 300)}`);
|
|
239
|
+
}
|
|
240
|
+
const visibleComponents = builtPrompt.visibleComponents;
|
|
241
|
+
return parsed.proposals
|
|
242
|
+
.slice(0, Math.min(config.proposalsPerIteration, input.remainingCandidates))
|
|
243
|
+
.map((proposal) => {
|
|
244
|
+
const hiddenUpdates = Object.keys(proposal.updates).filter((path) => !visibleComponents.has(path));
|
|
245
|
+
if (hiddenUpdates.length > 0) {
|
|
246
|
+
throw new Error(`reflective optimizer attempted to replace components it was not shown in full: ${hiddenUpdates.join(", ")}`);
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
updates: proposal.updates,
|
|
250
|
+
...(proposal.rationale ? { rationale: proposal.rationale } : {}),
|
|
251
|
+
usage: response.usage,
|
|
252
|
+
};
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
export const createReflectiveOptimizer = (rawConfig = {}) => reflectiveOptimizer(ReflectiveOptimizerConfigSchema.parse(rawConfig));
|
|
257
|
+
//# sourceMappingURL=reflective.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflective.js","sourceRoot":"","sources":["../../src/optimization/reflective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGL,mBAAmB,EACnB,UAAU,EACV,sBAAsB,EAEtB,qBAAqB,EACrB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC;KAC7C,MAAM,CAAC;IACN,QAAQ,EAAE,sBAAsB,CAAC,OAAO,CAAC,aAAa,CAAC;IACvD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,eAAe,EAAE,qBAAqB,CAAC,QAAQ,EAAE;IACjD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;IACvD,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAC9D,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAChE,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7D,6DAA6D;IAC7D,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,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,CAAC,CAAC;IACP,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,SAAS,GAAY,EAAE,EAAa,EAAE,CAC9E,mBAAmB,CAAC,+BAA+B,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type ExperimentSelector, type GraderAnnotation } from "../core/index.js";
|
|
3
|
+
export declare const LoadedGraderAnnotationsSchema: z.ZodObject<{
|
|
4
|
+
path: z.ZodString;
|
|
5
|
+
directory: z.ZodString;
|
|
6
|
+
dataset: z.ZodObject<{
|
|
7
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
8
|
+
annotations: z.ZodArray<z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
runDir: z.ZodString;
|
|
11
|
+
rubricPath: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
12
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
13
|
+
expected: z.ZodObject<{
|
|
14
|
+
casePassed: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
caseScore: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
assertions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
17
|
+
passed: z.ZodBoolean;
|
|
18
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
}, z.core.$strict>>>;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
source: z.ZodEnum<{
|
|
22
|
+
human: "human";
|
|
23
|
+
synthetic: "synthetic";
|
|
24
|
+
}>;
|
|
25
|
+
annotator: z.ZodOptional<z.ZodString>;
|
|
26
|
+
labeledAt: z.ZodOptional<z.ZodString>;
|
|
27
|
+
reviewer: z.ZodOptional<z.ZodString>;
|
|
28
|
+
feedback: z.ZodOptional<z.ZodString>;
|
|
29
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
30
|
+
}, z.core.$strict>>;
|
|
31
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
annotations: z.ZodArray<z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
runDir: z.ZodString;
|
|
36
|
+
rubricPath: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
37
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
38
|
+
expected: z.ZodObject<{
|
|
39
|
+
casePassed: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
caseScore: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
assertions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
42
|
+
passed: z.ZodBoolean;
|
|
43
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
}, z.core.$strict>>>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
source: z.ZodEnum<{
|
|
47
|
+
human: "human";
|
|
48
|
+
synthetic: "synthetic";
|
|
49
|
+
}>;
|
|
50
|
+
annotator: z.ZodOptional<z.ZodString>;
|
|
51
|
+
labeledAt: z.ZodOptional<z.ZodString>;
|
|
52
|
+
reviewer: z.ZodOptional<z.ZodString>;
|
|
53
|
+
feedback: z.ZodOptional<z.ZodString>;
|
|
54
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
hash: z.ZodString;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
export type LoadedGraderAnnotations = z.infer<typeof LoadedGraderAnnotationsSchema>;
|
|
59
|
+
export declare const loadGraderAnnotations: (filePath: string) => Promise<LoadedGraderAnnotations>;
|
|
60
|
+
export declare const selectGraderAnnotations: (annotations: readonly GraderAnnotation[], selector: ExperimentSelector) => GraderAnnotation[];
|
|
61
|
+
export declare const assertDisjointAnnotationSplits: (splits: Array<{
|
|
62
|
+
name: string;
|
|
63
|
+
annotations: readonly GraderAnnotation[];
|
|
64
|
+
}>) => void;
|
|
65
|
+
//# sourceMappingURL=annotation-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-loader.d.ts","sourceRoot":"","sources":["../../src/orchestrator/annotation-loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,KAAK,kBAAkB,EAEvB,KAAK,gBAAgB,EAItB,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAQ/B,CAAC;AACZ,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAepF,eAAO,MAAM,qBAAqB,aAAoB,MAAM,KAAG,OAAO,CAAC,uBAAuB,CAiB7F,CAAC;AAEF,eAAO,MAAM,uBAAuB,gBACrB,SAAS,gBAAgB,EAAE,YAC9B,kBAAkB,KAC3B,gBAAgB,EAWlB,CAAC;AAEF,eAAO,MAAM,8BAA8B,WACjC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAA;CAAE,CAAC,KACxE,IAsBF,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, extname, resolve, sep } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { formatZodIssues, GraderAnnotationDatasetSchema, GraderAnnotationSchema, valueHash, } from "../core/index.js";
|
|
6
|
+
export const LoadedGraderAnnotationsSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
path: z.string(),
|
|
9
|
+
directory: z.string(),
|
|
10
|
+
dataset: GraderAnnotationDatasetSchema,
|
|
11
|
+
annotations: z.array(GraderAnnotationSchema),
|
|
12
|
+
hash: z.string(),
|
|
13
|
+
})
|
|
14
|
+
.strict();
|
|
15
|
+
const loadAuthoredDataset = async (path) => {
|
|
16
|
+
if (extname(path).toLowerCase() === ".json") {
|
|
17
|
+
return JSON.parse(await readFile(path, "utf8"));
|
|
18
|
+
}
|
|
19
|
+
const mod = (await import(pathToFileURL(path).href));
|
|
20
|
+
if (mod.default === undefined) {
|
|
21
|
+
throw new Error(`Lux grader annotations at ${path} have no default export. Use \`export default defineGraderAnnotations({ ... })\`.`);
|
|
22
|
+
}
|
|
23
|
+
return mod.default;
|
|
24
|
+
};
|
|
25
|
+
export const loadGraderAnnotations = async (filePath) => {
|
|
26
|
+
const path = resolve(filePath);
|
|
27
|
+
const parsed = GraderAnnotationDatasetSchema.safeParse(await loadAuthoredDataset(path));
|
|
28
|
+
if (!parsed.success) {
|
|
29
|
+
throw new Error(`Invalid Lux grader annotations at ${path}: ${formatZodIssues(parsed.error)}`);
|
|
30
|
+
}
|
|
31
|
+
const directory = dirname(path);
|
|
32
|
+
return LoadedGraderAnnotationsSchema.parse({
|
|
33
|
+
path,
|
|
34
|
+
directory,
|
|
35
|
+
dataset: parsed.data,
|
|
36
|
+
annotations: parsed.data.annotations.map((annotation) => ({
|
|
37
|
+
...annotation,
|
|
38
|
+
runDir: resolve(directory, annotation.runDir.split(/[\\/]/).join(sep)),
|
|
39
|
+
})),
|
|
40
|
+
hash: valueHash(parsed.data),
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export const selectGraderAnnotations = (annotations, selector) => {
|
|
44
|
+
const patterns = selector.patterns.map((pattern) => pattern.toLowerCase());
|
|
45
|
+
const tags = selector.tags.map((tag) => tag.toLowerCase());
|
|
46
|
+
return annotations.filter((annotation) => {
|
|
47
|
+
const haystack = `${annotation.id}\n${annotation.rubricPath}`.toLowerCase();
|
|
48
|
+
const patternMatch = patterns.length === 0 || patterns.some((pattern) => haystack.includes(pattern));
|
|
49
|
+
const annotationTags = new Set(annotation.tags.map((tag) => tag.toLowerCase()));
|
|
50
|
+
const tagMatch = tags.length === 0 || tags.some((tag) => annotationTags.has(tag));
|
|
51
|
+
return patternMatch && tagMatch;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
export const assertDisjointAnnotationSplits = (splits) => {
|
|
55
|
+
const idOwners = new Map();
|
|
56
|
+
const runOwners = new Map();
|
|
57
|
+
for (const split of splits) {
|
|
58
|
+
for (const annotation of split.annotations) {
|
|
59
|
+
const idOwner = idOwners.get(annotation.id);
|
|
60
|
+
if (idOwner) {
|
|
61
|
+
throw new Error(`grader annotation '${annotation.id}' appears in both ${idOwner} and ${split.name} splits`);
|
|
62
|
+
}
|
|
63
|
+
idOwners.set(annotation.id, split.name);
|
|
64
|
+
const runIdentity = resolve(annotation.runDir);
|
|
65
|
+
const runOwner = runOwners.get(runIdentity);
|
|
66
|
+
if (runOwner) {
|
|
67
|
+
throw new Error(`grader evidence run '${annotation.runDir}' appears in both ${runOwner} and ${split.name} splits`);
|
|
68
|
+
}
|
|
69
|
+
runOwners.set(runIdentity, split.name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=annotation-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-loader.js","sourceRoot":"","sources":["../../src/orchestrator/annotation-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,eAAe,EAEf,6BAA6B,EAC7B,sBAAs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,CAClG,CAAC;YACJ,CAAC;YACD,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-store.d.ts","sourceRoot":"","sources":["../../src/orchestrator/annotation-store.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAE7B,MAAM,kBAAkB,CAAC;AAsE1B,eAAO,MAAM,sBAAsB,aACvB,MAAM,cACJ,gBAAgB,KAC3B,OAAO,CAAC,uBAAuB,CA4BjC,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { hostname } from "node:os";
|
|
5
|
+
import { dirname, resolve } from "node:path";
|
|
6
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
7
|
+
import { GraderAnnotationDatasetSchema, } from "../core/index.js";
|
|
8
|
+
import { claimLockForRecovery, publishOwnedLock, releaseOwnedLock } from "./owned-lock.js";
|
|
9
|
+
const LOCK_WAIT_MS = 5_000;
|
|
10
|
+
const STALE_LOCK_MS = 30_000;
|
|
11
|
+
const processIsAlive = (pid) => {
|
|
12
|
+
try {
|
|
13
|
+
process.kill(pid, 0);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return error.code !== "ESRCH";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const recoverStaleLock = async (lockPath) => {
|
|
21
|
+
const claim = await claimLockForRecovery(lockPath);
|
|
22
|
+
if (!claim)
|
|
23
|
+
return false;
|
|
24
|
+
let owner;
|
|
25
|
+
try {
|
|
26
|
+
try {
|
|
27
|
+
owner = JSON.parse(await readFile(claim.path, "utf8"));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const ageMs = Date.now() - Date.parse(owner.acquiredAt);
|
|
33
|
+
if (owner.hostname !== hostname() ||
|
|
34
|
+
!Number.isFinite(ageMs) ||
|
|
35
|
+
ageMs < STALE_LOCK_MS ||
|
|
36
|
+
processIsAlive(owner.pid)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return await claim.removeLock();
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
await claim.release();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const acquireAnnotationLock = async (path) => {
|
|
46
|
+
const lockPath = `${path}.lock`;
|
|
47
|
+
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
48
|
+
while (true) {
|
|
49
|
+
try {
|
|
50
|
+
const owner = await publishOwnedLock(lockPath, {
|
|
51
|
+
pid: process.pid,
|
|
52
|
+
hostname: hostname(),
|
|
53
|
+
acquiredAt: new Date().toISOString(),
|
|
54
|
+
});
|
|
55
|
+
return async () => {
|
|
56
|
+
await releaseOwnedLock(lockPath, owner.lockToken);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (error.code !== "EEXIST")
|
|
61
|
+
throw error;
|
|
62
|
+
if (await recoverStaleLock(lockPath))
|
|
63
|
+
continue;
|
|
64
|
+
if (Date.now() >= deadline) {
|
|
65
|
+
throw new Error(`timed out waiting to update grader annotations: ${path}`);
|
|
66
|
+
}
|
|
67
|
+
await delay(10);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export const upsertGraderAnnotation = async (filePath, annotation) => {
|
|
72
|
+
const path = resolve(filePath);
|
|
73
|
+
await mkdir(dirname(path), { recursive: true });
|
|
74
|
+
const release = await acquireAnnotationLock(path);
|
|
75
|
+
const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
76
|
+
try {
|
|
77
|
+
const dataset = existsSync(path)
|
|
78
|
+
? GraderAnnotationDatasetSchema.parse(JSON.parse(await readFile(path, "utf8")))
|
|
79
|
+
: { schemaVersion: 1, annotations: [] };
|
|
80
|
+
const existing = dataset.annotations.findIndex((entry) => entry.id === annotation.id);
|
|
81
|
+
if (existing === -1)
|
|
82
|
+
dataset.annotations.push(annotation);
|
|
83
|
+
else {
|
|
84
|
+
const current = dataset.annotations[existing];
|
|
85
|
+
if (current?.runDir !== annotation.runDir || current.rubricPath !== annotation.rubricPath) {
|
|
86
|
+
throw new Error(`annotation id '${annotation.id}' already targets different evidence; choose a unique id`);
|
|
87
|
+
}
|
|
88
|
+
dataset.annotations[existing] = annotation;
|
|
89
|
+
}
|
|
90
|
+
dataset.annotations.sort((a, b) => a.id.localeCompare(b.id));
|
|
91
|
+
await writeFile(temporary, `${JSON.stringify(dataset, null, 2)}\n`, { flag: "wx" });
|
|
92
|
+
await rename(temporary, path);
|
|
93
|
+
return dataset;
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
await rm(temporary, { force: true });
|
|
97
|
+
await release();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=annotation-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-store.js","sourceRoot":"","sources":["../../src/orchestrator/annotation-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAA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AC,CAAC;QAC7D,MAAM,SAAS,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACpF,MAAM,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACrC,MAAM,OAAO,EAAE,CAAC;IAClB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const assertAuthoredImportsContained: (root: string, entryPaths: readonly string[]) => Promise<void>;
|
|
2
|
+
export declare const authoredDependencyGraphHash: (root: string, entryPaths: readonly string[]) => Promise<string>;
|
|
3
|
+
//# sourceMappingURL=authored-dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored-dependencies.d.ts","sourceRoot":"","sources":["../../src/orchestrator/authored-dependencies.ts"],"names":[],"mappings":"AA4KA,eAAO,MAAM,8BAA8B,SACnC,MAAM,cACA,SAAS,MAAM,EAAE,KAC5B,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF,eAAO,MAAM,2BAA2B,SAChC,MAAM,cACA,SAAS,MAAM,EAAE,KAC5B,OAAO,CAAC,MAAM,CAUhB,CAAC"}
|