skillfit 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -15
- package/README.zh-CN.md +41 -15
- 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 +166 -53
- 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 +68 -38
- package/dist/commands/bench.test.js +101 -0
- package/dist/commands/eval-component.js +17 -0
- package/dist/commands/eval-export.js +152 -0
- package/dist/commands/eval-export.test.js +122 -0
- package/dist/commands/eval.js +14 -3
- package/dist/commands/eval.test.js +58 -1
- package/dist/harness/bench.js +21 -2
- package/dist/harness/eval-audit.js +42 -4
- package/dist/harness/eval-budget.js +51 -0
- package/dist/harness/eval-budget.test.js +210 -0
- package/dist/harness/eval-component.test.js +36 -0
- package/dist/harness/eval-contract.js +5 -1
- package/dist/harness/replay-package.js +85 -0
- package/dist/harness/runner.js +22 -1
- package/docs/bench-authoring.md +40 -0
- package/docs/bench-check-json.md +115 -0
- package/docs/case-management.md +65 -0
- package/docs/eval-component.md +60 -49
- 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/first-real-eval.md +6 -0
- package/docs/growth-roadmap-2026-10.md +57 -93
- package/docs/metrics.md +21 -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 +30 -0
- package/docs/releases/0.10.0.md +45 -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 +88 -0
- package/docs/schemas/bench-check.schema.json +109 -0
- package/docs/schemas/eval-request.schema.json +12 -0
- package/docs/sharing-results.md +6 -0
- 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
package/dist/harness/bench.js
CHANGED
|
@@ -23,7 +23,7 @@ function assertCommandTokensExist(benchDir, command, label) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
export function validateBenchTask(benchDir, raw, index) {
|
|
27
27
|
if (typeof raw !== 'object' || raw === null) {
|
|
28
28
|
throw new Error(`bench.json task #${index + 1} must be an object`);
|
|
29
29
|
}
|
|
@@ -120,7 +120,7 @@ export function loadBench(benchDir) {
|
|
|
120
120
|
if (!Array.isArray(raw.tasks) || raw.tasks.length === 0) {
|
|
121
121
|
throw new Error(`bench.json in ${dir} must list at least one task`);
|
|
122
122
|
}
|
|
123
|
-
const tasks = raw.tasks.map((task, index) =>
|
|
123
|
+
const tasks = raw.tasks.map((task, index) => validateBenchTask(dir, task, index));
|
|
124
124
|
const seen = new Set();
|
|
125
125
|
for (const task of tasks) {
|
|
126
126
|
if (seen.has(task.id)) {
|
|
@@ -132,3 +132,22 @@ export function loadBench(benchDir) {
|
|
|
132
132
|
const contentSha256 = hashFileSet(dir, listFilesRecursive(dir));
|
|
133
133
|
return { dir, name, schemaVersion: BENCH_SCHEMA_VERSION, tasks, contentSha256 };
|
|
134
134
|
}
|
|
135
|
+
/** Keep manifest order so selecting IDs cannot silently change balanced pair order. */
|
|
136
|
+
export function parseTaskIds(value) {
|
|
137
|
+
const taskIds = value;
|
|
138
|
+
if (!Array.isArray(taskIds) || taskIds.length === 0 || taskIds.some(id => typeof id !== 'string' || !TASK_ID_PATTERN.test(id))) {
|
|
139
|
+
throw new Error('taskIds must be a nonempty array of valid task IDs.');
|
|
140
|
+
}
|
|
141
|
+
if (new Set(taskIds).size !== taskIds.length)
|
|
142
|
+
throw new Error('Duplicate task selection.');
|
|
143
|
+
return [...taskIds];
|
|
144
|
+
}
|
|
145
|
+
export function selectBenchTasks(bench, selection) {
|
|
146
|
+
if (selection === undefined)
|
|
147
|
+
return bench;
|
|
148
|
+
const taskIds = parseTaskIds(selection);
|
|
149
|
+
const missing = taskIds.filter(id => !bench.tasks.some(task => task.id === id));
|
|
150
|
+
if (missing.length)
|
|
151
|
+
throw new Error(`Unknown task selection: ${missing.join(', ')}`);
|
|
152
|
+
return { ...bench, tasks: bench.tasks.filter(task => taskIds.includes(task.id)) };
|
|
153
|
+
}
|
|
@@ -13,6 +13,7 @@ import { verdictFromOutput } from './verifier-summary.js';
|
|
|
13
13
|
import { parseEvalReport } from '../commands/eval-report.js';
|
|
14
14
|
import { pairConditions } from './types.js';
|
|
15
15
|
import { NATIVE_DIFF_PATH, NATIVE_DIFF_SNAPSHOT } from './native-diff.js';
|
|
16
|
+
import { assertSpendingCanContinue, parseSpendingBudget, spendingBudgetState } from './eval-budget.js';
|
|
16
17
|
function inside(root, path) {
|
|
17
18
|
const rel = relative(root, path);
|
|
18
19
|
return !isAbsolute(rel) && rel !== '..' && !rel.startsWith(`..${sep}`);
|
|
@@ -136,11 +137,14 @@ export async function auditEvaluation(value, runDir, options = {}) {
|
|
|
136
137
|
else
|
|
137
138
|
assert.equal(raw.nativeDiffTool, undefined, 'Unrecorded native diff environment.');
|
|
138
139
|
const all = { baseline: [], treatment: [] }, paired = { baseline: [], treatment: [] };
|
|
140
|
+
if (details.taskIds !== undefined)
|
|
141
|
+
assert.deepEqual(details.taskIds, report.tasks.map(task => task.id), 'Selected task IDs differ from the frozen plan.');
|
|
139
142
|
const bench = options.replay ? loadBench(options.benchDir ?? String(record(raw.bench, 'bench').dir)) : null;
|
|
140
143
|
if (bench)
|
|
141
144
|
assert.equal(bench.contentSha256, report.bench.sha256, 'Replay bench differs from the frozen task set.');
|
|
142
145
|
let invoked = 0;
|
|
143
146
|
const expectedAgentOrder = [];
|
|
147
|
+
const budgetReceipts = new Map();
|
|
144
148
|
const rawTasks = raw.tasks;
|
|
145
149
|
for (const [taskIndex, task] of report.tasks.entries()) {
|
|
146
150
|
assert.ok(/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(task.id), 'Unsafe task id.');
|
|
@@ -151,6 +155,7 @@ export async function auditEvaluation(value, runDir, options = {}) {
|
|
|
151
155
|
const rel = `${task.id}/${arm}/trial-${trial}/_result.json`;
|
|
152
156
|
assert.ok(typeof files[rel] === 'string', `Receipt not sealed: ${rel}`);
|
|
153
157
|
const r = receipt(readComponentJson(member(root, rel)).value);
|
|
158
|
+
budgetReceipts.set(`${task.id}/${arm}/trial-${trial}`, r);
|
|
154
159
|
assert.equal(r.condition, arm);
|
|
155
160
|
assert.equal(r.taskId, task.id);
|
|
156
161
|
assert.equal(r.trial, trial);
|
|
@@ -240,6 +245,28 @@ export async function auditEvaluation(value, runDir, options = {}) {
|
|
|
240
245
|
if (pairOrder)
|
|
241
246
|
assert.deepEqual(ledger.filter(e => e.event === 'started' && e.role === 'agent')
|
|
242
247
|
.map(e => String(e.workdir).split(/[\\/]/).slice(-3).join('/')), expectedAgentOrder, 'Recorded execution order differs from the frozen pair order.');
|
|
248
|
+
if (details.spendingBudget !== undefined) {
|
|
249
|
+
const limits = parseSpendingBudget(details.spendingBudget);
|
|
250
|
+
assert.ok(pairOrder, 'Budget replay requires the recorded pair order.');
|
|
251
|
+
assert.ok(typeof files['_budget.jsonl'] === 'string', 'Budget events are not sealed.');
|
|
252
|
+
const events = readFileSync(join(root, '_budget.jsonl'), 'utf8').trim().split('\n').filter(Boolean).map(line => JSON.parse(line));
|
|
253
|
+
assert.equal(events.length, expectedAgentOrder.length * 2, 'Budget event coverage differs from calls.');
|
|
254
|
+
const observations = [];
|
|
255
|
+
for (const [ordinal, path] of expectedAgentOrder.entries()) {
|
|
256
|
+
const [taskId, condition, trialPath] = path.split('/');
|
|
257
|
+
const trial = Number(trialPath.slice('trial-'.length));
|
|
258
|
+
const before = spendingBudgetState(limits, observations);
|
|
259
|
+
assertSpendingCanContinue(before);
|
|
260
|
+
assert.deepEqual(events[ordinal * 2], { phase: 'before-call', taskId, condition, trial, state: before }, 'Budget before-call state differs from receipts.');
|
|
261
|
+
observations.push(budgetReceipts.get(path));
|
|
262
|
+
const after = spendingBudgetState(limits, observations);
|
|
263
|
+
assert.equal(after.incomplete.length, 0, 'Budget run has missing final usage.');
|
|
264
|
+
assert.notEqual(after.reason, 'EXECUTION_FAILED');
|
|
265
|
+
assert.deepEqual(events[ordinal * 2 + 1], { phase: 'after-call', taskId, condition, trial, state: after }, 'Budget after-call state differs from receipts.');
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else
|
|
269
|
+
assert.equal(files['_budget.jsonl'], undefined, 'Budget events were not declared in the native plan.');
|
|
243
270
|
// This component does not run a judge whose separate usage would be absent from agent costs.
|
|
244
271
|
assert.ok(raw.judge == null, 'Judge usage is not covered by component accounting.');
|
|
245
272
|
audit.verified = true;
|
|
@@ -256,12 +283,22 @@ export function stoppedAccounting(runDir) {
|
|
|
256
283
|
const paired = { baseline: [], treatment: [] };
|
|
257
284
|
const ledger = existsSync(join(root, '_calls.jsonl')) ? readFileSync(join(root, '_calls.jsonl'), 'utf8').trim().split('\n').filter(Boolean).map(line => record(JSON.parse(line), 'ledger')) : [];
|
|
258
285
|
let missingReceipts = 0;
|
|
286
|
+
const invalidReceipts = [];
|
|
259
287
|
for (const event of ledger.filter(e => e.event === 'started' && e.role === 'agent')) {
|
|
260
288
|
const parts = String(event.workdir).split(/[\\/]/), trialDir = parts.slice(-3).join('/');
|
|
261
289
|
assert.ok(/^[a-zA-Z0-9][a-zA-Z0-9._-]*\/(baseline|treatment)\/trial-[0-9]+$/.test(trialDir));
|
|
262
290
|
const arm = parts.at(-2), file = join(root, trialDir, '_result.json');
|
|
263
|
-
if (existsSync(file))
|
|
264
|
-
|
|
291
|
+
if (existsSync(file)) {
|
|
292
|
+
try {
|
|
293
|
+
all[arm].push(receipt(readComponentJson(file).value));
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
// Keep the malformed file untouched. It is not safe to turn invalid counters
|
|
297
|
+
// into a complete cost record, nor to hide every other retained invocation.
|
|
298
|
+
invalidReceipts.push({ path: `${trialDir}/_result.json`, reason: String(error) });
|
|
299
|
+
all[arm].push({ executorInvoked: true, passed: false, error: 'Invocation receipt invalid; raw file retained', durationSeconds: NaN, tokens: null, usageStatus: 'unknown' });
|
|
300
|
+
}
|
|
301
|
+
}
|
|
265
302
|
else {
|
|
266
303
|
missingReceipts++;
|
|
267
304
|
all[arm].push({ executorInvoked: true, passed: false, error: 'Invocation receipt missing', durationSeconds: NaN, tokens: null, usageStatus: 'unknown' });
|
|
@@ -269,7 +306,8 @@ export function stoppedAccounting(runDir) {
|
|
|
269
306
|
}
|
|
270
307
|
const populations = summarizeCosts(all, paired);
|
|
271
308
|
return { populations, startedAgentDispatches: all.baseline.length + all.treatment.length,
|
|
272
|
-
recordedExecutorInvocations: populations.attempts.baseline.runs + populations.attempts.treatment.runs - missingReceipts,
|
|
273
|
-
invocationsWithUnknownReceipts: missingReceipts,
|
|
309
|
+
recordedExecutorInvocations: populations.attempts.baseline.runs + populations.attempts.treatment.runs - missingReceipts - invalidReceipts.length,
|
|
310
|
+
invocationsWithUnknownReceipts: missingReceipts + invalidReceipts.length,
|
|
311
|
+
...(invalidReceipts.length ? { invalidReceipts } : {}),
|
|
274
312
|
scope: 'Known agent invocation spending from stopped-run receipts; missing fields remain unknown. No paired efficacy comparison or exact bill.' };
|
|
275
313
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { COST_METRICS, summarizeCosts } from './costs.js';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
export function parseSpendingBudget(value) {
|
|
5
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
6
|
+
throw new Error('spendingBudget must be an object.');
|
|
7
|
+
const input = value;
|
|
8
|
+
if (Object.keys(input).some(key => !COST_METRICS.includes(key)))
|
|
9
|
+
throw new Error('spendingBudget has unknown fields.');
|
|
10
|
+
return Object.fromEntries(COST_METRICS.map(metric => {
|
|
11
|
+
const amount = input[metric];
|
|
12
|
+
if (typeof amount !== 'number' || !Number.isFinite(amount) || amount <= 0 || amount > Number.MAX_SAFE_INTEGER ||
|
|
13
|
+
(metric !== 'durationSeconds' && !Number.isSafeInteger(amount))) {
|
|
14
|
+
throw new Error(`spendingBudget.${metric} must be a positive ${metric === 'durationSeconds' ? 'finite number' : 'safe integer'}.`);
|
|
15
|
+
}
|
|
16
|
+
return [metric, amount];
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
export function spendingBudgetState(limits, observations) {
|
|
20
|
+
const counter = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : undefined;
|
|
21
|
+
const normalized = observations.map(row => ({ ...row, tokens: row.tokens ? {
|
|
22
|
+
input: counter(row.tokens.input), cachedInput: counter(row.tokens.cachedInput), output: counter(row.tokens.output),
|
|
23
|
+
} : null }));
|
|
24
|
+
const population = summarizeCosts({ baseline: normalized, treatment: [] }, { baseline: [], treatment: [] }).attempts.baseline;
|
|
25
|
+
const reached = COST_METRICS.filter(metric => population.metrics[metric].knownTotal >= limits[metric]);
|
|
26
|
+
const incomplete = COST_METRICS.filter(metric => population.metrics[metric].coverage.final !== population.runs);
|
|
27
|
+
const executionFailed = observations.some(row => row.error !== null);
|
|
28
|
+
const reason = executionFailed ? 'EXECUTION_FAILED' : incomplete.length ? 'FINAL_USAGE_MISSING' : reached.length ? 'SPENDING_BUDGET_REACHED' : null;
|
|
29
|
+
return { schemaVersion: 1, invocations: population.runs, metrics: population.metrics, reached, incomplete, reason };
|
|
30
|
+
}
|
|
31
|
+
export function assertSpendingCanContinue(state) {
|
|
32
|
+
if (state.reason)
|
|
33
|
+
throw new Error(`${state.reason}: no further agent calls; reached=${state.reached.join(',') || 'none'}, incomplete=${state.incomplete.join(',') || 'none'}. Retained spending is not discarded; no retry or replacement.`);
|
|
34
|
+
}
|
|
35
|
+
/** Informational on stopped evidence; a completed native audit verifies every event. */
|
|
36
|
+
export function spendingBudgetReport(runDir) {
|
|
37
|
+
const planPath = join(runDir, '_plan.json');
|
|
38
|
+
if (!existsSync(planPath))
|
|
39
|
+
return null;
|
|
40
|
+
const plan = JSON.parse(readFileSync(planPath, 'utf8'));
|
|
41
|
+
if (plan.details?.spendingBudget === undefined)
|
|
42
|
+
return null;
|
|
43
|
+
const limits = parseSpendingBudget(plan.details.spendingBudget), path = join(runDir, '_budget.jsonl');
|
|
44
|
+
try {
|
|
45
|
+
const events = existsSync(path) ? readFileSync(path, 'utf8').trim().split('\n').filter(Boolean).map(line => JSON.parse(line)) : [];
|
|
46
|
+
return { limits, events: events.length, latestState: events.at(-1)?.state ?? null, readError: null };
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return { limits, events: null, latestState: null, readError: String(error) };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
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'), `const passed=${!functionalFailure};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 () => {
|
|
61
|
+
count++;
|
|
62
|
+
return result ? result() : { output: 'done', tokens: { input: 10, cachedInput: 6, output: 3 } };
|
|
63
|
+
} };
|
|
64
|
+
const options = { executor, skillInstallDir: 'project-skills', sessionOptions: { homeDir: root, env: {}, versionProbe: () => null } };
|
|
65
|
+
return { root, body, request, options, calls: () => count, directory: join(root, 'runs/budget') };
|
|
66
|
+
}
|
|
67
|
+
async function execute(f) {
|
|
68
|
+
const preview = await runEvalComponent(f.request, { ...f.options, dryRun: true });
|
|
69
|
+
assert.ok('plan' in preview);
|
|
70
|
+
assert.equal(f.calls(), 0);
|
|
71
|
+
assert.equal(existsSync(f.directory), false);
|
|
72
|
+
return runEvalComponent(f.request, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 });
|
|
73
|
+
}
|
|
74
|
+
for (const metric of COST_METRICS)
|
|
75
|
+
test(`${metric} stop line blocks the second executor and retains the first complete receipt`, async (t) => {
|
|
76
|
+
const values = { input: 10, cachedInput: 6, uncachedInput: 4, output: 3, durationSeconds: 0.000001 };
|
|
77
|
+
const f = setup(t, { [metric]: values[metric] }), result = await execute(f);
|
|
78
|
+
assert.equal(f.calls(), 1);
|
|
79
|
+
assert.equal(result.status, 'stopped');
|
|
80
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
81
|
+
const receipt = JSON.parse(readFileSync(join(f.directory, 'first/baseline/trial-1/_result.json'), 'utf8'));
|
|
82
|
+
assert.deepEqual(receipt.tokens, { input: 10, cachedInput: 6, output: 3 });
|
|
83
|
+
assert.equal(existsSync(join(f.directory, 'first/treatment/trial-1')), false);
|
|
84
|
+
assert.ok('spendingBudget' in result);
|
|
85
|
+
assert.ok(result.spendingBudget);
|
|
86
|
+
assert.ok(result.spendingBudget.latestState.reached.includes(metric));
|
|
87
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 10);
|
|
88
|
+
const replay = await reportEvalComponent(f.directory);
|
|
89
|
+
assert.equal(replay.status, 'stopped');
|
|
90
|
+
assert.ok('spendingBudget' in replay);
|
|
91
|
+
assert.deepEqual(replay.spendingBudget, result.spendingBudget);
|
|
92
|
+
});
|
|
93
|
+
test('an in-flight overshoot is retained instead of clamped to its stop line', async (t) => {
|
|
94
|
+
const f = setup(t, { input: 5 }), result = await execute(f);
|
|
95
|
+
assert.equal(f.calls(), 1);
|
|
96
|
+
assert.ok('spendingBudget' in result);
|
|
97
|
+
assert.ok(result.spendingBudget);
|
|
98
|
+
assert.equal(result.spendingBudget.limits.input, 5);
|
|
99
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 10);
|
|
100
|
+
});
|
|
101
|
+
for (const [label, tokens] of [['no counters', undefined], ['missing cache', { input: 10, output: 3 }], ['incompatible cache', { input: 10, cachedInput: 11, output: 3 }]]) {
|
|
102
|
+
test(`${label}: missing or incompatible final usage refuses another call without filling cache with zero`, async (t) => {
|
|
103
|
+
const f = setup(t, {}, () => ({ output: 'returned', tokens })), result = await execute(f);
|
|
104
|
+
assert.equal(f.calls(), 1);
|
|
105
|
+
assert.equal(result.status, 'stopped');
|
|
106
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
107
|
+
assert.ok('spendingBudget' in result);
|
|
108
|
+
assert.ok(result.spendingBudget);
|
|
109
|
+
assert.equal(result.spendingBudget.latestState.reason, 'FINAL_USAGE_MISSING');
|
|
110
|
+
assert.equal(result.spendingBudget.latestState.metrics.cachedInput.coverage.unknown, 1);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
test('invalid retained receipts remain untouched and appear as unknown rather than disappearing or becoming zero-cost success', async (t) => {
|
|
114
|
+
const f = setup(t, {}, () => ({ output: 'invalid counters', tokens: { input: 10, cachedInput: 11, output: 3 } }));
|
|
115
|
+
const result = await execute(f), path = join(f.directory, 'first/baseline/trial-1/_result.json'), hash = sha256File(path);
|
|
116
|
+
const value = JSON.parse(JSON.stringify(result));
|
|
117
|
+
assert.equal(value.costs.invocationsWithUnknownReceipts, 1);
|
|
118
|
+
assert.equal(value.costs.recordedExecutorInvocations, 0);
|
|
119
|
+
assert.equal(value.costs.invalidReceipts.length, 1);
|
|
120
|
+
assert.equal(value.costs.populations.attempts.baseline.metrics.input.coverage.unknown, 1);
|
|
121
|
+
await reportEvalComponent(f.directory);
|
|
122
|
+
assert.equal(sha256File(path), hash);
|
|
123
|
+
assert.equal(f.calls(), 1);
|
|
124
|
+
});
|
|
125
|
+
test('an executor guard failure stops immediately while retaining its complete returned usage', async (t) => {
|
|
126
|
+
const f = setup(t, {}, () => ({ output: 'retained', guardError: 'simulated configuration drift', tokens: { input: 12, cachedInput: 8, output: 2 } }));
|
|
127
|
+
const result = await execute(f);
|
|
128
|
+
assert.equal(result.status, 'stopped');
|
|
129
|
+
assert.equal(f.calls(), 1);
|
|
130
|
+
assert.ok('spendingBudget' in result);
|
|
131
|
+
assert.ok(result.spendingBudget);
|
|
132
|
+
assert.equal(result.spendingBudget.latestState.reason, 'EXECUTION_FAILED');
|
|
133
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 12);
|
|
134
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.coverage.final, 1);
|
|
135
|
+
});
|
|
136
|
+
test('executor failure retains partial usage, stops once and never replaces the call', async (t) => {
|
|
137
|
+
const f = setup(t, {}, () => { throw new ExecutorFailure('offline simulated routing failure', { output: 'partial', usageStatus: 'partial', tokens: { input: 17, cachedInput: 4, output: 2 } }); });
|
|
138
|
+
const result = await execute(f);
|
|
139
|
+
assert.equal(f.calls(), 1);
|
|
140
|
+
assert.equal(result.status, 'stopped');
|
|
141
|
+
assert.ok('spendingBudget' in result);
|
|
142
|
+
assert.ok(result.spendingBudget);
|
|
143
|
+
assert.equal(result.spendingBudget.latestState.reason, 'EXECUTION_FAILED');
|
|
144
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 17);
|
|
145
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.coverage.partial, 1);
|
|
146
|
+
});
|
|
147
|
+
test('ordinary functional failures spend budget and are not executor failures or replacement samples', async (t) => {
|
|
148
|
+
const f = setup(t, {}, undefined, true), result = await execute(f);
|
|
149
|
+
assert.equal(f.calls(), 4);
|
|
150
|
+
assert.equal(result.status, 'completed');
|
|
151
|
+
assert.ok('spendingBudget' in result);
|
|
152
|
+
assert.ok(result.spendingBudget);
|
|
153
|
+
assert.equal(result.spendingBudget.latestState.metrics.input.knownTotal, 40);
|
|
154
|
+
assert.equal(result.spendingBudget.latestState.reason, null);
|
|
155
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
156
|
+
});
|
|
157
|
+
test('complete budget events bind the plan and reproduce from native receipts', async (t) => {
|
|
158
|
+
const f = setup(t), result = await execute(f);
|
|
159
|
+
assert.equal(f.calls(), 4);
|
|
160
|
+
assert.equal(result.status, 'completed');
|
|
161
|
+
assert.ok('evidence' in result);
|
|
162
|
+
assert.equal(result.evidence.verified, true);
|
|
163
|
+
assert.ok('spendingBudget' in result);
|
|
164
|
+
assert.ok(result.spendingBudget);
|
|
165
|
+
assert.equal(result.spendingBudget.events, 8);
|
|
166
|
+
assert.equal(result.spendingBudget.latestState.metrics.uncachedInput.knownTotal, 16);
|
|
167
|
+
const replay = await reportEvalComponent(f.directory, { replay: true });
|
|
168
|
+
assert.equal(replay.evidence.verified, true);
|
|
169
|
+
assert.ok('spendingBudget' in replay);
|
|
170
|
+
assert.deepEqual(replay.spendingBudget, result.spendingBudget);
|
|
171
|
+
});
|
|
172
|
+
test('a resealed under-reported budget trace fails the semantic native audit', async (t) => {
|
|
173
|
+
const f = setup(t);
|
|
174
|
+
await execute(f);
|
|
175
|
+
const path = join(f.directory, '_budget.jsonl'), rows = readFileSync(path, 'utf8').trim().split('\n').map(line => JSON.parse(line));
|
|
176
|
+
rows[1].state.metrics.input.knownTotal = 0;
|
|
177
|
+
writeFileSync(path, rows.map(row => JSON.stringify(row)).join('\n') + '\n');
|
|
178
|
+
const indexPath = join(f.directory, '_artifacts.json'), index = JSON.parse(readFileSync(indexPath, 'utf8'));
|
|
179
|
+
index.files['_budget.jsonl'] = sha256File(path);
|
|
180
|
+
writeFileSync(indexPath, JSON.stringify(index, null, 2) + '\n');
|
|
181
|
+
const result = await reportEvalComponent(f.directory);
|
|
182
|
+
assert.equal(result.evidence.verified, false);
|
|
183
|
+
assert.match(result.evidence.reasons.join(' '), /Budget after-call/);
|
|
184
|
+
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
185
|
+
});
|
|
186
|
+
test('changed stop lines invalidate a preview and cannot silently increase the approved budget', async (t) => {
|
|
187
|
+
const f = setup(t), preview = await runEvalComponent(f.request, { ...f.options, dryRun: true });
|
|
188
|
+
assert.ok('plan' in preview);
|
|
189
|
+
writeFileSync(f.request, JSON.stringify({ ...f.body, spendingBudget: { ...limits, input: 2000 } }));
|
|
190
|
+
await assert.rejects(runEvalComponent(f.request, { ...f.options, dryRun: false, expectedPlanSha256: preview.plan.sha256 }), /changed/);
|
|
191
|
+
assert.equal(f.calls(), 0);
|
|
192
|
+
assert.equal(existsSync(f.directory), false);
|
|
193
|
+
});
|
|
194
|
+
test('call ceiling remains independent and old request normalization omits the new optional field', async (t) => {
|
|
195
|
+
const f = setup(t);
|
|
196
|
+
const { spendingBudget: _unused, ...old } = f.body;
|
|
197
|
+
assert.equal(Object.hasOwn(parseEvalRequest(old, f.root), 'spendingBudget'), false);
|
|
198
|
+
writeFileSync(f.request, JSON.stringify({ ...f.body, maxCalls: 3 }));
|
|
199
|
+
await assert.rejects(runEvalComponent(f.request, { ...f.options, dryRun: true }), /exceeding --max-calls/);
|
|
200
|
+
assert.equal(f.calls(), 0);
|
|
201
|
+
});
|
|
202
|
+
test('a stop line reached only by the final declared call permits no extra call and preserves a complete cohort', async (t) => {
|
|
203
|
+
const f = setup(t, { input: 40 }), result = await execute(f);
|
|
204
|
+
assert.equal(f.calls(), 4);
|
|
205
|
+
assert.equal(result.status, 'completed');
|
|
206
|
+
assert.ok('spendingBudget' in result);
|
|
207
|
+
assert.ok(result.spendingBudget);
|
|
208
|
+
assert.deepEqual(result.spendingBudget.latestState.reached, ['input']);
|
|
209
|
+
assert.equal(result.evidence.verified, true);
|
|
210
|
+
});
|
|
@@ -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
|
+
await assert.rejects(() => exportEvaluation(f.runDir, output, { yes: true, log: () => { } }), /request changed/);
|
|
72
|
+
const recovered = join(f.root, 'recovered-request.json');
|
|
73
|
+
writeFileSync(recovered, originalRequest);
|
|
74
|
+
await exportEvaluation(f.runDir, output, { yes: true, inputRoots: [`request=${recovered}`], log: () => { } });
|
|
75
|
+
assert.equal(readFileSync(join(output, 'inputs/request.json'), 'utf8'), originalRequest);
|
|
76
|
+
assert.equal(readFileSync(join(output, 'inputs/baseline-skill/answer.txt'), 'utf8'), '1');
|
|
77
|
+
assert.equal(readFileSync(join(output, 'inputs/target/answer.txt'), 'utf8'), '2');
|
|
78
|
+
for (const path of ['bench', 'old', 'new', 'runs'])
|
|
79
|
+
rmSync(join(f.root, path), { 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
|
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstatSync, readFileSync, readdirSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
export function packageFiles(root, prefix = '') {
|
|
5
|
+
const files = [];
|
|
6
|
+
for (const entry of readdirSync(join(root, prefix), { withFileTypes: true })) {
|
|
7
|
+
if (entry.name === '.git')
|
|
8
|
+
continue;
|
|
9
|
+
const path = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
10
|
+
if (entry.isSymbolicLink())
|
|
11
|
+
throw new Error(`Portable packages do not support symbolic links: ${path}`);
|
|
12
|
+
if (entry.isDirectory())
|
|
13
|
+
files.push(...packageFiles(root, path));
|
|
14
|
+
else if (entry.isFile())
|
|
15
|
+
files.push(path);
|
|
16
|
+
else
|
|
17
|
+
throw new Error(`Unsupported artifact: ${path}`);
|
|
18
|
+
}
|
|
19
|
+
return files.sort();
|
|
20
|
+
}
|
|
21
|
+
export function packageMember(root, path) {
|
|
22
|
+
if (!path || isAbsolute(path) || /^[A-Za-z]:/.test(path) || path.includes('\\') || path.includes('\0') ||
|
|
23
|
+
path.split('/').some(part => !part || part === '.' || part === '..' || part === '.git'))
|
|
24
|
+
throw new Error(`Unsafe package path: ${path}`);
|
|
25
|
+
const target = resolve(root, path), rel = relative(realpathSync(root), realpathSync(target));
|
|
26
|
+
if (isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`) || !lstatSync(target).isFile())
|
|
27
|
+
throw new Error(`Package file escapes its root: ${path}`);
|
|
28
|
+
return target;
|
|
29
|
+
}
|
|
30
|
+
export function packageHash(path) {
|
|
31
|
+
return createHash('sha256').update(readFileSync(path)).digest('hex');
|
|
32
|
+
}
|
|
33
|
+
/** Checksums detect changed/missing files; they do not authenticate an unknown publisher. */
|
|
34
|
+
export function verifyReplayPackage(root) {
|
|
35
|
+
const metadata = JSON.parse(readFileSync(packageMember(root, 'replay-package.json'), 'utf8'));
|
|
36
|
+
if (metadata.schemaVersion !== 1 || metadata.kind !== 'skillfit.replay-package' ||
|
|
37
|
+
typeof metadata.sourcePlanSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(metadata.sourcePlanSha256) ||
|
|
38
|
+
typeof metadata.hasManifest !== 'boolean' || !['completed', 'stopped', 'incomplete'].includes(metadata.nativeStatus) ||
|
|
39
|
+
!metadata.files || typeof metadata.files !== 'object' || Array.isArray(metadata.files))
|
|
40
|
+
throw new Error('Invalid replay-package.json.');
|
|
41
|
+
const actual = packageFiles(root).filter(path => path !== 'replay-package.json');
|
|
42
|
+
if (JSON.stringify(actual) !== JSON.stringify(Object.keys(metadata.files).sort()))
|
|
43
|
+
throw new Error('Portable file inventory changed.');
|
|
44
|
+
for (const [path, hash] of Object.entries(metadata.files)) {
|
|
45
|
+
if (typeof hash !== 'string' || !/^[a-f0-9]{64}$/.test(hash) || packageHash(packageMember(root, path)) !== hash)
|
|
46
|
+
throw new Error(`Portable file hash mismatch: ${path}`);
|
|
47
|
+
}
|
|
48
|
+
if (packageHash(packageMember(root, 'run/_plan.json')) !== metadata.sourcePlanSha256)
|
|
49
|
+
throw new Error('Portable native plan changed.');
|
|
50
|
+
const session = JSON.parse(readFileSync(packageMember(root, 'run/_session.json'), 'utf8'));
|
|
51
|
+
if (session.planSha256 !== metadata.sourcePlanSha256 || session.status !== metadata.nativeStatus)
|
|
52
|
+
throw new Error('Portable session differs from its source plan.');
|
|
53
|
+
for (const file of ['run/_artifacts.json', 'inputs/bench/bench.json', 'runtime/package.json', 'runtime/dist/cli.js', 'reproduce.mjs']) {
|
|
54
|
+
if (!(file in metadata.files))
|
|
55
|
+
throw new Error(`Required portable file is missing: ${file}`);
|
|
56
|
+
}
|
|
57
|
+
if (metadata.hasManifest !== ('run/manifest.json' in metadata.files))
|
|
58
|
+
throw new Error('Portable manifest coverage changed.');
|
|
59
|
+
return metadata;
|
|
60
|
+
}
|
|
61
|
+
/** Serialize these dependency-free functions so old pinned runtimes need no new export API. */
|
|
62
|
+
export function portableReproducer() {
|
|
63
|
+
return `import {createHash} from 'node:crypto';
|
|
64
|
+
import {lstatSync,readFileSync,readdirSync,realpathSync} from 'node:fs';
|
|
65
|
+
import {isAbsolute,join,relative,resolve,sep} from 'node:path';
|
|
66
|
+
import {fileURLToPath} from 'node:url';
|
|
67
|
+
import {spawnSync} from 'node:child_process';
|
|
68
|
+
${packageFiles.toString()}
|
|
69
|
+
${packageMember.toString()}
|
|
70
|
+
${packageHash.toString()}
|
|
71
|
+
${verifyReplayPackage.toString()}
|
|
72
|
+
try {
|
|
73
|
+
const root=fileURLToPath(new URL('.',import.meta.url)), metadata=verifyReplayPackage(root);
|
|
74
|
+
if(process.argv.includes('--verify-only')) {
|
|
75
|
+
console.log(JSON.stringify({schemaVersion:1,kind:'skillfit.replay-package-verification',verified:true,files:Object.keys(metadata.files).length,nativeStatus:metadata.nativeStatus,modelCalls:0}));
|
|
76
|
+
} else {
|
|
77
|
+
const child=spawnSync(process.execPath,[join(root,'runtime/dist/cli.js'),'report','eval',join(root,'run'),'--json','--replay','--bench',join(root,'inputs/bench')],{cwd:root,encoding:'utf8',maxBuffer:32*1024*1024});
|
|
78
|
+
if(child.error||child.status!==0) throw new Error(child.error?.message||child.stderr||'Pinned offline replay failed.');
|
|
79
|
+
const result=JSON.parse(child.stdout);
|
|
80
|
+
if(metadata.hasManifest&&!result.evidence?.verified) throw new Error('Offline evidence audit failed: '+JSON.stringify(result.evidence));
|
|
81
|
+
console.log(JSON.stringify({...result,portableReplay:{verified:true,sourcePlanSha256:metadata.sourcePlanSha256,modelCalls:0,scope:'Offline evidence reproduction; no new observations or upgrade authorization.'}},null,2));
|
|
82
|
+
}
|
|
83
|
+
} catch(error) { console.error(error.message); process.exitCode=2; }
|
|
84
|
+
`;
|
|
85
|
+
}
|
package/dist/harness/runner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { appendFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, join, resolve } from 'node:path';
|
|
4
4
|
import { MOCK_MARKER_FILE, RUN_GROUP_PATTERN } from './constants.js';
|
|
5
5
|
import { assertInstalledSkillFixtures, assertSkillRevisionTargets, installSkillResources, installedSkillDestination } from './installed-skill.js';
|
|
@@ -17,6 +17,7 @@ import { ExecutorFailure } from './types.js';
|
|
|
17
17
|
import { summarizeCosts } from './costs.js';
|
|
18
18
|
import { executionClock } from './execution-timing.js';
|
|
19
19
|
import { verdictFromOutput } from './verifier-summary.js';
|
|
20
|
+
import { assertSpendingCanContinue, parseSpendingBudget, spendingBudgetState } from './eval-budget.js';
|
|
20
21
|
function applyOverlay(overlayDir, runDir) {
|
|
21
22
|
for (const rel of listFilesRecursive(overlayDir)) {
|
|
22
23
|
const destination = join(runDir, rel);
|
|
@@ -566,6 +567,9 @@ function summarizeTask(taskId, outcomes, survivors, judgeResults, readObservatio
|
|
|
566
567
|
};
|
|
567
568
|
}
|
|
568
569
|
export async function runExperiment(plan) {
|
|
570
|
+
const budget = plan.spendingBudget === undefined ? undefined : parseSpendingBudget(plan.spendingBudget);
|
|
571
|
+
if (budget && plan.judge)
|
|
572
|
+
throw new Error('spendingBudget does not cover judge calls.');
|
|
569
573
|
assertInputModeSupported(plan.inputMode ?? 'snapshot', plan.executor);
|
|
570
574
|
const pairOrder = plan.pairOrder ?? 'baseline-first';
|
|
571
575
|
if (pairOrder !== 'baseline-first' && pairOrder !== 'balanced')
|
|
@@ -599,6 +603,14 @@ export async function runExperiment(plan) {
|
|
|
599
603
|
const taskSummaries = [];
|
|
600
604
|
const allOutcomes = { baseline: [], treatment: [] };
|
|
601
605
|
const allSurvivors = { baseline: [], treatment: [] };
|
|
606
|
+
const budgetObservations = [];
|
|
607
|
+
const budgetEvent = (phase, taskId, condition, trial) => {
|
|
608
|
+
if (!budget)
|
|
609
|
+
return null;
|
|
610
|
+
const state = spendingBudgetState(budget, budgetObservations);
|
|
611
|
+
appendFileSync(join(groupDir, '_budget.jsonl'), JSON.stringify({ phase, taskId, condition, trial, state }) + '\n', 'utf8');
|
|
612
|
+
return state;
|
|
613
|
+
};
|
|
602
614
|
for (const [taskIndex, task] of plan.bench.tasks.entries()) {
|
|
603
615
|
const outcomes = { baseline: [], treatment: [] };
|
|
604
616
|
// Interleaved: the trial loop is outermost so the two arms of a pair run adjacently. Running
|
|
@@ -606,10 +618,19 @@ export async function runExperiment(plan) {
|
|
|
606
618
|
// provider drift or rate-limit degradation would land entirely on one arm.
|
|
607
619
|
for (let trial = 1; trial <= plan.trials; trial++) {
|
|
608
620
|
for (const condition of pairConditions(pairOrder, taskIndex, trial)) {
|
|
621
|
+
const before = budgetEvent('before-call', task.id, condition, trial);
|
|
622
|
+
if (before)
|
|
623
|
+
assertSpendingCanContinue(before);
|
|
609
624
|
plan.log?.(`Running ${task.id} / ${condition} / trial ${trial}…`);
|
|
610
625
|
const outcome = await runTrial(plan, task.id, condition, trial);
|
|
611
626
|
outcomes[condition].push(outcome);
|
|
612
627
|
allOutcomes[condition].push(outcome);
|
|
628
|
+
budgetObservations.push(outcome);
|
|
629
|
+
const after = budgetEvent('after-call', task.id, condition, trial);
|
|
630
|
+
// A reached line prevents the next call; incomplete or failed evidence stops even
|
|
631
|
+
// after the final scheduled call. One in-flight invocation may cross a stop line.
|
|
632
|
+
if (after && (after.incomplete.length || after.reason === 'EXECUTION_FAILED'))
|
|
633
|
+
assertSpendingCanContinue(after);
|
|
613
634
|
}
|
|
614
635
|
}
|
|
615
636
|
const survivors = pairedSurvivors(outcomes);
|