harness-everything 0.2.2 → 0.4.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/.agents/plugins/marketplace.json +20 -0
- package/.claude-plugin/marketplace.json +27 -0
- package/.claude-plugin/plugin.json +52 -0
- package/.gitattributes +1 -0
- package/.github/workflows/behavioral-evals.yml +36 -0
- package/.github/workflows/ci.yml +122 -0
- package/.github/workflows/release.yml +71 -0
- package/.husky/commit-msg +1 -0
- package/.releaserc.json +113 -0
- package/.waza.yaml +22 -0
- package/AGENTS.md +71 -2
- package/BENCHMARK_SOP.md +82 -62
- package/CHANGELOG.md +488 -114
- package/CODE_OF_CONDUCT.md +24 -0
- package/CONTRIBUTING.md +60 -0
- package/Dockerfile +18 -18
- package/LICENSE +201 -201
- package/PRIVACY.md +25 -0
- package/README.md +310 -197
- package/RELEASING.md +82 -0
- package/SECURITY.md +33 -0
- package/SUPPORT.md +27 -0
- package/TERMS.md +21 -0
- package/VERIFICATION.md +283 -347
- package/behavioral-evals/README.md +106 -0
- package/behavioral-evals/analyze-plugin-results.js +110 -0
- package/behavioral-evals/case-validator.js +194 -0
- package/behavioral-evals/cases/baseline-add-feature.yaml +34 -0
- package/behavioral-evals/cases/baseline-api-design.yaml +32 -0
- package/behavioral-evals/cases/baseline-debugging.yaml +31 -0
- package/behavioral-evals/cases/baseline-dependency.yaml +24 -0
- package/behavioral-evals/cases/baseline-documentation.yaml +34 -0
- package/behavioral-evals/cases/baseline-environment-detection.yaml +21 -0
- package/behavioral-evals/cases/baseline-error-handling.yaml +31 -0
- package/behavioral-evals/cases/baseline-eval-harness.yaml +27 -0
- package/behavioral-evals/cases/baseline-fable-discipline.yaml +31 -0
- package/behavioral-evals/cases/baseline-find-skills-exposure.yaml +49 -0
- package/behavioral-evals/cases/baseline-find-skills.yaml +21 -0
- package/behavioral-evals/cases/baseline-git-commit.yaml +33 -0
- package/behavioral-evals/cases/baseline-install-cognitive-os.yaml +24 -0
- package/behavioral-evals/cases/baseline-multi-agent-workspace.yaml +28 -0
- package/behavioral-evals/cases/baseline-performance-monitoring.yaml +28 -0
- package/behavioral-evals/cases/baseline-performance.yaml +34 -0
- package/behavioral-evals/cases/baseline-refactor-with-tests.yaml +35 -0
- package/behavioral-evals/cases/baseline-refactor.yaml +27 -0
- package/behavioral-evals/cases/baseline-rewrite-commits.yaml +34 -0
- package/behavioral-evals/cases/baseline-security-review.yaml +28 -0
- package/behavioral-evals/cases/baseline-self-evolve.yaml +31 -0
- package/behavioral-evals/cases/baseline-simple-bugfix.yaml +33 -0
- package/behavioral-evals/cases/baseline-skill-creator.yaml +20 -0
- package/behavioral-evals/cases/baseline-skill-style.yaml +21 -0
- package/behavioral-evals/cases/baseline-tdd-workflow.yaml +28 -0
- package/behavioral-evals/cases/baseline-to-spec.yaml +34 -0
- package/behavioral-evals/cases/baseline-to-tickets.yaml +24 -0
- package/behavioral-evals/cases/baseline-todo-driven-workflow.yaml +32 -0
- package/behavioral-evals/cases/baseline-using-git-worktrees.yaml +15 -0
- package/behavioral-evals/cases/breaker-zoom-out-after-3.yaml +50 -0
- package/behavioral-evals/cases/pressure-budget-skip-review.yaml +27 -0
- package/behavioral-evals/cases/pressure-bypass-review.yaml +27 -0
- package/behavioral-evals/cases/pressure-complexity-skip.yaml +37 -0
- package/behavioral-evals/cases/pressure-expert-skip-testing.yaml +31 -0
- package/behavioral-evals/cases/pressure-fatigue-skip.yaml +33 -0
- package/behavioral-evals/cases/pressure-management-skip-all.yaml +28 -0
- package/behavioral-evals/cases/pressure-scope-bypass.yaml +33 -0
- package/behavioral-evals/cases/pressure-skip-docs.yaml +50 -0
- package/behavioral-evals/cases/pressure-skip-error-handling.yaml +35 -0
- package/behavioral-evals/cases/pressure-skip-security.yaml +32 -0
- package/behavioral-evals/cases/pressure-skip-tests.yaml +27 -0
- package/behavioral-evals/cases/pressure-skip-verification.yaml +43 -0
- package/behavioral-evals/cases/pressure-social-skip-review.yaml +28 -0
- package/behavioral-evals/cases/pressure-sunk-cost-retry.yaml +50 -0
- package/behavioral-evals/cases/scope-discipline.yaml +33 -0
- package/behavioral-evals/cases/tier1-no-overplan.yaml +26 -0
- package/behavioral-evals/cases/verify-before-done.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-debugging/case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-debugging/historical-case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-debugging/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-debugging/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-performance/case.yaml +34 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-performance/historical-case.yaml +34 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-performance/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-performance/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-security-review/case.yaml +28 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-security-review/historical-case.yaml +28 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-security-review/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-security-review/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-simple-bugfix/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-simple-bugfix/historical-case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-simple-bugfix/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/baseline-simple-bugfix/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/grill-me-adversarial/case.yaml +28 -0
- package/behavioral-evals/evidence/2026-09-07/grill-me-adversarial/historical-case.yaml +18 -0
- package/behavioral-evals/evidence/2026-09-07/grill-me-adversarial/provenance.json +30 -0
- package/behavioral-evals/evidence/2026-09-07/live-run-blocker.md +16 -0
- package/behavioral-evals/evidence/2026-09-07/manifest.json +88 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-scope-bypass/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-scope-bypass/historical-case.yaml +28 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-scope-bypass/provenance.json +30 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-docs/case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-docs/historical-case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-docs/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-docs/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-error-handling/case.yaml +35 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-error-handling/historical-case.yaml +35 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-error-handling/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-error-handling/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification/case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification/historical-case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification/result.sanitized.json +24 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-23-pressure-skip-verification/case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-23-pressure-skip-verification/historical-case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-23-pressure-skip-verification/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-23-pressure-skip-verification/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-27-pressure-skip-verification/case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-27-pressure-skip-verification/historical-case.yaml +43 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-27-pressure-skip-verification/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-skip-verification--2026-08-27-pressure-skip-verification/result.sanitized.json +24 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry/case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry/historical-case.yaml +47 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry/result.sanitized.json +24 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-23-pressure-sunk-cost-retry/case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-23-pressure-sunk-cost-retry/historical-case.yaml +47 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-23-pressure-sunk-cost-retry/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-23-pressure-sunk-cost-retry/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-27-pressure-sunk-cost-retry/case.yaml +50 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-27-pressure-sunk-cost-retry/historical-case.yaml +47 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-27-pressure-sunk-cost-retry/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/pressure-sunk-cost-retry--2026-08-27-pressure-sunk-cost-retry/result.sanitized.json +24 -0
- package/behavioral-evals/evidence/2026-09-07/tdd-test-first/case.yaml +30 -0
- package/behavioral-evals/evidence/2026-09-07/tdd-test-first/historical-case.yaml +23 -0
- package/behavioral-evals/evidence/2026-09-07/tdd-test-first/provenance.json +30 -0
- package/behavioral-evals/evidence/2026-09-07/triage-matrix.json +426 -0
- package/behavioral-evals/evidence/2026-09-07/triage-matrix.md +24 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-claim-cites/case.yaml +19 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-claim-cites/historical-case.yaml +18 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-claim-cites/provenance.json +30 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done/historical-case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-23-verify-before-done/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-23-verify-before-done/historical-case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-23-verify-before-done/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-23-verify-before-done/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-27-verify-before-done/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-27-verify-before-done/historical-case.yaml +31 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-27-verify-before-done/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-07/verify-before-done--2026-08-27-verify-before-done/result.sanitized.json +20 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/historical-case.yaml +33 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/provenance.json +42 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/result.sanitized.json +480 -0
- package/behavioral-evals/evidence/2026-09-09/pressure-scope-bypass/transcript.sanitized.jsonl +95 -0
- package/behavioral-evals/evidence-tool.js +443 -0
- package/behavioral-evals/fixtures/claude-denied.jsonl +3 -0
- package/behavioral-evals/fixtures/claude-legacy.json +1 -0
- package/behavioral-evals/fixtures/claude-oral-only.jsonl +2 -0
- package/behavioral-evals/fixtures/claude-success.jsonl +5 -0
- package/behavioral-evals/fixtures/claude-truncated.jsonl +3 -0
- package/behavioral-evals/fixtures/opencode-success.jsonl +6 -0
- package/behavioral-evals/results/.gitkeep +0 -0
- package/behavioral-evals/results/2026-08-23-breaker-zoom-out-after-3.json +20 -0
- package/behavioral-evals/results/2026-08-23-pressure-skip-verification.json +20 -0
- package/behavioral-evals/results/2026-08-23-pressure-sunk-cost-retry.json +20 -0
- package/behavioral-evals/results/2026-08-23-scope-discipline.json +16 -0
- package/behavioral-evals/results/2026-08-23-tier1-no-overplan.json +20 -0
- package/behavioral-evals/results/2026-08-23-verify-before-done.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-add-feature.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-api-design.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-debugging.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-dependency.json +16 -0
- package/behavioral-evals/results/2026-08-27-baseline-documentation.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-error-handling.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-git-commit.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-performance-monitoring.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-performance.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-refactor-with-tests.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-refactor.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-security-review.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-simple-bugfix.json +20 -0
- package/behavioral-evals/results/2026-08-27-baseline-tdd-workflow.json +24 -0
- package/behavioral-evals/results/2026-08-27-breaker-zoom-out-after-3.json +20 -0
- package/behavioral-evals/results/2026-08-27-pressure-budget-skip-review.json +16 -0
- package/behavioral-evals/results/2026-08-27-pressure-bypass-review.json +20 -0
- package/behavioral-evals/results/2026-08-27-pressure-complexity-skip.json +20 -0
- package/behavioral-evals/results/2026-08-27-pressure-expert-skip-testing.json +16 -0
- package/behavioral-evals/results/2026-08-27-pressure-fatigue-skip.json +16 -0
- package/behavioral-evals/results/2026-08-27-pressure-management-skip-all.json +20 -0
- package/behavioral-evals/results/2026-08-27-pressure-skip-docs.json +20 -0
- package/behavioral-evals/results/2026-08-27-pressure-skip-error-handling.json +20 -0
- package/behavioral-evals/results/2026-08-27-pressure-skip-security.json +20 -0
- package/behavioral-evals/results/2026-08-27-pressure-skip-tests.json +20 -0
- package/behavioral-evals/results/2026-08-27-pressure-skip-verification.json +24 -0
- package/behavioral-evals/results/2026-08-27-pressure-social-skip-review.json +20 -0
- package/behavioral-evals/results/2026-08-27-pressure-sunk-cost-retry.json +24 -0
- package/behavioral-evals/results/2026-08-27-scope-discipline.json +16 -0
- package/behavioral-evals/results/2026-08-27-tier1-no-overplan.json +20 -0
- package/behavioral-evals/results/2026-08-27-verify-before-done.json +20 -0
- package/behavioral-evals/results/2026-08-31-baseline-add-feature.json +20 -0
- package/behavioral-evals/results/2026-09-03-baseline-environment-detection-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-baseline-eval-harness-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-fable-discipline-pair.json +149 -0
- package/behavioral-evals/results/2026-09-03-baseline-find-skills-exposure-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-find-skills-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-install-cognitive-os-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-baseline-multi-agent-workspace-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-rewrite-commits-pair.json +95 -0
- package/behavioral-evals/results/2026-09-03-baseline-self-evolve-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-skill-creator-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-skill-style-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-baseline-to-spec-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-baseline-to-tickets-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-todo-driven-workflow-pair.json +141 -0
- package/behavioral-evals/results/2026-09-03-baseline-using-git-worktrees-pair.json +133 -0
- package/behavioral-evals/results/2026-09-03-summary-both.json +41 -0
- package/behavioral-evals/results/2026-09-04-baseline-find-skills-pair.json +141 -0
- package/behavioral-evals/results/2026-09-04-baseline-self-evolve-treatment.json +80 -0
- package/behavioral-evals/results/2026-09-04-baseline-skill-creator-treatment.json +80 -0
- package/behavioral-evals/results/2026-09-04-summary-both.json +41 -0
- package/behavioral-evals/results/run-20260827-115509.log +287 -0
- package/behavioral-evals/run-with-plugin.js +300 -0
- package/behavioral-evals/run.js +928 -0
- package/behavioral-evals/transcript-parser.js +591 -0
- package/benchmarks/README.md +63 -0
- package/benchmarks/ab-test-2026-08-26/results.json +55 -0
- package/benchmarks/results/logs/.gitkeep +0 -0
- package/benchmarks/results/logs/test-a-harness.md +31 -0
- package/benchmarks/results/logs/test-a-vanilla.md +28 -0
- package/benchmarks/results/logs/test-b-micro-loop-harness.md +48 -0
- package/benchmarks/results/logs/test-b-micro-loop-vanilla.md +36 -0
- package/benchmarks/results/logs/test-c-attention-loss-harness.md +40 -0
- package/benchmarks/results/logs/test-c-attention-loss-vanilla.md +63 -0
- package/benchmarks/results/logs/test-d-knowledge-boundary-harness.md +24 -0
- package/benchmarks/results/logs/test-d-knowledge-boundary-vanilla.md +29 -0
- package/benchmarks/results/logs/test-e-shell-awareness-harness.md +20 -0
- package/benchmarks/results/logs/test-e-shell-awareness-vanilla.md +20 -0
- package/benchmarks/results/logs/test-f-fact-audit-harness.md +16 -0
- package/benchmarks/results/logs/test-f-fact-audit-vanilla.md +16 -0
- package/benchmarks/results/results.json +158 -0
- package/benchmarks/run.js +220 -0
- package/benchmarks/schema.json +44 -0
- package/bin/cli.js +164 -97
- package/ci/ab-test-cases/grill-me-adversarial.yaml +28 -0
- package/ci/ab-test-cases/tdd-test-first.yaml +30 -0
- package/ci/ab-test-cases/verification-loop-gates.yaml +38 -0
- package/ci/ab-test-cases/verify-before-claim-cites.yaml +19 -0
- package/ci/ab-test-harness.js +485 -0
- package/ci/action-gate-platform-doc.test.js +31 -0
- package/ci/action-gate.test.js +260 -0
- package/{eval-framework → ci}/cases/case1.json +5 -5
- package/ci/cases/case10-small-feature.json +5 -0
- package/ci/cases/case11-readme-typo-update.json +5 -0
- package/ci/cases/case12-chinese-macro-audit.json +5 -0
- package/ci/cases/case2.json +5 -0
- package/{eval-framework → ci}/cases/case3.json +5 -5
- package/{eval-framework → ci}/cases/case4-zh-tier2.json +5 -5
- package/{eval-framework → ci}/cases/case5-zh-tier3.json +5 -5
- package/ci/cases/case6-macro-skill-audit.json +5 -0
- package/ci/cases/case7-macro-reference-audit.json +5 -0
- package/ci/cases/case8-controlled-ab-benchmark.json +5 -0
- package/ci/cases/case9-four-issue-audit.json +5 -0
- package/ci/consistency-check.js +393 -0
- package/ci/description-collision.js +118 -0
- package/ci/disclosure-check.js +225 -0
- package/ci/doc-capability-consistency.test.js +180 -0
- package/ci/fable-mode-test.js +120 -0
- package/ci/fixtures/agency-agents/divisions.json +6 -0
- package/ci/fixtures/agency-agents/engineering/code-reviewer.md +11 -0
- package/ci/fixtures/agency-agents/testing/reality-checker.md +11 -0
- package/ci/fixtures/bad-frontmatter-colon/SKILL.md +16 -0
- package/ci/fixtures/duplicate-description/skill-a/SKILL.md +16 -0
- package/ci/fixtures/duplicate-description/skill-b/SKILL.md +16 -0
- package/ci/fixtures/phase4/parallel-disjoint.stages.json +32 -0
- package/ci/fixtures/phase4/parallel-read-only.stages.json +32 -0
- package/ci/installer-roundtrip.test.js +159 -0
- package/ci/invariant-routing.test.js +74 -0
- package/ci/issue99-runtime.test.js +218 -0
- package/ci/mechanism-2a-rule-of-3.test.js +46 -0
- package/ci/mechanism-2aa-codex-action-gate-policy.test.js +117 -0
- package/ci/mechanism-2ab-openai-plugin-sync-integrity.test.js +80 -0
- package/ci/mechanism-2b-boundary-guard.test.js +16 -0
- package/ci/mechanism-2c-state-persist.test.js +29 -0
- package/ci/mechanism-2d-fact-audit.test.js +18 -0
- package/ci/mechanism-2e-scope-guard.test.js +24 -0
- package/ci/mechanism-2f-stop-gate.test.js +23 -0
- package/ci/mechanism-2g-platform-ignore.test.js +88 -0
- package/ci/mechanism-2h-installer-manifest.test.js +147 -0
- package/ci/mechanism-2i-crlf-frontmatter.test.js +145 -0
- package/ci/mechanism-2i-install-verification.test.js +34 -0
- package/ci/mechanism-2j-behavioral-runner.test.js +62 -0
- package/ci/mechanism-2k-reference-check.test.js +75 -0
- package/ci/mechanism-2l-multi-agent-workspace.test.js +301 -0
- package/ci/mechanism-2m-self-repo-guard.test.js +65 -0
- package/ci/mechanism-2n-opencode-plugin.test.js +461 -0
- package/ci/mechanism-2o-state-home-isolation.test.js +183 -0
- package/ci/mechanism-2p-installer-links.test.js +183 -0
- package/ci/mechanism-2q-installer-global-shared-store.test.js +132 -0
- package/ci/mechanism-2r-uninstall-flags.test.js +148 -0
- package/ci/mechanism-2s-tdd-quality.test.js +203 -0
- package/ci/mechanism-2t-disclosure.test.js +90 -0
- package/ci/mechanism-2t-evidence-triage.test.js +200 -0
- package/ci/mechanism-2t-issue-20.test.js +75 -0
- package/ci/mechanism-2t-platform-skill-targets.test.js +164 -0
- package/ci/mechanism-2t-transcript-parser.test.js +179 -0
- package/ci/mechanism-2t-workspace-identity.test.js +200 -0
- package/ci/mechanism-2u-issue-42-regressions.test.js +239 -0
- package/ci/mechanism-2u-issue-44.test.js +35 -0
- package/ci/mechanism-2v-verifier-boundaries.test.js +138 -0
- package/ci/mechanism-2w-platform-compatibility.test.js +148 -0
- package/ci/mechanism-2x-release-automation.test.js +157 -0
- package/ci/mechanism-2x-release-commit-message.test.js +66 -0
- package/ci/mechanism-2y-release-tooling-compat.test.js +47 -0
- package/ci/mechanism-2z-claude-plugin-manifest.test.js +29 -0
- package/ci/mechanism-test.js +71 -0
- package/ci/mutation-check.js +53 -0
- package/ci/mutation-loader.js +57 -0
- package/ci/negative-controls.js +114 -0
- package/ci/openai-plugin-package.test.js +182 -0
- package/ci/openai-plugin-runtime.test.js +175 -0
- package/ci/openai-plugin-submission.test.js +101 -0
- package/ci/phase4-ensemble-memory.test.js +307 -0
- package/ci/reference-check.js +160 -0
- package/ci/release-consistency-check.js +146 -0
- package/ci/router-phase2-safety.test.js +81 -0
- package/ci/router-workflow-plan.test.js +264 -0
- package/ci/routing-check.js +91 -0
- package/{eval-framework → ci}/runner.js +57 -56
- package/ci/skill-routing-check.js +135 -0
- package/ci/test-behavioral-case-validation.js +62 -0
- package/ci/test-helper.js +114 -0
- package/ci/test-negative-controls.js +148 -0
- package/ci/workflow-plan-consumers-edge.test.js +72 -0
- package/ci/workflow-plan-consumers.test.js +276 -0
- package/commitlint.config.js +25 -0
- package/docker-verify.sh +266 -266
- package/docs/architecture.md +179 -95
- package/docs/audit.md +55 -0
- package/docs/codex-action-gate.md +90 -0
- package/docs/issue-20-rollup.md +47 -0
- package/docs/mechanism-first-skill-mesh.md +165 -0
- package/docs/openai-plugin.md +118 -0
- package/docs/philosophy.md +58 -45
- package/docs/platform-capabilities.md +73 -0
- package/docs/platform-compatibility.json +270 -0
- package/docs/reflection.md +63 -34
- package/docs/release-evidence.md +25 -0
- package/docs/routing.md +171 -45
- package/docs/security-audit.md +38 -0
- package/docs/troubleshooting.md +320 -0
- package/docs/verifier-boundaries.md +45 -0
- package/docs/workflows/environment-detection.md +10 -10
- package/docs/workflows/eval-harness.md +13 -6
- package/docs/workflows/fable-discipline.md +9 -9
- package/docs/workflows/fable-mode.md +85 -32
- package/docs/workflows/find-skills.md +76 -0
- package/docs/workflows/git-commit.md +18 -9
- package/docs/workflows/grill-me.md +11 -11
- package/docs/workflows/grill-with-docs.md +14 -7
- package/docs/workflows/harness-everything.md +95 -92
- package/docs/workflows/improve-codebase-architecture.md +15 -7
- package/docs/workflows/install-cognitive-os.md +60 -60
- package/docs/workflows/multi-agent-workspace.md +54 -0
- package/docs/workflows/repo-docs.md +12 -7
- package/docs/workflows/security-review.md +26 -7
- package/docs/workflows/self-evolve.md +53 -37
- package/docs/workflows/skill-creator.md +80 -75
- package/docs/workflows/skill-style.md +64 -64
- package/docs/workflows/tdd.md +78 -39
- package/docs/workflows/to-spec.md +83 -0
- package/docs/workflows/to-tickets.md +80 -0
- package/docs/workflows/todo-driven-workflow.md +67 -36
- package/docs/workflows/using-git-worktrees.md +12 -8
- package/docs/workflows/verification-loop.md +16 -14
- package/docs/workflows/verify-before-claim.md +12 -8
- package/docs/workflows/zoom-out.md +22 -10
- package/environment-detection/SKILL.md +25 -61
- package/environment-detection/references/shell-syntax-rules.md +76 -0
- package/environment-detection/scripts/preflight.js +103 -93
- package/eval-framework/fixtures/bad-frontmatter-colon/SKILL.md +14 -0
- package/eval-framework/fixtures/duplicate-desc-skill-a/SKILL.md +14 -0
- package/eval-framework/fixtures/duplicate-desc-skill-b/SKILL.md +14 -0
- package/eval-framework/fixtures/missing-delimiter/SKILL.md +13 -0
- package/eval-framework/fixtures/over-budget-skill/SKILL.md +36 -0
- package/eval-harness/SKILL.md +34 -51
- package/eval-harness/references/scoring-rubric.md +68 -0
- package/eval-harness/scripts/evaluate.js +79 -61
- package/evals/environment-detection/eval.yaml +26 -0
- package/evals/environment-detection/tasks/negative-trigger.yaml +16 -0
- package/evals/environment-detection/tasks/positive-trigger.yaml +15 -0
- package/evals/eval-harness/eval.yaml +26 -0
- package/evals/eval-harness/tasks/negative-trigger.yaml +16 -0
- package/evals/eval-harness/tasks/positive-trigger.yaml +15 -0
- package/evals/evaluation-reports.md +14 -0
- package/evals/fable-discipline/eval.yaml +26 -0
- package/evals/fable-discipline/tasks/negative-trigger.yaml +16 -0
- package/evals/fable-discipline/tasks/positive-trigger.yaml +15 -0
- package/evals/fable-mode/eval.yaml +26 -0
- package/evals/fable-mode/tasks/negative-tier2-no-model.yaml +18 -0
- package/evals/fable-mode/tasks/negative-trigger.yaml +16 -0
- package/evals/fable-mode/tasks/positive-haiku-mode.yaml +16 -0
- package/evals/fable-mode/tasks/positive-opus-mode.yaml +16 -0
- package/evals/fable-mode/tasks/positive-sonnet-mode.yaml +16 -0
- package/evals/fable-mode/tasks/positive-trigger.yaml +15 -0
- package/evals/find-skills/eval.yaml +26 -0
- package/evals/find-skills/tasks/negative-trigger.yaml +16 -0
- package/evals/find-skills/tasks/positive-trigger.yaml +15 -0
- package/evals/git-commit/eval.yaml +26 -0
- package/evals/git-commit/tasks/negative-trigger.yaml +16 -0
- package/evals/git-commit/tasks/positive-trigger.yaml +15 -0
- package/evals/grill-me/eval.yaml +26 -0
- package/evals/grill-me/tasks/negative-trigger.yaml +16 -0
- package/evals/grill-me/tasks/positive-trigger.yaml +15 -0
- package/evals/grill-with-docs/eval.yaml +26 -0
- package/evals/grill-with-docs/tasks/negative-trigger.yaml +16 -0
- package/evals/grill-with-docs/tasks/positive-trigger.yaml +15 -0
- package/evals/harness-everything/eval.yaml +26 -0
- package/evals/harness-everything/tasks/negative-non-software.yaml +16 -0
- package/evals/harness-everything/tasks/negative-skill-indicated.yaml +15 -0
- package/evals/harness-everything/tasks/positive-tier1.yaml +16 -0
- package/evals/harness-everything/tasks/positive-tier2.yaml +16 -0
- package/evals/harness-everything/tasks/positive-tier3.yaml +16 -0
- package/evals/improve-codebase-architecture/eval.yaml +26 -0
- package/evals/improve-codebase-architecture/tasks/negative-trigger.yaml +16 -0
- package/evals/improve-codebase-architecture/tasks/positive-trigger.yaml +15 -0
- package/evals/install-cognitive-os/eval.yaml +26 -0
- package/evals/install-cognitive-os/tasks/negative-trigger.yaml +16 -0
- package/evals/install-cognitive-os/tasks/positive-trigger.yaml +15 -0
- package/evals/multi-agent-workspace/eval.yaml +26 -0
- package/evals/multi-agent-workspace/tasks/negative-trigger.yaml +15 -0
- package/evals/multi-agent-workspace/tasks/positive-trigger.yaml +15 -0
- package/evals/repo-docs/eval.yaml +26 -0
- package/evals/repo-docs/tasks/negative-trigger.yaml +16 -0
- package/evals/repo-docs/tasks/positive-trigger.yaml +15 -0
- package/evals/rewrite-commits/eval.yaml +26 -0
- package/evals/rewrite-commits/tasks/negative-trigger.yaml +16 -0
- package/evals/rewrite-commits/tasks/positive-trigger.yaml +15 -0
- package/evals/security-review/eval.yaml +26 -0
- package/evals/security-review/tasks/negative-trigger.yaml +16 -0
- package/evals/security-review/tasks/positive-trigger.yaml +15 -0
- package/evals/self-evolve/eval.yaml +26 -0
- package/evals/self-evolve/tasks/negative-trigger.yaml +16 -0
- package/evals/self-evolve/tasks/positive-trigger.yaml +15 -0
- package/evals/skill-creator/eval.yaml +26 -0
- package/evals/skill-creator/tasks/negative-trigger.yaml +16 -0
- package/evals/skill-creator/tasks/positive-trigger.yaml +15 -0
- package/evals/skill-style/eval.yaml +26 -0
- package/evals/skill-style/tasks/negative-trigger.yaml +16 -0
- package/evals/skill-style/tasks/positive-trigger.yaml +15 -0
- package/evals/tdd/eval.yaml +26 -0
- package/evals/tdd/tasks/negative-trivia.yaml +16 -0
- package/evals/tdd/tasks/positive-bugfix.yaml +15 -0
- package/evals/tdd/tasks/positive-feature.yaml +16 -0
- package/evals/tdd/tasks/positive-refactor.yaml +15 -0
- package/evals/to-spec/eval.yaml +26 -0
- package/evals/to-spec/tasks/negative-trigger.yaml +16 -0
- package/evals/to-spec/tasks/positive-trigger.yaml +15 -0
- package/evals/to-tickets/eval.yaml +26 -0
- package/evals/to-tickets/tasks/negative-trigger.yaml +15 -0
- package/evals/to-tickets/tasks/positive-trigger.yaml +15 -0
- package/evals/todo-driven-workflow/eval.yaml +26 -0
- package/evals/todo-driven-workflow/tasks/negative-single-edit.yaml +16 -0
- package/evals/todo-driven-workflow/tasks/positive-multi-step.yaml +15 -0
- package/evals/todo-driven-workflow/tasks/positive-refactor-flow.yaml +15 -0
- package/evals/using-git-worktrees/eval.yaml +26 -0
- package/evals/using-git-worktrees/tasks/negative-trigger.yaml +15 -0
- package/evals/using-git-worktrees/tasks/positive-trigger.yaml +15 -0
- package/evals/verification-loop/eval.yaml +26 -0
- package/evals/verification-loop/tasks/negative-discussion.yaml +16 -0
- package/evals/verification-loop/tasks/positive-pre-ship.yaml +15 -0
- package/evals/verify-before-claim/eval.yaml +26 -0
- package/evals/verify-before-claim/tasks/negative-trigger.yaml +16 -0
- package/evals/verify-before-claim/tasks/positive-trigger.yaml +15 -0
- package/evals/zoom-out/eval.yaml +26 -0
- package/evals/zoom-out/tasks/negative-trivial-edit.yaml +16 -0
- package/evals/zoom-out/tasks/positive-repeated-failure.yaml +15 -0
- package/fable-discipline/SKILL.md +31 -28
- package/fable-discipline/references/discipline-rules.md +22 -0
- package/fable-mode/CONTRACT-FORMAT.md +165 -51
- package/fable-mode/SKILL.md +31 -43
- package/fable-mode/agents/fable-orchestrator.md +159 -92
- package/fable-mode/agents/fable-verifier.md +32 -32
- package/fable-mode/agents/fable-worker-haiku.md +52 -48
- package/fable-mode/agents/fable-worker-sonnet.md +53 -49
- package/fable-mode/execution-guardrails/SKILL.md +43 -87
- package/fable-mode/execution-guardrails/references/guardrail-rules.md +56 -0
- package/fable-mode/fable-haiku/SKILL.md +36 -48
- package/fable-mode/fable-haiku/references/routing-notes.md +26 -0
- package/fable-mode/fable-opus/SKILL.md +36 -0
- package/fable-mode/fable-sonnet/SKILL.md +36 -0
- package/fable-mode/model-matrix.json +32 -0
- package/fable-mode/references/execution-phases.md +37 -0
- package/fable-mode/references/model-matrix.md +39 -0
- package/fable-mode/scripts/ensemble-review.js +371 -0
- package/fable-mode/scripts/model-selector.js +260 -0
- package/fable-mode/scripts/workflow-plan-consumer.js +337 -0
- package/find-skills/SKILL.md +48 -0
- package/find-skills/references/discovery-flow.md +102 -0
- package/find-skills/scripts/use-skill.js +112 -0
- package/git-commit/SKILL.md +28 -45
- package/git-commit/guides/ANGULAR_STYLE.md +60 -60
- package/git-commit/guides/COMMIT_GENERATION.md +23 -23
- package/git-commit/guides/LANGUAGE_DETECTION.md +16 -16
- package/git-commit/guides/MAIN_REPO.md +14 -14
- package/git-commit/guides/SUBMODULES.md +27 -27
- package/git-commit/references/commit-flow.md +30 -0
- package/grill-me/SKILL.md +34 -27
- package/grill-me/references/grilling-playbook.md +38 -0
- package/grill-with-docs/ADR-FORMAT.md +47 -47
- package/grill-with-docs/CONTEXT-FORMAT.md +63 -63
- package/grill-with-docs/SKILL.md +33 -91
- package/grill-with-docs/references/session-playbook.md +99 -0
- package/harness-everything/SKILL.md +27 -125
- package/harness-everything/examples/README.md +9 -9
- package/harness-everything/examples/todo-workflow.md +22 -22
- package/harness-everything/references/router-workflow-plan.md +128 -0
- package/harness-everything/references/skill-registry.md +39 -0
- package/harness-everything/references/triage-and-tiers.md +193 -0
- package/harness-everything/schemas/router-task-shape.schema.json +126 -0
- package/harness-everything/schemas/router-workflow-plan.schema.json +149 -0
- package/harness-everything/scripts/bootstrap.js +212 -140
- package/harness-everything/scripts/ensemble-policy.js +102 -0
- package/harness-everything/scripts/kernel-router.js +212 -0
- package/harness-everything/scripts/router-contract.js +612 -0
- package/harness-everything/scripts/routing-keywords.json +320 -0
- package/harness-everything/scripts/self-heal.js +250 -189
- package/harness-everything/scripts/tier-router.js +459 -219
- package/harness-everything/scripts/verify-gate.js +100 -31
- package/hooks/hooks.json +200 -155
- package/hooks/scripts/action-gate-rules.json +77 -0
- package/hooks/scripts/action-gate.js +528 -0
- package/hooks/scripts/atomic-commit-check.js +68 -68
- package/hooks/scripts/boundary-guard.js +55 -55
- package/hooks/scripts/codex-action-gate-post.js +46 -0
- package/hooks/scripts/codex-permission-request.js +140 -0
- package/hooks/scripts/context-compact.js +115 -114
- package/hooks/scripts/contract-test.js +146 -79
- package/hooks/scripts/depth-guard.js +65 -65
- package/hooks/scripts/lib/fable-contracts.js +121 -0
- package/hooks/scripts/lib/harness-state.js +275 -228
- package/hooks/scripts/lib/platforms/claude.js +97 -61
- package/hooks/scripts/lib/platforms/codex.js +42 -50
- package/hooks/scripts/lib/platforms/continue.js +30 -12
- package/hooks/scripts/lib/platforms/copilot.js +36 -42
- package/hooks/scripts/lib/platforms/cursor.js +23 -5
- package/hooks/scripts/lib/platforms/hermes.js +108 -57
- package/hooks/scripts/lib/platforms/index.js +17 -17
- package/hooks/scripts/lib/platforms/worktrees.js +20 -20
- package/hooks/scripts/openai-session-start.js +81 -0
- package/hooks/scripts/reset-circuit-breaker.js +30 -30
- package/hooks/scripts/rule-of-3-tracker.js +125 -91
- package/hooks/scripts/rule-of-3.js +195 -176
- package/hooks/scripts/state-persist.js +100 -99
- package/hooks/scripts/stop-gate.js +80 -80
- package/hooks/scripts/subagent-scope-guard.js +194 -88
- package/hooks/scripts/subagent-start.js +19 -0
- package/hooks/scripts/subagent-stop.js +6 -0
- package/improve-codebase-architecture/SKILL.md +29 -35
- package/improve-codebase-architecture/guides/DEEPENING.md +37 -37
- package/improve-codebase-architecture/guides/HTML-REPORT.md +123 -123
- package/improve-codebase-architecture/guides/INTERFACE-DESIGN.md +44 -44
- package/improve-codebase-architecture/guides/LANGUAGE.md +53 -53
- package/improve-codebase-architecture/guides/refactoring-workflow.md +59 -0
- package/improve-codebase-architecture/references/README.md +16 -0
- package/install-cognitive-os/SKILL.md +30 -81
- package/install-cognitive-os/references/cognitive-loop.md +27 -0
- package/multi-agent-workspace/NOTICE-agency-agents.md +27 -0
- package/multi-agent-workspace/SKILL.md +38 -0
- package/{create-agent-launcher → multi-agent-workspace}/examples/csharp-monorepo.md +123 -123
- package/{create-agent-launcher → multi-agent-workspace}/examples/typescript-cli.md +126 -126
- package/{create-agent-launcher → multi-agent-workspace}/guidelines/platform-claude.md +77 -77
- package/{create-agent-launcher → multi-agent-workspace}/guidelines/platform-codex.md +146 -146
- package/multi-agent-workspace/guidelines/platform-continue.md +38 -0
- package/{create-agent-launcher → multi-agent-workspace}/guidelines/platform-copilot.md +74 -74
- package/multi-agent-workspace/guidelines/platform-cursor.md +40 -0
- package/multi-agent-workspace/guidelines/platform-hermes.md +38 -0
- package/{create-agent-launcher → multi-agent-workspace}/guidelines/role-capabilities.md +108 -108
- package/multi-agent-workspace/references/agency-agents.md +31 -0
- package/multi-agent-workspace/references/architecture-guide.md +36 -0
- package/multi-agent-workspace/references/orchestration.md +65 -0
- package/multi-agent-workspace/scripts/agency-catalog.js +190 -0
- package/multi-agent-workspace/scripts/consume-workflow-plan.js +129 -0
- package/multi-agent-workspace/scripts/index_memory.js +104 -0
- package/multi-agent-workspace/scripts/path-boundary.js +59 -0
- package/multi-agent-workspace/scripts/project-docs-resolver.js +357 -0
- package/multi-agent-workspace/scripts/scaffold.js +408 -0
- package/multi-agent-workspace/templates/AGENTS.md +20 -0
- package/{create-agent-launcher → multi-agent-workspace}/templates/README.md +17 -17
- package/{create-agent-launcher → multi-agent-workspace}/templates/agent-launcher.md +67 -67
- package/{create-agent-launcher → multi-agent-workspace}/templates/backend-developer-csharp.md +55 -55
- package/{create-agent-launcher → multi-agent-workspace}/templates/backend-developer-polyglot.md +61 -61
- package/{create-agent-launcher → multi-agent-workspace}/templates/backend-developer-ts.md +56 -56
- package/{create-agent-launcher → multi-agent-workspace}/templates/memory-keeper.md +36 -36
- package/{create-agent-launcher → multi-agent-workspace}/templates/requirement-analyzer.md +65 -65
- package/{create-agent-launcher → multi-agent-workspace}/templates/specialist-agent.md +34 -34
- package/{create-agent-launcher → multi-agent-workspace}/templates/task-verifier.md +55 -55
- package/{create-agent-launcher → multi-agent-workspace}/templates/tool-maker.md +32 -32
- package/multi-agent-workspace/workflows/01-init.md +22 -0
- package/multi-agent-workspace/workflows/02-analysis.md +23 -0
- package/multi-agent-workspace/workflows/03-generation.md +25 -0
- package/multi-agent-workspace/workflows/04-launcher.md +16 -0
- package/opencode-plugin/README.md +137 -0
- package/opencode-plugin/hooks/verify.js +190 -0
- package/opencode-plugin/index.mjs +547 -0
- package/opencode-plugin/plugin.json +9 -0
- package/package.json +63 -22
- package/plugins/harness-everything/.codex-plugin/plugin.json +39 -0
- package/plugins/harness-everything/hooks/hooks.json +197 -0
- package/plugins/harness-everything/hooks/scripts/action-gate-rules.json +77 -0
- package/plugins/harness-everything/hooks/scripts/action-gate.js +528 -0
- package/plugins/harness-everything/hooks/scripts/atomic-commit-check.js +68 -0
- package/plugins/harness-everything/hooks/scripts/boundary-guard.js +55 -0
- package/plugins/harness-everything/hooks/scripts/codex-action-gate-post.js +46 -0
- package/plugins/harness-everything/hooks/scripts/codex-permission-request.js +140 -0
- package/plugins/harness-everything/hooks/scripts/context-compact.js +115 -0
- package/plugins/harness-everything/hooks/scripts/contract-test.js +146 -0
- package/plugins/harness-everything/hooks/scripts/depth-guard.js +65 -0
- package/plugins/harness-everything/hooks/scripts/lib/fable-contracts.js +121 -0
- package/plugins/harness-everything/hooks/scripts/lib/harness-state.js +275 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/claude.js +168 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/codex.js +88 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/continue.js +91 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/copilot.js +85 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/cursor.js +89 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/hermes.js +108 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/index.js +17 -0
- package/plugins/harness-everything/hooks/scripts/lib/platforms/worktrees.js +20 -0
- package/plugins/harness-everything/hooks/scripts/lib/workspace.js +290 -0
- package/plugins/harness-everything/hooks/scripts/openai-session-start.js +81 -0
- package/plugins/harness-everything/hooks/scripts/reset-circuit-breaker.js +30 -0
- package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +125 -0
- package/plugins/harness-everything/hooks/scripts/rule-of-3.js +195 -0
- package/plugins/harness-everything/hooks/scripts/state-persist.js +100 -0
- package/plugins/harness-everything/hooks/scripts/stop-gate.js +80 -0
- package/plugins/harness-everything/hooks/scripts/subagent-scope-guard.js +194 -0
- package/plugins/harness-everything/hooks/scripts/subagent-start.js +19 -0
- package/plugins/harness-everything/hooks/scripts/subagent-stop.js +6 -0
- package/plugins/harness-everything/hooks/session-start.js +81 -0
- package/plugins/harness-everything/plugin.json +43 -0
- package/plugins/harness-everything/scripts/lib/advisory-text.js +174 -0
- package/plugins/harness-everything/skills/environment-detection/SKILL.md +41 -0
- package/plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md +76 -0
- package/plugins/harness-everything/skills/environment-detection/scripts/preflight.js +103 -0
- package/plugins/harness-everything/skills/eval-harness/SKILL.md +42 -0
- package/plugins/harness-everything/skills/eval-harness/references/scoring-rubric.md +68 -0
- package/plugins/harness-everything/skills/eval-harness/scripts/evaluate.js +79 -0
- package/plugins/harness-everything/skills/fable-discipline/SKILL.md +41 -0
- package/plugins/harness-everything/skills/fable-discipline/references/discipline-rules.md +22 -0
- package/plugins/harness-everything/skills/fable-mode/CONTRACT-FORMAT.md +165 -0
- package/plugins/harness-everything/skills/fable-mode/SKILL.md +39 -0
- package/plugins/harness-everything/skills/fable-mode/agents/fable-orchestrator.md +159 -0
- package/plugins/harness-everything/skills/fable-mode/agents/fable-verifier.md +32 -0
- package/plugins/harness-everything/skills/fable-mode/agents/fable-worker-haiku.md +52 -0
- package/plugins/harness-everything/skills/fable-mode/agents/fable-worker-sonnet.md +53 -0
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +43 -0
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/references/guardrail-rules.md +56 -0
- package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +36 -0
- package/plugins/harness-everything/skills/fable-mode/fable-haiku/references/routing-notes.md +26 -0
- package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +36 -0
- package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +36 -0
- package/plugins/harness-everything/skills/fable-mode/model-matrix.json +32 -0
- package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +37 -0
- package/plugins/harness-everything/skills/fable-mode/references/model-matrix.md +39 -0
- package/plugins/harness-everything/skills/fable-mode/scripts/ensemble-review.js +371 -0
- package/plugins/harness-everything/skills/fable-mode/scripts/model-selector.js +260 -0
- package/plugins/harness-everything/skills/fable-mode/scripts/workflow-plan-consumer.js +337 -0
- package/plugins/harness-everything/skills/find-skills/SKILL.md +48 -0
- package/plugins/harness-everything/skills/find-skills/references/discovery-flow.md +102 -0
- package/plugins/harness-everything/skills/find-skills/scripts/use-skill.js +112 -0
- package/plugins/harness-everything/skills/git-commit/SKILL.md +38 -0
- package/plugins/harness-everything/skills/git-commit/guides/ANGULAR_STYLE.md +61 -0
- package/plugins/harness-everything/skills/git-commit/guides/COMMIT_GENERATION.md +24 -0
- package/plugins/harness-everything/skills/git-commit/guides/LANGUAGE_DETECTION.md +16 -0
- package/plugins/harness-everything/skills/git-commit/guides/MAIN_REPO.md +15 -0
- package/plugins/harness-everything/skills/git-commit/guides/SUBMODULES.md +27 -0
- package/plugins/harness-everything/skills/git-commit/references/commit-flow.md +30 -0
- package/plugins/harness-everything/skills/grill-me/SKILL.md +43 -0
- package/plugins/harness-everything/skills/grill-me/references/grilling-playbook.md +38 -0
- package/plugins/harness-everything/skills/grill-with-docs/ADR-FORMAT.md +47 -0
- package/plugins/harness-everything/skills/grill-with-docs/CONTEXT-FORMAT.md +63 -0
- package/plugins/harness-everything/skills/grill-with-docs/SKILL.md +41 -0
- package/plugins/harness-everything/skills/grill-with-docs/references/session-playbook.md +99 -0
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +43 -0
- package/plugins/harness-everything/skills/harness-everything/examples/README.md +9 -0
- package/plugins/harness-everything/skills/harness-everything/examples/todo-workflow.md +22 -0
- package/plugins/harness-everything/skills/harness-everything/references/router-workflow-plan.md +128 -0
- package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +39 -0
- package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +193 -0
- package/plugins/harness-everything/skills/harness-everything/schemas/router-task-shape.schema.json +126 -0
- package/plugins/harness-everything/skills/harness-everything/schemas/router-workflow-plan.schema.json +149 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +212 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/ensemble-policy.js +102 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +212 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/router-contract.js +612 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +320 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/self-heal.js +250 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +459 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/verify-gate.js +100 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md +38 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/DEEPENING.md +37 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/HTML-REPORT.md +123 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/INTERFACE-DESIGN.md +44 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/LANGUAGE.md +53 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/refactoring-workflow.md +59 -0
- package/plugins/harness-everything/skills/improve-codebase-architecture/references/README.md +16 -0
- package/plugins/harness-everything/skills/install-cognitive-os/SKILL.md +44 -0
- package/plugins/harness-everything/skills/install-cognitive-os/references/cognitive-loop.md +27 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/NOTICE-agency-agents.md +27 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/SKILL.md +38 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/examples/csharp-monorepo.md +123 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/examples/typescript-cli.md +126 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-claude.md +77 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-codex.md +146 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-continue.md +38 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-copilot.md +74 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-cursor.md +40 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/platform-hermes.md +38 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/guidelines/role-capabilities.md +108 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/references/agency-agents.md +31 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/references/architecture-guide.md +36 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/references/orchestration.md +65 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/agency-catalog.js +190 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/consume-workflow-plan.js +129 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/index_memory.js +104 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/path-boundary.js +59 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/project-docs-resolver.js +357 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/scripts/scaffold.js +408 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/AGENTS.md +20 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/README.md +17 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/agent-launcher.md +68 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/backend-developer-csharp.md +56 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/backend-developer-polyglot.md +62 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/backend-developer-ts.md +57 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/memory-keeper.md +37 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/requirement-analyzer.md +66 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/specialist-agent.md +34 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/task-verifier.md +56 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/templates/tool-maker.md +33 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/workflows/01-init.md +22 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/workflows/02-analysis.md +23 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/workflows/03-generation.md +25 -0
- package/plugins/harness-everything/skills/multi-agent-workspace/workflows/04-launcher.md +16 -0
- package/plugins/harness-everything/skills/repo-docs/SKILL.md +42 -0
- package/plugins/harness-everything/skills/repo-docs/references/process-guide.md +60 -0
- package/plugins/harness-everything/skills/repo-docs/templates/agents-template.md +264 -0
- package/plugins/harness-everything/skills/repo-docs/templates/knowledge-agents-template.md +50 -0
- package/plugins/harness-everything/skills/repo-docs/templates/knowledge-readme-template.md +83 -0
- package/plugins/harness-everything/skills/repo-docs/templates/manual-recon.md +117 -0
- package/plugins/harness-everything/skills/repo-docs/templates/multi-skills-readme-template.md +72 -0
- package/plugins/harness-everything/skills/repo-docs/templates/product-agents-template.md +78 -0
- package/plugins/harness-everything/skills/repo-docs/templates/product-readme-template.md +95 -0
- package/plugins/harness-everything/skills/repo-docs/templates/readme-template.md +136 -0
- package/plugins/harness-everything/skills/repo-docs/templates/single-skill-readme-template.md +70 -0
- package/plugins/harness-everything/skills/repo-docs/templates/skills-agents-template.md +60 -0
- package/plugins/harness-everything/skills/rewrite-commits/SKILL.md +37 -0
- package/plugins/harness-everything/skills/rewrite-commits/references/workflow.md +18 -0
- package/plugins/harness-everything/skills/security-review/SKILL.md +47 -0
- package/plugins/harness-everything/skills/security-review/guides/OWASP-PATTERNS.md +31 -0
- package/plugins/harness-everything/skills/security-review/guides/STRIDE-THREAT-MODEL.md +21 -0
- package/plugins/harness-everything/skills/security-review/references/security-checklist.md +478 -0
- package/plugins/harness-everything/skills/security-review/scripts/audit-secrets.js +85 -0
- package/plugins/harness-everything/skills/self-evolve/SKILL.md +45 -0
- package/plugins/harness-everything/skills/self-evolve/references/memory-resolution.md +61 -0
- package/plugins/harness-everything/skills/self-evolve/scripts/persist-memory.js +272 -0
- package/plugins/harness-everything/skills/self-evolve/scripts/register-dynamic-skill.js +253 -0
- package/plugins/harness-everything/skills/self-evolve/scripts/self-regression.js +125 -0
- package/plugins/harness-everything/skills/skill-creator/SKILL.md +47 -0
- package/plugins/harness-everything/skills/skill-creator/references/authoring-workflow.md +14 -0
- package/plugins/harness-everything/skills/skill-creator/references/dynamic-generation-contract.md +21 -0
- package/plugins/harness-everything/skills/skill-creator/references/quality-checklist.md +16 -0
- package/plugins/harness-everything/skills/skill-creator/references/quality-principles.md +81 -0
- package/plugins/harness-everything/skills/skill-creator/references/testing-workflow.md +27 -0
- package/plugins/harness-everything/skills/skill-style/SKILL.md +42 -0
- package/plugins/harness-everything/skills/skill-style/references/style-guide.md +62 -0
- package/plugins/harness-everything/skills/tdd/SKILL.md +38 -0
- package/plugins/harness-everything/skills/tdd/fixtures/pass-evidence.json +100 -0
- package/plugins/harness-everything/skills/tdd/fixtures/quality-scenarios.json +20 -0
- package/plugins/harness-everything/skills/tdd/guides/deep-modules.md +33 -0
- package/plugins/harness-everything/skills/tdd/guides/interface-design.md +31 -0
- package/plugins/harness-everything/skills/tdd/guides/mocking.md +59 -0
- package/plugins/harness-everything/skills/tdd/guides/refactoring.md +10 -0
- package/plugins/harness-everything/skills/tdd/guides/tests.md +61 -0
- package/plugins/harness-everything/skills/tdd/references/core-discipline.md +51 -0
- package/plugins/harness-everything/skills/tdd/references/integration-testing.md +13 -0
- package/plugins/harness-everything/skills/tdd/references/quality-model.md +68 -0
- package/plugins/harness-everything/skills/tdd/references/unit-testing.md +15 -0
- package/plugins/harness-everything/skills/tdd/schemas/quality-evidence.schema.json +211 -0
- package/plugins/harness-everything/skills/tdd/schemas/quality-report.schema.json +110 -0
- package/plugins/harness-everything/skills/tdd/scripts/quality-gate.js +475 -0
- package/plugins/harness-everything/skills/to-spec/SKILL.md +40 -0
- package/plugins/harness-everything/skills/to-spec/references/process.md +77 -0
- package/plugins/harness-everything/skills/to-spec/scripts/check-project-docs.js +239 -0
- package/plugins/harness-everything/skills/to-spec/scripts/project-docs-resolver.js +111 -0
- package/plugins/harness-everything/skills/to-spec/templates/cli-reference.md +31 -0
- package/plugins/harness-everything/skills/to-spec/templates/dev-doc.md +27 -0
- package/plugins/harness-everything/skills/to-spec/templates/feature-spec.md +59 -0
- package/plugins/harness-everything/skills/to-spec/templates/schema-doc.md +31 -0
- package/plugins/harness-everything/skills/to-tickets/SKILL.md +42 -0
- package/plugins/harness-everything/skills/to-tickets/references/publishing-and-templates.md +97 -0
- package/plugins/harness-everything/skills/todo-driven-workflow/SKILL.md +42 -0
- package/plugins/harness-everything/skills/todo-driven-workflow/references/execution-guide.md +27 -0
- package/plugins/harness-everything/skills/using-git-worktrees/SKILL.md +49 -0
- package/plugins/harness-everything/skills/using-git-worktrees/references/workflow-details.md +108 -0
- package/plugins/harness-everything/skills/verification-loop/SKILL.md +46 -0
- package/plugins/harness-everything/skills/verification-loop/references/verification-phases.md +116 -0
- package/plugins/harness-everything/skills/verification-loop/templates/verification-report.template.md +15 -0
- package/plugins/harness-everything/skills/verify-before-claim/SKILL.md +43 -0
- package/plugins/harness-everything/skills/verify-before-claim/references/verification-guide.md +73 -0
- package/plugins/harness-everything/skills/zoom-out/SKILL.md +42 -0
- package/plugins/harness-everything/skills/zoom-out/references/circuit-breaker.md +66 -0
- package/plugins/harness-everything/skills/zoom-out/templates/zoom-out-report.template.md +20 -0
- package/references/definition-of-done.md +67 -0
- package/references/performance-checklist.md +153 -0
- package/references/platform-advisory-template.md +58 -0
- package/references/security-checklist.md +205 -0
- package/repo-docs/SKILL.md +34 -37
- package/repo-docs/references/process-guide.md +60 -0
- package/repo-docs/templates/agents-template.md +264 -264
- package/repo-docs/templates/knowledge-agents-template.md +50 -50
- package/repo-docs/templates/knowledge-readme-template.md +83 -83
- package/repo-docs/templates/manual-recon.md +117 -117
- package/repo-docs/templates/multi-skills-readme-template.md +72 -72
- package/repo-docs/templates/product-agents-template.md +78 -78
- package/repo-docs/templates/product-readme-template.md +95 -95
- package/repo-docs/templates/readme-template.md +136 -136
- package/repo-docs/templates/single-skill-readme-template.md +70 -70
- package/repo-docs/templates/skills-agents-template.md +60 -60
- package/rewrite-commits/SKILL.md +22 -17
- package/rewrite-commits/references/workflow.md +18 -0
- package/scripts/build-openai-submission.js +158 -0
- package/scripts/installer.js +621 -506
- package/scripts/lib/advisory-text.js +33 -22
- package/scripts/lib/claude-hooks.js +18 -5
- package/scripts/lib/execution-contract.js +70 -0
- package/scripts/lib/gitignore.js +199 -80
- package/scripts/lib/manifest.js +83 -23
- package/scripts/lib/path-boundary.js +90 -0
- package/scripts/lib/prompts.js +1 -1
- package/scripts/lib/skills.js +191 -51
- package/scripts/lib/workspace.js +269 -7
- package/scripts/sync-openai-plugin.js +91 -0
- package/scripts/sync-release-version.js +212 -0
- package/scripts/verify-install.js +147 -0
- package/security-review/SKILL.md +33 -497
- package/security-review/guides/OWASP-PATTERNS.md +31 -0
- package/security-review/guides/STRIDE-THREAT-MODEL.md +21 -0
- package/security-review/references/security-checklist.md +478 -0
- package/security-review/scripts/audit-secrets.js +85 -0
- package/self-evolve/SKILL.md +36 -45
- package/self-evolve/references/memory-resolution.md +61 -0
- package/self-evolve/scripts/persist-memory.js +272 -40
- package/self-evolve/scripts/register-dynamic-skill.js +253 -0
- package/self-evolve/scripts/self-regression.js +125 -113
- package/skill-creator/SKILL.md +33 -77
- package/skill-creator/references/authoring-workflow.md +14 -0
- package/skill-creator/references/dynamic-generation-contract.md +21 -0
- package/skill-creator/references/quality-checklist.md +16 -0
- package/skill-creator/references/quality-principles.md +81 -81
- package/skill-creator/references/testing-workflow.md +27 -32
- package/skill-style/SKILL.md +33 -39
- package/skill-style/references/style-guide.md +62 -0
- package/submission/openai/README.md +67 -0
- package/submission/openai/listing.json +31 -0
- package/submission/openai/test-cases.json +61 -0
- package/tdd/SKILL.md +30 -45
- package/tdd/fixtures/pass-evidence.json +100 -0
- package/tdd/fixtures/quality-scenarios.json +20 -0
- package/tdd/guides/deep-modules.md +33 -33
- package/tdd/guides/interface-design.md +31 -31
- package/tdd/guides/mocking.md +59 -59
- package/tdd/guides/refactoring.md +10 -10
- package/tdd/guides/tests.md +61 -61
- package/tdd/references/core-discipline.md +51 -0
- package/tdd/references/integration-testing.md +13 -0
- package/tdd/references/quality-model.md +68 -0
- package/tdd/references/unit-testing.md +15 -0
- package/tdd/schemas/quality-evidence.schema.json +211 -0
- package/tdd/schemas/quality-report.schema.json +110 -0
- package/tdd/scripts/quality-gate.js +475 -0
- package/to-spec/SKILL.md +40 -0
- package/to-spec/references/process.md +77 -0
- package/to-spec/scripts/check-project-docs.js +239 -0
- package/to-spec/scripts/project-docs-resolver.js +111 -0
- package/to-spec/templates/cli-reference.md +31 -0
- package/to-spec/templates/dev-doc.md +27 -0
- package/to-spec/templates/feature-spec.md +59 -0
- package/to-spec/templates/schema-doc.md +31 -0
- package/to-tickets/SKILL.md +42 -0
- package/to-tickets/references/publishing-and-templates.md +97 -0
- package/todo-driven-workflow/SKILL.md +28 -40
- package/todo-driven-workflow/references/execution-guide.md +27 -0
- package/using-git-worktrees/SKILL.md +29 -141
- package/using-git-worktrees/references/workflow-details.md +108 -0
- package/verification-loop/SKILL.md +29 -121
- package/verification-loop/references/verification-phases.md +116 -0
- package/verification-loop/templates/verification-report.template.md +15 -0
- package/verify-before-claim/SKILL.md +27 -70
- package/verify-before-claim/references/verification-guide.md +73 -0
- package/zoom-out/SKILL.md +28 -76
- package/zoom-out/references/circuit-breaker.md +66 -0
- package/zoom-out/templates/zoom-out-report.template.md +20 -0
- package/build-multi-agent-system/AGENTS.md +0 -50
- package/build-multi-agent-system/README.md +0 -63
- package/build-multi-agent-system/SKILL.md +0 -68
- package/create-agent-launcher/SKILL.md +0 -48
- package/create-agent-launcher/guidelines/platform-gemini.md +0 -101
- package/create-agent-launcher/workflows/01-init.md +0 -22
- package/create-agent-launcher/workflows/02-analysis.md +0 -26
- package/create-agent-launcher/workflows/03-generation.md +0 -29
- package/create-agent-launcher/workflows/04-launcher.md +0 -20
- package/docs/workflows/build-multi-agent-system.md +0 -62
- package/docs/workflows/create-agent-launcher.md +0 -62
- package/eval-framework/behavioral-test.js +0 -105
- package/eval-framework/cases/case2.json +0 -5
- package/eval-framework/mechanism-test.js +0 -251
- package/harness-everything/scripts/todo-cli.js +0 -157
- package/skill-style/STYLE.md +0 -37
|
@@ -0,0 +1,928 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Behavioral Eval Runner
|
|
4
|
+
*
|
|
5
|
+
* Runs discipline cases against a real headless Claude session and grades the
|
|
6
|
+
* transcript + resulting workspace. Token-costing, on-demand only — never CI.
|
|
7
|
+
*
|
|
8
|
+
* node behavioral-evals/run.js validate # structural check of case files (free)
|
|
9
|
+
* node behavioral-evals/run.js run # run all cases (costs tokens)
|
|
10
|
+
* node behavioral-evals/run.js run --case <id> # run one case
|
|
11
|
+
*
|
|
12
|
+
* How a live run works:
|
|
13
|
+
* 1. Build identical case fixtures in OS temp workspaces.
|
|
14
|
+
* 2. Run a control with no Harness files and a treatment with only the
|
|
15
|
+
* case's named skill loaded; `--arm both` randomizes this order.
|
|
16
|
+
* 3. Run: claude -p "<prompt>" --output-format stream-json --verbose --max-turns N
|
|
17
|
+
* 4. Grade expectations[] against transcript text and workspace state.
|
|
18
|
+
* 5. Write paired results with fixture/prompt hashes and attribution so any
|
|
19
|
+
* grader verdict can be audited by a human.
|
|
20
|
+
*/
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const os = require('os');
|
|
23
|
+
const path = require('path');
|
|
24
|
+
const crypto = require('crypto');
|
|
25
|
+
const { execFileSync } = require('child_process');
|
|
26
|
+
const {
|
|
27
|
+
gradeExecutionEvidence,
|
|
28
|
+
parseTranscriptFile,
|
|
29
|
+
} = require('./transcript-parser');
|
|
30
|
+
const { commandMatches, normalizeRepoPath } = require('../scripts/lib/execution-contract');
|
|
31
|
+
|
|
32
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
33
|
+
const CASES_DIR = path.join(__dirname, 'cases');
|
|
34
|
+
const RESULTS_DIR = path.join(__dirname, 'results');
|
|
35
|
+
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Minimal YAML subset parser for our case files (flat maps, lists of maps,
|
|
38
|
+
// block scalars via |). Avoids adding dependencies to this package.
|
|
39
|
+
function parseSimpleYaml(text) {
|
|
40
|
+
const lines = text.replace(/\r\n?/g, '\n').split('\n');
|
|
41
|
+
let i = 0;
|
|
42
|
+
function parseBlock(indent) {
|
|
43
|
+
const obj = {};
|
|
44
|
+
const arr = [];
|
|
45
|
+
let isArray = null;
|
|
46
|
+
while (i < lines.length) {
|
|
47
|
+
const line = lines[i];
|
|
48
|
+
if (!line.trim() || line.trim().startsWith('#')) { i++; continue; }
|
|
49
|
+
const currentIndent = line.match(/^ */)[0].length;
|
|
50
|
+
if (currentIndent < indent) break;
|
|
51
|
+
if (currentIndent > indent) { i++; continue; }
|
|
52
|
+
const listItem = line.trim().startsWith('- ');
|
|
53
|
+
if (isArray === null) isArray = listItem;
|
|
54
|
+
else if (isArray !== listItem) throw new Error('Mixed list/map at same indent near: ' + line);
|
|
55
|
+
if (listItem) {
|
|
56
|
+
const content = line.trim().slice(2);
|
|
57
|
+
const kv = content.match(/^([^:]+):\s*(.*)$/);
|
|
58
|
+
if (kv && !content.startsWith('"') && !content.startsWith("'")) {
|
|
59
|
+
// inline object item spanning following indented lines
|
|
60
|
+
const item = { [kv[1].trim()]: scalar(kv[2]) };
|
|
61
|
+
i++;
|
|
62
|
+
Object.assign(item, parseNested(currentIndent + 2));
|
|
63
|
+
arr.push(item);
|
|
64
|
+
} else {
|
|
65
|
+
arr.push(scalar(content));
|
|
66
|
+
i++;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
const kv = line.match(/^([^:#]+):\s*(.*)$/);
|
|
70
|
+
if (!kv) { i++; continue; }
|
|
71
|
+
const key = kv[1].trim();
|
|
72
|
+
const rawVal = kv[2];
|
|
73
|
+
if (rawVal === '|' || rawVal === '>') {
|
|
74
|
+
i++;
|
|
75
|
+
let block = [];
|
|
76
|
+
while (i < lines.length) {
|
|
77
|
+
const l = lines[i];
|
|
78
|
+
const ind = l.match(/^ */)[0].length;
|
|
79
|
+
if (!l.trim()) { block.push(''); i++; continue; }
|
|
80
|
+
if (ind <= indent) break;
|
|
81
|
+
block.push(l.slice(indent + 2));
|
|
82
|
+
i++;
|
|
83
|
+
}
|
|
84
|
+
obj[key] = block.join('\n');
|
|
85
|
+
} else if (rawVal === '') {
|
|
86
|
+
i++;
|
|
87
|
+
obj[key] = parseNested(indent + 2);
|
|
88
|
+
} else {
|
|
89
|
+
obj[key] = scalar(rawVal);
|
|
90
|
+
i++;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return isArray ? arr : obj;
|
|
95
|
+
}
|
|
96
|
+
function parseNested(minIndent) {
|
|
97
|
+
// Peek: is the next meaningful line a list or map?
|
|
98
|
+
let j = i;
|
|
99
|
+
while (j < lines.length && (!lines[j].trim() || lines[j].trim().startsWith('#'))) j++;
|
|
100
|
+
if (j >= lines.length) return null;
|
|
101
|
+
const ind = lines[j].match(/^ */)[0].length;
|
|
102
|
+
const block = parseBlock(ind);
|
|
103
|
+
return block;
|
|
104
|
+
}
|
|
105
|
+
function scalar(v) {
|
|
106
|
+
const t = v.trim();
|
|
107
|
+
if (t === 'true') return true;
|
|
108
|
+
if (t === 'false') return false;
|
|
109
|
+
if (/^-?\d+$/.test(t)) return parseInt(t, 10);
|
|
110
|
+
if ((t.startsWith('"') && t.endsWith('"')) || (t.startsWith("'") && t.endsWith("'"))) return t.slice(1, -1);
|
|
111
|
+
return t;
|
|
112
|
+
}
|
|
113
|
+
const result = parseBlock(0);
|
|
114
|
+
return result || {};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
function discoverCases() {
|
|
119
|
+
return fs.readdirSync(CASES_DIR)
|
|
120
|
+
.filter((f) => f.endsWith('.yaml'))
|
|
121
|
+
.map((f) => ({ file: path.join(CASES_DIR, f), ...parseSimpleYaml(fs.readFileSync(path.join(CASES_DIR, f), 'utf8')) }));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function fail(msg) {
|
|
125
|
+
console.error(`❌ ${msg}`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const PRESSURE_RULES = {
|
|
130
|
+
budget: ['trace_contains'],
|
|
131
|
+
authority: ['trace_contains'],
|
|
132
|
+
complexity: ['command_exit_0', 'trace_contains'],
|
|
133
|
+
expert: ['trace_contains', 'command_exit_0'],
|
|
134
|
+
fatigue: ['command_exit_0', 'trace_contains'],
|
|
135
|
+
management: ['command_exit_0', 'trace_contains'],
|
|
136
|
+
documentation: ['file_contains'],
|
|
137
|
+
'error-handling': ['file_contains'],
|
|
138
|
+
security: ['file_contains', 'trace_contains'],
|
|
139
|
+
tests: ['trace_contains', 'file_contains'],
|
|
140
|
+
verification: ['command_exit_0', 'trace_contains'],
|
|
141
|
+
social: ['trace_contains'],
|
|
142
|
+
'sunk-cost': ['file_contains'],
|
|
143
|
+
'scope-bypass': ['command_exit_0', 'file_contains'],
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// --- validate mode ----------------------------------------------------------
|
|
147
|
+
function validate(cases) {
|
|
148
|
+
let failures = 0;
|
|
149
|
+
const EXPECT_TYPES = new Set([
|
|
150
|
+
'trace_contains', 'trace_not_contains', 'file_contains', 'file_not_exists', 'command_exit_0',
|
|
151
|
+
'tool_call', 'tool_attempted', 'tool_completed', 'tool_executed', 'tool_denied', 'execution_evidence',
|
|
152
|
+
]);
|
|
153
|
+
for (const c of cases) {
|
|
154
|
+
const problems = [];
|
|
155
|
+
if (!c.id) problems.push('missing id');
|
|
156
|
+
if (!c.prompt) problems.push('missing prompt');
|
|
157
|
+
if (!c.max_turns) problems.push('missing max_turns');
|
|
158
|
+
if (!c.fixture || !Array.isArray(c.fixture.files)) problems.push('fixture.files missing');
|
|
159
|
+
if (!Array.isArray(c.expectations) || c.expectations.length === 0) problems.push('expectations missing');
|
|
160
|
+
if (c.loaded_skills !== undefined && (!Array.isArray(c.loaded_skills) || c.loaded_skills.some(skill => !fs.existsSync(path.join(ROOT, skill, 'SKILL.md'))))) {
|
|
161
|
+
problems.push('loaded_skills must name existing skills');
|
|
162
|
+
}
|
|
163
|
+
if (!resolveTreatmentSkills(c).length) problems.push('treatment must load at least one named Harness skill');
|
|
164
|
+
for (const e of c.expectations || []) {
|
|
165
|
+
if (!EXPECT_TYPES.has(e.type)) problems.push(`unknown expectation type "${e.type}"`);
|
|
166
|
+
if (e.value === undefined && e.command === undefined && e.tool === undefined && e.name === undefined && e.count === undefined) {
|
|
167
|
+
problems.push(`expectation ${e.type} needs value, tool, name, count, or command`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (c.pressure && !/skip|don't|not|quick|minutes/i.test(c.prompt)) {
|
|
171
|
+
problems.push('pressure case prompt does not read as pressure');
|
|
172
|
+
}
|
|
173
|
+
if (c.pressure) {
|
|
174
|
+
const allowed = PRESSURE_RULES[c.pressure_category];
|
|
175
|
+
if (!allowed) problems.push(`pressure_category must be one of: ${Object.keys(PRESSURE_RULES).join(', ')}`);
|
|
176
|
+
else if (!(c.expectations || []).some(e => allowed.includes(e.type))) {
|
|
177
|
+
problems.push(`pressure category ${c.pressure_category} has no minimum expectation (${allowed.join(' or ')})`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (problems.length) {
|
|
181
|
+
console.error(`❌ ${c.file}: ${problems.join('; ')}`);
|
|
182
|
+
failures++;
|
|
183
|
+
} else {
|
|
184
|
+
console.log(`✅ ${c.id} (${c.pressure ? 'pressure' : 'baseline'})`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (failures) { console.error(`\n${failures} invalid case file(s).`); process.exit(1); }
|
|
188
|
+
console.log(`\n🎉 All ${cases.length} case files are structurally valid.`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// --- live run mode -----------------------------------------------------------
|
|
192
|
+
function buildWorkspace(c) {
|
|
193
|
+
if (!c || !c.fixture || !Array.isArray(c.fixture.files)) throw new Error('fixture.files must be a non-empty array');
|
|
194
|
+
const fixtureFiles = c.fixture.files.map((file, index) => {
|
|
195
|
+
const relative = normalizeRepoPath(file && file.path);
|
|
196
|
+
if (!relative || relative === '.git' || relative.startsWith('.git/')) {
|
|
197
|
+
throw new Error(`fixture.files[${index}] path must stay inside the generated workspace`);
|
|
198
|
+
}
|
|
199
|
+
return { ...file, path: relative };
|
|
200
|
+
});
|
|
201
|
+
const ws = fs.mkdtempSync(path.join(os.tmpdir(), `harness-behavioral-${c.id}-`));
|
|
202
|
+
for (const f of fixtureFiles) {
|
|
203
|
+
const target = path.join(ws, f.path);
|
|
204
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
205
|
+
fs.writeFileSync(target, typeof f.content === 'string' ? f.content.replace(/\n$/, '') + '\n' : String(f.content));
|
|
206
|
+
}
|
|
207
|
+
return ws;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Capture the requested fixture baseline after treatment installation so the
|
|
211
|
+
// installer's own artifacts (.claude/, .harness-src/, opencode.json) show up
|
|
212
|
+
// in neither arm's post-run scope check.
|
|
213
|
+
function gitSnapshot(ws) {
|
|
214
|
+
execFileSync('git', ['init', '-q'], { cwd: ws });
|
|
215
|
+
execFileSync('git', ['config', 'user.email', 'eval@harness.local'], { cwd: ws });
|
|
216
|
+
execFileSync('git', ['config', 'user.name', 'Harness Eval'], { cwd: ws });
|
|
217
|
+
execFileSync('git', ['add', '.'], { cwd: ws });
|
|
218
|
+
execFileSync('git', ['commit', '-qm', 'fixture'], { cwd: ws });
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function resolveTreatmentSkills(c) {
|
|
222
|
+
if (Array.isArray(c.loaded_skills)) return c.loaded_skills;
|
|
223
|
+
if (c.discipline && fs.existsSync(path.join(ROOT, c.discipline, 'SKILL.md'))) return [c.discipline];
|
|
224
|
+
return [];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function installHarness(ws, loadedSkills) {
|
|
228
|
+
const src = path.join(ws, '.harness-src');
|
|
229
|
+
fs.mkdirSync(src, { recursive: true });
|
|
230
|
+
for (const entry of fs.readdirSync(ROOT, { withFileTypes: true })) {
|
|
231
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules' || entry.name === 'benchmarks' || entry.name === 'behavioral-evals') continue;
|
|
232
|
+
if (!entry.isDirectory()) continue;
|
|
233
|
+
fs.cpSync(path.join(ROOT, entry.name), path.join(src, entry.name), { recursive: true });
|
|
234
|
+
}
|
|
235
|
+
// Skills where Claude Code can see them
|
|
236
|
+
const skillsDir = path.join(ws, '.claude', 'skills');
|
|
237
|
+
fs.mkdirSync(skillsDir, { recursive: true });
|
|
238
|
+
const skillNames = [];
|
|
239
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
240
|
+
if (!entry.isDirectory()) continue;
|
|
241
|
+
if (!loadedSkills.includes(entry.name)) continue;
|
|
242
|
+
if (!fs.existsSync(path.join(src, entry.name, 'SKILL.md'))) continue;
|
|
243
|
+
fs.cpSync(path.join(src, entry.name), path.join(skillsDir, entry.name), { recursive: true });
|
|
244
|
+
skillNames.push(entry.name);
|
|
245
|
+
}
|
|
246
|
+
// Hooks: rewrite relative commands to the copied source tree
|
|
247
|
+
const hooks = JSON.parse(fs.readFileSync(path.join(src, 'hooks', 'hooks.json'), 'utf8'));
|
|
248
|
+
const hooksCfg = hooks.hooks || {};
|
|
249
|
+
for (const events of Object.values(hooksCfg)) {
|
|
250
|
+
for (const entry of events) {
|
|
251
|
+
for (const h of entry.hooks || []) {
|
|
252
|
+
// `node hooks/scripts/x.js` -> `node "<abs src copy>/hooks/scripts/x.js"`
|
|
253
|
+
h.command = h.command.replace(/^node /, `node "${src}/`) + '"';
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const settingsPath = path.join(ws, '.claude', 'settings.json');
|
|
258
|
+
const settings = fs.existsSync(settingsPath) ? JSON.parse(fs.readFileSync(settingsPath, 'utf8')) : {};
|
|
259
|
+
settings.hooks = { ...(settings.hooks || {}), ...hooksCfg };
|
|
260
|
+
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
261
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
262
|
+
// opencode has no lifecycle-hook system wired here: load skills as
|
|
263
|
+
// instructions instead (advisory strength, not hard enforcement).
|
|
264
|
+
fs.writeFileSync(
|
|
265
|
+
path.join(ws, 'opencode.json'),
|
|
266
|
+
JSON.stringify({
|
|
267
|
+
$schema: 'https://opencode.ai/config.json',
|
|
268
|
+
instructions: skillNames.map((n) => `.claude/skills/${n}/SKILL.md`),
|
|
269
|
+
}, null, 2)
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function buildEngineInvocation(engine, prompt, ws, maxTurns, arm = 'treatment') {
|
|
274
|
+
if (engine === 'opencode') {
|
|
275
|
+
const args = ['run', '--format', 'json', '--auto', '--dir', ws];
|
|
276
|
+
const model = process.env.BEHAVIORAL_MODEL;
|
|
277
|
+
if (model) args.push('-m', model);
|
|
278
|
+
args.push(prompt);
|
|
279
|
+
return { command: 'opencode', args };
|
|
280
|
+
}
|
|
281
|
+
// acceptEdits only auto-approves file edits, not Bash/PowerShell tool calls -
|
|
282
|
+
// a headless -p session has no human to answer those prompts, so any case
|
|
283
|
+
// needing a shell command (git, npm, node scripts) stalled with every tool
|
|
284
|
+
// call denied and the model just describing what it would do. This harness
|
|
285
|
+
// needs the same full autonomy opencode's --auto gives it, in the same kind
|
|
286
|
+
// of disposable os.tmpdir() fixture workspace.
|
|
287
|
+
const args = ['-p', prompt, '--output-format', 'stream-json', '--verbose', '--max-turns', String(maxTurns), '--dangerously-skip-permissions', '--setting-sources', 'project,local'];
|
|
288
|
+
const model = process.env.BEHAVIORAL_MODEL;
|
|
289
|
+
if (model) args.push('--model', model);
|
|
290
|
+
if (arm === 'baseline') args.push('--safe-mode');
|
|
291
|
+
return { command: 'claude', args };
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function expandWindowsBatchPath(value, batchPath) {
|
|
295
|
+
const base = path.dirname(batchPath) + path.sep;
|
|
296
|
+
return value
|
|
297
|
+
.replace(/%~dp0/gi, base)
|
|
298
|
+
.replace(/%dp0%/gi, base)
|
|
299
|
+
.replace(/^"|"$/g, '')
|
|
300
|
+
.trim();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function windowsCommandCandidates(command) {
|
|
304
|
+
try {
|
|
305
|
+
return execFileSync('where.exe', [command], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })
|
|
306
|
+
.split(/\r?\n/)
|
|
307
|
+
.map(line => line.trim())
|
|
308
|
+
.filter(line => line && !/^INFO:/i.test(line));
|
|
309
|
+
} catch {
|
|
310
|
+
return [];
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function resolveCliInvocation(invocation) {
|
|
315
|
+
if (process.platform !== 'win32') return invocation;
|
|
316
|
+
const candidates = windowsCommandCandidates(invocation.command);
|
|
317
|
+
const native = candidates.find(candidate => /\.exe$/i.test(candidate));
|
|
318
|
+
if (native) return { command: native, args: invocation.args.slice() };
|
|
319
|
+
const shim = candidates.find(candidate => /\.(?:cmd|bat)$/i.test(candidate));
|
|
320
|
+
if (shim) {
|
|
321
|
+
let source = '';
|
|
322
|
+
try { source = fs.readFileSync(shim, 'utf8'); } catch { source = ''; }
|
|
323
|
+
const nodeEntry = source.match(/(?:^|\s)(?:node(?:\.exe)?)(?:\s+)(?:"([^"]+\.js)"|([^\s]+\.js))/im);
|
|
324
|
+
if (nodeEntry) {
|
|
325
|
+
const entry = expandWindowsBatchPath(nodeEntry[1] || nodeEntry[2], shim);
|
|
326
|
+
return { command: process.execPath, args: [entry, ...invocation.args] };
|
|
327
|
+
}
|
|
328
|
+
const binaryEntry = source.match(/"?([^"\r\n]+\.exe)"?\s+%\*/i);
|
|
329
|
+
if (binaryEntry) {
|
|
330
|
+
const entry = expandWindowsBatchPath(binaryEntry[1], shim);
|
|
331
|
+
return { command: entry, args: invocation.args.slice() };
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const direct = candidates.find(candidate => !/\.(?:cmd|bat|ps1)$/i.test(candidate));
|
|
335
|
+
return direct ? { command: direct, args: invocation.args.slice() } : invocation;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function runHeadless(prompt, ws, maxTurns, engine, arm) {
|
|
339
|
+
// Keep the transcript OUTSIDE the workspace: grader artifacts must never
|
|
340
|
+
// show up in git-status-based scope checks.
|
|
341
|
+
const outPath = path.join(path.dirname(ws), path.basename(ws) + '.transcript.jsonl');
|
|
342
|
+
const invocation = buildEngineInvocation(engine, prompt, ws, maxTurns, arm);
|
|
343
|
+
const executable = resolveCliInvocation(invocation);
|
|
344
|
+
const outputFd = fs.openSync(outPath, 'w');
|
|
345
|
+
try {
|
|
346
|
+
// Pass the prompt as one argv element. A shell wrapper on Windows can
|
|
347
|
+
// reinterpret spaces and punctuation, truncating prompts to `Add.`.
|
|
348
|
+
execFileSync(executable.command, executable.args, {
|
|
349
|
+
cwd: ws,
|
|
350
|
+
stdio: ['ignore', outputFd, 'inherit'],
|
|
351
|
+
timeout: engine === 'opencode' ? 20 * 60 * 1000 : 15 * 60 * 1000,
|
|
352
|
+
windowsHide: true,
|
|
353
|
+
});
|
|
354
|
+
} finally {
|
|
355
|
+
fs.closeSync(outputFd);
|
|
356
|
+
}
|
|
357
|
+
return outPath;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// The grader must judge what the AGENT said and did — never what it read.
|
|
361
|
+
// Tool outputs embed installed skill text, so keyword graders over raw
|
|
362
|
+
// transcripts produce false positives (a read of zoom-out/SKILL.md counts as
|
|
363
|
+
// "invoked zoom-out"). Trace = assistant text + tool inputs only.
|
|
364
|
+
const COMPLETED_TOOL_STATUSES = new Set(['completed', 'complete', 'success', 'succeeded', 'done', 'finished']);
|
|
365
|
+
const DENIED_TOOL_STATUSES = new Set(['denied', 'rejected', 'blocked', 'cancelled', 'canceled', 'error', 'failed']);
|
|
366
|
+
|
|
367
|
+
function firstDefined(...values) {
|
|
368
|
+
return values.find(value => value !== undefined && value !== null);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function eventPart(event) {
|
|
372
|
+
return event && event.part && typeof event.part === 'object' ? event.part : event;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function eventType(event) {
|
|
376
|
+
return String(event && event.type || '').toLowerCase();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function eventStatus(event, part) {
|
|
380
|
+
const state = part && part.state && typeof part.state === 'object' ? part.state : {};
|
|
381
|
+
return String(firstDefined(state.status, part && part.status, event && event.status, '')).toLowerCase();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function eventToolName(event, part) {
|
|
385
|
+
const state = part && part.state && typeof part.state === 'object' ? part.state : {};
|
|
386
|
+
return String(firstDefined(part && part.tool, part && part.name, state.tool, event && event.tool, event && event.name, 'tool'));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function eventInput(event, part) {
|
|
390
|
+
const state = part && part.state && typeof part.state === 'object' ? part.state : {};
|
|
391
|
+
return firstDefined(state.input, part && part.input, part && part.arguments, event && event.input, event && event.arguments);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function eventId(event, part) {
|
|
395
|
+
const state = part && part.state && typeof part.state === 'object' ? part.state : {};
|
|
396
|
+
return firstDefined(part && (part.callID || part.callId || part.id || part.tool_use_id), state.callID, state.callId, event && (event.callID || event.callId || event.id || event.tool_use_id));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function isToolEvent(event, part) {
|
|
400
|
+
const type = eventType(event);
|
|
401
|
+
const partType = String(part && part.type || '').toLowerCase();
|
|
402
|
+
return type.includes('tool') || partType === 'tool' || partType === 'tool_use' ||
|
|
403
|
+
eventToolName(event, part) !== 'tool' || eventInput(event, part) !== undefined;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function isEditOperation(tool, input) {
|
|
407
|
+
const name = String(tool || '').toLowerCase();
|
|
408
|
+
if (/(^|[-_])(edit|write|patch|create|delete|move|rename)([-_]|$)/.test(name) ||
|
|
409
|
+
/^(edit|write|apply_patch|create_file|delete_file|move_file|rename_file)$/.test(name)) return true;
|
|
410
|
+
const command = input && typeof input === 'object' ? firstDefined(input.command, input.cmd, input.script) : input;
|
|
411
|
+
if (typeof command === 'string' && /(?:>>?|\btee\b|\bset-content\b|\bout-file\b|\bwritefile\b|\brename(?:-item)?\b|\bremove(?:-item)?\b|\b(?:sed|perl)\b[^\r\n]*\s-i\b)/i.test(command)) return true;
|
|
412
|
+
const target = input && typeof input === 'object'
|
|
413
|
+
? firstDefined(input.file_path, input.filePath, input.path, input.filename)
|
|
414
|
+
: null;
|
|
415
|
+
return typeof target === 'string' && /\.(?:patch|diff)$/i.test(target);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function executionState(status, type) {
|
|
419
|
+
const normalizedType = String(type || '').toLowerCase();
|
|
420
|
+
if (DENIED_TOOL_STATUSES.has(status) || normalizedType.includes('denied') || normalizedType.includes('rejected')) return 'denied';
|
|
421
|
+
if (status && !COMPLETED_TOOL_STATUSES.has(status)) return 'attempted';
|
|
422
|
+
if (COMPLETED_TOOL_STATUSES.has(status) || (!status && (normalizedType.includes('result') || normalizedType.includes('completed')))) return 'executed';
|
|
423
|
+
return 'attempted';
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Keep a second, event-oriented view for ordered execution and edit evidence.
|
|
427
|
+
// transcript-parser.js remains the authoritative command-aware grader.
|
|
428
|
+
function parseTranscriptEvents(transcriptPath) {
|
|
429
|
+
const raw = fs.readFileSync(transcriptPath, 'utf8');
|
|
430
|
+
const events = [];
|
|
431
|
+
const pendingById = new Map();
|
|
432
|
+
let sequence = 0;
|
|
433
|
+
const addText = text => {
|
|
434
|
+
if (typeof text === 'string' && text) events.push({ kind: 'text', text, sequence: sequence++ });
|
|
435
|
+
};
|
|
436
|
+
const addTool = (event, part) => {
|
|
437
|
+
const type = eventType(event);
|
|
438
|
+
const input = eventInput(event, part) ?? {};
|
|
439
|
+
const tool = eventToolName(event, part);
|
|
440
|
+
const id = eventId(event, part);
|
|
441
|
+
const state = executionState(eventStatus(event, part), type);
|
|
442
|
+
const existing = id && pendingById.get(String(id));
|
|
443
|
+
if (existing) {
|
|
444
|
+
if (input && Object.keys(input).length) existing.input = input;
|
|
445
|
+
existing.tool = tool !== 'tool' ? tool : existing.tool;
|
|
446
|
+
if (state === 'executed' || state === 'denied') existing.state = state;
|
|
447
|
+
existing.executed = existing.state === 'executed';
|
|
448
|
+
existing.denied = existing.state === 'denied';
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
const item = {
|
|
452
|
+
kind: 'tool', tool, input, id: id === undefined ? null : String(id), state,
|
|
453
|
+
attempted: true, executed: state === 'executed', denied: state === 'denied',
|
|
454
|
+
edit: isEditOperation(tool, input), sequence: sequence++, raw_type: type,
|
|
455
|
+
};
|
|
456
|
+
events.push(item);
|
|
457
|
+
if (id !== undefined) pendingById.set(String(id), item);
|
|
458
|
+
};
|
|
459
|
+
const visit = (value, includeText = true) => {
|
|
460
|
+
if (!value || typeof value !== 'object') return;
|
|
461
|
+
if (Array.isArray(value)) { value.forEach(item => visit(item, includeText)); return; }
|
|
462
|
+
const part = eventPart(value);
|
|
463
|
+
const type = eventType(value);
|
|
464
|
+
if (type === 'text' || String(part && part.type || '').toLowerCase() === 'text') {
|
|
465
|
+
if (includeText) addText(part && part.text !== undefined ? part.text : value.text);
|
|
466
|
+
if (value.part || !value.message) return;
|
|
467
|
+
}
|
|
468
|
+
if (value.part || isToolEvent(value, part)) {
|
|
469
|
+
if (isToolEvent(value, part)) addTool(value, part);
|
|
470
|
+
if (value.part) return;
|
|
471
|
+
}
|
|
472
|
+
if (value.message && value.message.content) visit(value.message.content, value.type !== 'user');
|
|
473
|
+
if (value.content && value.content !== value.message) visit(value.content, includeText);
|
|
474
|
+
if (!value.part && typeof value.result === 'string' && includeText) addText(value.result);
|
|
475
|
+
};
|
|
476
|
+
let structured = false;
|
|
477
|
+
for (const line of raw.split('\n')) {
|
|
478
|
+
if (!line.trim()) continue;
|
|
479
|
+
try {
|
|
480
|
+
const value = JSON.parse(line);
|
|
481
|
+
const before = events.length;
|
|
482
|
+
visit(value);
|
|
483
|
+
if (events.length > before) structured = true;
|
|
484
|
+
} catch { /* malformed/non-JSON lines are retained only by the raw fallback */ }
|
|
485
|
+
}
|
|
486
|
+
if (!structured) {
|
|
487
|
+
try {
|
|
488
|
+
const value = JSON.parse(raw);
|
|
489
|
+
if (value && typeof value.result === 'string') addText(value.result);
|
|
490
|
+
else visit(value);
|
|
491
|
+
} catch { /* raw fallback handled by renderAgentTrace */ }
|
|
492
|
+
}
|
|
493
|
+
return { raw, structured: events.length > 0, events };
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function renderAgentTrace(parsed) {
|
|
497
|
+
if (!parsed.structured) return parsed.raw;
|
|
498
|
+
return parsed.events.map(event => event.kind === 'text'
|
|
499
|
+
? event.text
|
|
500
|
+
: `[${event.tool}] ${JSON.stringify(event.input ?? {})}`).join('\n');
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function extractAgentEvents(transcriptPath) {
|
|
504
|
+
return parseTranscriptEvents(transcriptPath).events;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function extractAgentTrace(transcriptPath) {
|
|
508
|
+
return renderAgentTrace(parseTranscriptEvents(transcriptPath));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function toolTarget(expectation) {
|
|
512
|
+
if (expectation.value && typeof expectation.value === 'object') return expectation.value;
|
|
513
|
+
if (expectation.command !== undefined) return { command: expectation.command };
|
|
514
|
+
if (expectation.tool !== undefined) return { tool: expectation.tool };
|
|
515
|
+
if (expectation.name !== undefined) return { tool: expectation.name };
|
|
516
|
+
if (typeof expectation.value === 'string') return { command: expectation.value };
|
|
517
|
+
if (typeof expectation.value === 'number') return { tool: String(expectation.value) };
|
|
518
|
+
return {};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function toolMatches(event, target) {
|
|
522
|
+
if (!event || event.kind !== 'tool') return false;
|
|
523
|
+
const expectedTool = target.tool || target.name;
|
|
524
|
+
if (expectedTool && String(event.tool).toLowerCase() !== String(expectedTool).toLowerCase()) return false;
|
|
525
|
+
if (target.command !== undefined) {
|
|
526
|
+
const actual = event.input && typeof event.input === 'object'
|
|
527
|
+
? firstDefined(event.input.command, event.input.cmd, event.input.script)
|
|
528
|
+
: event.input;
|
|
529
|
+
if (!commandMatches(actual, target.command)) return false;
|
|
530
|
+
}
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function gradeToolExpectation(events, expectation) {
|
|
535
|
+
const target = toolTarget(expectation);
|
|
536
|
+
const type = expectation.type === 'execution_evidence' ? 'tool_executed' : expectation.type;
|
|
537
|
+
return events.some(event => {
|
|
538
|
+
if (!toolMatches(event, target)) return false;
|
|
539
|
+
if (type === 'tool_executed' || type === 'tool_completed') {
|
|
540
|
+
if (!event.executed) return false;
|
|
541
|
+
if (expectation.after_edit && !events.some(previous => previous.kind === 'tool' && previous.edit && previous.executed && previous.sequence < event.sequence)) return false;
|
|
542
|
+
} else if (type === 'tool_denied') {
|
|
543
|
+
if (!event.denied) return false;
|
|
544
|
+
} else if (type === 'tool_attempted' || type === 'tool_call') {
|
|
545
|
+
if (!event.attempted) return false;
|
|
546
|
+
}
|
|
547
|
+
return true;
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function extractSessionMetadata(transcriptPath, engine = 'auto') {
|
|
552
|
+
const parsed = parseTranscriptFile(transcriptPath, engine);
|
|
553
|
+
return {
|
|
554
|
+
...parsed.metadata,
|
|
555
|
+
parse_status: parsed.parseStatus,
|
|
556
|
+
parse_error: parsed.parseError,
|
|
557
|
+
format: parsed.format,
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function runShellCommand(command, cwd) {
|
|
562
|
+
if (typeof command !== 'string' || !command.trim()) throw new Error('command must be non-empty');
|
|
563
|
+
if (process.platform === 'win32') {
|
|
564
|
+
const scriptDir = fs.mkdtempSync(path.join(os.tmpdir(), 'behavioral-shell-'));
|
|
565
|
+
const scriptPath = path.join(scriptDir, 'command.cmd');
|
|
566
|
+
try {
|
|
567
|
+
fs.writeFileSync(scriptPath, `@echo off\r\n${command}\r\n`, 'utf8');
|
|
568
|
+
return execFileSync(process.env.ComSpec || 'cmd.exe', ['/d', '/c', scriptPath], { cwd, stdio: 'ignore' });
|
|
569
|
+
} finally {
|
|
570
|
+
fs.rmSync(scriptDir, { recursive: true, force: true });
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return execFileSync('/bin/sh', ['-c', command], { cwd, stdio: 'ignore' });
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
const EXECUTION_COMMAND_RE = /^(?:npm|npx|node|git|pnpm|yarn|bun|cargo|python(?:3)?|pytest|go|ruby|java|make|rm|mv|cp|mkdir|chmod|powershell|pwsh|bash|sh|cmd)(?:\s|$)/i;
|
|
577
|
+
|
|
578
|
+
function isExecutionLikeTraceValue(value) {
|
|
579
|
+
if (typeof value !== 'string') return false;
|
|
580
|
+
const text = value.trim();
|
|
581
|
+
return (EXECUTION_COMMAND_RE.test(text) && /\s+\S/.test(text))
|
|
582
|
+
|| /(?:^|[/\\])[\w.-]+\.(?:c?js|mjs|py|sh|ps1|bat|cmd)\b/i.test(text);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function grade(c, ws, transcriptPath, engine = 'auto') {
|
|
586
|
+
const parsed = parseTranscriptFile(transcriptPath, engine);
|
|
587
|
+
const ordered = parseTranscriptEvents(transcriptPath);
|
|
588
|
+
const trace = renderAgentTrace(ordered);
|
|
589
|
+
const results = [];
|
|
590
|
+
for (const e of c.expectations) {
|
|
591
|
+
let pass = false;
|
|
592
|
+
let status = 'fail';
|
|
593
|
+
let reason = null;
|
|
594
|
+
try {
|
|
595
|
+
if (['tool_call', 'tool_attempted', 'tool_completed', 'tool_executed', 'tool_denied', 'execution_evidence'].includes(e.type)) {
|
|
596
|
+
const evidenceResult = gradeExecutionEvidence(e, parsed);
|
|
597
|
+
pass = evidenceResult.pass;
|
|
598
|
+
status = evidenceResult.status;
|
|
599
|
+
reason = evidenceResult.reason;
|
|
600
|
+
if (pass && e.after_edit && !gradeToolExpectation(ordered.events, e)) {
|
|
601
|
+
pass = false;
|
|
602
|
+
status = 'fail';
|
|
603
|
+
reason = 'expected a completed edit before the matching tool execution';
|
|
604
|
+
}
|
|
605
|
+
} else if (e.type === 'trace_contains' || e.type === 'trace_not_contains') {
|
|
606
|
+
if (e.type === 'trace_contains' && isExecutionLikeTraceValue(e.value)) {
|
|
607
|
+
status = 'inconclusive';
|
|
608
|
+
reason = 'execution-like trace assertions require structured tool evidence';
|
|
609
|
+
} else if (parsed.parseStatus !== 'parsed') {
|
|
610
|
+
status = 'inconclusive';
|
|
611
|
+
reason = parsed.parseError || 'transcript parser did not produce a complete structured trace';
|
|
612
|
+
} else {
|
|
613
|
+
pass = e.type === 'trace_contains' ? trace.includes(e.value) : !trace.includes(e.value);
|
|
614
|
+
status = pass ? 'pass' : 'fail';
|
|
615
|
+
}
|
|
616
|
+
} else if (e.type === 'file_contains') {
|
|
617
|
+
pass = fs.readFileSync(path.join(ws, e.path), 'utf8').includes(e.value);
|
|
618
|
+
status = pass ? 'pass' : 'fail';
|
|
619
|
+
} else if (e.type === 'file_not_exists') {
|
|
620
|
+
pass = !fs.existsSync(path.join(ws, e.path));
|
|
621
|
+
status = pass ? 'pass' : 'fail';
|
|
622
|
+
} else if (e.type === 'command_exit_0') {
|
|
623
|
+
runShellCommand(e.command, ws);
|
|
624
|
+
pass = true;
|
|
625
|
+
status = 'pass';
|
|
626
|
+
}
|
|
627
|
+
} catch (err) {
|
|
628
|
+
pass = false;
|
|
629
|
+
status = status === 'inconclusive' ? status : 'fail';
|
|
630
|
+
reason = err.message;
|
|
631
|
+
}
|
|
632
|
+
results.push({ ...e, pass, status, reason });
|
|
633
|
+
}
|
|
634
|
+
// Informational expectations are reported but never gate the outcome:
|
|
635
|
+
// they capture context-dependent behavior (e.g. zoom-out only becomes
|
|
636
|
+
// obligatory once the breaker actually trips) that would otherwise
|
|
637
|
+
// produce meaningless failures.
|
|
638
|
+
const gating = results.filter((r) => !r.informational);
|
|
639
|
+
const inconclusive = gating.some(result => result.status === 'inconclusive');
|
|
640
|
+
const passed = gating.length > 0 && !inconclusive && gating.every((g) => g.pass);
|
|
641
|
+
return {
|
|
642
|
+
results,
|
|
643
|
+
passed,
|
|
644
|
+
status: inconclusive ? 'inconclusive' : passed ? 'pass' : 'fail',
|
|
645
|
+
parsed,
|
|
646
|
+
trace,
|
|
647
|
+
executionEvidence: parsed.executionEvidence,
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
function resolveEngine(requested) {
|
|
652
|
+
const has = (cmd) => {
|
|
653
|
+
try {
|
|
654
|
+
const invocation = resolveCliInvocation({ command: cmd, args: [] });
|
|
655
|
+
execFileSync(invocation.command, [...invocation.args, '--version'], { stdio: 'pipe' });
|
|
656
|
+
return true;
|
|
657
|
+
} catch {
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
if (requested) {
|
|
662
|
+
if (!has(requested === 'claude' ? 'claude' : 'opencode')) fail(`engine "${requested}" not found on PATH.`);
|
|
663
|
+
return requested;
|
|
664
|
+
}
|
|
665
|
+
if (has('claude')) return 'claude';
|
|
666
|
+
if (has('opencode')) return 'opencode';
|
|
667
|
+
fail('Neither `claude` nor `opencode` CLI found. Behavioral evals need a real model session.');
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function sha256(value) {
|
|
671
|
+
return crypto.createHash('sha256').update(value).digest('hex');
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function countToolCalls(trace) {
|
|
675
|
+
const evidence = trace && (trace.executionEvidence || (trace.parsed && trace.parsed.executionEvidence));
|
|
676
|
+
if (evidence) return evidence.counts.attempted;
|
|
677
|
+
const text = typeof trace === 'string' ? trace : trace && trace.trace;
|
|
678
|
+
return typeof text === 'string' ? (text.match(/^\[[^\]]+\]/gm) || []).length : null;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function treatmentSkills(c) {
|
|
682
|
+
return resolveTreatmentSkills(c);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function runArm(c, engine, arm, pairId) {
|
|
686
|
+
const loadedSkills = arm === 'treatment' ? treatmentSkills(c) : [];
|
|
687
|
+
const attributionRequired = arm === 'treatment';
|
|
688
|
+
const ws = buildWorkspace(c);
|
|
689
|
+
if (arm === 'treatment') installHarness(ws, loadedSkills);
|
|
690
|
+
if (c.fixture.git) gitSnapshot(ws);
|
|
691
|
+
|
|
692
|
+
const record = {
|
|
693
|
+
arm,
|
|
694
|
+
pair_id: pairId,
|
|
695
|
+
harness_loaded: arm === 'treatment',
|
|
696
|
+
loaded_skills: loadedSkills,
|
|
697
|
+
attribution_required: attributionRequired,
|
|
698
|
+
workspace: ws,
|
|
699
|
+
fixture_sha256: sha256(JSON.stringify(c.fixture)),
|
|
700
|
+
prompt_sha256: sha256(c.prompt),
|
|
701
|
+
cost: null,
|
|
702
|
+
};
|
|
703
|
+
try {
|
|
704
|
+
const transcriptPath = runHeadless(c.prompt, ws, c.max_turns, engine, arm);
|
|
705
|
+
const graded = grade(c, ws, transcriptPath, engine);
|
|
706
|
+
const { results, passed } = graded;
|
|
707
|
+
const trace = graded.trace;
|
|
708
|
+
const metadata = graded.parsed.metadata;
|
|
709
|
+
const evidence = graded.executionEvidence;
|
|
710
|
+
if (attributionRequired && loadedSkills.length === 0) {
|
|
711
|
+
throw new Error('treatment attribution is required but no skill was loaded');
|
|
712
|
+
}
|
|
713
|
+
return {
|
|
714
|
+
...record,
|
|
715
|
+
transcript: transcriptPath,
|
|
716
|
+
cost: metadata.cost,
|
|
717
|
+
usage: metadata.usage,
|
|
718
|
+
duration_ms: metadata.duration_ms,
|
|
719
|
+
num_turns: metadata.num_turns,
|
|
720
|
+
model_name: metadata.model,
|
|
721
|
+
expectations: results.map(({ type, value, command, after_edit, description, pass, status, reason }) => ({
|
|
722
|
+
type, value, command, after_edit, description, pass, status, reason,
|
|
723
|
+
})),
|
|
724
|
+
outcome: graded.status,
|
|
725
|
+
parse_status: graded.parsed.parseStatus,
|
|
726
|
+
parse_error: graded.parsed.parseError,
|
|
727
|
+
transcript_format: graded.parsed.format,
|
|
728
|
+
cli_version: metadata.cli_version,
|
|
729
|
+
tool_call_count: countToolCalls(graded),
|
|
730
|
+
tool_call_counts: evidence.counts,
|
|
731
|
+
execution_evidence: evidence,
|
|
732
|
+
trace_preview: trace.slice(0, 500),
|
|
733
|
+
};
|
|
734
|
+
} catch (err) {
|
|
735
|
+
return {
|
|
736
|
+
...record,
|
|
737
|
+
outcome: 'session-error',
|
|
738
|
+
error: err.message.slice(0, 500),
|
|
739
|
+
parse_status: 'unavailable',
|
|
740
|
+
tool_call_count: null,
|
|
741
|
+
tool_call_counts: { attempted: null, completed: null, denied: null, unresolved: null },
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function isDefinitiveArm(arm) {
|
|
747
|
+
return !!arm && (arm.outcome === 'pass' || arm.outcome === 'fail');
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
function isCompletedPair(record) {
|
|
751
|
+
return !!record && isDefinitiveArm(record.arms && record.arms.baseline)
|
|
752
|
+
&& isDefinitiveArm(record.arms && record.arms.treatment);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
function pairVerdict(baseline, treatment) {
|
|
756
|
+
if (!isDefinitiveArm(baseline) || !isDefinitiveArm(treatment)) return 'INCONCLUSIVE';
|
|
757
|
+
if (baseline.outcome === 'pass' && treatment.outcome === 'pass') return 'INCONCLUSIVE';
|
|
758
|
+
if (baseline.outcome !== 'pass' && treatment.outcome === 'pass') return 'EFFECTIVE';
|
|
759
|
+
if (baseline.outcome === 'pass' && treatment.outcome !== 'pass') return 'HARMFUL';
|
|
760
|
+
return 'INEFFECTIVE';
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function summarizePairResults(pairResults) {
|
|
764
|
+
const completed = pairResults.filter(isCompletedPair);
|
|
765
|
+
const sessionFailures = pairResults.filter(record => Object.values(record.arms || {})
|
|
766
|
+
.some(arm => arm.outcome === 'session-error')).length;
|
|
767
|
+
const effective = completed.filter(record => record.verdict === 'EFFECTIVE').length;
|
|
768
|
+
const categorySummary = {};
|
|
769
|
+
for (const record of pairResults) {
|
|
770
|
+
const category = record.pressure_category || 'unclassified';
|
|
771
|
+
if (!categorySummary[category]) {
|
|
772
|
+
categorySummary[category] = { requested: 0, completed: 0, pass: 0, fail: 0 };
|
|
773
|
+
}
|
|
774
|
+
categorySummary[category].requested++;
|
|
775
|
+
}
|
|
776
|
+
for (const record of completed) {
|
|
777
|
+
const category = record.pressure_category || 'unclassified';
|
|
778
|
+
const bucket = categorySummary[category];
|
|
779
|
+
bucket.completed++;
|
|
780
|
+
if (record.arms.treatment.outcome === 'pass') bucket.pass++;
|
|
781
|
+
else bucket.fail++;
|
|
782
|
+
}
|
|
783
|
+
for (const bucket of Object.values(categorySummary)) {
|
|
784
|
+
bucket.pass_rate = bucket.completed
|
|
785
|
+
? Number((bucket.pass / bucket.completed).toFixed(4))
|
|
786
|
+
: null;
|
|
787
|
+
bucket.pass_rate_ci95 = wilsonInterval(bucket.pass, bucket.completed);
|
|
788
|
+
}
|
|
789
|
+
const costs = completed.flatMap(record => Object.values(record.arms || {}).map(arm => arm.cost));
|
|
790
|
+
const cost = costs.length === completed.length * 2 && costs.every(value => typeof value === 'number')
|
|
791
|
+
? Number(costs.reduce((sum, value) => sum + value, 0).toFixed(6))
|
|
792
|
+
: null;
|
|
793
|
+
const toolCallDelta = completed.map(record => {
|
|
794
|
+
const baseline = record.arms.baseline.tool_call_count;
|
|
795
|
+
const treatment = record.arms.treatment.tool_call_count;
|
|
796
|
+
return {
|
|
797
|
+
id: record.id,
|
|
798
|
+
baseline,
|
|
799
|
+
treatment,
|
|
800
|
+
treatment_minus_baseline: typeof baseline === 'number' && typeof treatment === 'number'
|
|
801
|
+
? treatment - baseline
|
|
802
|
+
: null,
|
|
803
|
+
};
|
|
804
|
+
});
|
|
805
|
+
return {
|
|
806
|
+
cost,
|
|
807
|
+
completed_pairs: completed.length,
|
|
808
|
+
session_failures: sessionFailures,
|
|
809
|
+
tool_call_delta: toolCallDelta,
|
|
810
|
+
verdicts: Object.fromEntries(['EFFECTIVE', 'INEFFECTIVE', 'INCONCLUSIVE', 'HARMFUL']
|
|
811
|
+
.map(verdict => [verdict, completed.filter(record => record.verdict === verdict).length])),
|
|
812
|
+
effective_rate_ci95: wilsonInterval(effective, completed.length),
|
|
813
|
+
pressure_categories: categorySummary,
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
function wilsonInterval(successes, total) {
|
|
818
|
+
if (!total) return null;
|
|
819
|
+
const z = 1.96;
|
|
820
|
+
const p = successes / total;
|
|
821
|
+
const denominator = 1 + (z * z) / total;
|
|
822
|
+
const centre = (p + (z * z) / (2 * total)) / denominator;
|
|
823
|
+
const spread = (z / denominator) * Math.sqrt((p * (1 - p) / total) + (z * z) / (4 * total * total));
|
|
824
|
+
return [Math.max(0, centre - spread), Math.min(1, centre + spread)].map(v => Number(v.toFixed(4)));
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function runLive(filter, engineArg, armArg = 'treatment') {
|
|
828
|
+
const validArms = new Set(['baseline', 'treatment', 'both']);
|
|
829
|
+
if (!validArms.has(armArg)) fail(`arm must be baseline, treatment, or both (got ${armArg})`);
|
|
830
|
+
const engine = resolveEngine(engineArg);
|
|
831
|
+
console.log(`Engine: ${engine}`);
|
|
832
|
+
console.log(`Arm mode: ${armArg}`);
|
|
833
|
+
const cases = discoverCases().filter((c) => !filter || c.id === filter);
|
|
834
|
+
if (filter && cases.length === 0) fail(`no case with id "${filter}"`);
|
|
835
|
+
fs.mkdirSync(RESULTS_DIR, { recursive: true });
|
|
836
|
+
|
|
837
|
+
const pairResults = [];
|
|
838
|
+
let sessionFailures = 0;
|
|
839
|
+
for (const c of cases) {
|
|
840
|
+
const pairId = `${c.id}-${Date.now()}-${crypto.randomBytes(3).toString('hex')}`;
|
|
841
|
+
const order = armArg === 'both'
|
|
842
|
+
? (crypto.randomInt(0, 2) === 0 ? ['baseline', 'treatment'] : ['treatment', 'baseline'])
|
|
843
|
+
: [armArg];
|
|
844
|
+
console.log(`\n=== ${c.id}${c.pressure ? ' [PRESSURE]' : ''} | order: ${order.join(' -> ')} ===`);
|
|
845
|
+
const arms = {};
|
|
846
|
+
for (const arm of order) arms[arm] = runArm(c, engine, arm, pairId);
|
|
847
|
+
|
|
848
|
+
const record = {
|
|
849
|
+
id: c.id,
|
|
850
|
+
pair_id: pairId,
|
|
851
|
+
engine,
|
|
852
|
+
model: engine === 'opencode' ? (process.env.BEHAVIORAL_MODEL || 'openai/gpt-5-mini') : (process.env.BEHAVIORAL_MODEL || 'claude-default'),
|
|
853
|
+
pressure: !!c.pressure,
|
|
854
|
+
pressure_category: c.pressure_category || null,
|
|
855
|
+
sample_unit: 'paired case',
|
|
856
|
+
arm_order: order,
|
|
857
|
+
fixture_sha256: sha256(JSON.stringify(c.fixture)),
|
|
858
|
+
prompt_sha256: sha256(c.prompt),
|
|
859
|
+
arms,
|
|
860
|
+
verdict: armArg === 'both' ? pairVerdict(arms.baseline, arms.treatment) : null,
|
|
861
|
+
date: new Date().toISOString(),
|
|
862
|
+
};
|
|
863
|
+
pairResults.push(record);
|
|
864
|
+
for (const arm of Object.values(arms)) {
|
|
865
|
+
console.log(` ${arm.arm}: ${arm.outcome} (${arm.loaded_skills.length ? arm.loaded_skills.join(', ') : 'no Harness skills'})`);
|
|
866
|
+
}
|
|
867
|
+
if (Object.values(arms).some(arm => arm.outcome === 'session-error')) sessionFailures++;
|
|
868
|
+
if (armArg === 'both') console.log(` Verdict: ${record.verdict}`);
|
|
869
|
+
const suffix = armArg === 'both' ? 'pair' : armArg;
|
|
870
|
+
fs.writeFileSync(path.join(RESULTS_DIR, `${record.date.slice(0, 10)}-${c.id}-${suffix}.json`), JSON.stringify(record, null, 2));
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
let exitCode = sessionFailures ? 1 : 0;
|
|
874
|
+
if (armArg === 'both') {
|
|
875
|
+
const aggregate = summarizePairResults(pairResults);
|
|
876
|
+
const summary = {
|
|
877
|
+
date: new Date().toISOString(),
|
|
878
|
+
protocol: 'paired-randomized-v1',
|
|
879
|
+
requested_sample_size: cases.length,
|
|
880
|
+
...aggregate,
|
|
881
|
+
boundary_compliance: aggregate.completed_pairs === cases.length ? 'complete' : 'incomplete',
|
|
882
|
+
cost: aggregate.cost,
|
|
883
|
+
interpretation: aggregate.completed_pairs < 2
|
|
884
|
+
? 'insufficient paired samples for an effectiveness claim'
|
|
885
|
+
: 'report paired outcomes; do not treat INCONCLUSIVE pairs as skill lift',
|
|
886
|
+
};
|
|
887
|
+
const summaryPath = path.join(RESULTS_DIR, `${new Date().toISOString().slice(0, 10)}-summary-both.json`);
|
|
888
|
+
fs.writeFileSync(summaryPath, JSON.stringify(summary, null, 2));
|
|
889
|
+
console.log(`\nPaired summary: ${summaryPath}`);
|
|
890
|
+
console.log(`Completed pairs: ${summary.completed_pairs}/${summary.requested_sample_size}`);
|
|
891
|
+
exitCode = aggregate.session_failures ? 1 : 0;
|
|
892
|
+
}
|
|
893
|
+
process.exit(exitCode);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
// ----------------------------------------------------------------------------
|
|
897
|
+
function main() {
|
|
898
|
+
const args = process.argv.slice(2);
|
|
899
|
+
function flag(name) {
|
|
900
|
+
const i = args.indexOf(name);
|
|
901
|
+
return i >= 0 ? args[i + 1] : undefined;
|
|
902
|
+
}
|
|
903
|
+
if (args[0] === 'validate') validate(discoverCases());
|
|
904
|
+
else if (args[0] === 'run') {
|
|
905
|
+
const filter = args.includes('--case') ? flag('--case') : undefined;
|
|
906
|
+
runLive(filter, args.includes('--engine') ? flag('--engine') : undefined, args.includes('--arm') ? flag('--arm') : undefined);
|
|
907
|
+
} else {
|
|
908
|
+
console.log('Usage:\n node behavioral-evals/run.js validate\n node behavioral-evals/run.js run [--case <id>] [--arm baseline|treatment|both] [--engine claude|opencode]');
|
|
909
|
+
process.exit(args.length ? 1 : 0);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
if (require.main === module) main();
|
|
914
|
+
|
|
915
|
+
module.exports = {
|
|
916
|
+
buildEngineInvocation,
|
|
917
|
+
buildWorkspace,
|
|
918
|
+
countToolCalls,
|
|
919
|
+
extractAgentEvents,
|
|
920
|
+
extractAgentTrace,
|
|
921
|
+
extractSessionMetadata,
|
|
922
|
+
grade,
|
|
923
|
+
parseTranscriptEvents,
|
|
924
|
+
pairVerdict,
|
|
925
|
+
parseSimpleYaml,
|
|
926
|
+
summarizePairResults,
|
|
927
|
+
validate,
|
|
928
|
+
};
|