skillfit 0.9.1 → 0.10.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/README.md +48 -14
- package/README.zh-CN.md +48 -14
- package/benches/README.md +23 -0
- package/benches/contrib/README.md +1 -0
- package/benches/contrib/oss-skill-independent/README.md +60 -0
- package/benches/contrib/oss-skill-independent/bench.json +79 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/Readme.md +1015 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/esm.mjs +15 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/index.js +27 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/argument.js +147 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/command.js +1944 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/error.js +45 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/help.js +396 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/option.js +208 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/suggestSimilar.js +100 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/package.json +63 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/typings/index.d.ts +774 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/typings/index.test-d.ts +416 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/upstream-package.json +69 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/Readme.md +1149 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/esm.mjs +16 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/index.js +24 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/argument.js +149 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/command.js +2662 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/error.js +39 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/help.js +713 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/option.js +367 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/suggestSimilar.js +101 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/package.json +71 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/esm.d.mts +3 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/index.d.ts +1045 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/index.test-d.ts +737 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/upstream-package.json +82 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/index.d.ts +40 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/index.js +68 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/package.json +54 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/readme.md +99 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/upstream-package.json +54 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/index.js +67 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/package.json +46 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/index.js +132 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/package.json +57 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/readme.md +181 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/upstream-package.json +58 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/index.js +84 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/package.json +48 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/index.js +116 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/package.json +60 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/readme.md +170 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/upstream-package.json +60 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/index.d.ts +149 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/index.js +93 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/package.json +52 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/readme.md +192 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/upstream-package.json +52 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/index.js +114 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/package.json +48 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/readme.md +158 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/upstream-package.json +48 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/index.js +122 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/package.json +50 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/readme.md +190 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/upstream-package.json +50 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/Readme.md +1015 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/esm.mjs +15 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/index.js +27 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/argument.js +147 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/command.js +1948 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/error.js +45 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/help.js +396 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/option.js +208 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/suggestSimilar.js +100 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/package.json +63 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/typings/index.d.ts +774 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/typings/index.test-d.ts +416 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/upstream-package.json +69 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/Readme.md +1149 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/esm.mjs +16 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/index.js +24 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/argument.js +149 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/command.js +2666 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/error.js +39 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/help.js +713 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/option.js +367 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/suggestSimilar.js +101 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/package.json +71 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/esm.d.mts +3 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/index.d.ts +1045 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/index.test-d.ts +737 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/upstream-package.json +82 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/async-hooks-stub.js +15 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/index.d.ts +40 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/index.js +71 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/package.json +61 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/readme.md +99 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/regression.test.mjs +6 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/upstream-package.json +54 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/index.js +67 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/package.json +46 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/index.js +148 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/package.json +57 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/readme.md +181 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/upstream-package.json +58 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/index.js +84 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/package.json +48 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-commander-async-listener-order.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-commander-output-isolation.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-limit-async-context.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-limit-map-iteration-rejection.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-throttle-sync-throw.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-custom-timers.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-infinity-abort.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-rejection-listener.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/index.js +121 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/package.json +60 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/readme.md +170 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/regression.test.mjs +6 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/upstream-package.json +60 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/index.d.ts +149 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/index.js +95 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/package.json +52 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/readme.md +192 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/upstream-package.json +52 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/index.js +114 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/package.json +48 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/readme.md +158 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/upstream-package.json +48 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/index.js +122 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/package.json +50 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/readme.md +190 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/upstream-package.json +50 -0
- package/benches/contrib/oss-skill-independent/prompts/commander-async-listener-order.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/commander-output-isolation.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/limit-async-context.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/limit-map-iteration-rejection.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/throttle-sync-throw.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/timeout-custom-timers.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/timeout-infinity-abort.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/timeout-rejection-listener.md +3 -0
- package/benches/contrib/oss-skill-independent/provenance.json +1903 -0
- package/benches/contrib/oss-skill-independent/task-specs.json +63 -0
- package/benches/contrib/oss-skill-independent/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/verifiers/cases.mjs +197 -0
- package/benches/contrib/oss-skill-independent/verifiers/commander-async-listener-order.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/commander-output-isolation.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/grade.mjs +48 -0
- package/benches/contrib/oss-skill-independent/verifiers/limit-async-context.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/limit-map-iteration-rejection.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/probe.mjs +16 -0
- package/benches/contrib/oss-skill-independent/verifiers/regression-evidence.mjs +105 -0
- package/benches/contrib/oss-skill-independent/verifiers/test-reporter.mjs +29 -0
- package/benches/contrib/oss-skill-independent/verifiers/throttle-sync-throw.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/timeout-custom-timers.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/timeout-infinity-abort.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/timeout-rejection-listener.mjs +1 -0
- package/dist/cli.js +183 -64
- package/dist/commands/bench-check-json.test.js +221 -0
- package/dist/commands/bench-check-report.js +48 -0
- package/dist/commands/bench-command-template.js +129 -0
- package/dist/commands/bench-manage.js +91 -0
- package/dist/commands/bench-manage.test.js +87 -0
- package/dist/commands/bench.js +166 -128
- package/dist/commands/bench.test.js +101 -0
- package/dist/commands/eval-component.js +25 -1
- package/dist/commands/eval-export.js +178 -0
- package/dist/commands/eval-export.test.js +279 -0
- package/dist/commands/eval-interruption.test.js +238 -0
- package/dist/commands/eval-preflight.js +61 -0
- package/dist/commands/eval-preflight.test.js +239 -0
- package/dist/commands/eval-report.js +44 -13
- package/dist/commands/eval-report.test.js +2 -2
- package/dist/commands/eval.js +94 -61
- package/dist/commands/eval.test.js +58 -1
- package/dist/harness/bench.js +21 -2
- package/dist/harness/eval-audit.js +45 -5
- package/dist/harness/eval-budget.js +51 -0
- package/dist/harness/eval-budget.test.js +212 -0
- package/dist/harness/eval-component.test.js +36 -0
- package/dist/harness/eval-contract.js +5 -1
- package/dist/harness/executors/api.js +10 -1
- package/dist/harness/executors/api.test.js +43 -0
- package/dist/harness/executors/cli.js +24 -3
- package/dist/harness/experiment-session.js +60 -9
- package/dist/harness/experiment-session.test.js +43 -1
- package/dist/harness/input-snapshot.js +150 -0
- package/dist/harness/interruption.js +48 -0
- package/dist/harness/interruption.test.js +31 -0
- package/dist/harness/replay-package.js +85 -0
- package/dist/harness/runner.js +74 -15
- package/dist/harness/trigger.js +20 -4
- package/docs/bench-authoring.md +40 -0
- package/docs/bench-check-json.md +122 -0
- package/docs/case-management.md +65 -0
- package/docs/eval-case-preflight.md +110 -0
- package/docs/eval-component.md +88 -49
- package/docs/eval-costs.md +9 -0
- package/docs/evaluation-input-snapshots.md +124 -0
- package/docs/evaluation-interruption.md +89 -0
- package/docs/evaluation-reports.md +49 -0
- package/docs/examples/check-receiver-mechanism-proposal.mjs +124 -0
- package/docs/examples/prepare-native-diff-probe.mjs +75 -0
- package/docs/examples/reproduce-independent-comparison-budget.mjs +73 -0
- package/docs/experiment-workflow.md +9 -2
- package/docs/first-real-eval.md +10 -1
- package/docs/growth-roadmap-2026-10.md +62 -93
- package/docs/metrics.md +52 -0
- package/docs/plans/2026-10-14-evidence-and-release-sequence.md +29 -12
- package/docs/plans/2026-10-15-independent-comparison-budget.json +1769 -0
- package/docs/plans/2026-10-15-independent-comparison-inputs.json +373 -0
- package/docs/plans/2026-10-15-independent-comparison-proposal.md +177 -0
- package/docs/plans/2026-10-15-native-diff-mechanism.md +105 -0
- package/docs/plans/2026-10-15-receiver-mechanism-proposal.json +342 -0
- package/docs/plans/2026-10-15-receiver-mechanism-proposal.md +146 -0
- package/docs/plans/2026-10-15-receiver-mechanism-verification.json +105 -0
- package/docs/plans/2026-10-16-case-workflow-and-release.md +49 -0
- package/docs/releases/0.10.0-ci-registry-install.json +140 -0
- package/docs/releases/0.10.0-feature-smoke.json +22 -0
- package/docs/releases/0.10.0-feature-smoke.mjs +62 -0
- package/docs/releases/0.10.0-signatures.txt +7 -0
- package/docs/releases/0.10.0-verification.json +76 -0
- package/docs/releases/0.10.0.md +81 -0
- package/docs/releases/0.10.1-feature-smoke.mjs +95 -0
- package/docs/releases/0.10.1.md +38 -0
- package/docs/releases/0.9.1-first-publication.json +249 -0
- package/docs/releases/0.9.1-verification.json +122 -0
- package/docs/releases/0.9.1.md +33 -1
- package/docs/releases/trusted-publishing.md +61 -0
- package/docs/replay-packages.md +97 -0
- package/docs/schemas/bench-check.schema.json +109 -0
- package/docs/schemas/eval-preflight.schema.json +57 -0
- package/docs/schemas/eval-request.schema.json +12 -0
- package/docs/schemas/eval-result.schema.json +11 -0
- package/docs/sharing-results.md +11 -2
- package/docs/skill-evaluation-evidence.md +52 -0
- package/evidence/2026-10-15-diagnosing-receiver-correction.md +140 -0
- package/evidence/2026-10-15-independent-comparison-regression-stop.md +162 -0
- package/evidence/2026-10-15-independent-offline-readiness.md +144 -0
- package/evidence/2026-10-15-native-diff-mechanism.md +196 -0
- package/evidence/2026-10-15-receiver-mechanism-stop.md +154 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/README.md +35 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/expected.json +577 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/receiver-contract.test.mjs +138 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/replay.mjs +127 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/verification.json +105 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/README.md +32 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/checks.json +32 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/verification.json +25 -0
- package/evidence/artifacts/2026-10-15-independent-offline-readiness/README.md +17 -0
- package/evidence/artifacts/2026-10-15-independent-offline-readiness/verification.json +1548 -0
- package/evidence/artifacts/2026-10-15-native-diff-mechanism/README.md +48 -0
- package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/README.md +38 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/checks.json +118 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/verification.json +36 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/LICENSE +21 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/SKILL.md +51 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/agents/openai.yaml +3 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/scripts/hitl-loop.template.sh +44 -0
- package/package.json +1 -1
- package/skills/skillfit/SKILL.md +17 -5
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync, existsSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { test } from 'node:test';
|
|
6
|
+
import { runEvalComponent, reportEvalComponent } from '../commands/eval-component.js';
|
|
7
|
+
import { parseEvalRequest } from './eval-contract.js';
|
|
8
|
+
import { assertSpendingCanContinue, parseSpendingBudget, spendingBudgetState } from './eval-budget.js';
|
|
9
|
+
import { COST_METRICS } from './costs.js';
|
|
10
|
+
import { sha256File } from './hash.js';
|
|
11
|
+
import { ExecutorFailure } from './types.js';
|
|
12
|
+
const limits = { input: 1000, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 };
|
|
13
|
+
const observation = (extra = {}) => ({ executorInvoked: true, passed: true, error: null,
|
|
14
|
+
tokens: { input: 10, cachedInput: 6, output: 3 }, usageStatus: 'final', durationSeconds: 2, ...extra });
|
|
15
|
+
test('spending stop lines require all five positive values and reject malformed counters/limits', () => {
|
|
16
|
+
assert.deepEqual(parseSpendingBudget(limits), limits);
|
|
17
|
+
for (const bad of [null, [], {}, { ...limits, surprise: 1 }, { ...limits, output: 0 }, { ...limits, input: 1.5 }, { ...limits, durationSeconds: Infinity }]) {
|
|
18
|
+
assert.throws(() => parseSpendingBudget(bad), /spendingBudget/);
|
|
19
|
+
}
|
|
20
|
+
for (const value of [NaN, Infinity, -1, 0.5, Number.MAX_SAFE_INTEGER + 1]) {
|
|
21
|
+
const state = spendingBudgetState(limits, [observation({ tokens: { input: value, cachedInput: 2, output: 3 } })]);
|
|
22
|
+
assert.equal(state.reason, 'FINAL_USAGE_MISSING');
|
|
23
|
+
assert.ok(state.incomplete.includes('input'));
|
|
24
|
+
assert.equal(state.metrics.input.coverage.unknown, 1);
|
|
25
|
+
assert.throws(() => assertSpendingCanContinue(state), /no further/);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
test('all-invocation budgets count functional failures, partial costs and unknown partitions without double counting cache', () => {
|
|
29
|
+
const state = spendingBudgetState(limits, [observation({ passed: false }), observation({ usageStatus: 'partial', tokens: { input: 7, output: 2 } })]);
|
|
30
|
+
assert.equal(state.invocations, 2);
|
|
31
|
+
assert.equal(state.metrics.input.knownTotal, 17);
|
|
32
|
+
assert.equal(state.metrics.cachedInput.knownTotal, 6);
|
|
33
|
+
assert.equal(state.metrics.cachedInput.coverage.unknown, 1);
|
|
34
|
+
assert.equal(state.metrics.uncachedInput.knownTotal, 4);
|
|
35
|
+
assert.equal(state.metrics.uncachedInput.coverage.unknown, 1);
|
|
36
|
+
assert.equal(state.metrics.input.coverage.partial, 1);
|
|
37
|
+
assert.equal(state.reason, 'FINAL_USAGE_MISSING');
|
|
38
|
+
});
|
|
39
|
+
function setup(t, change = {}, result, functionalFailure = false) {
|
|
40
|
+
const root = mkdtempSync(join(tmpdir(), 'skillfit-budget-'));
|
|
41
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
42
|
+
for (const name of ['old', 'new']) {
|
|
43
|
+
mkdirSync(join(root, name));
|
|
44
|
+
writeFileSync(join(root, name, 'SKILL.md'), `---\nname: budget-skill\ndescription: Diagnose answers.\n---\nCheck the public answer using the ${name} revision.\n`);
|
|
45
|
+
}
|
|
46
|
+
const bench = join(root, 'bench');
|
|
47
|
+
mkdirSync(join(bench, 'fixture'), { recursive: true });
|
|
48
|
+
writeFileSync(join(bench, 'fixture/answer.txt'), 'pending');
|
|
49
|
+
writeFileSync(join(bench, 'prompt.md'), 'Repair the answer.');
|
|
50
|
+
writeFileSync(join(bench, 'check.mjs'), `import{readFileSync}from'node:fs';import{join}from'node:path';const passed=readFileSync(join(process.argv[2],'answer.txt'),'utf8')==='fixed';console.log(JSON.stringify({passed,checks:[{name:'answer',pass:passed}]}));process.exit(passed?0:1);\n`);
|
|
51
|
+
writeFileSync(join(bench, 'bench.json'), JSON.stringify({ schemaVersion: 1, name: 'budget', tasks: [
|
|
52
|
+
{ id: 'first', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node check.mjs', verifierKind: 'command' },
|
|
53
|
+
{ id: 'second', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node check.mjs', verifierKind: 'command' },
|
|
54
|
+
] }));
|
|
55
|
+
const body = { schemaVersion: 1, baselineSkill: 'old', candidateSkill: 'new', bench: 'bench', agent: 'codex', purpose: 'validation',
|
|
56
|
+
pairOrder: 'balanced', trials: 1, maxCalls: 4, spendingBudget: { ...limits, ...change }, runsRoot: 'runs', runGroup: 'budget' };
|
|
57
|
+
const request = join(root, 'request.json');
|
|
58
|
+
writeFileSync(request, JSON.stringify(body));
|
|
59
|
+
let count = 0;
|
|
60
|
+
const executor = { describe: () => ({ kind: 'mock', model: 'offline-budget' }), run: async (_prompt, workdir) => {
|
|
61
|
+
if (!functionalFailure)
|
|
62
|
+
writeFileSync(join(workdir, 'answer.txt'), 'fixed');
|
|
63
|
+
count++;
|
|
64
|
+
return result ? result() : { output: 'done', tokens: { input: 10, cachedInput: 6, output: 3 } };
|
|
65
|
+
} };
|
|
66
|
+
const options = { executor, skillInstallDir: 'project-skills', sessionOptions: { homeDir: root, env: {}, versionProbe: () => null } };
|
|
67
|
+
return { root, body, request, options, calls: () => count, directory: join(root, 'runs/budget') };
|
|
68
|
+
}
|
|
69
|
+
async function execute(f) {
|
|
70
|
+
const preview = await runEvalComponent(f.request, { ...f.options, dryRun: true });
|
|
71
|
+
assert.ok('plan' in preview);
|
|
72
|
+
assert.equal(f.calls(), 0);
|
|
73
|
+
assert.equal(existsSync(f.directory), false);
|
|
74
|
+
return runEvalComponent(f.request, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
75
|
+
}
|
|
76
|
+
for (const metric of COST_METRICS)
|
|
77
|
+
test(`${metric} stop line blocks the second executor and retains the first complete receipt`, async (t) => {
|
|
78
|
+
const values = { input: 10, cachedInput: 6, uncachedInput: 4, output: 3, durationSeconds: 0.000001 };
|
|
79
|
+
const f = setup(t, { [metric]: values[metric] }), result = await execute(f);
|
|
80
|
+
assert.equal(f.calls(), 1);
|
|
81
|
+
assert.equal(result.status, 'stopped');
|
|
82
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
83
|
+
const receipt = JSON.parse(readFileSync(join(f.directory, 'first/baseline/trial-1/_result.json'), 'utf8'));
|
|
84
|
+
assert.deepEqual(receipt.tokens, { input: 10, cachedInput: 6, output: 3 });
|
|
85
|
+
assert.equal(existsSync(join(f.directory, 'first/treatment/trial-1')), false);
|
|
86
|
+
assert.ok('spendingBudget' in result);
|
|
87
|
+
assert.ok(result.spendingBudget);
|
|
88
|
+
assert.ok(result.spendingBudget.latestState.reached.includes(metric));
|
|
89
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 10);
|
|
90
|
+
const replay = await reportEvalComponent(f.directory);
|
|
91
|
+
assert.equal(replay.status, 'stopped');
|
|
92
|
+
assert.ok('spendingBudget' in replay);
|
|
93
|
+
assert.deepEqual(replay.spendingBudget, result.spendingBudget);
|
|
94
|
+
});
|
|
95
|
+
test('an in-flight overshoot is retained instead of clamped to its stop line', async (t) => {
|
|
96
|
+
const f = setup(t, { input: 5 }), result = await execute(f);
|
|
97
|
+
assert.equal(f.calls(), 1);
|
|
98
|
+
assert.ok('spendingBudget' in result);
|
|
99
|
+
assert.ok(result.spendingBudget);
|
|
100
|
+
assert.equal(result.spendingBudget.limits.input, 5);
|
|
101
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 10);
|
|
102
|
+
});
|
|
103
|
+
for (const [label, tokens] of [['no counters', undefined], ['missing cache', { input: 10, output: 3 }], ['incompatible cache', { input: 10, cachedInput: 11, output: 3 }]]) {
|
|
104
|
+
test(`${label}: missing or incompatible final usage refuses another call without filling cache with zero`, async (t) => {
|
|
105
|
+
const f = setup(t, {}, () => ({ output: 'returned', tokens })), result = await execute(f);
|
|
106
|
+
assert.equal(f.calls(), 1);
|
|
107
|
+
assert.equal(result.status, 'stopped');
|
|
108
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
109
|
+
assert.ok('spendingBudget' in result);
|
|
110
|
+
assert.ok(result.spendingBudget);
|
|
111
|
+
assert.equal(result.spendingBudget.latestState.reason, 'FINAL_USAGE_MISSING');
|
|
112
|
+
assert.equal(result.spendingBudget.latestState.metrics.cachedInput.coverage.unknown, 1);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
test('invalid retained receipts remain untouched and appear as unknown rather than disappearing or becoming zero-cost success', async (t) => {
|
|
116
|
+
const f = setup(t, {}, () => ({ output: 'invalid counters', tokens: { input: 10, cachedInput: 11, output: 3 } }));
|
|
117
|
+
const result = await execute(f), path = join(f.directory, 'first/baseline/trial-1/_result.json'), hash = sha256File(path);
|
|
118
|
+
const value = JSON.parse(JSON.stringify(result));
|
|
119
|
+
assert.equal(value.costs.invocationsWithUnknownReceipts, 1);
|
|
120
|
+
assert.equal(value.costs.recordedExecutorInvocations, 0);
|
|
121
|
+
assert.equal(value.costs.invalidReceipts.length, 1);
|
|
122
|
+
assert.equal(value.costs.populations.attempts.baseline.metrics.input.coverage.unknown, 1);
|
|
123
|
+
await reportEvalComponent(f.directory);
|
|
124
|
+
assert.equal(sha256File(path), hash);
|
|
125
|
+
assert.equal(f.calls(), 1);
|
|
126
|
+
});
|
|
127
|
+
test('an executor guard failure stops immediately while retaining its complete returned usage', async (t) => {
|
|
128
|
+
const f = setup(t, {}, () => ({ output: 'retained', guardError: 'simulated configuration drift', tokens: { input: 12, cachedInput: 8, output: 2 } }));
|
|
129
|
+
const result = await execute(f);
|
|
130
|
+
assert.equal(result.status, 'stopped');
|
|
131
|
+
assert.equal(f.calls(), 1);
|
|
132
|
+
assert.ok('spendingBudget' in result);
|
|
133
|
+
assert.ok(result.spendingBudget);
|
|
134
|
+
assert.equal(result.spendingBudget.latestState.reason, 'EXECUTION_FAILED');
|
|
135
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 12);
|
|
136
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.coverage.final, 1);
|
|
137
|
+
});
|
|
138
|
+
test('executor failure retains partial usage, stops once and never replaces the call', async (t) => {
|
|
139
|
+
const f = setup(t, {}, () => { throw new ExecutorFailure('offline simulated routing failure', { output: 'partial', usageStatus: 'partial', tokens: { input: 17, cachedInput: 4, output: 2 } }); });
|
|
140
|
+
const result = await execute(f);
|
|
141
|
+
assert.equal(f.calls(), 1);
|
|
142
|
+
assert.equal(result.status, 'stopped');
|
|
143
|
+
assert.ok('spendingBudget' in result);
|
|
144
|
+
assert.ok(result.spendingBudget);
|
|
145
|
+
assert.equal(result.spendingBudget.latestState.reason, 'EXECUTION_FAILED');
|
|
146
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 17);
|
|
147
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.coverage.partial, 1);
|
|
148
|
+
});
|
|
149
|
+
test('ordinary functional failures spend budget and are not executor failures or replacement samples', async (t) => {
|
|
150
|
+
const f = setup(t, {}, undefined, true), result = await execute(f);
|
|
151
|
+
assert.equal(f.calls(), 4);
|
|
152
|
+
assert.equal(result.status, 'completed');
|
|
153
|
+
assert.ok('spendingBudget' in result);
|
|
154
|
+
assert.ok(result.spendingBudget);
|
|
155
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 40);
|
|
156
|
+
assert.equal(result.spendingBudget.latestState.reason, null);
|
|
157
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
158
|
+
});
|
|
159
|
+
test('complete budget events bind the plan and reproduce from native receipts', async (t) => {
|
|
160
|
+
const f = setup(t), result = await execute(f);
|
|
161
|
+
assert.equal(f.calls(), 4);
|
|
162
|
+
assert.equal(result.status, 'completed');
|
|
163
|
+
assert.ok('evidence' in result);
|
|
164
|
+
assert.equal(result.evidence.verified, true);
|
|
165
|
+
assert.ok('spendingBudget' in result);
|
|
166
|
+
assert.ok(result.spendingBudget);
|
|
167
|
+
assert.equal(result.spendingBudget.events, 8);
|
|
168
|
+
assert.equal(result.spendingBudget.latestState.metrics.uncachedInput.knownTotal, 16);
|
|
169
|
+
const replay = await reportEvalComponent(f.directory, { replay: true });
|
|
170
|
+
assert.equal(replay.evidence.verified, true);
|
|
171
|
+
assert.ok('spendingBudget' in replay);
|
|
172
|
+
assert.deepEqual(replay.spendingBudget, result.spendingBudget);
|
|
173
|
+
});
|
|
174
|
+
test('a resealed under-reported budget trace fails the semantic native audit', async (t) => {
|
|
175
|
+
const f = setup(t);
|
|
176
|
+
await execute(f);
|
|
177
|
+
const path = join(f.directory, '_budget.jsonl'), rows = readFileSync(path, 'utf8').trim().split('\n').map(line => JSON.parse(line));
|
|
178
|
+
rows[1].state.metrics.input.knownTotal = 0;
|
|
179
|
+
writeFileSync(path, rows.map(row => JSON.stringify(row)).join('\n') + '\n');
|
|
180
|
+
const indexPath = join(f.directory, '_artifacts.json'), index = JSON.parse(readFileSync(indexPath, 'utf8'));
|
|
181
|
+
index.files['_budget.jsonl'] = sha256File(path);
|
|
182
|
+
writeFileSync(indexPath, JSON.stringify(index, null, 2) + '\n');
|
|
183
|
+
const result = await reportEvalComponent(f.directory);
|
|
184
|
+
assert.equal(result.evidence.verified, false);
|
|
185
|
+
assert.match(result.evidence.reasons.join(' '), /Budget after-call/);
|
|
186
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
187
|
+
});
|
|
188
|
+
test('changed stop lines invalidate a preview and cannot silently increase the approved budget', async (t) => {
|
|
189
|
+
const f = setup(t), preview = await runEvalComponent(f.request, { ...f.options, dryRun: true });
|
|
190
|
+
assert.ok('plan' in preview);
|
|
191
|
+
writeFileSync(f.request, JSON.stringify({ ...f.body, spendingBudget: { ...limits, input: 2000 } }));
|
|
192
|
+
await assert.rejects(runEvalComponent(f.request, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 }), /changed/);
|
|
193
|
+
assert.equal(f.calls(), 0);
|
|
194
|
+
assert.equal(existsSync(f.directory), false);
|
|
195
|
+
});
|
|
196
|
+
test('call ceiling remains independent and old request normalization omits the new optional field', async (t) => {
|
|
197
|
+
const f = setup(t);
|
|
198
|
+
const { spendingBudget: _unused, ...old } = f.body;
|
|
199
|
+
assert.equal(Object.hasOwn(parseEvalRequest(old, f.root), 'spendingBudget'), false);
|
|
200
|
+
writeFileSync(f.request, JSON.stringify({ ...f.body, maxCalls: 3 }));
|
|
201
|
+
await assert.rejects(runEvalComponent(f.request, { ...f.options, dryRun: true }), /exceeding --max-calls/);
|
|
202
|
+
assert.equal(f.calls(), 0);
|
|
203
|
+
});
|
|
204
|
+
test('a stop line reached only by the final declared call permits no extra call and preserves a complete cohort', async (t) => {
|
|
205
|
+
const f = setup(t, { input: 40 }), result = await execute(f);
|
|
206
|
+
assert.equal(f.calls(), 4);
|
|
207
|
+
assert.equal(result.status, 'completed');
|
|
208
|
+
assert.ok('spendingBudget' in result);
|
|
209
|
+
assert.ok(result.spendingBudget);
|
|
210
|
+
assert.deepEqual(result.spendingBudget.latestState.reached, ['input']);
|
|
211
|
+
assert.equal(result.evidence.verified, true);
|
|
212
|
+
});
|
|
@@ -6,6 +6,7 @@ import { join } from 'node:path';
|
|
|
6
6
|
import { test } from 'node:test';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import { reportEvalComponent, runEvalComponent } from '../commands/eval-component.js';
|
|
9
|
+
import { exportEvaluation } from '../commands/eval-export.js';
|
|
9
10
|
import { runEval } from '../commands/eval.js';
|
|
10
11
|
import { assessEvaluation } from './eval-acceptance.js';
|
|
11
12
|
import { parseAcceptancePolicy, parseEvalRequest, policyHash } from './eval-contract.js';
|
|
@@ -49,6 +50,41 @@ async function run(t) {
|
|
|
49
50
|
const result = await runEvalComponent(f.requestPath, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
50
51
|
return { ...f, preview, result };
|
|
51
52
|
}
|
|
53
|
+
test('request taskIds bind preview, native scope and offline assessment without relaxing adoption', async (t) => {
|
|
54
|
+
const f = setup(t);
|
|
55
|
+
writeFileSync(f.requestPath, JSON.stringify({ ...f.body, taskIds: ['fix'], maxCalls: 2 }));
|
|
56
|
+
const preview = await runEvalComponent(f.requestPath, { ...f.options, dryRun: true });
|
|
57
|
+
assert.ok('plan' in preview);
|
|
58
|
+
assert.equal(preview.plan.evaluation.plannedCalls, 2);
|
|
59
|
+
assert.deepEqual(preview.plan.evaluation.bench.taskIds, ['fix']);
|
|
60
|
+
const result = await runEvalComponent(f.requestPath, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
61
|
+
assert.equal(f.calls(), 2);
|
|
62
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
63
|
+
const replay = await reportEvalComponent(f.runDir, { replay: true });
|
|
64
|
+
assert.ok('evidence' in replay && replay.evidence.verified);
|
|
65
|
+
assert.equal(f.calls(), 2);
|
|
66
|
+
});
|
|
67
|
+
test('component exports include the frozen request and both complete Skills and replay without originals', async (t) => {
|
|
68
|
+
const f = await run(t), output = join(f.root, 'portable');
|
|
69
|
+
const originalRequest = readFileSync(f.requestPath, 'utf8');
|
|
70
|
+
writeFileSync(f.requestPath, '{}');
|
|
71
|
+
for (const path of ['bench', 'old', 'new'])
|
|
72
|
+
rmSync(join(f.root, path), { recursive: true });
|
|
73
|
+
const nativeReplay = await reportEvalComponent(f.runDir, { replay: true });
|
|
74
|
+
assert.ok('evidence' in nativeReplay && nativeReplay.evidence.verified);
|
|
75
|
+
await exportEvaluation(f.runDir, output, { yes: true, log: () => { } });
|
|
76
|
+
assert.equal(readFileSync(join(output, 'inputs/request.json'), 'utf8'), originalRequest);
|
|
77
|
+
assert.equal(readFileSync(join(output, 'inputs/baseline-skill/answer.txt'), 'utf8'), '1');
|
|
78
|
+
assert.equal(readFileSync(join(output, 'inputs/target/answer.txt'), 'utf8'), '2');
|
|
79
|
+
rmSync(join(f.root, 'runs'), { recursive: true });
|
|
80
|
+
const child = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
|
|
81
|
+
assert.equal(child.status, 0, child.stderr);
|
|
82
|
+
const replay = JSON.parse(child.stdout);
|
|
83
|
+
assert.equal(replay.evidence.verified, true);
|
|
84
|
+
assert.deepEqual(replay.costs, 'costs' in f.result ? f.result.costs : null);
|
|
85
|
+
assert.equal(replay.acceptance.decision, 'reject');
|
|
86
|
+
assert.equal(f.calls(), 4);
|
|
87
|
+
});
|
|
52
88
|
test('installed component delivers and freezes a working diff tool identically in both arms', async (t) => {
|
|
53
89
|
const f = setup(t), prompts = [];
|
|
54
90
|
const executor = { ...f.executor, run: async (prompt, workdir) => {
|
|
@@ -5,6 +5,8 @@ import { RUN_GROUP_PATTERN } from './constants.js';
|
|
|
5
5
|
import { DEFAULT_CLI_TIMEOUT_MS } from './executors/cli.js';
|
|
6
6
|
import { sha256Text } from './hash.js';
|
|
7
7
|
import { CONCLUSIVE_TASKS, CONCLUSIVE_TRIALS } from './report.js';
|
|
8
|
+
import { parseSpendingBudget } from './eval-budget.js';
|
|
9
|
+
import { parseTaskIds } from './bench.js';
|
|
8
10
|
export function record(value, label) {
|
|
9
11
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
10
12
|
throw new Error(`${label} must be an object.`);
|
|
@@ -70,7 +72,7 @@ export function parseAcceptancePolicy(value = {}) {
|
|
|
70
72
|
}
|
|
71
73
|
export function parseEvalRequest(value, baseDir) {
|
|
72
74
|
const r = record(value, 'request');
|
|
73
|
-
keys(r, ['schemaVersion', 'baselineSkill', 'candidateSkill', 'bench', 'agent', 'purpose', 'pairOrder', 'executorTimeoutSeconds', 'trials', 'maxCalls', 'runsRoot', 'runGroup', 'policy'], 'request');
|
|
75
|
+
keys(r, ['schemaVersion', 'baselineSkill', 'candidateSkill', 'bench', 'taskIds', 'agent', 'purpose', 'pairOrder', 'executorTimeoutSeconds', 'trials', 'maxCalls', 'spendingBudget', 'runsRoot', 'runGroup', 'policy'], 'request');
|
|
74
76
|
if (r.schemaVersion !== 1)
|
|
75
77
|
throw new Error('request.schemaVersion must be 1.');
|
|
76
78
|
const agent = text(r.agent, 'request.agent');
|
|
@@ -86,10 +88,12 @@ export function parseEvalRequest(value, baseDir) {
|
|
|
86
88
|
baselineSkill: resolve(baseDir, text(r.baselineSkill, 'request.baselineSkill')),
|
|
87
89
|
candidateSkill: resolve(baseDir, text(r.candidateSkill, 'request.candidateSkill')),
|
|
88
90
|
bench: resolve(baseDir, text(r.bench, 'request.bench')),
|
|
91
|
+
...(r.taskIds !== undefined ? { taskIds: parseTaskIds(r.taskIds) } : {}),
|
|
89
92
|
agent, purpose: r.purpose, pairOrder: r.pairOrder ?? 'baseline-first',
|
|
90
93
|
executorTimeoutSeconds: numeric(r.executorTimeoutSeconds ?? DEFAULT_CLI_TIMEOUT_MS / 1000, 'request.executorTimeoutSeconds', 1, 3600, true),
|
|
91
94
|
trials: numeric(r.trials, 'request.trials', 1, 20, true),
|
|
92
95
|
maxCalls: numeric(r.maxCalls, 'request.maxCalls', 1, Number.MAX_SAFE_INTEGER, true),
|
|
96
|
+
...(r.spendingBudget !== undefined ? { spendingBudget: parseSpendingBudget(r.spendingBudget) } : {}),
|
|
93
97
|
runsRoot: resolve(baseDir, text(r.runsRoot, 'request.runsRoot')), runGroup,
|
|
94
98
|
policy: parseAcceptancePolicy(r.policy),
|
|
95
99
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { evaluationSignal } from '../interruption.js';
|
|
1
2
|
function tokenCount(value) {
|
|
2
3
|
return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
3
4
|
}
|
|
@@ -6,11 +7,17 @@ function tokenUsage(usage) {
|
|
|
6
7
|
return undefined;
|
|
7
8
|
const input = tokenCount(usage.prompt_tokens);
|
|
8
9
|
const output = tokenCount(usage.completion_tokens);
|
|
10
|
+
const details = usage.prompt_tokens_details;
|
|
11
|
+
const cached = details && typeof details === 'object' && !Array.isArray(details)
|
|
12
|
+
? tokenCount(details.cached_tokens) : undefined;
|
|
13
|
+
const cachedInput = input !== undefined && Number.isSafeInteger(input) && cached !== undefined && Number.isSafeInteger(cached) && cached <= input
|
|
14
|
+
? cached : undefined;
|
|
9
15
|
if (input === undefined && output === undefined)
|
|
10
16
|
return undefined;
|
|
11
17
|
return {
|
|
12
18
|
...(input !== undefined ? { input } : {}),
|
|
13
19
|
...(output !== undefined ? { output } : {}),
|
|
20
|
+
...(cachedInput !== undefined ? { cachedInput } : {}),
|
|
14
21
|
};
|
|
15
22
|
}
|
|
16
23
|
const DEFAULT_TIMEOUT_MS = 2 * 60 * 1000;
|
|
@@ -41,6 +48,8 @@ export class ApiExecutor {
|
|
|
41
48
|
return { kind: 'api', model: this.model, detail: this.baseUrl, sampling: null };
|
|
42
49
|
}
|
|
43
50
|
async run(prompt, _workdir) {
|
|
51
|
+
const interrupted = evaluationSignal();
|
|
52
|
+
interrupted?.throwIfAborted();
|
|
44
53
|
const response = await this.fetchImpl(`${this.baseUrl}/chat/completions`, {
|
|
45
54
|
method: 'POST',
|
|
46
55
|
headers: {
|
|
@@ -51,7 +60,7 @@ export class ApiExecutor {
|
|
|
51
60
|
model: this.model,
|
|
52
61
|
messages: [{ role: 'user', content: prompt }],
|
|
53
62
|
}),
|
|
54
|
-
signal: AbortSignal.timeout(this.timeoutMs),
|
|
63
|
+
signal: interrupted ? AbortSignal.any([interrupted, AbortSignal.timeout(this.timeoutMs)]) : AbortSignal.timeout(this.timeoutMs),
|
|
55
64
|
});
|
|
56
65
|
if (!response.ok) {
|
|
57
66
|
const body = (await response.text()).slice(0, 300);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
2
|
import { test } from 'node:test';
|
|
3
3
|
import { ApiExecutor } from './api.js';
|
|
4
|
+
import { summarizeCosts } from '../costs.js';
|
|
5
|
+
import { spendingBudgetState } from '../eval-budget.js';
|
|
4
6
|
function jsonResponse(body, status = 200) {
|
|
5
7
|
return new Response(JSON.stringify(body), {
|
|
6
8
|
status,
|
|
@@ -34,6 +36,47 @@ test('ApiExecutor throws on non-2xx responses', async () => {
|
|
|
34
36
|
const executor = new ApiExecutor({ apiKey: 'k', fetchImpl });
|
|
35
37
|
await assert.rejects(() => executor.run('hi', '/tmp'), /status 500/);
|
|
36
38
|
});
|
|
39
|
+
test('API cache counts reach cost partitions and budget stop lines without double counting', async () => {
|
|
40
|
+
for (const cached of [0, 80, 100]) {
|
|
41
|
+
const fetchImpl = async () => jsonResponse({ choices: [{ message: { content: 'offline' } }],
|
|
42
|
+
usage: { prompt_tokens: 100, completion_tokens: 10, prompt_tokens_details: { cached_tokens: cached } } });
|
|
43
|
+
const result = await new ApiExecutor({ apiKey: 'offline-only', fetchImpl }).run('offline');
|
|
44
|
+
assert.deepEqual(result.tokens, { input: 100, output: 10, cachedInput: cached });
|
|
45
|
+
const record = { executorInvoked: true, passed: true, error: null, durationSeconds: 1, tokens: result.tokens, usageStatus: 'final' };
|
|
46
|
+
const costs = summarizeCosts({ baseline: [record], treatment: [] }, { baseline: [record], treatment: [] });
|
|
47
|
+
const metrics = costs.attempts.baseline.metrics;
|
|
48
|
+
assert.equal(metrics.input.knownTotal, 100);
|
|
49
|
+
assert.equal(metrics.cachedInput.knownTotal, cached);
|
|
50
|
+
assert.equal(metrics.uncachedInput.knownTotal, 100 - cached);
|
|
51
|
+
assert.equal(metrics.cachedInput.coverage.final, 1);
|
|
52
|
+
const state = spendingBudgetState({ input: 100, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 }, [record]);
|
|
53
|
+
assert.equal(state.incomplete.length, 0);
|
|
54
|
+
assert.ok(state.reached.includes('input'));
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
test('missing, malformed and incompatible API cache counts stay unknown rather than becoming zero', async () => {
|
|
58
|
+
const cases = [undefined, null, false, 'cache', [], {}, { cached_tokens: null }, { cached_tokens: '0' },
|
|
59
|
+
{ cached_tokens: -1 }, { cached_tokens: 101 }, { cached_tokens: 0.5 }, { cached_tokens: Number.MAX_SAFE_INTEGER + 1 }];
|
|
60
|
+
for (const details of cases) {
|
|
61
|
+
const fetchImpl = async () => jsonResponse({ choices: [{ message: { content: 'offline' } }],
|
|
62
|
+
usage: { prompt_tokens: 100, completion_tokens: 10, prompt_tokens_details: details } });
|
|
63
|
+
const tokens = (await new ApiExecutor({ apiKey: 'offline-only', fetchImpl }).run('offline')).tokens;
|
|
64
|
+
assert.deepEqual(tokens, { input: 100, output: 10 });
|
|
65
|
+
const state = spendingBudgetState({ input: 1000, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 }, [{ executorInvoked: true, passed: true, error: null, durationSeconds: 1, tokens, usageStatus: 'final' }]);
|
|
66
|
+
assert.equal(state.reason, 'FINAL_USAGE_MISSING');
|
|
67
|
+
assert.ok(state.incomplete.includes('cachedInput'));
|
|
68
|
+
assert.equal(state.metrics.uncachedInput.coverage.unknown, 1);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
test('cache counts without a valid input total cannot establish an API input partition', async () => {
|
|
72
|
+
for (const input of [undefined, null, '100', -1, 0.5]) {
|
|
73
|
+
const fetchImpl = async () => jsonResponse({ choices: [{ message: { content: 'offline' } }],
|
|
74
|
+
usage: { prompt_tokens: input, completion_tokens: 10, prompt_tokens_details: { cached_tokens: 0 } } });
|
|
75
|
+
const tokens = (await new ApiExecutor({ apiKey: 'offline-only', fetchImpl }).run('offline')).tokens;
|
|
76
|
+
assert.equal(tokens.cachedInput, undefined);
|
|
77
|
+
assert.equal(tokens.output, 10);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
37
80
|
test('ApiExecutor ignores usage objects that do not contain finite token counts', async () => {
|
|
38
81
|
const fetchImpl = (async () => jsonResponse({
|
|
39
82
|
choices: [{ message: { content: 'answer' } }],
|
|
@@ -7,6 +7,7 @@ import { probeKimiSessionUsage } from '../kimi-usage.js';
|
|
|
7
7
|
import { probeCodexPartialUsage } from '../codex-usage.js';
|
|
8
8
|
import { ExecutorFailure } from '../types.js';
|
|
9
9
|
import { ExecutionDeadline } from '../execution-timing.js';
|
|
10
|
+
import { evaluationSignal } from '../interruption.js';
|
|
10
11
|
export const DEFAULT_CLI_TIMEOUT_MS = 10 * 60 * 1000;
|
|
11
12
|
const MAX_AGENT_OUTPUT_BYTES = 32 * 1024 * 1024;
|
|
12
13
|
const DEFAULT_PROMPT_FILE = '_prompt.txt';
|
|
@@ -137,6 +138,9 @@ export class CliExecutor {
|
|
|
137
138
|
};
|
|
138
139
|
}
|
|
139
140
|
run(prompt, workdir) {
|
|
141
|
+
const signal = evaluationSignal();
|
|
142
|
+
if (signal?.aborted)
|
|
143
|
+
return Promise.reject(new ExecutorFailure(String(signal.reason), { output: '' }, false));
|
|
140
144
|
const startedAtMs = Date.now();
|
|
141
145
|
let argv = this.argv;
|
|
142
146
|
if (this.projectTrustConfigArg) {
|
|
@@ -195,7 +199,7 @@ export class CliExecutor {
|
|
|
195
199
|
}
|
|
196
200
|
return new ExecutorFailure(message, { ...result, usageStatus: 'partial' });
|
|
197
201
|
};
|
|
198
|
-
const stopMessage = () => overflow
|
|
202
|
+
const stopMessage = () => signal?.aborted ? signal.reason.message : overflow
|
|
199
203
|
? `"${command}" produced more than ${MAX_AGENT_OUTPUT_BYTES} bytes of output`
|
|
200
204
|
: deadline.timingError ? `"${command}" execution timing anomaly: ${deadline.timingError}`
|
|
201
205
|
: `"${command}" timed out after ${this.timeoutMs}ms`;
|
|
@@ -229,7 +233,13 @@ export class CliExecutor {
|
|
|
229
233
|
checkDeadline();
|
|
230
234
|
}, this.timeoutMs);
|
|
231
235
|
const heartbeat = setInterval(() => checkDeadline(), deadline.heartbeatMs);
|
|
232
|
-
const
|
|
236
|
+
const onAbort = () => stopChild();
|
|
237
|
+
const clearTimers = () => {
|
|
238
|
+
clearTimeout(timer);
|
|
239
|
+
clearInterval(heartbeat);
|
|
240
|
+
clearTimeout(drainTimer);
|
|
241
|
+
signal?.removeEventListener('abort', onAbort);
|
|
242
|
+
};
|
|
233
243
|
const take = (chunk, sink) => {
|
|
234
244
|
checkDeadline();
|
|
235
245
|
bytes += chunk.length;
|
|
@@ -253,6 +263,10 @@ export class CliExecutor {
|
|
|
253
263
|
child.on('close', (code) => {
|
|
254
264
|
checkDeadline(false);
|
|
255
265
|
clearTimers();
|
|
266
|
+
if (signal?.aborted) {
|
|
267
|
+
rejectPromise(failure(stopMessage()));
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
256
270
|
if (overflow) {
|
|
257
271
|
rejectPromise(failure(`"${command}" produced more than ${MAX_AGENT_OUTPUT_BYTES} bytes of output`));
|
|
258
272
|
return;
|
|
@@ -287,12 +301,19 @@ export class CliExecutor {
|
|
|
287
301
|
}
|
|
288
302
|
resolvePromise(result);
|
|
289
303
|
});
|
|
290
|
-
|
|
304
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
305
|
+
if (signal?.aborted)
|
|
306
|
+
onAbort();
|
|
307
|
+
if (this.promptVia === 'stdin' && !signal?.aborted) {
|
|
291
308
|
// A child that exits before draining stdin makes the write fail (EPIPE on POSIX, EOF on
|
|
292
309
|
// Windows). With no listener that surfaces as an uncaught exception rather than a rejection,
|
|
293
310
|
// so the caller's catch never runs and the process dies mid-trial leaving a half-populated
|
|
294
311
|
// run group behind. Reject instead, and kill the child so it cannot outlive the failure.
|
|
295
312
|
child.stdin.on('error', (error) => {
|
|
313
|
+
// Killing the tree can close stdin too. Let close/the bounded drain
|
|
314
|
+
// retain parsed usage instead of replacing cancellation with EPIPE.
|
|
315
|
+
if (stopping)
|
|
316
|
+
return;
|
|
296
317
|
clearTimers();
|
|
297
318
|
deadline.observe();
|
|
298
319
|
killTree(child);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, readdirSync, realpathSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
@@ -8,6 +8,9 @@ import { parseFrontmatter } from '../frontmatter.js';
|
|
|
8
8
|
import { hashFileSet, sha256File, sha256Text } from './hash.js';
|
|
9
9
|
import { assertNativeDiffFile, assertNativeDiffWorkspace, NATIVE_DIFF_SNAPSHOT } from './native-diff.js';
|
|
10
10
|
import { ExecutorFailure } from './types.js';
|
|
11
|
+
import { EvaluationInterrupted, evaluationSignal, throwIfEvaluationInterrupted } from './interruption.js';
|
|
12
|
+
import { freezeInputSnapshot, verifyInputSnapshot } from './input-snapshot.js';
|
|
13
|
+
import { loadBench } from './bench.js';
|
|
11
14
|
function skillInventory(root) {
|
|
12
15
|
if (!existsSync(root))
|
|
13
16
|
return { root, entries: ['missing'] };
|
|
@@ -163,6 +166,7 @@ export class ExperimentSession {
|
|
|
163
166
|
finished = false;
|
|
164
167
|
guardFiles;
|
|
165
168
|
nativeDiffTool;
|
|
169
|
+
inputSnapshot;
|
|
166
170
|
constructor(options) {
|
|
167
171
|
this.nativeDiffTool = options.details.nativeDiffTool !== undefined;
|
|
168
172
|
this.guardFiles = (options.guardFiles ?? []).map(file => ({ ...file, path: resolve(file.path) }));
|
|
@@ -256,17 +260,37 @@ export class ExperimentSession {
|
|
|
256
260
|
agent: options.agent ?? null, cliVersion, configuredSettings: configured, servedModel: 'unrecorded',
|
|
257
261
|
plannedCalls: this.plannedCalls, maxCalls: this.maxCalls, workspaces: this.workspaces, workspaceAliases: this.workspaceAliases,
|
|
258
262
|
inputs: this.inputs, guardFiles: this.guardFiles, configurations: this.configs, skillInventories: this.inventories, warnings, details: options.details };
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
mkdirSync(this.groupDir
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
mkdirSync(dirname(this.groupDir), { recursive: true });
|
|
264
|
+
// Claim exclusively; a failed setup removes only the fresh directory we own.
|
|
265
|
+
mkdirSync(this.groupDir);
|
|
266
|
+
try {
|
|
267
|
+
this.inputSnapshot = freezeInputSnapshot(this.groupDir, this.inputs, this.guardFiles);
|
|
268
|
+
if (loadBench(join(this.groupDir, '_inputs/bench')).contentSha256 !== options.bench.contentSha256)
|
|
269
|
+
throw new Error('Sealed bench does not match the planned content hash; keep Git metadata and run outputs outside bench inputs.');
|
|
270
|
+
for (const input of this.inputs)
|
|
271
|
+
if (pin(input.label, input.root, input.exclude).sha256 !== input.sha256)
|
|
272
|
+
throw new Error(`Frozen ${input.label} input changed while sealing snapshots.`);
|
|
273
|
+
for (const file of this.guardFiles)
|
|
274
|
+
if (sha256File(file.path) !== file.sha256)
|
|
275
|
+
throw new Error(`Frozen ${file.label} changed while sealing snapshots.`);
|
|
276
|
+
throwIfEvaluationInterrupted();
|
|
277
|
+
const bytes = JSON.stringify({ ...plan, inputSnapshot: this.inputSnapshot }, null, 2) + '\n';
|
|
278
|
+
this.planSha256 = sha256Text(bytes);
|
|
279
|
+
writeFileSync(join(this.groupDir, '_plan.json'), bytes, { flag: 'wx' });
|
|
280
|
+
if (sha256File(join(this.groupDir, '_plan.json')) !== this.planSha256)
|
|
281
|
+
throw new Error('Frozen plan write verification failed.');
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
rmSync(this.groupDir, { recursive: true, force: true });
|
|
285
|
+
throw error;
|
|
286
|
+
}
|
|
265
287
|
}
|
|
266
288
|
check() {
|
|
267
289
|
if (this.stopReason)
|
|
268
290
|
throw new Error(this.stopReason);
|
|
269
291
|
try {
|
|
292
|
+
throwIfEvaluationInterrupted();
|
|
293
|
+
verifyInputSnapshot(this.groupDir, { inputs: this.inputs, guardFiles: this.guardFiles, inputSnapshot: this.inputSnapshot });
|
|
270
294
|
if (this.nativeDiffTool) {
|
|
271
295
|
assertNativeDiffFile(join(this.groupDir, NATIVE_DIFF_SNAPSHOT));
|
|
272
296
|
for (const workdir of this.workspaces)
|
|
@@ -299,6 +323,15 @@ export class ExperimentSession {
|
|
|
299
323
|
throw error;
|
|
300
324
|
}
|
|
301
325
|
}
|
|
326
|
+
/** Only this fresh session may hand its prepared directory to an engine. */
|
|
327
|
+
assertPrepared() {
|
|
328
|
+
if (this.finished || this.callsStarted !== 0 ||
|
|
329
|
+
readdirSync(this.groupDir).sort().join() !== '_inputs,_inputs.json,_plan.json' ||
|
|
330
|
+
sha256File(join(this.groupDir, '_plan.json')) !== this.planSha256) {
|
|
331
|
+
throw new Error(`Run group directory already exists or preparation changed: ${this.groupDir}`);
|
|
332
|
+
}
|
|
333
|
+
verifyInputSnapshot(this.groupDir, { inputs: this.inputs, guardFiles: this.guardFiles, inputSnapshot: this.inputSnapshot });
|
|
334
|
+
}
|
|
302
335
|
wrap(executor, role) {
|
|
303
336
|
return { describe: () => executor.describe(), run: async (prompt, workdir) => {
|
|
304
337
|
try {
|
|
@@ -323,14 +356,23 @@ export class ExperimentSession {
|
|
|
323
356
|
}
|
|
324
357
|
catch {
|
|
325
358
|
if (role === 'judge')
|
|
326
|
-
throw new
|
|
359
|
+
throw new ExecutorFailure(this.stopReason, result);
|
|
327
360
|
return { ...result, guardError: this.stopReason };
|
|
328
361
|
}
|
|
329
362
|
return result;
|
|
330
363
|
}
|
|
331
364
|
catch (error) {
|
|
332
365
|
if (!this.stopReason)
|
|
333
|
-
this.stopReason =
|
|
366
|
+
this.stopReason = evaluationSignal()?.aborted
|
|
367
|
+
? evaluationSignal().reason.message
|
|
368
|
+
: `${role} executor failed; inspect the per-trial error receipt. No further calls.`;
|
|
369
|
+
if (role === 'judge' && evaluationSignal()?.aborted) {
|
|
370
|
+
const result = error instanceof ExecutorFailure ? error.result : null;
|
|
371
|
+
writeFileSync(join(this.groupDir, `_interrupted-judge-${call}.json`), JSON.stringify({
|
|
372
|
+
schemaVersion: 1, call, role, error: error.message, result,
|
|
373
|
+
scope: 'Interrupted judge output and available usage only; separate judge spending is not a complete primary-agent cost total.',
|
|
374
|
+
}, null, 2) + '\n', { flag: 'wx' });
|
|
375
|
+
}
|
|
334
376
|
if (this.callsFinished < call) {
|
|
335
377
|
this.callsFinished++;
|
|
336
378
|
appendFileSync(ledger, JSON.stringify({ event: 'failed', call, at: new Date().toISOString() }) + '\n');
|
|
@@ -354,6 +396,15 @@ export class ExperimentSession {
|
|
|
354
396
|
if (this.finished)
|
|
355
397
|
return;
|
|
356
398
|
this.finished = true;
|
|
399
|
+
const interruption = evaluationSignal()?.reason;
|
|
400
|
+
if (interruption instanceof EvaluationInterrupted) {
|
|
401
|
+
if (!this.stopReason)
|
|
402
|
+
this.stopReason = interruption.message;
|
|
403
|
+
writeFileSync(join(this.groupDir, '_interruption.json'), JSON.stringify({
|
|
404
|
+
schemaVersion: 1, signal: interruption.signalName, receivedAt: interruption.receivedAt,
|
|
405
|
+
exitCode: interruption.exitCode, automaticRetry: false,
|
|
406
|
+
}, null, 2) + '\n', { flag: 'wx' });
|
|
407
|
+
}
|
|
357
408
|
if (error && !this.stopReason)
|
|
358
409
|
this.stopReason = 'Experiment setup or execution stopped; inspect the command error and retained receipts.';
|
|
359
410
|
this.settle();
|