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
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const assert = require('node:assert/strict');
|
|
4
|
-
const crypto = require('node:crypto');
|
|
5
4
|
const fs = require('node:fs');
|
|
6
5
|
const os = require('node:os');
|
|
7
6
|
const path = require('node:path');
|
|
@@ -11,8 +10,7 @@ const { createV2Driver } = require('./lib/opencode-v2-driver');
|
|
|
11
10
|
|
|
12
11
|
const ROOT = path.resolve(__dirname, '..');
|
|
13
12
|
const STOP_GATE = path.join(ROOT, 'hooks/scripts/workflow-stop-gate.js');
|
|
14
|
-
const
|
|
15
|
-
const savedEnv = Object.fromEntries(['HOME', 'HARNESS_STATE_HOME', 'HARNESS_WORKSPACE_ROOT', 'HARNESS_DOC_RECONCILIATION_PILOT'].map(key => [key, process.env[key]]));
|
|
13
|
+
const savedEnv = Object.fromEntries(['HOME', 'USERPROFILE', 'HARNESS_STATE_HOME', 'HARNESS_WORKSPACE_ROOT', 'HARNESS_DOC_RECONCILIATION_PILOT', 'HARNESS_TELEMETRY'].map(key => [key, process.env[key]]));
|
|
16
14
|
|
|
17
15
|
function git(cwd, args) {
|
|
18
16
|
const env = { ...process.env, GIT_AUTHOR_NAME: 'Harness test', GIT_AUTHOR_EMAIL: 'harness@example.invalid', GIT_COMMITTER_NAME: 'Harness test', GIT_COMMITTER_EMAIL: 'harness@example.invalid' };
|
|
@@ -88,7 +86,6 @@ function seedWorkflow(rootOrFixture, sessionId) {
|
|
|
88
86
|
{ id: 'verify-doc', stepType: 'verification', summary: 'Verify the governed retry change', acceptance: 'the objective checks are recorded' },
|
|
89
87
|
]), plan, plan.strategy, 'fixture workflow for the OpenCode reconciliation path');
|
|
90
88
|
obligations.materializeExecutionObligations(context, plan);
|
|
91
|
-
require(PILOT).captureBaseline(context);
|
|
92
89
|
require(path.join(ROOT, 'hooks/scripts/lib/workflow-runtime.js')).saveWorkflow(context);
|
|
93
90
|
return { sessionDir, payload };
|
|
94
91
|
}
|
|
@@ -107,13 +104,15 @@ function writeEditState(sessionDir, values) {
|
|
|
107
104
|
}));
|
|
108
105
|
}
|
|
109
106
|
|
|
110
|
-
async function withV2DocFixture(fn) {
|
|
111
|
-
const d = await createV2Driver();
|
|
112
|
-
const pilotSaved = Object.fromEntries(['HARNESS_WORKSPACE_ROOT', 'HARNESS_DOC_RECONCILIATION_PILOT'].map(key => [key, process.env[key]]));
|
|
107
|
+
async function withV2DocFixture(fn, options = {}) {
|
|
108
|
+
const d = await createV2Driver(options);
|
|
109
|
+
const pilotSaved = Object.fromEntries(['HARNESS_WORKSPACE_ROOT', 'HARNESS_DOC_RECONCILIATION_PILOT', 'HARNESS_TELEMETRY'].map(key => [key, process.env[key]]));
|
|
113
110
|
try {
|
|
114
111
|
initWorkspace(d.workspace);
|
|
115
112
|
process.env.HARNESS_WORKSPACE_ROOT = d.workspace;
|
|
116
|
-
process.env.
|
|
113
|
+
process.env.HARNESS_TELEMETRY = 'local';
|
|
114
|
+
if (options.pilotFlag === undefined) delete process.env.HARNESS_DOC_RECONCILIATION_PILOT;
|
|
115
|
+
else process.env.HARNESS_DOC_RECONCILIATION_PILOT = options.pilotFlag;
|
|
117
116
|
return await fn(d);
|
|
118
117
|
} finally {
|
|
119
118
|
for (const [key, value] of Object.entries(pilotSaved)) {
|
|
@@ -124,10 +123,19 @@ async function withV2DocFixture(fn) {
|
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
function
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
function readJson(file) {
|
|
127
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function readTelemetryEvents(sessionDir) {
|
|
131
|
+
const file = path.join(path.dirname(path.dirname(sessionDir)), 'telemetry', 'events.jsonl');
|
|
132
|
+
if (!fs.existsSync(file)) return [];
|
|
133
|
+
return fs.readFileSync(file, 'utf8').trim().split(/\r?\n/).filter(Boolean).map(line => JSON.parse(line));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function readObservationRecords(observationsDir) {
|
|
137
|
+
const file = path.join(observationsDir, 'observations-index.json');
|
|
138
|
+
return fs.existsSync(file) ? readJson(file).records : [];
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
function restoreEnv() {
|
|
@@ -137,306 +145,178 @@ function restoreEnv() {
|
|
|
137
145
|
}
|
|
138
146
|
}
|
|
139
147
|
|
|
140
|
-
test('existing Stop consumer
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
test('existing Stop consumer runs ordinary workflow Stop without writing an E1 pilot report', () => {
|
|
149
|
+
for (const [label, pilotFlag] of [['pilot-1', '1'], ['pilot-unset', undefined]]) {
|
|
150
|
+
const fixture = makeFixture();
|
|
151
|
+
try {
|
|
152
|
+
if (pilotFlag === undefined) delete process.env.HARNESS_DOC_RECONCILIATION_PILOT;
|
|
153
|
+
else process.env.HARNESS_DOC_RECONCILIATION_PILOT = pilotFlag;
|
|
154
|
+
const control = seedWorkflow(fixture, `stop-positive-control-${label}`);
|
|
155
|
+
const result = runJson(STOP_GATE, fixture.root, control.payload);
|
|
156
|
+
const reportPath = path.join(control.sessionDir, 'doc-reconciliation-pilot.json');
|
|
157
|
+
const workflow = readJson(path.join(control.sessionDir, 'workflow-run.json'));
|
|
158
|
+
assert.equal(result.status, 0, `${label}: ${result.stderr}`);
|
|
159
|
+
assert.match(result.stderr, /\[Workflow Reminder\] Unresolved workflow evidence:/, `${label}: ordinary Stop reminder still fires`);
|
|
160
|
+
assert.ok(Array.isArray(workflow.unresolved) && workflow.unresolved.length > 0, `${label}: ordinary Stop records unresolved obligations`);
|
|
161
|
+
assert.equal(fs.existsSync(reportPath), false, `${label}: Stop must not write doc-reconciliation-pilot.json`);
|
|
162
|
+
} finally {
|
|
163
|
+
fixture.cleanup();
|
|
164
|
+
restoreEnv();
|
|
165
|
+
}
|
|
154
166
|
}
|
|
155
167
|
});
|
|
156
168
|
|
|
157
|
-
test('
|
|
158
|
-
const
|
|
159
|
-
const pilot = require(PILOT);
|
|
160
|
-
const originalAssess = pilot.assess;
|
|
161
|
-
const assessmentSessions = [];
|
|
162
|
-
pilot.assess = function (context, ...args) {
|
|
163
|
-
assessmentSessions.push(context?.sessionId);
|
|
164
|
-
return originalAssess.call(this, context, ...args);
|
|
165
|
-
};
|
|
166
|
-
try {
|
|
169
|
+
test('V2 execute.after writes no E1 journal while ordinary telemetry, edit, observation, and Stop remain active', async () => {
|
|
170
|
+
for (const [label, pilotFlag] of [['pilot-1', '1'], ['pilot-unset', undefined]]) {
|
|
167
171
|
await withV2DocFixture(async d => {
|
|
168
|
-
const sessionId =
|
|
172
|
+
const sessionId = `native-v2-unhooked-${label}`;
|
|
169
173
|
const { sessionDir } = seedWorkflow(d.workspace, sessionId);
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
const observationsDir = process.env.HARNESS_OBSERVATIONS_DIR;
|
|
175
|
+
|
|
176
|
+
await d.sessionHook('prompt')({
|
|
177
|
+
sessionID: sessionId,
|
|
178
|
+
messageID: `turn-${label}`,
|
|
179
|
+
prompt: { text: 'update retry doc and verify' },
|
|
175
180
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
|
|
182
|
+
const skillEvent = { tool: 'skill', sessionID: sessionId, id: 'call-skill', messageID: 'msg-skill', input: { skill: 'tdd' } };
|
|
183
|
+
await d.toolHook('execute.before')(skillEvent);
|
|
184
|
+
await d.toolHook('execute.after')({ ...skillEvent, status: 'completed', result: { output: 'loaded' } });
|
|
185
|
+
|
|
186
|
+
const editEvent = {
|
|
187
|
+
tool: 'edit', sessionID: sessionId, id: 'call-edit', messageID: 'msg-edit',
|
|
188
|
+
input: { filePath: path.join(d.workspace, 'docs/adr/GRPH-001.md') },
|
|
189
|
+
};
|
|
190
|
+
await d.toolHook('execute.before')(editEvent);
|
|
191
|
+
await d.toolHook('execute.after')({ ...editEvent, status: 'completed', result: { output: 'ok', metadata: { exit: 0 } } });
|
|
192
|
+
|
|
193
|
+
const bashEvent = {
|
|
194
|
+
tool: 'bash', sessionID: sessionId, id: 'call-bash', messageID: 'msg-bash',
|
|
179
195
|
input: { command: 'doc-check' },
|
|
196
|
+
};
|
|
197
|
+
await d.toolHook('execute.before')(bashEvent);
|
|
198
|
+
await d.toolHook('execute.after')({
|
|
199
|
+
...bashEvent, status: 'completed',
|
|
200
|
+
error: { name: 'NativeError', message: 'native command error', code: 'NATIVE_FAILURE' },
|
|
180
201
|
});
|
|
181
202
|
|
|
203
|
+
// Path-specific sentinel: E1 host capture journal must not be created.
|
|
182
204
|
const journal = path.join(sessionDir, 'opencode-captures.jsonl');
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
errorRecord.error?.name !== 'NativeError' || errorRecord.error?.message !== 'native command error' ||
|
|
199
|
-
errorRecord.error?.code !== 'NATIVE_FAILURE' || errorRecord.exit === 0) {
|
|
200
|
-
findings.push(`native error was not preserved as failure without fabricated exit zero: ${JSON.stringify(errorRecord)}`);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const reportPath = path.join(sessionDir, 'doc-reconciliation-pilot.json');
|
|
205
|
+
assert.equal(fs.existsSync(journal), false, `${label}: V2 execute.after must not write opencode-captures.jsonl`);
|
|
206
|
+
|
|
207
|
+
// Positive controls: ordinary edit state, compliance, and telemetry remain active.
|
|
208
|
+
const editState = readJson(path.join(sessionDir, 'edit-state.json'));
|
|
209
|
+
const compliance = readJson(path.join(sessionDir, 'compliance.json'));
|
|
210
|
+
assert.equal(editState.verificationPending, true, `${label}: edit marks verificationPending`);
|
|
211
|
+
assert.equal(editState.editsSinceVerification, 1, `${label}: edit increments editsSinceVerification`);
|
|
212
|
+
assert.equal(compliance.totalEdits, 1, `${label}: compliance records totalEdits`);
|
|
213
|
+
const preIdleTelemetry = readTelemetryEvents(sessionDir).map(item => item.event);
|
|
214
|
+
assert.ok(preIdleTelemetry.includes('skill.invoke'), `${label}: telemetry records skill.invoke`);
|
|
215
|
+
assert.ok(preIdleTelemetry.includes('skill.loaded'), `${label}: telemetry records skill.loaded`);
|
|
216
|
+
assert.ok(preIdleTelemetry.includes('tool.observed'), `${label}: telemetry records tool.observed`);
|
|
217
|
+
|
|
218
|
+
// Completion triggers ordinary verification, observation closure, telemetry close, and Stop without E1 report.
|
|
219
|
+
const workflowFile = path.join(sessionDir, 'workflow-run.json');
|
|
204
220
|
d.emit('session.execution.succeeded', sessionId);
|
|
205
221
|
await d.waitFor(
|
|
206
|
-
() =>
|
|
207
|
-
|
|
222
|
+
() => readObservationRecords(observationsDir).length === 1
|
|
223
|
+
&& readJson(path.join(sessionDir, 'edit-state.json')).verificationPending === false
|
|
224
|
+
&& Array.isArray(readJson(workflowFile).unresolved)
|
|
225
|
+
&& readJson(workflowFile).unresolved.length > 0,
|
|
226
|
+
{ label: `${label}: observation, verification, and ordinary Stop completion`, timeoutMs: 8000 },
|
|
208
227
|
);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
assert.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
pilot.assess = originalAssess;
|
|
228
|
+
|
|
229
|
+
const [obsRecord] = readObservationRecords(observationsDir);
|
|
230
|
+
assert.equal(obsRecord.host, 'opencode', `${label}: observation host is opencode`);
|
|
231
|
+
assert.equal(obsRecord.writer.sessionId, sessionId, `${label}: observation session matches`);
|
|
232
|
+
assert.equal(obsRecord.behavior.filesWritten, 1, `${label}: observation counted the edit`);
|
|
233
|
+
const postIdleTelemetry = readTelemetryEvents(sessionDir).map(item => item.event);
|
|
234
|
+
assert.ok(postIdleTelemetry.includes('skill.complete'), `${label}: telemetry closes active skill on idle`);
|
|
235
|
+
assert.equal(fs.existsSync(journal), false, `${label}: opencode-captures.jsonl remains absent after idle`);
|
|
236
|
+
assert.equal(fs.existsSync(path.join(sessionDir, 'doc-reconciliation-pilot.json')), false, `${label}: no E1 pilot report after idle`);
|
|
237
|
+
}, { observations: 'on', pilotFlag });
|
|
220
238
|
}
|
|
221
239
|
});
|
|
222
240
|
|
|
223
|
-
test('session idle
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
for (const [suffix, state] of cases) {
|
|
241
|
-
const sessionId = `idle-${suffix}`;
|
|
242
|
-
const { sessionDir } = seedWorkflow(d.workspace, sessionId);
|
|
243
|
-
writeEditState(sessionDir, state);
|
|
244
|
-
const reportPath = path.join(sessionDir, 'doc-reconciliation-pilot.json');
|
|
245
|
-
d.emit('session.execution.succeeded', sessionId);
|
|
246
|
-
await d.waitFor(
|
|
247
|
-
() => assessmentSessions.filter(id => id === sessionId).length === 1 && fs.existsSync(reportPath),
|
|
248
|
-
{ label: `${suffix} V2 completion Stop assessment`, timeoutMs: 8000 },
|
|
249
|
-
);
|
|
250
|
-
const report = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
|
|
251
|
-
if (assessmentSessions.filter(id => id === sessionId).length !== 1) {
|
|
252
|
-
findings.push(`${suffix}: consumer assessment count=${assessmentSessions.filter(id => id === sessionId).length}, expected exactly one`);
|
|
253
|
-
}
|
|
254
|
-
if (!report || report.pilotCredit !== false || report.pilotStatus !== 'unresolved') {
|
|
255
|
-
findings.push(`${suffix}: expected one refused/unavailable report, received ${JSON.stringify(report)}`);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
const cleanupSession = 'idle-no-verification-pending';
|
|
259
|
-
d.emit('session.execution.succeeded', cleanupSession);
|
|
241
|
+
test('session idle finally releases the controller across all four early returns and completes ordinary Stop/verification/reminder paths', async () => {
|
|
242
|
+
await withV2DocFixture(async d => {
|
|
243
|
+
const cases = [
|
|
244
|
+
['follow-up-pending', { followUpPending: true }],
|
|
245
|
+
['follow-up-delivery-pending', { followUpDeliveryPending: true, followUpMessage: 'deliver once' }],
|
|
246
|
+
['no-verification-pending', { verificationPending: false, editsSinceVerification: 0 }],
|
|
247
|
+
['verification-succeeds', { verificationPending: true, editsSinceVerification: 1 }],
|
|
248
|
+
];
|
|
249
|
+
for (const [suffix, state] of cases) {
|
|
250
|
+
const sessionId = `idle-${suffix}`;
|
|
251
|
+
const { sessionDir } = seedWorkflow(d.workspace, sessionId);
|
|
252
|
+
const workflowFile = path.join(sessionDir, 'workflow-run.json');
|
|
253
|
+
const editStateFile = path.join(sessionDir, 'edit-state.json');
|
|
254
|
+
writeEditState(sessionDir, state);
|
|
255
|
+
|
|
256
|
+
const promptsBefore = d.prompts.length;
|
|
257
|
+
d.emit('session.execution.succeeded', sessionId);
|
|
260
258
|
await d.waitFor(
|
|
261
|
-
() =>
|
|
262
|
-
{ label:
|
|
259
|
+
() => Array.isArray(readJson(workflowFile).unresolved) && readJson(workflowFile).unresolved.length > 0,
|
|
260
|
+
{ label: `${suffix}: ordinary Stop ran on first idle`, timeoutMs: 8000 },
|
|
263
261
|
);
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
|
|
263
|
+
const afterFirst = readJson(editStateFile);
|
|
264
|
+
if (suffix === 'follow-up-pending') {
|
|
265
|
+
assert.equal(d.prompts.length, promptsBefore, `${suffix}: no duplicate prompt sent`);
|
|
266
|
+
} else if (suffix === 'follow-up-delivery-pending') {
|
|
267
|
+
assert.equal(d.prompts.length, promptsBefore + 1, `${suffix}: pending reminder prompt delivered`);
|
|
268
|
+
assert.equal(d.prompts.at(-1).sessionID, sessionId);
|
|
269
|
+
assert.equal(d.prompts.at(-1).text, 'deliver once');
|
|
270
|
+
assert.equal(afterFirst.followUpPending, true);
|
|
271
|
+
assert.equal(afterFirst.followUpDeliveryPending, false);
|
|
272
|
+
} else if (suffix === 'no-verification-pending') {
|
|
273
|
+
assert.equal(d.prompts.length, promptsBefore, `${suffix}: no prompt sent without pending verification`);
|
|
274
|
+
} else if (suffix === 'verification-succeeds') {
|
|
275
|
+
assert.equal(afterFirst.verificationPending, false, `${suffix}: passing verification clears verificationPending`);
|
|
276
|
+
assert.equal(afterFirst.editsSinceVerification, 0, `${suffix}: passing verification resets editsSinceVerification`);
|
|
277
|
+
assert.equal(readJson(path.join(sessionDir, 'compliance.json')).verifiedEdits, 1, `${suffix}: compliance increments verifiedEdits`);
|
|
266
278
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
279
|
+
|
|
280
|
+
assert.equal(fs.existsSync(path.join(sessionDir, 'doc-reconciliation-pilot.json')), false, `${suffix}: no E1 pilot report`);
|
|
281
|
+
assert.equal(fs.existsSync(path.join(sessionDir, 'opencode-captures.jsonl')), false, `${suffix}: no E1 capture journal`);
|
|
282
|
+
|
|
283
|
+
// Prove finally released the per-session controller: clear workflow.unresolved and fire a second idle.
|
|
284
|
+
const wf = readJson(workflowFile);
|
|
285
|
+
wf.unresolved = [];
|
|
286
|
+
fs.writeFileSync(workflowFile, JSON.stringify(wf, null, 2));
|
|
287
|
+
d.emit('session.execution.succeeded', sessionId);
|
|
288
|
+
await d.waitFor(
|
|
289
|
+
() => Array.isArray(readJson(workflowFile).unresolved) && readJson(workflowFile).unresolved.length > 0,
|
|
290
|
+
{ label: `${suffix}: second idle runs after finally releases controller`, timeoutMs: 8000 },
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
}, { pilotFlag: '1' });
|
|
272
294
|
});
|
|
273
295
|
|
|
274
|
-
test('
|
|
296
|
+
test('pilot flag values and no-workflow stay unhooked and fail-closed', async () => {
|
|
275
297
|
await withV2DocFixture(async d => {
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const { sessionDir: v1Dir } = seedWorkflow(d.workspace, v1Session);
|
|
290
|
-
await d.toolHook('execute.after')({
|
|
291
|
-
tool: 'edit', sessionID: v1Session, id: 'v1-call', input: { filePath: path.join(d.workspace, 'docs/adr/GRPH-001.md') },
|
|
292
|
-
});
|
|
293
|
-
await d.settled({ quietMs: 100 });
|
|
294
|
-
assert.equal(fs.existsSync(path.join(v1Dir, 'opencode-captures.jsonl')), false, 'V1/no-status output must not create a native capture');
|
|
298
|
+
for (const [label, pilotFlag] of [['pilot-1', '1'], ['pilot-0', '0'], ['pilot-unset', undefined]]) {
|
|
299
|
+
if (pilotFlag === undefined) delete process.env.HARNESS_DOC_RECONCILIATION_PILOT;
|
|
300
|
+
else process.env.HARNESS_DOC_RECONCILIATION_PILOT = pilotFlag;
|
|
301
|
+
const sessionId = `flag-control-${label}`;
|
|
302
|
+
const { sessionDir } = seedWorkflow(d.workspace, sessionId);
|
|
303
|
+
await d.toolHook('execute.after')({
|
|
304
|
+
tool: 'edit', sessionID: sessionId, id: `call-${label}`, status: 'completed',
|
|
305
|
+
result: { output: 'ok', metadata: { exit: 0 } },
|
|
306
|
+
input: { filePath: path.join(d.workspace, 'docs/adr/GRPH-001.md') },
|
|
307
|
+
});
|
|
308
|
+
assert.equal(fs.existsSync(path.join(sessionDir, 'edit-state.json')), true, `${label}: positive control edit-state written`);
|
|
309
|
+
assert.equal(fs.existsSync(path.join(sessionDir, 'opencode-captures.jsonl')), false, `${label}: V2 execute.after must not write opencode-captures.jsonl`);
|
|
310
|
+
}
|
|
295
311
|
|
|
296
312
|
const noWorkflow = 'no-workflow';
|
|
297
313
|
const { getSessionDir } = require(path.join(ROOT, 'hooks/scripts/lib/harness-state.js'));
|
|
298
314
|
const noWorkflowDir = getSessionDir(d.workspace, noWorkflow, { session_id: noWorkflow, cwd: d.workspace, host_id: 'opencode' });
|
|
315
|
+
process.env.HARNESS_DOC_RECONCILIATION_PILOT = '1';
|
|
299
316
|
d.emit('session.execution.succeeded', noWorkflow);
|
|
300
317
|
await d.settled({ quietMs: 150 });
|
|
301
318
|
assert.equal(fs.existsSync(path.join(noWorkflowDir, 'doc-reconciliation-pilot.json')), false, 'no workflow must not write a pilot report');
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const { sessionDir: offDir } = seedWorkflow(d.workspace, offSession);
|
|
305
|
-
process.env.HARNESS_DOC_RECONCILIATION_PILOT = '0';
|
|
306
|
-
d.emit('session.execution.succeeded', offSession);
|
|
307
|
-
await d.settled({ quietMs: 150 });
|
|
308
|
-
assert.equal(fs.existsSync(path.join(offDir, 'doc-reconciliation-pilot.json')), false, 'pilot OFF must not write a reconciliation report');
|
|
309
|
-
|
|
310
|
-
const { createClaudeOriginProvider } = require(path.join(ROOT, 'hooks/scripts/lib/doc-reconciliation-provider.js'));
|
|
311
|
-
const claudeProvider = createClaudeOriginProvider({ hostId: 'opencode', sessionId: 'native-host-control' });
|
|
312
|
-
const claudeContext = claudeProvider.resolveContext({ workspaceRoot: d.workspace });
|
|
313
|
-
assert.equal(claudeContext.status, 'unavailable', 'OpenCode must not enter through Claude provider semantics');
|
|
314
|
-
assert.ok(claudeContext.diagnostics.some(item => item.code === 'unsupported-host'));
|
|
315
|
-
});
|
|
319
|
+
assert.equal(fs.existsSync(path.join(noWorkflowDir, 'workflow-run.json')), false, 'no workflow must not create a workflow file');
|
|
320
|
+
}, { pilotFlag: '1' });
|
|
316
321
|
});
|
|
317
322
|
|
|
318
|
-
const OPENCODE_SESSION = 'provider-session';
|
|
319
|
-
const OPENCODE_QUALIFICATION = {
|
|
320
|
-
source: 'fake-test-fixture', faked: true, toolUseIdPopulated: true, agentIdPopulated: true,
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
function opencodeCapture(overrides = {}) {
|
|
324
|
-
return {
|
|
325
|
-
schema: 'opencode-capture-record/1', hostId: 'opencode', session_id: OPENCODE_SESSION,
|
|
326
|
-
call_id: 'provider-call', tool: 'bash', command: 'npm test', cwd: ROOT,
|
|
327
|
-
status: 'completed', exit: 0, result_digest: 'a'.repeat(64), result_bytes: 1,
|
|
328
|
-
observedIdentity: { workflowId: 'provider-workflow', workflowRevision: 3, baselinePin: null },
|
|
329
|
-
...overrides,
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function opencodeProvider(captures, overrides = {}) {
|
|
334
|
-
const { createOpencodeOriginProvider } = require(path.join(ROOT, 'hooks/scripts/lib/doc-reconciliation-provider.js'));
|
|
335
|
-
return createOpencodeOriginProvider({
|
|
336
|
-
hostId: 'opencode', sessionId: OPENCODE_SESSION, workspaceRoot: ROOT,
|
|
337
|
-
workflowId: 'provider-workflow', workflowRevision: 3, taskId: 'provider-task',
|
|
338
|
-
principals: { author: 'provider-author', executors: ['provider-executor'] },
|
|
339
|
-
qualification: OPENCODE_QUALIFICATION, captures,
|
|
340
|
-
...overrides,
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
function diagnosticCode(result) { return result.diagnostics?.[0]?.code; }
|
|
345
|
-
|
|
346
|
-
test('fake-DI OpenCode origin accepts the complete native execution record shape', () => {
|
|
347
|
-
const provider = opencodeProvider([opencodeCapture({ unrecognizedPrivateField: 'must-not-leak' })]);
|
|
348
|
-
const context = provider.resolveContext({ workspaceRoot: ROOT });
|
|
349
|
-
const result = provider.resolveEvent({
|
|
350
|
-
reference: 'provider-call',
|
|
351
|
-
identity: { workspaceId: 'ws-provider', sessionId: OPENCODE_SESSION, workflowId: 'provider-workflow', workflowRevision: 3 },
|
|
352
|
-
});
|
|
353
|
-
assert.equal(context.status, 'accepted');
|
|
354
|
-
assert.match(context.originRef, /^origin:\/\/opencode\//);
|
|
355
|
-
assert.equal(context.context.activeHost, 'opencode');
|
|
356
|
-
assert.equal(result.status, 'accepted');
|
|
357
|
-
assert.equal(result.originRef, context.originRef);
|
|
358
|
-
assert.equal(result.event.originRef, context.originRef);
|
|
359
|
-
assert.deepEqual(Object.keys(result.event).sort(), [
|
|
360
|
-
'argv', 'artifactDigests', 'captured', 'capability', 'command', 'cwd', 'endIdentity', 'eventId',
|
|
361
|
-
'exitCode', 'identity', 'kind', 'originRef', 'paths', 'principalId', 'producerId', 'provenance', 'resultRef',
|
|
362
|
-
'signal', 'startIdentity', 'toolCorrelationId',
|
|
363
|
-
].sort());
|
|
364
|
-
assert.equal(result.event.producerId, 'opencode-origin-provider');
|
|
365
|
-
assert.equal(result.event.capability, 'shell-command');
|
|
366
|
-
assert.equal(result.event.kind, 'execution');
|
|
367
|
-
assert.equal(result.event.exitCode, 0);
|
|
368
|
-
assert.equal(result.event.cwd, ROOT);
|
|
369
|
-
assert.equal(result.event.toolCorrelationId, 'provider-call');
|
|
370
|
-
assert.equal(result.event.captured.responseDigest, 'a'.repeat(64));
|
|
371
|
-
assert.deepEqual(result.correlation, { toolCorrelationId: 'provider-call', resultRef: result.event.resultRef });
|
|
372
|
-
|
|
373
|
-
const emptyResultDigest = crypto.createHash('sha256').update('').digest('hex');
|
|
374
|
-
const minimum = opencodeProvider([opencodeCapture({ call_id: 'empty-result', result_digest: emptyResultDigest, result_bytes: 0 })])
|
|
375
|
-
.resolveEvent({ reference: 'empty-result', identity: { workflowId: 'provider-workflow' } });
|
|
376
|
-
assert.equal(minimum.status, 'accepted', 'zero result bytes are the valid minimum boundary');
|
|
377
|
-
assert.equal(minimum.event.captured.responseDigest, emptyResultDigest);
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
test('production OpenCode qualification remains unmet with otherwise valid origin input', () => {
|
|
381
|
-
const provider = opencodeProvider([opencodeCapture()], { qualification: undefined });
|
|
382
|
-
const context = provider.resolveContext({ workspaceRoot: ROOT });
|
|
383
|
-
const result = provider.resolveEvent({ reference: 'provider-call', identity: { workflowId: 'provider-workflow' } });
|
|
384
|
-
assert.equal(context.status, 'unavailable');
|
|
385
|
-
assert.equal(diagnosticCode(context), 'live-gate-unmet');
|
|
386
|
-
assert.equal(result.status, 'unavailable');
|
|
387
|
-
assert.equal(diagnosticCode(result), 'live-gate-unmet');
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
test('OpenCode provider rejects native error, incomplete outcome, and missing cwd', () => {
|
|
391
|
-
const cases = [
|
|
392
|
-
['native-error', { error: { name: 'Error', message: 'failed' } }, 'failure-not-credited', 'provider-call'],
|
|
393
|
-
['missing-status', { status: undefined }, 'outcome-ambiguous', 'provider-call'],
|
|
394
|
-
['empty-status', { status: '' }, 'outcome-ambiguous', 'provider-call'],
|
|
395
|
-
['null-status', { status: null }, 'outcome-ambiguous', 'provider-call'],
|
|
396
|
-
['wrong-type-status', { status: 1 }, 'outcome-ambiguous', 'provider-call'],
|
|
397
|
-
['ambiguous-status', { status: 'running' }, 'outcome-ambiguous', 'provider-call'],
|
|
398
|
-
['missing-process-exit', { exit: undefined }, 'outcome-ambiguous', 'provider-call'],
|
|
399
|
-
['negative-result-bytes', { result_bytes: -1 }, 'stdout-withheld', 'provider-call'],
|
|
400
|
-
['missing-doc-check-cwd', { cwd: undefined, command: 'node harness-everything/scripts/doc-check.js' }, 'unregistered-command', 'provider-call#doc-lint'],
|
|
401
|
-
];
|
|
402
|
-
for (const [name, changes, expected, reference] of cases) {
|
|
403
|
-
const result = opencodeProvider([opencodeCapture(changes)]).resolveEvent({ reference, identity: { workflowId: 'provider-workflow' } });
|
|
404
|
-
assert.equal(result.status, 'rejected', `${name}: ${JSON.stringify(result)}`);
|
|
405
|
-
assert.equal(diagnosticCode(result), expected, name);
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
test('OpenCode provider rejects malformed references and unsupported host input', () => {
|
|
410
|
-
const invalidReference = opencodeProvider([opencodeCapture()]).resolveEvent({ reference: '' });
|
|
411
|
-
assert.equal(invalidReference.status, 'unavailable');
|
|
412
|
-
assert.equal(diagnosticCode(invalidReference), 'invalid-input');
|
|
413
|
-
|
|
414
|
-
const unsupportedContext = opencodeProvider([], { hostId: 'codex' }).resolveContext({ workspaceRoot: ROOT });
|
|
415
|
-
assert.equal(unsupportedContext.status, 'unavailable');
|
|
416
|
-
assert.equal(diagnosticCode(unsupportedContext), 'unsupported-host');
|
|
417
|
-
|
|
418
|
-
const unsupportedEvent = opencodeProvider([], { hostId: 'claude-code' }).resolveEvent({ reference: 'provider-call' });
|
|
419
|
-
assert.equal(unsupportedEvent.status, 'unavailable');
|
|
420
|
-
assert.equal(diagnosticCode(unsupportedEvent), 'unsupported-host');
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
test('OpenCode provider rejects stale, replayed, and Claude-origin records', () => {
|
|
424
|
-
const identity = { workflowId: 'provider-workflow', workflowRevision: 3 };
|
|
425
|
-
const stale = opencodeCapture({ observedIdentity: { workflowId: 'provider-workflow', workflowRevision: 2, baselinePin: null } });
|
|
426
|
-
assert.equal(diagnosticCode(opencodeProvider([stale]).resolveEvent({ reference: stale.call_id, identity })), 'identity-mismatch');
|
|
427
|
-
|
|
428
|
-
const first = opencodeCapture({ call_id: 'first-call' });
|
|
429
|
-
const replay = opencodeCapture({ call_id: 'replayed-call' });
|
|
430
|
-
const replayProvider = opencodeProvider([first, replay]);
|
|
431
|
-
assert.equal(diagnosticCode(replayProvider.resolveEvent({ reference: replay.call_id, identity })), 'replayed-record');
|
|
432
|
-
|
|
433
|
-
const claudeRecord = opencodeCapture({ hostId: 'claude-code' });
|
|
434
|
-
assert.equal(diagnosticCode(opencodeProvider([claudeRecord]).resolveEvent({ reference: claudeRecord.call_id, identity })), 'record-origin-mismatch');
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
test('OpenCode quality-review record is refused when reviewer equals the author', () => {
|
|
438
|
-
const record = opencodeCapture({ agent_id: 'provider-author' });
|
|
439
|
-
const result = opencodeProvider([record]).resolveEvent({ reference: `${record.call_id}#quality-review` });
|
|
440
|
-
assert.equal(result.status, 'rejected');
|
|
441
|
-
assert.equal(diagnosticCode(result), 'reviewer-not-independent');
|
|
442
|
-
});
|