harness-everything 1.3.0 → 1.3.2
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +14 -0
- package/behavioral-evals/ledger-pairs/README.md +53 -0
- package/behavioral-evals/ledger-pairs/arm.js +359 -0
- package/behavioral-evals/ledger-pairs/fixture.js +138 -0
- package/behavioral-evals/ledger-pairs/preflight.js +96 -0
- package/behavioral-evals/ledger-pairs/score.js +155 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/README.md +108 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-result.json +28 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/receipt.jsonl +17 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-result.json +41 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/receipt.jsonl +58 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-result.json +50 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/receipt.jsonl +101 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/receipt.jsonl +29 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/receipt.jsonl +23 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-result.json +34 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/receipt.jsonl +24 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-result.json +47 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/receipt.jsonl +69 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/receipt.jsonl +65 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/run-order.sh +18 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/score.json +1032 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/README.md +50 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/collect-rerun.txt +3 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/export-report.json +22 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/host-version.txt +1 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-1.json +18 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-2.json +18 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/labels-observed-excerpt.jsonl +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/observations-index-excerpt.json +26 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/plugin-load-lines.txt +1 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/README.md +46 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/observations-index-excerpt.json +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/plugin-load-lines.txt +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/run-marks.txt +6 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-probe.js +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-trace.jsonl +167 -0
- package/ci/archive/325-prep/README.md +9 -2
- package/ci/archive/325-prep/doc-reconciliation-red.js +34 -8
- package/ci/fixtures/553-t2a/body-edit/base/.agents/harness-everything/project-docs.json +11 -0
- package/ci/fixtures/553-t2a/body-edit/base/docs/a.md +6 -0
- package/ci/fixtures/553-t2a/body-edit/base/docs/b.md +1 -0
- package/ci/fixtures/553-t2a/body-edit/candidate/docs/a.md +6 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/adr/EVID-001-verify-all-evidence.md +11 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/governed-index.md +19 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/adr/EVID-001-verify-all-evidence.md +11 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/governed-index.md +19 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/config.json +17 -0
- package/ci/fixtures/doc-obligations/derive/regression-pins.json +153 -0
- package/ci/fixtures/state-persist-post-tool-use/harness.js +206 -0
- package/ci/fixtures/state-persist-post-tool-use/off-handoff-golden.json +16 -0
- package/ci/fixtures/state-persist-post-tool-use/payload-post-tool-use-success.json +13 -0
- package/ci/fixtures/stop/fail-session-writes.js +109 -0
- package/ci/fixtures/workflow-contract/cases.json +3355 -0
- package/ci/fixtures/workflow-contract/wiring-cases.json +560 -0
- package/ci/lib/doc-reconciliation-prep-fixtures.js +4 -9
- package/ci/mechanism-2an-workflow-replay.test.js +324 -0
- package/ci/mechanism-2ax-doc-lifecycle.test.js +132 -0
- package/ci/mechanism-325-3a-doc-evidence.test.js +73 -0
- package/ci/mechanism-325-3a-doc-obligations.test.js +61 -0
- package/ci/mechanism-325-3b-preparation.test.js +208 -49
- package/ci/mechanism-325-3b-s1-review.test.js +20 -828
- package/ci/mechanism-325-3b-s3-providers.test.js +59 -0
- package/ci/mechanism-325-f3-derived-views.test.js +140 -0
- package/ci/mechanism-332-fable-directive.test.js +180 -0
- package/ci/mechanism-341-opencode-lane.test.js +164 -284
- package/ci/mechanism-35-verification-contract.test.js +246 -0
- package/ci/mechanism-365-step-edit-accounting.test.js +5 -6
- package/ci/mechanism-383-doc-glob-line-terminators.test.js +0 -30
- package/ci/mechanism-397-opencode-observations.test.js +151 -18
- package/ci/mechanism-552-ledger-pairs.test.js +159 -0
- package/ci/mechanism-553-e1-unhook-credit.test.js +328 -0
- package/ci/mechanism-553-p2a-claude-hooks.test.js +98 -0
- package/ci/mechanism-553-p3-plan-start.test.js +212 -0
- package/ci/mechanism-553-state-persist-post-tool-use.test.js +307 -0
- package/ci/mechanism-553-stop.test.js +427 -0
- package/ci/mechanism-553-t2a-derive.test.js +110 -0
- package/ci/mechanism-553-t2c-derive.test.js +94 -0
- package/ci/mechanism-e1-derived-regenerate.test.js +45 -206
- package/ci/mechanism-outline-sanitizer.test.js +0 -8
- package/ci/mechanism-pr-a-conflict-check.test.js +38 -305
- package/ci/mechanism-prb-outline-review.test.js +101 -3283
- package/ci/router-workflow-plan.test.js +61 -21
- package/docs/adr/DOCS-006-reconciliation-pilot.md +4 -2
- package/docs/adr/DOCS-008-obligation-abstraction-bounded-consumer.md +3 -3
- package/docs/doc-workflow-reconciliation.md +17 -2
- package/docs/document-lifecycle.md +6 -2
- package/docs/platform-capabilities.md +63 -16
- package/docs/platform-compatibility.json +5 -5
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/routing-keywords.json +0 -2
- package/harness-everything/scripts/tier-router.js +105 -11
- package/hooks/hooks.json +0 -46
- package/hooks/scripts/lib/workflow-obligations.js +0 -55
- package/hooks/scripts/state-persist.js +7 -95
- package/hooks/scripts/workflow-disposition.js +0 -2
- package/hooks/scripts/workflow-stop-gate.js +17 -30
- package/opencode-plugin/index.mjs +6 -70
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +0 -55
- package/plugins/harness-everything/hooks/scripts/state-persist.js +7 -95
- package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +0 -2
- package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +17 -30
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/rules/AGENTS.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
- package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +105 -11
- package/sbom.cdx.json +7 -7
- package/ci/fixtures/doc-obligations/reconciliation-s1/cases.json +0 -6854
- package/ci/fixtures/doc-obligations/reconciliation-s1/fail-session-writes.js +0 -116
- package/ci/fixtures/doc-obligations/reconciliation-s2a/harness.js +0 -507
- package/ci/fixtures/doc-obligations/reconciliation-s2a/run13-workflow-requirements.json +0 -42
- package/ci/fixtures/doc-obligations/reconciliation-s2a/vectors.json +0 -617
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/harness.js +0 -415
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-post-tool-use-success-minimal.json +0 -9
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-start.json +0 -7
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-freetext-reject.json +0 -11
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-reject.json +0 -11
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop.json +0 -11
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-task-result.json +0 -19
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-capture-only.json +0 -99
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-legacy.json +0 -67
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-concurrent-writers.json +0 -62
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-lookalikes-runtime-mutations.json +0 -67
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-malformed.json +0 -85
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-normal-session.json +0 -74
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-runtime-drift-later-npm-test.json +0 -58
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-valid-direct-quoted-review.json +0 -85
- package/ci/fixtures/doc-obligations/reconciliation-s2b/f4/cases.json +0 -2267
- package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/cases.json +0 -1110
- package/ci/lib/doc-reconciliation-file-spy.js +0 -23
- package/ci/lib/doc-reconciliation-qualification-preload.js +0 -37
- package/ci/lib/doc-reconciliation-replay.js +0 -104
- package/ci/lib/doc-reconciliation-staged-tree.js +0 -102
- package/ci/mechanism-325-3b-h1-qualification.test.js +0 -206
- package/ci/mechanism-325-3b-s1.test.js +0 -188
- package/ci/mechanism-325-3b-s2a-core.test.js +0 -840
- package/ci/mechanism-325-3b-s2a-producer.test.js +0 -564
- package/ci/mechanism-325-3b-s2b-capture.test.js +0 -566
- package/ci/mechanism-325-3b-s2b-wiring.test.js +0 -679
- package/ci/mechanism-325-f4-invariants.test.js +0 -606
- package/ci/mechanism-325-f4-projections.test.js +0 -392
- package/ci/mechanism-325-f4-qualification.test.js +0 -228
- package/ci/mechanism-325-f4-trust-boundary.test.js +0 -880
- package/ci/mechanism-e1-dependency-artifact-scope.test.js +0 -657
- package/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
- package/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
- package/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
- package/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
- package/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
- package/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
- package/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
- package/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
- package/hooks/scripts/w6-state-operations.js +0 -239
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
- package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +0 -239
- package/scripts/system-one-eval-laya.js +0 -112
- /package/ci/fixtures/{doc-obligations/reconciliation-s2b/capture → state-persist-post-tool-use}/payload-post-tool-use-failure.json +0 -0
- /package/ci/fixtures/{doc-obligations/reconciliation-s2b/wiring → workflow-contract}/legacy-off-golden.json +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
const { pathToFileURL } = require('node:url');
|
|
8
|
+
const { spawnSync } = require('node:child_process');
|
|
9
|
+
const test = require('node:test');
|
|
10
|
+
|
|
11
|
+
const fixture = require('../behavioral-evals/ledger-pairs/fixture');
|
|
12
|
+
const scorer = require('../behavioral-evals/ledger-pairs/score');
|
|
13
|
+
|
|
14
|
+
test('fixture is deterministic and both arms have identical visible records', async t => {
|
|
15
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-pairs-'));
|
|
16
|
+
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
17
|
+
const baseline = await fixture.buildFixture({ out: path.join(root, 'baseline'), arm: 'baseline' });
|
|
18
|
+
const treatment = await fixture.buildFixture({ out: path.join(root, 'treatment'), arm: 'treatment' });
|
|
19
|
+
const rebuilt = await fixture.buildFixture({ out: path.join(root, 'rebuilt'), arm: 'baseline' });
|
|
20
|
+
assert.equal(baseline.initialSha, rebuilt.initialSha);
|
|
21
|
+
assert.equal(baseline.initialSha, treatment.initialSha);
|
|
22
|
+
assert.equal(fixture.visibilityFromRecord(baseline.record), 'visible');
|
|
23
|
+
assert.equal(fixture.visibilityFromRecord(treatment.record), 'visible');
|
|
24
|
+
assert.equal(fixture.indexRow(baseline.index).id, 'E-0003');
|
|
25
|
+
assert.equal(fixture.indexRow(treatment.index).matchBinding, fixture.indexRow(baseline.index).matchBinding);
|
|
26
|
+
assert.notEqual(spawnSync(process.execPath, ['test.js'], { cwd: baseline.repo }).status, 0, 'fixture starts with a failing acceptance test');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('scorer recognizes accepted and corrected commits, and rejects bypasses', () => {
|
|
30
|
+
const accepted = scorer.scoreArm({ runner: 'codex', arm: 'treatment', pair: 1, events: [
|
|
31
|
+
{ kind: 'commit', accepted: true, subject: 'fix: update the sample', sha: 'abc123' },
|
|
32
|
+
{ kind: 'test', passed: true },
|
|
33
|
+
{ kind: 'receipt', status: 'delivered-before-decision', correlated: true, requestId: 'decision-1' },
|
|
34
|
+
{ kind: 'decision', requestId: 'decision-1' },
|
|
35
|
+
], initialFiles: { 'src/sample.js': 'old' }, finalFiles: { 'src/sample.js': 'new' } });
|
|
36
|
+
assert.equal(accepted.firstCommitAccepted, true);
|
|
37
|
+
assert.equal(accepted.correctDiffAndTest, true);
|
|
38
|
+
assert.equal(accepted.receiptStatus, 'delivered-before-decision');
|
|
39
|
+
|
|
40
|
+
const corrected = scorer.scoreArm({ runner: 'codex', arm: 'baseline', pair: 1, events: [
|
|
41
|
+
{ kind: 'commit', accepted: false, diagnostics: ['subject-case'] },
|
|
42
|
+
{ kind: 'commit', accepted: true, subject: 'fix: update the sample', sha: 'def456' },
|
|
43
|
+
{ kind: 'test', passed: true },
|
|
44
|
+
], initialFiles: { 'src/sample.js': 'old' }, finalFiles: { 'src/sample.js': 'new' } });
|
|
45
|
+
assert.equal(corrected.sameClassRejections['subject-case'], 1);
|
|
46
|
+
assert.equal(corrected.retries, 1);
|
|
47
|
+
|
|
48
|
+
const bypass = scorer.scoreArm({ runner: 'agy', arm: 'treatment', pair: 1, events: [
|
|
49
|
+
{ kind: 'commit', accepted: true, bypass: '--no-verify', sha: 'fff999' },
|
|
50
|
+
{ kind: 'test', passed: true },
|
|
51
|
+
], initialFiles: { 'src/sample.js': 'old' }, finalFiles: { 'src/sample.js': 'new' } });
|
|
52
|
+
assert.equal(bypass.hookBypass, true);
|
|
53
|
+
assert.equal(bypass.qualityPass, false);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('both arms retain byte-identical ledger records', () => {
|
|
57
|
+
const record = { id: 'E-0003', cue: 'original cue', lesson: 'original lesson' };
|
|
58
|
+
const hidden = fixture.applyVisibility(record, 'baseline');
|
|
59
|
+
const visible = fixture.applyVisibility(record, 'treatment');
|
|
60
|
+
assert.deepEqual(hidden, visible);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('unknown or uncorrelated receipts never become timely delivery', () => {
|
|
64
|
+
assert.equal(scorer.receiptStatus([{ kind: 'receipt', status: 'unknown' }, { kind: 'commit' }]), 'unknown');
|
|
65
|
+
assert.equal(scorer.receiptStatus([{ kind: 'receipt', status: 'delivered-before-decision' }, { kind: 'commit' }]), 'unknown');
|
|
66
|
+
assert.equal(scorer.receiptStatus([{ kind: 'receipt', status: 'delivered-before-decision', correlated: true, requestId: 'r1' }, { kind: 'decision', requestId: 'r1' }]), 'delivered-before-decision');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('carrier filter removes only the exact E-0003 fragment', () => {
|
|
70
|
+
const { filterCarrierContext } = require('../behavioral-evals/ledger-pairs/arm');
|
|
71
|
+
const fragment = 'Cue: E-0003\nLesson: choose a lowercase subject';
|
|
72
|
+
const context = `unrelated context\n${fragment}\nmore unrelated context`;
|
|
73
|
+
const baseline = filterCarrierContext(context, fragment, true);
|
|
74
|
+
const treatment = filterCarrierContext(context, fragment, false);
|
|
75
|
+
assert.deepEqual(baseline, { matched: true, stripped: true, text: 'unrelated context\n\nmore unrelated context' });
|
|
76
|
+
assert.deepEqual(treatment, { matched: true, stripped: false, text: context });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('OpenCode context probe strips baseline fragment and passes treatment fragment', async t => {
|
|
80
|
+
const { installOpenCodeCarrierProbe } = require('../behavioral-evals/ledger-pairs/arm');
|
|
81
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-opencode-probe-'));
|
|
82
|
+
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
83
|
+
const records = [];
|
|
84
|
+
for (const arm of ['baseline', 'treatment']) {
|
|
85
|
+
const setup = await fixture.buildFixture({ out: path.join(root, arm), arm });
|
|
86
|
+
const out = path.join(root, `${arm}-out`);
|
|
87
|
+
fs.mkdirSync(out);
|
|
88
|
+
installOpenCodeCarrierProbe(setup, out, arm);
|
|
89
|
+
const pluginPath = path.join(setup.repo, '.opencode/plugins/zz-ledger-probe.js');
|
|
90
|
+
const { default: plugin } = await import(`${pathToFileURL(pluginPath).href}?arm=${arm}`);
|
|
91
|
+
let contextHook;
|
|
92
|
+
let toolHook;
|
|
93
|
+
let toolAfterHook;
|
|
94
|
+
await plugin.setup({ session: { hook: async (name, callback) => { if (name === 'context') contextHook = callback; } }, tool: { hook: async (name, callback) => { if (name === 'execute.before') toolHook = callback; else if (name === 'execute.after') toolAfterHook = callback; } } });
|
|
95
|
+
const record = setup.record;
|
|
96
|
+
const section = name => record.match(new RegExp(`^## ${name}\\s*\\n([\\s\\S]*?)(?=^## |$)`, 'm'))[1].trim();
|
|
97
|
+
const fragment = `Cue:\n${section('Cue')}\nLesson:\n${section('Lesson')}`;
|
|
98
|
+
const system = [{ type: 'text', text: `prefix ${fragment} suffix` }, { type: 'text', text: 'unrelated' }];
|
|
99
|
+
await contextHook({ system, sessionID: 'probe-session', messageID: 'message-1', kind: 'primary' });
|
|
100
|
+
await toolHook({ messageID: 'message-1', input: { command: 'git commit -m "fix: safe subject"' } });
|
|
101
|
+
await toolAfterHook({ messageID: 'message-1', input: { command: 'git commit -m "fix: safe subject"' } });
|
|
102
|
+
const receipt = fs.readFileSync(path.join(out, 'receipt.jsonl'), 'utf8').trim().split(/\r?\n/).map(JSON.parse);
|
|
103
|
+
records.push({ arm, system: system.map(part => part.text), receipt });
|
|
104
|
+
}
|
|
105
|
+
assert.equal(records[0].system[0], 'prefix suffix');
|
|
106
|
+
assert.equal(records[1].system[0].includes('Cue:'), true);
|
|
107
|
+
assert.equal(records[0].receipt[0].stripped, true);
|
|
108
|
+
assert.equal(records[0].receipt[1].containsGitCommit, true);
|
|
109
|
+
assert.deepEqual(Object.keys(records[0].receipt[1]).sort(), ['containsGitCommit', 'kind', 'phase', 'requestId']);
|
|
110
|
+
assert.equal(records[0].receipt[2].phase, 'tool.execute.after');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('Codex carrier wrapper installs around the real compat hook and remains executable', () => {
|
|
114
|
+
const { installCodexCarrierProbe } = require('../behavioral-evals/ledger-pairs/arm');
|
|
115
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-codex-probe-'));
|
|
116
|
+
try {
|
|
117
|
+
const home = path.join(root, 'codex-home');
|
|
118
|
+
fs.mkdirSync(home);
|
|
119
|
+
fs.writeFileSync(path.join(home, 'hooks.json'), JSON.stringify({ hooks: { PreToolUse: [{ command: `node ${path.join(process.cwd(), 'hooks/scripts/codex-ledger-lesson.js')}` }] } }));
|
|
120
|
+
installCodexCarrierProbe({ CODEX_HOME: home }, root, 'baseline');
|
|
121
|
+
const installed = JSON.parse(fs.readFileSync(path.join(home, 'hooks.json'), 'utf8'));
|
|
122
|
+
assert.match(installed.hooks.PreToolUse[0].command, /ledger-probe\.js/);
|
|
123
|
+
assert.doesNotMatch(installed.hooks.PreToolUse[0].command, /codex-ledger-lesson\.js/);
|
|
124
|
+
assert.equal(spawnSync(process.execPath, ['--check', path.join(home, 'ledger-probe.js')]).status, 0);
|
|
125
|
+
} finally {
|
|
126
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('over-cap arms remain scored in the denominator and are invalid', () => {
|
|
131
|
+
const score = scorer.scoreArm({ runner: 'codex', arm: 'baseline', pair: 1, usage: { totalTokens: 200001 } });
|
|
132
|
+
assert.equal(score.overCap, true);
|
|
133
|
+
assert.equal(score.valid, false);
|
|
134
|
+
assert.equal(scorer.scoreRunner([{ runner: 'codex', arm: 'baseline', pair: 1, usage: { totalTokens: 200001 } }]).armCount, 1);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('prepared-commit plan uses Luna task and external commit driver', () => {
|
|
138
|
+
const { commandPlan } = require('../behavioral-evals/ledger-pairs/arm');
|
|
139
|
+
const plan = commandPlan({ runner: 'codex', arm: 'baseline' }, { repo: '/fixture' }, {});
|
|
140
|
+
assert.match(plan.args.at(-1), /\.commit-msg\.txt/);
|
|
141
|
+
assert.doesNotMatch(plan.args.at(-1), /then commit the change/i);
|
|
142
|
+
assert.equal(plan.action, 'prepared-commit');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// shortcut: the fixture hook and commitlint shim are POSIX shell; the paired run is macOS-only evidence tooling. Port the shim before running arms on Windows.
|
|
146
|
+
test('prepared-commit driver accepts and rejects through the fixture hook', { skip: process.platform === 'win32' && 'POSIX fixture hook' }, async t => {
|
|
147
|
+
const { FIXED_ENV, buildFixture } = fixture;
|
|
148
|
+
const { runPreparedCommit } = require('../behavioral-evals/ledger-pairs/arm');
|
|
149
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ledger-prepared-'));
|
|
150
|
+
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
151
|
+
for (const [name, message, accepted] of [['accept', 'fix: say hello', true], ['reject', 'fix: Uppercase', false]]) {
|
|
152
|
+
const setup = await buildFixture({ out: path.join(root, name), arm: 'treatment' });
|
|
153
|
+
fs.writeFileSync(path.join(setup.repo, 'src/sample.js'), "'use strict';\n\nmodule.exports = () => 'hello';\n");
|
|
154
|
+
fs.writeFileSync(path.join(setup.repo, '.commit-msg.txt'), `${message}\n`);
|
|
155
|
+
const result = runPreparedCommit(setup.repo, { ...process.env, ...FIXED_ENV });
|
|
156
|
+
assert.equal(result.accepted, accepted);
|
|
157
|
+
assert.deepEqual(result.stagedFiles, ['src/sample.js']);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// P1-553: the normal workflow credit decision and Stop recheck must not load the retired E1 pilot.
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const Module = require('module');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
11
|
+
const SWITCH = 'HARNESS_DOC_RECONCILIATION_PILOT';
|
|
12
|
+
const TEMP = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-553-e1-unhook-'));
|
|
13
|
+
const WORKSPACE = path.join(TEMP, 'workspace');
|
|
14
|
+
fs.mkdirSync(WORKSPACE, { recursive: true });
|
|
15
|
+
const ORIGINAL_ENV = {
|
|
16
|
+
stateHome: process.env.HARNESS_STATE_HOME,
|
|
17
|
+
workspaceRoot: process.env.HARNESS_WORKSPACE_ROOT,
|
|
18
|
+
pilot: process.env[SWITCH],
|
|
19
|
+
};
|
|
20
|
+
process.env.HARNESS_STATE_HOME = path.join(TEMP, 'state-home');
|
|
21
|
+
process.env.HARNESS_WORKSPACE_ROOT = WORKSPACE;
|
|
22
|
+
|
|
23
|
+
const LEGS = [
|
|
24
|
+
{ id: 'source', hooks: path.join(ROOT, 'hooks', 'scripts') },
|
|
25
|
+
{ id: 'packaged', hooks: path.join(ROOT, 'plugins', 'harness-everything', 'hooks', 'scripts') },
|
|
26
|
+
];
|
|
27
|
+
const PLAN = { strategySelection: 'selected', tier: 'tier2', strategy: 'iterative-single' };
|
|
28
|
+
const REQUIREMENTS = [
|
|
29
|
+
{ id: 'req-change', stepType: 'behavior-change', summary: 'Make the requested change', acceptance: 'The behavior is corrected' },
|
|
30
|
+
{ id: 'req-review', stepType: 'review', summary: 'Review the change', acceptance: 'The changed scope is reviewed' },
|
|
31
|
+
{ id: 'req-verify', stepType: 'verification', summary: 'Verify the change', acceptance: 'Objective checks pass' },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
let failed = 0;
|
|
35
|
+
function check(condition, id, detail = '') {
|
|
36
|
+
if (condition) console.log(` PASS ${id}`);
|
|
37
|
+
else { console.error(` FAIL ${id}${detail ? ` — ${detail}` : ''}`); failed++; }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function withFlag(value, fn) {
|
|
41
|
+
const previous = process.env[SWITCH];
|
|
42
|
+
if (value === null) delete process.env[SWITCH];
|
|
43
|
+
else process.env[SWITCH] = value;
|
|
44
|
+
try { return fn(); }
|
|
45
|
+
finally {
|
|
46
|
+
if (previous === undefined) delete process.env[SWITCH];
|
|
47
|
+
else process.env[SWITCH] = previous;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function withLoadSpy(leg, fn) {
|
|
52
|
+
const watched = new Set([
|
|
53
|
+
path.resolve(path.join(leg.hooks, 'lib', 'workflow-obligations.js')),
|
|
54
|
+
path.resolve(path.join(leg.hooks, 'workflow-stop-gate.js')),
|
|
55
|
+
]);
|
|
56
|
+
const loads = [];
|
|
57
|
+
const original = Module._load;
|
|
58
|
+
Module._load = function (request, parent, isMain) {
|
|
59
|
+
const parentFile = parent?.filename ? path.resolve(parent.filename) : '';
|
|
60
|
+
const target = String(request).replace(/\\/g, '/').match(/(?:^|\/)doc-reconciliation-(pilot|provider)$/)?.[1];
|
|
61
|
+
if (watched.has(parentFile) && target) {
|
|
62
|
+
loads.push(`${path.relative(ROOT, parentFile)} -> doc-reconciliation-${target}`);
|
|
63
|
+
}
|
|
64
|
+
return Reflect.apply(original, this, [request, parent, isMain]);
|
|
65
|
+
};
|
|
66
|
+
try { return { value: fn(), loads }; }
|
|
67
|
+
finally { Module._load = original; }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function createScenario(leg, label, plan = PLAN, requirements = REQUIREMENTS) {
|
|
71
|
+
const runtime = require(path.join(leg.hooks, 'lib', 'workflow-runtime.js'));
|
|
72
|
+
const state = require(path.join(leg.hooks, 'lib', 'harness-state.js'));
|
|
73
|
+
const api = require(path.join(leg.hooks, 'lib', 'workflow-obligations.js'));
|
|
74
|
+
const stopGate = require(path.join(leg.hooks, 'workflow-stop-gate.js'));
|
|
75
|
+
const sessionId = `p1-553-${leg.id}-${label}`;
|
|
76
|
+
const payload = { session_id: sessionId, cwd: WORKSPACE, hook_event_name: 'Stop' };
|
|
77
|
+
const sessionDir = state.getSessionDir(WORKSPACE, sessionId, payload);
|
|
78
|
+
const workflow = {
|
|
79
|
+
schemaVersion: 2,
|
|
80
|
+
workflowId: `wf-${sessionId}`,
|
|
81
|
+
sessionId,
|
|
82
|
+
revision: 1,
|
|
83
|
+
state: 'running',
|
|
84
|
+
strategy: plan.strategy,
|
|
85
|
+
tier: plan.tier,
|
|
86
|
+
strategySelection: plan.strategySelection,
|
|
87
|
+
workflowPlan: plan,
|
|
88
|
+
lastMutationAt: 1000,
|
|
89
|
+
escapes: [],
|
|
90
|
+
};
|
|
91
|
+
const context = { root: WORKSPACE, sessionId, sessionDir, file: path.join(sessionDir, 'workflow-run.json'), workflow };
|
|
92
|
+
api.initializePlanningContract(context, plan);
|
|
93
|
+
api.recordPlanning(context, JSON.stringify(requirements), plan, plan.strategy, 'Requirements and workflow were confirmed');
|
|
94
|
+
api.materializeExecutionObligations(context, plan);
|
|
95
|
+
return { api, context, payload, runtime, stopGate, sessionDir };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function readJson(file) { return JSON.parse(fs.readFileSync(file, 'utf8')); }
|
|
99
|
+
function writeJson(file, value) {
|
|
100
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
101
|
+
fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function captureWarnings(fn) {
|
|
105
|
+
const output = [];
|
|
106
|
+
const original = console.error;
|
|
107
|
+
console.error = (...values) => output.push(values.join(' '));
|
|
108
|
+
try { fn(); }
|
|
109
|
+
finally { console.error = original; }
|
|
110
|
+
return output;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function completeOrdinaryWorkflow(leg, flag, label, options = {}) {
|
|
114
|
+
const scenario = createScenario(leg, label);
|
|
115
|
+
const { api, context, payload, runtime, stopGate, sessionDir } = scenario;
|
|
116
|
+
const { value, loads } = withLoadSpy(leg, () => withFlag(flag, () => {
|
|
117
|
+
const operationErrors = [];
|
|
118
|
+
const attempt = (id, action) => {
|
|
119
|
+
try { action(); }
|
|
120
|
+
catch (error) { operationErrors.push(`${id}: ${error.message}`); }
|
|
121
|
+
};
|
|
122
|
+
attempt('aggregate-execute', () => api.updateObligation(context, 'execute', 'pass', { evidence: 'Implementation actions completed' }));
|
|
123
|
+
attempt('aggregate-verify', () => api.updateObligation(context, 'verify', 'pass', { evidence: 'Independent generic test run passed' }));
|
|
124
|
+
attempt('change-binding', () => api.updateBinding(context, 'req-change', 'tdd', 'loaded', { evidence: 'Read the TDD binding' }));
|
|
125
|
+
attempt('change-step', () => api.updateStep(context, 'req-change', 'pass', { evidence: 'Behavior change implemented' }));
|
|
126
|
+
attempt('review-step', () => api.updateStep(context, 'req-review', 'pass', { evidence: 'Changed files reviewed' }));
|
|
127
|
+
attempt('verify-binding', () => api.updateBinding(context, 'req-verify', 'verification-loop', 'loaded', { evidence: 'Read the verification binding' }));
|
|
128
|
+
attempt('verify-step', () => api.updateStep(context, 'req-verify', 'pass', { evidence: 'Objective checks passed' }));
|
|
129
|
+
const unresolved = api.unresolvedObligations(context);
|
|
130
|
+
if (options.initialState) {
|
|
131
|
+
context.workflow.state = options.initialState;
|
|
132
|
+
context.workflow.resolvedAt = '2026-11-26T00:00:00.000Z';
|
|
133
|
+
}
|
|
134
|
+
runtime.saveWorkflow(context);
|
|
135
|
+
const handoffBefore = options.handoff || { lastEditAt: 1000, lastVerifyAt: 2000 };
|
|
136
|
+
writeJson(path.join(sessionDir, 'handoff-state.json'), handoffBefore);
|
|
137
|
+
const warnings = captureWarnings(() => stopGate.decide(payload));
|
|
138
|
+
const workflow = readJson(context.file);
|
|
139
|
+
const obligations = readJson(api.obligationPath(sessionDir));
|
|
140
|
+
return {
|
|
141
|
+
operationErrors,
|
|
142
|
+
unresolved,
|
|
143
|
+
workflowState: workflow.state,
|
|
144
|
+
workflowUnresolved: workflow.unresolved || [],
|
|
145
|
+
executeStatus: obligations.obligations.find(item => item.id === 'execute')?.status,
|
|
146
|
+
verifyStatus: obligations.obligations.find(item => item.id === 'verify')?.status,
|
|
147
|
+
warnings,
|
|
148
|
+
handoffBefore,
|
|
149
|
+
handoffAfter: readJson(path.join(sessionDir, 'handoff-state.json')),
|
|
150
|
+
};
|
|
151
|
+
}));
|
|
152
|
+
const flagName = flag === null ? 'unset' : flag;
|
|
153
|
+
const assertionPrefix = `credit.${leg.id}.${label}.${flagName}`;
|
|
154
|
+
console.log(` SENTINEL ${leg.id}/${flagName}: ${loads.length ? loads.join('; ') : 'no E1 loads'}`);
|
|
155
|
+
check(loads.length === 0, `${assertionPrefix}.no-e1-load`, loads.join('; '));
|
|
156
|
+
check(value.operationErrors.length === 0 && value.unresolved.length === 0,
|
|
157
|
+
`${assertionPrefix}.typed-and-aggregate-complete`, JSON.stringify({ errors: value.operationErrors, unresolved: value.unresolved }));
|
|
158
|
+
const expectedState = options.expectedState || 'satisfied';
|
|
159
|
+
check(value.workflowState === expectedState &&
|
|
160
|
+
(expectedState === 'running'
|
|
161
|
+
? value.workflowUnresolved.includes('verification-after-edit-missing')
|
|
162
|
+
: value.workflowUnresolved.length === 0),
|
|
163
|
+
`${assertionPrefix}.stop-${expectedState}`, JSON.stringify(value));
|
|
164
|
+
check(value.executeStatus === 'pass' && value.verifyStatus === 'pass',
|
|
165
|
+
`${assertionPrefix}.aggregate-pass`, `${value.executeStatus}/${value.verifyStatus}`);
|
|
166
|
+
check(JSON.stringify(value.handoffAfter) === JSON.stringify(value.handoffBefore),
|
|
167
|
+
`${assertionPrefix}.handoff-preserved`, JSON.stringify(value.handoffAfter));
|
|
168
|
+
return value;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function missingBindingControl(leg) {
|
|
172
|
+
const scenario = createScenario(leg, 'missing-binding');
|
|
173
|
+
const { context, payload, runtime, stopGate, api, sessionDir } = scenario;
|
|
174
|
+
context.workflow.lastMutationAt = 1000;
|
|
175
|
+
runtime.saveWorkflow(context);
|
|
176
|
+
writeJson(path.join(sessionDir, 'handoff-state.json'), { lastEditAt: 1000 });
|
|
177
|
+
const { value, loads } = withLoadSpy(leg, () => withFlag(null, () => {
|
|
178
|
+
const warnings = captureWarnings(() => stopGate.decide(payload));
|
|
179
|
+
const workflow = readJson(context.file);
|
|
180
|
+
return { state: workflow.state, unresolved: workflow.unresolved || [], warnings,
|
|
181
|
+
obligations: readJson(api.obligationPath(sessionDir)) };
|
|
182
|
+
}));
|
|
183
|
+
check(loads.length === 0, `missing.${leg.id}.no-e1-load`, loads.join('; '));
|
|
184
|
+
check(value.state === 'running' && value.unresolved.includes('binding:req-change:tdd:pending'),
|
|
185
|
+
`missing.${leg.id}.required-binding-reminder`, JSON.stringify(value.unresolved));
|
|
186
|
+
check(value.unresolved.includes('verify:pending') && value.unresolved.includes('verification-after-edit-missing'),
|
|
187
|
+
`missing.${leg.id}.verification-reminder`, JSON.stringify(value.unresolved));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function fableStopControl(leg, correlated) {
|
|
191
|
+
const label = correlated ? 'fable-correlated' : 'fable-missing-run';
|
|
192
|
+
const plan = { strategySelection: 'selected', tier: 'tier3', strategy: 'fable-staged' };
|
|
193
|
+
const requirements = [{ id: 'stage-work', summary: 'Implement the stage work', acceptance: 'The stage check passes' }];
|
|
194
|
+
const scenario = createScenario(leg, label, plan, requirements);
|
|
195
|
+
const { context, payload, runtime, stopGate, sessionDir } = scenario;
|
|
196
|
+
const runId = `run-${label}-${leg.id}`;
|
|
197
|
+
context.workflow.runId = runId;
|
|
198
|
+
runtime.saveWorkflow(context);
|
|
199
|
+
if (correlated) {
|
|
200
|
+
const state = require(path.join(leg.hooks, 'lib', 'harness-state.js'));
|
|
201
|
+
const stateRoot = state.getStateRoot(WORKSPACE);
|
|
202
|
+
const runRoot = path.join(stateRoot, 'fable-runs', runId);
|
|
203
|
+
const stageId = 'stage-work';
|
|
204
|
+
const planId = 'plan-p1-553';
|
|
205
|
+
const verifiedAt = '2026-11-27T00:00:00.000Z';
|
|
206
|
+
const checkCommand = 'node ci/stage-check.js';
|
|
207
|
+
writeJson(path.join(runRoot, 'run.json'), {
|
|
208
|
+
runId, workflowId: context.workflow.workflowId, sessionId: context.sessionId,
|
|
209
|
+
strategy: 'fable-staged', createdAt: verifiedAt, planId, stageIds: [stageId],
|
|
210
|
+
});
|
|
211
|
+
writeJson(path.join(runRoot, 'contracts', `${stageId}.json`), {
|
|
212
|
+
stageId, runId, planId, sessionId: context.sessionId, status: 'pass', checkCommand,
|
|
213
|
+
workerId: 'worker-p1-553', verifiedAt, requiredBindings: [], optionalBindings: [],
|
|
214
|
+
agent: 'fable-worker', writeSet: ['hooks/scripts/lib/workflow-obligations.js'], dependsOn: [],
|
|
215
|
+
});
|
|
216
|
+
writeJson(path.join(runRoot, 'evidence', `${stageId}.json`), {
|
|
217
|
+
status: 'pass', exitCode: 0, runId, planId, stageId, sessionId: context.sessionId,
|
|
218
|
+
workerId: 'worker-p1-553', observedAt: verifiedAt, checkCommand,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const { value, loads } = withLoadSpy(leg, () => withFlag(null, () => {
|
|
222
|
+
const warnings = captureWarnings(() => stopGate.decide(payload));
|
|
223
|
+
const workflow = readJson(context.file);
|
|
224
|
+
return { state: workflow.state, unresolved: workflow.unresolved || [], warnings };
|
|
225
|
+
}));
|
|
226
|
+
check(loads.length === 0, `fable.${leg.id}.${correlated ? 'correlated' : 'missing'}.no-e1-load`, loads.join('; '));
|
|
227
|
+
if (correlated) {
|
|
228
|
+
check(value.state === 'satisfied' && value.unresolved.length === 0,
|
|
229
|
+
`fable.${leg.id}.correlated-run-satisfies`, JSON.stringify(value));
|
|
230
|
+
} else {
|
|
231
|
+
check(value.state === 'running' && value.unresolved.includes('correlated-run-missing'),
|
|
232
|
+
`fable.${leg.id}.missing-run-reminds`, JSON.stringify(value));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function ordinaryStopStorageFailureControl(leg) {
|
|
237
|
+
const scenario = createScenario(leg, 'stop-storage-failure');
|
|
238
|
+
const { context, payload, runtime, sessionDir } = scenario;
|
|
239
|
+
runtime.saveWorkflow(context);
|
|
240
|
+
writeJson(path.join(sessionDir, 'handoff-state.json'), { lastEditAt: 1000 });
|
|
241
|
+
const stopGatePath = path.join(leg.hooks, 'workflow-stop-gate.js');
|
|
242
|
+
const preload = path.join(TEMP, `stop-save-failure-${leg.id}.js`);
|
|
243
|
+
fs.writeFileSync(preload, [
|
|
244
|
+
"'use strict';",
|
|
245
|
+
"const Module = require('module');",
|
|
246
|
+
"const path = require('path');",
|
|
247
|
+
'const stopGate = path.resolve(process.env.HARNESS_P1_STOP_GATE);',
|
|
248
|
+
'const original = Module._load;',
|
|
249
|
+
'Module._load = function (request, parent, isMain) {',
|
|
250
|
+
" if (parent?.filename && path.resolve(parent.filename) === stopGate && request === './lib/workflow-runtime') {",
|
|
251
|
+
' const runtime = Reflect.apply(original, this, [request, parent, isMain]);',
|
|
252
|
+
" return { ...runtime, saveWorkflow() { throw new Error('simulated ordinary Stop storage failure'); } };",
|
|
253
|
+
' }',
|
|
254
|
+
' return Reflect.apply(original, this, [request, parent, isMain]);',
|
|
255
|
+
'};',
|
|
256
|
+
].join('\n') + '\n', 'utf8');
|
|
257
|
+
const result = require('child_process').spawnSync(process.execPath, ['--require', preload, stopGatePath], {
|
|
258
|
+
cwd: WORKSPACE,
|
|
259
|
+
encoding: 'utf8',
|
|
260
|
+
input: JSON.stringify(payload),
|
|
261
|
+
timeout: 10000,
|
|
262
|
+
env: {
|
|
263
|
+
...process.env,
|
|
264
|
+
HARNESS_STATE_HOME: path.join(TEMP, 'state-home'),
|
|
265
|
+
HARNESS_WORKSPACE_ROOT: WORKSPACE,
|
|
266
|
+
HARNESS_P1_STOP_GATE: stopGatePath,
|
|
267
|
+
[SWITCH]: '',
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
check(result.status === 0, `storage.${leg.id}.ordinary-stop-exits-zero`, result.stderr || result.error?.message || `status ${result.status}`);
|
|
271
|
+
check((result.stderr || '').includes('simulated ordinary Stop storage failure') &&
|
|
272
|
+
!(result.stderr || '').includes('withhold-persist-failed'),
|
|
273
|
+
`storage.${leg.id}.ordinary-error-is-not-pilot-recovery`, result.stderr || 'no ordinary storage diagnostic');
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
console.log('=== P1-553 E1 workflow-credit unhook ===');
|
|
277
|
+
try {
|
|
278
|
+
for (const leg of LEGS) {
|
|
279
|
+
if (!fs.existsSync(path.join(leg.hooks, 'workflow-stop-gate.js'))) {
|
|
280
|
+
check(false, `layout.${leg.id}.present`, 'workflow-stop-gate.js is missing');
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const results = new Map();
|
|
284
|
+
for (const [index, flag] of [null, '0', '1'].entries()) {
|
|
285
|
+
results.set(flag === null ? 'unset' : flag, completeOrdinaryWorkflow(leg, flag, `credit-${index}`));
|
|
286
|
+
}
|
|
287
|
+
const values = [...results.values()];
|
|
288
|
+
check(values.every(value => JSON.stringify(value) === JSON.stringify(values[0])),
|
|
289
|
+
`credit.${leg.id}.flag-values-identical`, JSON.stringify(Object.fromEntries(results)));
|
|
290
|
+
|
|
291
|
+
const legacyCases = [
|
|
292
|
+
{
|
|
293
|
+
id: 'doc-only', expectedState: 'running',
|
|
294
|
+
initialState: 'satisfied',
|
|
295
|
+
handoff: { lastEditAt: 1000, lastVerifyAt: 3000, lastDocVerifyAt: 3000, lastDocVerifyExitCode: 0 },
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: 'generic-then-doc', expectedState: 'satisfied',
|
|
299
|
+
handoff: { lastEditAt: 1000, lastVerifyAt: 3000, lastGenericVerifyAt: 2000,
|
|
300
|
+
lastGenericVerifyExitCode: 0, lastDocVerifyAt: 3000, lastDocVerifyExitCode: 0 },
|
|
301
|
+
},
|
|
302
|
+
{ id: 'off-aggregate', expectedState: 'satisfied', handoff: { lastEditAt: 1000, lastVerifyAt: 2000 } },
|
|
303
|
+
];
|
|
304
|
+
for (const fixture of legacyCases) {
|
|
305
|
+
completeOrdinaryWorkflow(leg, null, `legacy-${fixture.id}`, fixture);
|
|
306
|
+
}
|
|
307
|
+
missingBindingControl(leg);
|
|
308
|
+
fableStopControl(leg, false);
|
|
309
|
+
fableStopControl(leg, true);
|
|
310
|
+
ordinaryStopStorageFailureControl(leg);
|
|
311
|
+
}
|
|
312
|
+
} catch (error) {
|
|
313
|
+
console.error(`INFRA ${error.stack || error}`);
|
|
314
|
+
failed++;
|
|
315
|
+
} finally {
|
|
316
|
+
fs.rmSync(TEMP, { recursive: true, force: true });
|
|
317
|
+
if (ORIGINAL_ENV.stateHome === undefined) delete process.env.HARNESS_STATE_HOME;
|
|
318
|
+
else process.env.HARNESS_STATE_HOME = ORIGINAL_ENV.stateHome;
|
|
319
|
+
if (ORIGINAL_ENV.workspaceRoot === undefined) delete process.env.HARNESS_WORKSPACE_ROOT;
|
|
320
|
+
else process.env.HARNESS_WORKSPACE_ROOT = ORIGINAL_ENV.workspaceRoot;
|
|
321
|
+
if (ORIGINAL_ENV.pilot === undefined) delete process.env[SWITCH];
|
|
322
|
+
else process.env[SWITCH] = ORIGINAL_ENV.pilot;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (failed) {
|
|
326
|
+
console.error(`FAIL P1-553 E1 workflow-credit unhook: ${failed} assertions`);
|
|
327
|
+
process.exitCode = 1;
|
|
328
|
+
} else console.log('PASS P1-553 E1 workflow-credit unhook');
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// P2a-553: the Claude hook manifest must not register the retired E1 pilot
|
|
5
|
+
// capture routes, while the general PostToolUse / PostToolUseFailure / Stop
|
|
6
|
+
// registrations and the Codex native subagent adapters stay reachable.
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const helper = require('./test-helper');
|
|
10
|
+
|
|
11
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
12
|
+
const CLAUDE_MANIFEST = path.join(ROOT, 'hooks', 'hooks.json');
|
|
13
|
+
const CODEX_MANIFEST = path.join(ROOT, 'plugins', 'harness-everything', 'hooks', 'hooks.json');
|
|
14
|
+
|
|
15
|
+
const RETIRED = [
|
|
16
|
+
{ id: 'harness:pre:pilot-capture', event: 'PreToolUse' },
|
|
17
|
+
{ id: 'harness:post-task:pilot-capture', event: 'PostToolUse' },
|
|
18
|
+
{ id: 'harness:subagent:start-capture', event: 'SubagentStart' },
|
|
19
|
+
{ id: 'harness:subagent:stop-capture', event: 'SubagentStop' },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
// Drive the real manifest files, not a hand-built object (E-0008).
|
|
23
|
+
const claude = JSON.parse(fs.readFileSync(CLAUDE_MANIFEST, 'utf8'));
|
|
24
|
+
const codex = JSON.parse(fs.readFileSync(CODEX_MANIFEST, 'utf8'));
|
|
25
|
+
const hooks = claude.hooks || {};
|
|
26
|
+
const codexHooks = codex.hooks || {};
|
|
27
|
+
const groups = event => (Array.isArray(hooks[event]) ? hooks[event] : []);
|
|
28
|
+
const codexGroups = event => (Array.isArray(codexHooks[event]) ? codexHooks[event] : []);
|
|
29
|
+
const commands = group => ((group && group.hooks) || []).map(handler => (handler && handler.command) || '');
|
|
30
|
+
const registeredIds = () => Object.values(hooks).flat().map(group => group && group.id).filter(Boolean);
|
|
31
|
+
const check = (condition, id, detail) => helper.check(id, condition, detail);
|
|
32
|
+
|
|
33
|
+
// ---- Positive controls (must pass on the unchanged base) -------------------
|
|
34
|
+
|
|
35
|
+
check(groups('PostToolUse').some(group => group.id === 'harness:post:state-persist'),
|
|
36
|
+
'p2a.claude.control.posttooluse-general-reachable',
|
|
37
|
+
'general PostToolUse state-persist is absent from hooks/hooks.json');
|
|
38
|
+
check(groups('PostToolUseFailure').length > 0,
|
|
39
|
+
'p2a.claude.control.posttoolusefailure-reachable',
|
|
40
|
+
'PostToolUseFailure has no registrations');
|
|
41
|
+
check(groups('Stop').some(group => group.id === 'harness:stop:stop-gate') &&
|
|
42
|
+
groups('Stop').some(group => group.id === 'harness:stop:workflow-completion-gate'),
|
|
43
|
+
'p2a.claude.control.stop-reachable',
|
|
44
|
+
'Stop lost the stop-gate or workflow-completion-gate registration');
|
|
45
|
+
check(groups('PostToolUse').some(group => group.matcher === 'Task' &&
|
|
46
|
+
commands(group).some(command => /subagent-scope-guard\.js/.test(command))),
|
|
47
|
+
'p2a.claude.control.task-post-general-preserved',
|
|
48
|
+
'general Task post subagent-scope-guard was removed with the pilot capture');
|
|
49
|
+
|
|
50
|
+
// Positive control that reaches the real hook CLI: a general PostToolUse Bash
|
|
51
|
+
// still persists handoff state. Path-specific sentinel lives in the failure set.
|
|
52
|
+
helper.runHook('state-persist.js', {
|
|
53
|
+
session_id: helper.SESSION_ID,
|
|
54
|
+
hook_event_name: 'PostToolUse',
|
|
55
|
+
tool_name: 'Bash',
|
|
56
|
+
tool_response: { stdout: 'p2a-reach-probe', exitCode: 0 },
|
|
57
|
+
}, { HARNESS_DOC_RECONCILIATION_PILOT: '0' });
|
|
58
|
+
check(helper.stateExists('handoff-state.json'),
|
|
59
|
+
'p2a.claude.control.state-persist-reaches-code',
|
|
60
|
+
'the general state-persist hook did not write handoff-state.json');
|
|
61
|
+
|
|
62
|
+
// Codex native subagent adapters live in the packaged manifest. P2a must not
|
|
63
|
+
// edit that file (coordinator owns the mirror), so they must remain reachable.
|
|
64
|
+
check(codexGroups('SubagentStart').some(group =>
|
|
65
|
+
commands(group).some(command => /subagent-start\.js/.test(command))),
|
|
66
|
+
'p2a.codex.control.subagent-start-adapter',
|
|
67
|
+
'Codex SubagentStart adapter missing from plugins/harness-everything/hooks/hooks.json');
|
|
68
|
+
check(codexGroups('SubagentStop').some(group =>
|
|
69
|
+
commands(group).some(command => /subagent-stop\.js/.test(command))),
|
|
70
|
+
'p2a.codex.control.subagent-stop-adapter',
|
|
71
|
+
'Codex SubagentStop adapter missing from plugins/harness-everything/hooks/hooks.json');
|
|
72
|
+
|
|
73
|
+
// ---- RED assertions: acceptance row ①, one path-specific sentinel each -----
|
|
74
|
+
|
|
75
|
+
for (const { id, event } of RETIRED) {
|
|
76
|
+
check(!registeredIds().includes(id),
|
|
77
|
+
`p2a.claude.${event}.${id}.absent`,
|
|
78
|
+
`hooks/hooks.json still registers ${id} under ${event}`);
|
|
79
|
+
}
|
|
80
|
+
check(!Object.prototype.hasOwnProperty.call(hooks, 'SubagentStart') &&
|
|
81
|
+
!Object.prototype.hasOwnProperty.call(hooks, 'SubagentStop'),
|
|
82
|
+
'p2a.claude.subagent-events.absent',
|
|
83
|
+
'Claude manifest still declares SubagentStart/SubagentStop capture events');
|
|
84
|
+
check(!groups('PreToolUse').some(group =>
|
|
85
|
+
commands(group).some(command => /state-persist\.js/.test(command))),
|
|
86
|
+
'p2a.claude.pre.state-persist.absent',
|
|
87
|
+
'PreToolUse still routes to state-persist.js (pilot launch capture)');
|
|
88
|
+
check(!groups('PostToolUse').some(group =>
|
|
89
|
+
commands(group).some(command => /state-persist\.js/.test(command)) &&
|
|
90
|
+
/(?:^|\|)(Task|Agent)(?:\||$)/.test(group.matcher || '')),
|
|
91
|
+
'p2a.claude.post-task.state-persist.absent',
|
|
92
|
+
'PostToolUse still routes Task/Agent to state-persist.js (pilot result capture)');
|
|
93
|
+
check(!Object.values(hooks).flat().some(group =>
|
|
94
|
+
/Pilot-only doc-reconciliation/.test((group && group.description) || '')),
|
|
95
|
+
'p2a.claude.pilot-descriptions.absent',
|
|
96
|
+
'a pilot-only doc-reconciliation registration remains in hooks/hooks.json');
|
|
97
|
+
|
|
98
|
+
helper.finish();
|