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.
Files changed (216) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/AGENTS.md +1 -1
  4. package/CHANGELOG.md +14 -0
  5. package/behavioral-evals/ledger-pairs/README.md +53 -0
  6. package/behavioral-evals/ledger-pairs/arm.js +359 -0
  7. package/behavioral-evals/ledger-pairs/fixture.js +138 -0
  8. package/behavioral-evals/ledger-pairs/preflight.js +96 -0
  9. package/behavioral-evals/ledger-pairs/score.js +155 -0
  10. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/README.md +108 -0
  11. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-plan.json +14 -0
  12. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-result.json +35 -0
  13. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-plan.json +14 -0
  14. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-result.json +35 -0
  15. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-plan.json +14 -0
  16. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-result.json +35 -0
  17. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-plan.json +14 -0
  18. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-result.json +35 -0
  19. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-plan.json +14 -0
  20. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-result.json +35 -0
  21. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-plan.json +14 -0
  22. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-result.json +35 -0
  23. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-plan.json +14 -0
  24. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-result.json +28 -0
  25. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-plan.json +14 -0
  26. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-result.json +35 -0
  27. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-plan.json +13 -0
  28. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-result.json +56 -0
  29. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-plan.json +13 -0
  30. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-result.json +56 -0
  31. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-plan.json +13 -0
  32. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-result.json +56 -0
  33. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-plan.json +13 -0
  34. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-result.json +56 -0
  35. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-plan.json +13 -0
  36. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-result.json +49 -0
  37. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-plan.json +13 -0
  38. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-result.json +49 -0
  39. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-plan.json +13 -0
  40. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-result.json +49 -0
  41. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-plan.json +13 -0
  42. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-result.json +56 -0
  43. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-plan.json +14 -0
  44. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-result.json +44 -0
  45. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/receipt.jsonl +17 -0
  46. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-plan.json +14 -0
  47. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-result.json +41 -0
  48. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/receipt.jsonl +58 -0
  49. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-plan.json +14 -0
  50. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-result.json +50 -0
  51. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/receipt.jsonl +101 -0
  52. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-plan.json +14 -0
  53. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-result.json +44 -0
  54. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/receipt.jsonl +29 -0
  55. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-plan.json +14 -0
  56. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-result.json +44 -0
  57. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/receipt.jsonl +23 -0
  58. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-plan.json +14 -0
  59. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-result.json +34 -0
  60. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/receipt.jsonl +24 -0
  61. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-plan.json +14 -0
  62. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-result.json +47 -0
  63. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/receipt.jsonl +69 -0
  64. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-plan.json +14 -0
  65. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-result.json +44 -0
  66. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/receipt.jsonl +65 -0
  67. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/run-order.sh +18 -0
  68. package/benchmarks/results/live-host/ledger-pairs-2026-11-28/score.json +1032 -0
  69. package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/README.md +50 -0
  70. package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/collect-rerun.txt +3 -0
  71. package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/export-report.json +22 -0
  72. package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/host-version.txt +1 -0
  73. package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-1.json +18 -0
  74. package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-2.json +18 -0
  75. package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/labels-observed-excerpt.jsonl +2 -0
  76. package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/observations-index-excerpt.json +26 -0
  77. package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/plugin-load-lines.txt +1 -0
  78. package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/README.md +46 -0
  79. package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/observations-index-excerpt.json +16 -0
  80. package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/plugin-load-lines.txt +2 -0
  81. package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/run-marks.txt +6 -0
  82. package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-probe.js +16 -0
  83. package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-trace.jsonl +167 -0
  84. package/ci/archive/325-prep/README.md +9 -2
  85. package/ci/archive/325-prep/doc-reconciliation-red.js +34 -8
  86. package/ci/fixtures/553-t2a/body-edit/base/.agents/harness-everything/project-docs.json +11 -0
  87. package/ci/fixtures/553-t2a/body-edit/base/docs/a.md +6 -0
  88. package/ci/fixtures/553-t2a/body-edit/base/docs/b.md +1 -0
  89. package/ci/fixtures/553-t2a/body-edit/candidate/docs/a.md +6 -0
  90. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  91. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/governed-index.md +19 -0
  92. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  93. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/governed-index.md +19 -0
  94. package/ci/fixtures/553-t2c/derived-regenerate-must/config.json +17 -0
  95. package/ci/fixtures/doc-obligations/derive/regression-pins.json +153 -0
  96. package/ci/fixtures/state-persist-post-tool-use/harness.js +206 -0
  97. package/ci/fixtures/state-persist-post-tool-use/off-handoff-golden.json +16 -0
  98. package/ci/fixtures/state-persist-post-tool-use/payload-post-tool-use-success.json +13 -0
  99. package/ci/fixtures/stop/fail-session-writes.js +109 -0
  100. package/ci/fixtures/workflow-contract/cases.json +3355 -0
  101. package/ci/fixtures/workflow-contract/wiring-cases.json +560 -0
  102. package/ci/lib/doc-reconciliation-prep-fixtures.js +4 -9
  103. package/ci/mechanism-2an-workflow-replay.test.js +324 -0
  104. package/ci/mechanism-2ax-doc-lifecycle.test.js +132 -0
  105. package/ci/mechanism-325-3a-doc-evidence.test.js +73 -0
  106. package/ci/mechanism-325-3a-doc-obligations.test.js +61 -0
  107. package/ci/mechanism-325-3b-preparation.test.js +208 -49
  108. package/ci/mechanism-325-3b-s1-review.test.js +20 -828
  109. package/ci/mechanism-325-3b-s3-providers.test.js +59 -0
  110. package/ci/mechanism-325-f3-derived-views.test.js +140 -0
  111. package/ci/mechanism-332-fable-directive.test.js +180 -0
  112. package/ci/mechanism-341-opencode-lane.test.js +164 -284
  113. package/ci/mechanism-35-verification-contract.test.js +246 -0
  114. package/ci/mechanism-365-step-edit-accounting.test.js +5 -6
  115. package/ci/mechanism-383-doc-glob-line-terminators.test.js +0 -30
  116. package/ci/mechanism-397-opencode-observations.test.js +151 -18
  117. package/ci/mechanism-552-ledger-pairs.test.js +159 -0
  118. package/ci/mechanism-553-e1-unhook-credit.test.js +328 -0
  119. package/ci/mechanism-553-p2a-claude-hooks.test.js +98 -0
  120. package/ci/mechanism-553-p3-plan-start.test.js +212 -0
  121. package/ci/mechanism-553-state-persist-post-tool-use.test.js +307 -0
  122. package/ci/mechanism-553-stop.test.js +427 -0
  123. package/ci/mechanism-553-t2a-derive.test.js +110 -0
  124. package/ci/mechanism-553-t2c-derive.test.js +94 -0
  125. package/ci/mechanism-e1-derived-regenerate.test.js +45 -206
  126. package/ci/mechanism-outline-sanitizer.test.js +0 -8
  127. package/ci/mechanism-pr-a-conflict-check.test.js +38 -305
  128. package/ci/mechanism-prb-outline-review.test.js +101 -3283
  129. package/ci/router-workflow-plan.test.js +61 -21
  130. package/docs/adr/DOCS-006-reconciliation-pilot.md +4 -2
  131. package/docs/adr/DOCS-008-obligation-abstraction-bounded-consumer.md +3 -3
  132. package/docs/doc-workflow-reconciliation.md +17 -2
  133. package/docs/document-lifecycle.md +6 -2
  134. package/docs/platform-capabilities.md +63 -16
  135. package/docs/platform-compatibility.json +5 -5
  136. package/harness-everything/SKILL.md +1 -1
  137. package/harness-everything/scripts/routing-keywords.json +0 -2
  138. package/harness-everything/scripts/tier-router.js +105 -11
  139. package/hooks/hooks.json +0 -46
  140. package/hooks/scripts/lib/workflow-obligations.js +0 -55
  141. package/hooks/scripts/state-persist.js +7 -95
  142. package/hooks/scripts/workflow-disposition.js +0 -2
  143. package/hooks/scripts/workflow-stop-gate.js +17 -30
  144. package/opencode-plugin/index.mjs +6 -70
  145. package/opencode-plugin/plugin.json +1 -1
  146. package/package.json +1 -1
  147. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  148. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  149. package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +0 -55
  150. package/plugins/harness-everything/hooks/scripts/state-persist.js +7 -95
  151. package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +0 -2
  152. package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +17 -30
  153. package/plugins/harness-everything/plugin.json +1 -1
  154. package/plugins/harness-everything/rules/AGENTS.md +1 -1
  155. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  156. package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
  157. package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +105 -11
  158. package/sbom.cdx.json +7 -7
  159. package/ci/fixtures/doc-obligations/reconciliation-s1/cases.json +0 -6854
  160. package/ci/fixtures/doc-obligations/reconciliation-s1/fail-session-writes.js +0 -116
  161. package/ci/fixtures/doc-obligations/reconciliation-s2a/harness.js +0 -507
  162. package/ci/fixtures/doc-obligations/reconciliation-s2a/run13-workflow-requirements.json +0 -42
  163. package/ci/fixtures/doc-obligations/reconciliation-s2a/vectors.json +0 -617
  164. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/harness.js +0 -415
  165. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-post-tool-use-success-minimal.json +0 -9
  166. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-start.json +0 -7
  167. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-freetext-reject.json +0 -11
  168. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-reject.json +0 -11
  169. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop.json +0 -11
  170. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-task-result.json +0 -19
  171. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-capture-only.json +0 -99
  172. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-legacy.json +0 -67
  173. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-concurrent-writers.json +0 -62
  174. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-lookalikes-runtime-mutations.json +0 -67
  175. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-malformed.json +0 -85
  176. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-normal-session.json +0 -74
  177. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-runtime-drift-later-npm-test.json +0 -58
  178. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-valid-direct-quoted-review.json +0 -85
  179. package/ci/fixtures/doc-obligations/reconciliation-s2b/f4/cases.json +0 -2267
  180. package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/cases.json +0 -1110
  181. package/ci/lib/doc-reconciliation-file-spy.js +0 -23
  182. package/ci/lib/doc-reconciliation-qualification-preload.js +0 -37
  183. package/ci/lib/doc-reconciliation-replay.js +0 -104
  184. package/ci/lib/doc-reconciliation-staged-tree.js +0 -102
  185. package/ci/mechanism-325-3b-h1-qualification.test.js +0 -206
  186. package/ci/mechanism-325-3b-s1.test.js +0 -188
  187. package/ci/mechanism-325-3b-s2a-core.test.js +0 -840
  188. package/ci/mechanism-325-3b-s2a-producer.test.js +0 -564
  189. package/ci/mechanism-325-3b-s2b-capture.test.js +0 -566
  190. package/ci/mechanism-325-3b-s2b-wiring.test.js +0 -679
  191. package/ci/mechanism-325-f4-invariants.test.js +0 -606
  192. package/ci/mechanism-325-f4-projections.test.js +0 -392
  193. package/ci/mechanism-325-f4-qualification.test.js +0 -228
  194. package/ci/mechanism-325-f4-trust-boundary.test.js +0 -880
  195. package/ci/mechanism-e1-dependency-artifact-scope.test.js +0 -657
  196. package/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  197. package/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  198. package/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  199. package/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  200. package/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  201. package/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  202. package/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  203. package/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  204. package/hooks/scripts/w6-state-operations.js +0 -239
  205. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  206. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  207. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  208. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  209. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  210. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  211. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  212. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  213. package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +0 -239
  214. package/scripts/system-one-eval-laya.js +0 -112
  215. /package/ci/fixtures/{doc-obligations/reconciliation-s2b/capture → state-persist-post-tool-use}/payload-post-tool-use-failure.json +0 -0
  216. /package/ci/fixtures/{doc-obligations/reconciliation-s2b/wiring → workflow-contract}/legacy-off-golden.json +0 -0
@@ -10,7 +10,7 @@
10
10
  "name": "harness-everything",
11
11
  "source": "./",
12
12
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
13
- "version": "1.3.0",
13
+ "version": "1.3.2",
14
14
  "author": {
15
15
  "name": "Miya Daniel"
16
16
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harness-everything",
3
3
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
4
- "version": "1.3.0",
4
+ "version": "1.3.2",
5
5
  "author": {
6
6
  "name": "Miya Daniel"
7
7
  },
package/AGENTS.md CHANGED
@@ -55,7 +55,7 @@ flowchart LR
55
55
  - New features, fixes, tests, and host compatibility work target V2 only. No V1 public entrypoint, V1-only event fallback, V1 hook registration, or compatibility mode may be added.
56
56
  - Retain historical V1 artifacts, but never promote them to current V2 capability evidence.
57
57
  - Reintroducing V1 support requires an explicit owner-approved support-contract change; it is not a routine compatibility fix.
58
- - State the V2 API family as the supported boundary. Tested V2 versions are recorded separately (`2.1.3` server-log load-only; `2.1.4` limited session workspace trace; and one isolated `2.1.4` macOS 26.6.2 [V2 lifecycle trace](benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/README.md) establishing V2 default-export load, V2 tool hooks, V2 event envelope + `session.execution.succeeded`, and completion → verification → reminder delivery on a long-lived server — standalone `opencode run` exits before verification finishes; router/context injection, observations, ledger lessons, session create/delete reset, cancellation, global scope, npm install, and other versions/OSes were not exercised); none establishes a validated minimum patch version or coverage of every V2 release.
58
+ - State the V2 API family as the supported boundary. Tested V2 versions are recorded separately (`2.1.3` server-log load-only; `2.1.4` limited session workspace trace; one isolated `2.1.4` macOS 26.6.2 [V2 lifecycle trace](benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/README.md) establishing V2 default-export load, V2 tool hooks, V2 event envelope + `session.execution.succeeded`, and completion → verification → reminder delivery on a long-lived server — standalone `opencode run` exits before verification finishes; and two isolated `2.4.1` macOS 26.7.3 long-lived server runs: [turn → export trace](benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/README.md) establishing observation recording + idempotent training export, with router/context injection indirectly observed (model emitted the injected label contract) rather than a full injection trace, and [steering trace](benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/README.md) establishing mid-turn live steering delivery shape as witness-only for #450; ledger lessons, session create/delete reset, cancellation, global scope, npm install, and other versions/OSes remain unverified); none establishes a validated minimum patch version or coverage of every V2 release.
59
59
 
60
60
  **Historical / unsupported V1 evidence:** the retained [OpenCode evidence](benchmarks/results/live-host/opencode-2026-09-16/README.md) documents project-scope `.js` loading and edit/verification state on OpenCode 1.18.31 (macOS). It is preserved as historical/unsupported evidence only and does not establish current V2 capability:
61
61
 
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [1.3.2](https://github.com/dyphn1/Harness-everything/compare/v1.3.1...v1.3.2) (2026-11-28)
6
+
7
+ ### Bug Fixes
8
+
9
+ * **router:** decide fable directives by clause position and scope prohibitions ([#332](https://github.com/dyphn1/Harness-everything/issues/332)) ([000dbb1](https://github.com/dyphn1/Harness-everything/commit/000dbb16c9d4bd74612ce00791bc76a7d3f1a7e3))
10
+ * **router:** separate politeness prefixes from fable directive verbs ([#332](https://github.com/dyphn1/Harness-everything/issues/332)) ([0e488da](https://github.com/dyphn1/Harness-everything/commit/0e488da18c705964ee6a969256c9d48cecb2ca9c))
11
+ * **router:** treat a fable mention or negation as no fable request ([#332](https://github.com/dyphn1/Harness-everything/issues/332)) ([3b8b371](https://github.com/dyphn1/Harness-everything/commit/3b8b3710c56040347dc36f3576e1e04e4a3760ca))
12
+
13
+ ## [1.3.1](https://github.com/dyphn1/Harness-everything/compare/v1.3.0...v1.3.1) (2026-11-28)
14
+
5
15
  ## [1.3.0](https://github.com/dyphn1/Harness-everything/compare/v1.2.2...v1.3.0) (2026-11-26)
6
16
 
7
17
  ### Features
@@ -294,6 +304,10 @@ Claude-Session: https://claude.ai/code/session_01RPz4xUrN12wGoL19istZUE
294
304
 
295
305
  ## [Unreleased]
296
306
 
307
+ ### E1 pilot retirement
308
+
309
+ * **e1:** the E1 doc-reconciliation pilot is retired (#553). Its runtime modules and the W6 `inventory`/`seal` CLI (`hooks/scripts/w6-state-operations.js`) have been removed, and every `HARNESS_DOC_RECONCILIATION_PILOT` value is now ignored. Finish in-flight E1 work on the previous release, or end it and open a new session to redo review and verification. Recorded evidence stays in place; `doc-check` and document governance are unchanged.
310
+
297
311
  ### BREAKING CHANGES
298
312
 
299
313
  * **opencode:** support OpenCode V2 plugin API only; OpenCode 1.x / V1 is unsupported (#453). Removed the public `HarnessEnforcement` named V1 factory export, host `session.idle`, and legacy session-id event fallbacks; the V2 default export (`{ id, setup(ctx) }`) is now the only public surface. Historical OpenCode 1.18.31 evidence is retained for provenance only and does not establish V2 support.
@@ -0,0 +1,53 @@
1
+ # E-0003 paired carrier experiment
2
+
3
+ ## Design
4
+
5
+ ```mermaid
6
+ flowchart LR
7
+ F[Identical fixture files and hooks] --> P[Same E-0003 trigger]
8
+ P --> B[Baseline: strip exact carrier fragment]
9
+ P --> T[Treatment: pass carrier fragment]
10
+ B --> R[Receipt and next-decision evidence]
11
+ T --> R
12
+ R --> S[Score by runner; retain every assigned arm]
13
+ A[AGY prompt injection] --> S
14
+ ```
15
+
16
+ - Four baseline/treatment pairs per runner (12 pairs, 24 arms). Score Codex/Luna, OpenCode and AGY separately; never pool runners. Verdicts are **descriptive, inconclusive**.
17
+ - Baseline and treatment have byte-identical fixture files, initial commit, Git hook and permissions. Both can discover E-0003 in the workspace. OpenCode and Codex baseline probes strip only the exact `Cue`/`Lesson` carrier fragment after the Harness carrier appends it; treatment passes it through. This estimates the exploratory incremental effect of the carrier when the lesson is self-discoverable. Receipt files contain keyed statuses only, never command text.
18
+ - AGY remains a separate `agy-injection` intervention: same fixture files, with packet context added only to treatment.
19
+ - Luna's scored action is `prepared-commit`: Codex makes the source change, runs the test, stages `src/sample.js`, and writes `.commit-msg.txt`. The driver then performs `git add -A`, unstages the message file, verifies only `src/sample.js` is staged, and invokes `git commit -F` through the fixture hook. Do not pool this with direct commits from other runners.
20
+ - Token usage is post-hoc measurement including input, output and reasoning tokens when reported (cached usage is retained). Arms over 200,000 tokens are invalid and remain in the assigned-arm denominator. Every arm has a 45-minute timeout.
21
+ - Scoring requires an explicit correlated receipt before the matching scored decision. `unknown` remains unknown. Same-attempt diagnostics are merged; retries represent distinct attempts. File reads of the error ledger and `git log`/`git show` touching it are retained as a per-arm covariate.
22
+
23
+ ## Preflight and dry-run
24
+
25
+ Run the same no-model trigger against both fixture arms, then dry-run each runner. Keep the output directory outside the repository.
26
+
27
+ ```sh
28
+ node behavioral-evals/ledger-pairs/preflight.js --no-model --out "$OUT/pf"
29
+ node behavioral-evals/ledger-pairs/arm.js --runner codex --arm baseline --pair 1 --dry-run --out "$OUT/dry"
30
+ node behavioral-evals/ledger-pairs/arm.js --runner opencode --arm baseline --pair 1 --dry-run --out "$OUT/dry"
31
+ node behavioral-evals/ledger-pairs/arm.js --runner agy --arm baseline --pair 1 --dry-run --out "$OUT/dry"
32
+ ```
33
+
34
+ The preflight checks equal fixture bytes, matching E-0003 selection and commitlint accept/reject controls. It sends no model request and cannot establish live receipt. Review isolated live receipts before launching arms; OpenCode requires the isolated long-lived V2 server and actual next-request capture. Keep raw host captures private.
35
+
36
+ ## Balanced live order
37
+
38
+ Record a seed and shuffle pair IDs `1..4` separately for each runner. Assign exactly two pairs baseline-first and two treatment-first, run each pair consecutively, and retain the resulting order. For each arm, use an isolated HOME/XDG/TMPDIR/CODEX_HOME. Supply the coordinator's auth directory to Codex/OpenCode; OpenCode also needs `OPENCODE_PASSWORD`.
39
+
40
+ ```sh
41
+ node behavioral-evals/ledger-pairs/arm.js --runner codex --arm baseline --pair 1 --out "$OUT/live" --auth-dir "$AUTH_DIR"
42
+ node behavioral-evals/ledger-pairs/arm.js --runner codex --arm treatment --pair 1 --out "$OUT/live" --auth-dir "$AUTH_DIR"
43
+ ```
44
+
45
+ Run the same two commands for every assigned pair and runner in the recorded balanced order. Stop/mark an arm invalid if post-hoc usage exceeds 200,000 or elapsed time exceeds 45 minutes. Keep every assigned arm and its missing/contamination reasons.
46
+
47
+ ## Scoring
48
+
49
+ ```sh
50
+ node behavioral-evals/ledger-pairs/score.js "$OUT"/*/pair-*/arm-result.json
51
+ ```
52
+
53
+ Report assigned arms, valid pairs, missing/contamination reasons, commit action, first attempt, retries, correct diff/test, hook bypass, file reads, token usage, elapsed time and receipt state per runner. A no-model preflight or mechanism test is not live-host evidence.
@@ -0,0 +1,359 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs');
4
+ const os = require('node:os');
5
+ const path = require('node:path');
6
+ const { spawn, spawnSync } = require('node:child_process');
7
+ const net = require('node:net');
8
+ const { buildFixture, TASK_TEXT } = require('./fixture');
9
+
10
+ const REPO = path.resolve(__dirname, '../..');
11
+ const LEDGER_RECORD = '.agents/harness-everything/errors/E-0003-commitlint-subject.md';
12
+ const RUNNERS = ['codex', 'opencode', 'agy'];
13
+ const ARMS = ['baseline', 'treatment'];
14
+ const COMMIT_TASK_TEXT = `${TASK_TEXT.split('\n')[0]}\nRun the test and stage only src/sample.js. Write the commit subject you intend to use to .commit-msg.txt; do not run git commit. The driver will make the commit through the fixture hook.`;
15
+
16
+ function filterCarrierContext(text, fragment, strip) {
17
+ const matched = typeof text === 'string' && typeof fragment === 'string' && text.includes(fragment);
18
+ return { matched, stripped: Boolean(matched && strip), text: matched && strip ? text.replace(fragment, '') : text };
19
+ }
20
+
21
+ function parseArgs(argv) {
22
+ const args = { dryRun: false, timeoutMs: 45 * 60 * 1000 };
23
+ for (let i = 0; i < argv.length; i += 1) {
24
+ const key = argv[i];
25
+ if (key === '--dry-run') args.dryRun = true;
26
+ else if (['--runner', '--arm', '--pair', '--out', '--auth-dir', '--timeout-ms'].includes(key)) args[key.slice(2).replace(/-([a-z])/g, (_, c) => c.toUpperCase())] = argv[++i];
27
+ else throw new Error(`unknown argument: ${key}`);
28
+ }
29
+ if (!RUNNERS.includes(args.runner)) throw new Error('--runner must be codex|opencode|agy');
30
+ if (!ARMS.includes(args.arm)) throw new Error('--arm must be baseline|treatment');
31
+ if (!Number.isInteger(Number(args.pair)) || Number(args.pair) < 1 || Number(args.pair) > 4) throw new Error('--pair must be 1..4');
32
+ if (!args.out) throw new Error('--out is required');
33
+ args.pair = Number(args.pair);
34
+ args.timeoutMs = Number(args.timeoutMs);
35
+ if (!Number.isFinite(args.timeoutMs) || args.timeoutMs < 1 || args.timeoutMs > 45 * 60 * 1000) throw new Error('--timeout-ms must be between 1 and 2700000 (the 45-minute arm cap)');
36
+ return args;
37
+ }
38
+
39
+ function isolatedEnvironment(root, authDir, runner) {
40
+ const home = path.join(root, 'home');
41
+ const xdg = path.join(root, 'xdg');
42
+ const tmp = path.join(root, 'tmp');
43
+ const codexHome = path.join(root, 'codex-home');
44
+ for (const dir of [home, xdg, tmp, codexHome]) fs.mkdirSync(dir, { recursive: true });
45
+ // Minimal env: never inherit the coordinator's CLAUDE*/CODEX*/HARNESS_* session variables.
46
+ const base = {};
47
+ for (const k of ['PATH', 'LANG', 'TERM', 'SHELL', 'OPENCODE_PASSWORD']) if (process.env[k]) base[k] = process.env[k];
48
+ base.PONYTAIL_DEFAULT_MODE = 'off';
49
+ // agy keeps its login under ~/.gemini; isolating HOME logs it out, so agy keeps the real HOME (recorded in arm-plan).
50
+ if (runner === 'agy') return { ...base, HOME: process.env.HOME, TMPDIR: tmp };
51
+ const env = { ...base, HOME: home, USERPROFILE: home, XDG_CONFIG_HOME: path.join(xdg, 'config'), XDG_DATA_HOME: path.join(xdg, 'data'), XDG_STATE_HOME: path.join(xdg, 'state'), XDG_CACHE_HOME: path.join(xdg, 'cache'), TMPDIR: tmp, CODEX_HOME: codexHome };
52
+ for (const dir of [env.XDG_CONFIG_HOME, env.XDG_DATA_HOME, env.XDG_STATE_HOME, env.XDG_CACHE_HOME]) fs.mkdirSync(dir, { recursive: true });
53
+ if (authDir) copyAuth(path.resolve(authDir), { home, xdg, codexHome }, runner);
54
+ return env;
55
+ }
56
+
57
+ function copyAuth(source, destinations, runner) {
58
+ if (!fs.existsSync(source)) throw new Error(`auth directory not found: ${source}`);
59
+ const files = ['auth.json', 'credentials.json'];
60
+ for (const name of files) {
61
+ const from = path.join(source, name);
62
+ if (!fs.existsSync(from) || !fs.statSync(from).isFile()) continue;
63
+ // opencode reads auth from XDG_DATA_HOME/opencode; codex from CODEX_HOME.
64
+ const targets = runner === 'opencode' ? [path.join(destinations.xdg, 'data', 'opencode', name)] : [path.join(destinations.codexHome, name)];
65
+ for (const to of targets) {
66
+ fs.mkdirSync(path.dirname(to), { recursive: true });
67
+ fs.copyFileSync(from, to); fs.chmodSync(to, 0o600);
68
+ }
69
+ }
70
+ }
71
+
72
+ function quoteShell(value) {
73
+ return `'${String(value).replace(/'/g, "'\\''")}'`;
74
+ }
75
+
76
+ function commandPlan(args, fixture, env) {
77
+ if (args.runner === 'codex') {
78
+ return {
79
+ command: 'codex',
80
+ args: ['exec', '-m', 'gpt-6-luna', '-c', 'model_reasoning_effort="high"', '-s', 'workspace-write', '-C', fixture.repo, '--json', COMMIT_TASK_TEXT],
81
+ cwd: fixture.repo,
82
+ taskText: COMMIT_TASK_TEXT,
83
+ action: 'prepared-commit',
84
+ tokenCapEnforcement: 'post-hoc measurement',
85
+ carrier: 'Codex user-hook compatibility runtime installed under isolated CODEX_HOME; hooks/scripts/codex-ledger-lesson.js',
86
+ };
87
+ }
88
+ if (args.runner === 'opencode') {
89
+ const pluginPath = path.join(fixture.repo, '.opencode', 'plugins', 'harness-enforcement.js');
90
+ fs.mkdirSync(path.dirname(pluginPath), { recursive: true });
91
+ fs.writeFileSync(pluginPath, `export { default } from ${JSON.stringify(path.join(REPO, 'opencode-plugin/index.mjs'))};\n`);
92
+ fs.appendFileSync(path.join(fixture.repo, '.git', 'info', 'exclude'), '\n.opencode/\n');
93
+ return {
94
+ command: 'opencode',
95
+ args: ['run', '--server', '<isolated-long-lived-server>', '--auto', '--model', 'opencode/hy4-flash-free', '--format', 'json', TASK_TEXT],
96
+ cwd: fixture.repo,
97
+ taskText: TASK_TEXT,
98
+ action: 'commit',
99
+ tokenCapEnforcement: 'post-hoc measurement',
100
+ carrier: 'OpenCode V2 checkout plugin, one-line re-export, tool before/after to next context hook',
101
+ server: { command: 'opencode', args: ['serve', '--hostname', '127.0.0.1', '--port', '<ephemeral>'], requiredVersion: '2.4.1', env: 'OPENCODE_PASSWORD' },
102
+ };
103
+ }
104
+ const prompt = args.arm === 'treatment'
105
+ ? `${TASK_TEXT}\n\nPacket-context intervention (agy-injection; not a repository-ledger carrier):\n${fs.readFileSync(path.join(fixture.repo, LEDGER_RECORD), 'utf8').split('## Lesson')[1]?.split(/^## /m)[0] || ''}`
106
+ : TASK_TEXT;
107
+ return {
108
+ command: 'agy',
109
+ args: ['-p', prompt, '--model', 'gemini-4-hydrogen-high', '--mode', 'accept-edits', '--sandbox', '--settings', '{"permissions":{"allow":["command(*)","read_file(*)"]}}'],
110
+ cwd: fixture.repo,
111
+ taskText: prompt,
112
+ action: 'commit',
113
+ tokenCapEnforcement: 'post-hoc measurement',
114
+ carrier: 'none; packet-context injection, reported as agy-injection only',
115
+ isolation: 'real HOME (agy login lives in ~/.gemini); TMPDIR isolated; global agy plugins load equally in both arms',
116
+ };
117
+ }
118
+
119
+ async function ephemeralPort() {
120
+ const server = net.createServer();
121
+ await new Promise((resolve, reject) => server.once('error', reject).listen(0, '127.0.0.1', resolve));
122
+ const port = server.address().port;
123
+ await new Promise(resolve => server.close(resolve));
124
+ return port;
125
+ }
126
+
127
+ // 200k cap (owner: post-hoc measurement) counts uncached input + output + reasoning; cache reads are retained separately.
128
+ function usageTotal(u) { return u ? Math.max(0, u.inputTokens - (u.inputIncludesCache ? u.cachedTokens : 0)) + u.outputTokens + u.reasoningTokens : 0; }
129
+
130
+ function parseUsage(stdout) {
131
+ const totals = { inputTokens: 0, outputTokens: 0, reasoningTokens: 0, cachedTokens: 0, totalTokens: 0 };
132
+ let found = false;
133
+ function visit(value) {
134
+ if (!value || typeof value !== 'object') return;
135
+ for (const [key, child] of Object.entries(value)) {
136
+ const target = ({ total_tokens: 'totalTokens', tokens: 'totalTokens', input_tokens: 'inputTokens', prompt_tokens: 'inputTokens', output_tokens: 'outputTokens', completion_tokens: 'outputTokens', reasoning_tokens: 'reasoningTokens', cached_input_tokens: 'cachedTokens', cached_tokens: 'cachedTokens' })[key];
137
+ // opencode --format json nests usage as tokens:{input,output,reasoning,cache:{read}}.
138
+ if (key === 'tokens' && child && typeof child === 'object') {
139
+ for (const [k, t] of [['input', 'inputTokens'], ['output', 'outputTokens'], ['reasoning', 'reasoningTokens']]) if (Number.isFinite(child[k])) { totals[t] += child[k]; found = true; }
140
+ if (Number.isFinite(child.cache?.read)) { totals.cachedTokens += child.cache.read; found = true; }
141
+ continue;
142
+ }
143
+ if (target && Number.isFinite(child)) { totals[target] += child; found = true; }
144
+ else if (child && typeof child === 'object') visit(child);
145
+ }
146
+ }
147
+ for (const line of String(stdout || '').split(/\r?\n/)) { try { visit(JSON.parse(line)); } catch {} }
148
+ if (!found) return null;
149
+ if (!totals.totalTokens) totals.totalTokens = totals.inputTokens + totals.outputTokens + totals.reasoningTokens + totals.cachedTokens;
150
+ return totals;
151
+ }
152
+
153
+ function git(repo, args) {
154
+ return spawnSync('git', ['-C', repo, ...args], { encoding: 'utf8' });
155
+ }
156
+
157
+ function sanitize(text, env) {
158
+ let result = String(text || '');
159
+ for (const key of ['GEMINI_API_KEY', 'OPENCODE_PASSWORD']) {
160
+ if (env[key]) result = result.split(env[key]).join('[REDACTED]');
161
+ }
162
+ return result.replace(/(sk-[A-Za-z0-9_-]{16,}|AIza[A-Za-z0-9_-]{20,})/g, '[REDACTED]');
163
+ }
164
+
165
+ function runPreparedCommit(repo, env) {
166
+ const messagePath = path.join(repo, '.commit-msg.txt');
167
+ const staged = git(repo, ['add', '-A']);
168
+ if (fs.existsSync(messagePath)) git(repo, ['reset', '--', '.commit-msg.txt']);
169
+ const stagedFiles = git(repo, ['diff', '--cached', '--name-only']).stdout.trim().split(/\r?\n/).filter(Boolean);
170
+ if (staged.status !== 0 || !fs.existsSync(messagePath) || stagedFiles.length !== 1 || stagedFiles[0] !== 'src/sample.js') return { accepted: false, stagedFiles, failure: 'prepared-commit-missing-message-or-unexpected-stage', output: staged.stderr, diagnostics: [] };
171
+ const commit = spawnSync('git', ['-C', repo, 'commit', '-F', messagePath], { encoding: 'utf8', env });
172
+ const output = `${commit.stdout || ''}${commit.stderr || ''}`;
173
+ const diagnostics = ['subject-case', 'header-max-length', 'type-empty', 'subject-empty'].filter(diagnostic => output.includes(`[${diagnostic}]`));
174
+ return { accepted: commit.status === 0, stagedFiles, output, diagnostics };
175
+ }
176
+
177
+ function runProcess(plan, env, timeoutMs, logFile) {
178
+ return new Promise(resolve => {
179
+ const child = spawn(plan.command, plan.args, { cwd: plan.cwd, env, stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
180
+ let stdout = '';
181
+ let stderr = '';
182
+ let timedOut = false;
183
+ const timeout = setTimeout(() => { timedOut = true; child.kill('SIGTERM'); }, timeoutMs);
184
+ child.stdout.on('data', chunk => { stdout += chunk; });
185
+ child.stderr.on('data', chunk => { stderr += chunk; });
186
+ child.on('error', error => { stderr += `${error.message}\n`; });
187
+ child.on('close', code => {
188
+ clearTimeout(timeout);
189
+ const body = `EXIT_CODE=${code}\nTIMED_OUT=${timedOut}\n--- stdout ---\n${sanitize(stdout, env)}\n--- stderr ---\n${sanitize(stderr, env)}\n`;
190
+ fs.writeFileSync(logFile, body, { mode: 0o600 });
191
+ resolve({ code, timedOut, stdout: sanitize(stdout, env), stderr: sanitize(stderr, env) });
192
+ });
193
+ });
194
+ }
195
+
196
+ function installCodexCarrierProbe(env, out, arm) {
197
+ const hooksFile = path.join(env.CODEX_HOME, 'hooks.json');
198
+ const wrapper = path.join(env.CODEX_HOME, 'ledger-probe.js');
199
+ const receiptFile = path.join(out, 'receipt.jsonl');
200
+ const sourceHook = path.join(REPO, 'hooks/scripts/codex-ledger-lesson.js');
201
+ const source = `'use strict';\nconst fs=require('node:fs');\nconst path=require('node:path');\nconst {spawnSync}=require('node:child_process');\nconst filter=${filterCarrierContext.toString()};\nconst input=fs.readFileSync(0,'utf8');\nconst payload=JSON.parse(input||'{}');\nconst result=spawnSync(process.execPath,[${JSON.stringify(sourceHook)}],{input,encoding:'utf8',cwd:payload.cwd,env:process.env});\nconst record=fs.readFileSync(path.join(payload.cwd,'.agents/harness-everything/errors/E-0003-commitlint-subject.md'),'utf8');const section=n=>{const m=record.match(new RegExp('^## '+n+'\\\\s*\\\\n([\\\\s\\\\S]*?)(?=^## |$)','m'));return m?m[1].trim():''};const fragment='Cue:\\n'+section('Cue')+'\\nLesson:\\n'+section('Lesson');\nlet output=result.stdout||'';let matched=false;let stripped=false;\ntry{const data=JSON.parse(output||'{}');const key=data.hookSpecificOutput?.additionalContext;const filtered=filter(key,fragment,${JSON.stringify(arm === 'baseline')});matched=filtered.matched;stripped=filtered.stripped;if(stripped){data.hookSpecificOutput.additionalContext=filtered.text;output=JSON.stringify(data)}}catch{}\nconst command=payload.tool_input?.command||'';const compound=/&&|\\|\\||\\n/.test(command);fs.appendFileSync(${JSON.stringify(receiptFile)},JSON.stringify({phase:payload.hook_event_name||'unknown',requestId:payload.turn_id||payload.turnId||null,matched,stripped,kind:compound?'compound':/^\\s*git\\s+commit\\b/.test(command)?'direct':'other',containsGitCommit:/\\bgit\\s+commit\\b/i.test(command)})+'\\n',{mode:0o600});\nprocess.stdout.write(output);process.stderr.write(result.stderr||'');process.exitCode=result.status||0;\n`;
202
+ fs.writeFileSync(wrapper, source, { mode: 0o700 });
203
+ const config = JSON.parse(fs.readFileSync(hooksFile, 'utf8'));
204
+ let changed = false;
205
+ function rewrite(value) {
206
+ if (Array.isArray(value)) return value.map(rewrite);
207
+ if (!value || typeof value !== 'object') return typeof value === 'string' && value.includes('codex-ledger-lesson.js') ? (changed = true, value.replace(/[^\s"']*codex-ledger-lesson\.js/, wrapper)) : value;
208
+ return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, rewrite(child)]));
209
+ }
210
+ const rewritten = rewrite(config);
211
+ if (!changed) throw new Error('Codex compatibility hooks did not expose codex-ledger-lesson.js for probe wrapping');
212
+ fs.writeFileSync(hooksFile, `${JSON.stringify(rewritten, null, 2)}\n`, { mode: 0o600 });
213
+ }
214
+
215
+ function installOpenCodeCarrierProbe(fixture, out, arm) {
216
+ const pluginPath = path.join(fixture.repo, '.opencode', 'plugins', 'zz-ledger-probe.js');
217
+ const receiptFile = path.join(out, 'receipt.jsonl');
218
+ fs.mkdirSync(path.dirname(pluginPath), { recursive: true });
219
+ fs.writeFileSync(pluginPath, `import fs from 'node:fs';\nimport path from 'node:path';\nconst filter=${filterCarrierContext.toString()};\nconst receipt=${JSON.stringify(receiptFile)};\nconst root=${JSON.stringify(fixture.repo)};\nconst baseline=${JSON.stringify(arm === 'baseline')};\nconst write=x=>fs.appendFileSync(receipt,JSON.stringify(x)+'\\n',{mode:0o600});\nconst fragment=()=>{const record=fs.readFileSync(path.join(root,'.agents/harness-everything/errors/E-0003-commitlint-subject.md'),'utf8');const section=n=>{const m=record.match(new RegExp('^## '+n+'\\\\s*\\\\n([\\\\s\\\\S]*?)(?=^## |$)','m'));return m?m[1].trim():''};return 'Cue:\\n'+section('Cue')+'\\nLesson:\\n'+section('Lesson')};\nconst toolReceipt=(phase,event)=>{const command=typeof event.input?.command==='string'?event.input.command:'';const kind=/&&|\\|\\||\\n/.test(command)?'compound':/^\\s*git\\s+commit\\b/.test(command)?'direct':'other';write({phase,requestId:event.messageID||event.messageId||null,kind,containsGitCommit:/\\bgit\\s+commit\\b/i.test(command)})};\nexport default {id:'fixture.ledger-probe',async setup(ctx){await ctx.session.hook('context',event=>{const exact=fragment();const system=Array.isArray(event.system)?event.system:[];for(const part of system){if(typeof part?.text!=='string')continue;const filtered=filter(part.text,exact,baseline);if(!filtered.matched)continue;write({phase:'context',requestId:event.messageID||event.messageId||null,matched:true,stripped:filtered.stripped});if(filtered.stripped)part.text=filtered.text}});await ctx.tool.hook('execute.before',event=>toolReceipt('tool.execute.before',event));await ctx.tool.hook('execute.after',event=>toolReceipt('tool.execute.after',event))}};\n`);
220
+ }
221
+
222
+ async function runArm(args) {
223
+ const out = path.resolve(args.out, args.runner, `pair-${args.pair}-${args.arm}`);
224
+ fs.mkdirSync(out, { recursive: true });
225
+ const fixture = await buildFixture({ out: path.join(out, 'fixture'), arm: args.arm, sourceRoot: REPO });
226
+ const env = isolatedEnvironment(out, args.authDir, args.runner);
227
+ const plan = commandPlan(args, fixture, env);
228
+ const manifest = {
229
+ schemaVersion: 1,
230
+ runner: args.runner,
231
+ arm: args.arm,
232
+ pair: args.pair,
233
+ intervention: args.runner === 'agy' ? 'agy-injection' : 'repo-ledger-context-visibility',
234
+ visibility: fixture.visibility,
235
+ initialSha: fixture.initialSha,
236
+ taskText: plan.taskText,
237
+ carrier: plan.carrier,
238
+ tokenLimit: { max: 200000, enforcement: plan.tokenCapEnforcement },
239
+ timeoutMs: args.timeoutMs,
240
+ commitlintResolution: fixture.commitlintResolution,
241
+ command: plan,
242
+ liveHostEvidence: 'UNCHECKED until retained matcher receipt and next-request capture are reviewed',
243
+ };
244
+ fs.writeFileSync(path.join(out, 'arm-plan.json'), `${JSON.stringify(manifest, null, 2)}\n`, { mode: 0o600 });
245
+ if (args.dryRun) return { out, manifest };
246
+
247
+ if (args.runner === 'codex') {
248
+ const install = await runProcess({ command: process.execPath, args: [path.join(REPO, 'scripts/codex-hooks-compat.js'), 'install', '--codex-home', env.CODEX_HOME, '--allow-unreleased-source'], cwd: REPO }, env, 60000, path.join(out, 'hook-install.log'));
249
+ if (install.code !== 0) throw new Error(`isolated Codex hook install failed; see ${path.join(out, 'hook-install.log')}`);
250
+ installCodexCarrierProbe(env, out, args.arm);
251
+ }
252
+
253
+ let server;
254
+ if (args.runner === 'opencode') {
255
+ if (!env.OPENCODE_PASSWORD) throw new Error('OPENCODE_PASSWORD is required for isolated opencode serve');
256
+ const version = spawnSync('opencode', ['--version'], { encoding: 'utf8', env });
257
+ const actualVersion = (version.stdout || '').trim();
258
+ if (version.status !== 0 || !/(^|[^0-9.])2\.4\.1($|[^0-9])/.test(actualVersion)) throw new Error(`OpenCode must be 2.4.1 for this packet; found ${actualVersion || 'unknown'}`);
259
+ manifest.runnerVersion = actualVersion;
260
+ installOpenCodeCarrierProbe(fixture, out, args.arm);
261
+ const port = await ephemeralPort();
262
+ server = spawn('opencode', ['serve', '--hostname', '127.0.0.1', '--port', String(port)], { cwd: fixture.repo, env, stdio: ['ignore', 'pipe', 'pipe'] });
263
+ fs.writeFileSync(path.join(out, 'server.pid'), `${server.pid}\n`, { mode: 0o600 });
264
+ const serverLog = fs.createWriteStream(path.join(out, 'server.log'), { mode: 0o600 });
265
+ server.stdout.pipe(serverLog);
266
+ server.stderr.pipe(serverLog);
267
+ await new Promise(resolve => setTimeout(resolve, 1500));
268
+ plan.args[2] = `http://127.0.0.1:${port}`;
269
+ fs.writeFileSync(path.join(out, 'arm-plan.json'), `${JSON.stringify(manifest, null, 2)}\n`, { mode: 0o600 });
270
+ }
271
+ const startedAt = new Date().toISOString();
272
+ const result = await runProcess(plan, env, args.timeoutMs, path.join(out, 'transcript.log'));
273
+ if (server) server.kill('SIGTERM');
274
+ let preparedCommit = null;
275
+ if (args.runner === 'codex') {
276
+ preparedCommit = runPreparedCommit(fixture.repo, { ...env, ...require('./fixture').FIXED_ENV });
277
+ fs.appendFileSync(path.join(out, 'transcript.log'), `\n--- prepared-commit driver ---\n${preparedCommit.output || preparedCommit.failure || ''}\n`);
278
+ }
279
+ const endedAt = new Date().toISOString();
280
+ const log = fs.readFileSync(path.join(out, 'transcript.log'), 'utf8');
281
+ const recordPath = path.join(fixture.repo, LEDGER_RECORD);
282
+ const recordBeforeRestore = fs.readFileSync(recordPath, 'utf8');
283
+ const visibilityUntouched = recordBeforeRestore === fixture.record;
284
+ const head = git(fixture.repo, ['rev-parse', 'HEAD']).stdout.trim();
285
+ const commits = head && head !== fixture.initialSha ? git(fixture.repo, ['rev-list', '--reverse', `${fixture.initialSha}..HEAD`]).stdout.trim().split(/\r?\n/).filter(Boolean) : [];
286
+ const changedFiles = head && head !== fixture.initialSha ? git(fixture.repo, ['diff', '--name-only', `${fixture.initialSha}..HEAD`]).stdout.trim().split(/\r?\n/).filter(Boolean) : [];
287
+ const finalSource = fs.readFileSync(path.join(fixture.repo, 'src/sample.js'), 'utf8');
288
+ const test = spawnSync(process.execPath, ['test.js'], { cwd: fixture.repo, encoding: 'utf8' });
289
+ const diagnostics = [];
290
+ for (const diagnostic of ['subject-case', 'header-max-length', 'type-empty', 'subject-empty']) {
291
+ const count = (log.match(new RegExp(`\\[${diagnostic}\\]`, 'g')) || []).length;
292
+ for (let i = 0; i < count; i += 1) diagnostics.push(diagnostic);
293
+ }
294
+ const events = diagnostics.length ? [{ kind: 'commit', accepted: false, attemptId: args.runner === 'codex' ? 'driver-commit-1' : 'unresolved-attempt-1', diagnostics: [...new Set(diagnostics)] }] : [];
295
+ const receiptFile = path.join(out, 'receipt.jsonl');
296
+ const probeRecords = fs.existsSync(receiptFile) ? fs.readFileSync(receiptFile, 'utf8').split(/\r?\n/).filter(Boolean).map(line => JSON.parse(line)) : [];
297
+ const receiptEvents = [];
298
+ if (args.runner === 'opencode') {
299
+ for (const receipt of probeRecords.filter(row => row.phase === 'context')) {
300
+ const linkedAction = receipt.requestId && probeRecords.find(row => row.phase === 'tool.execute.before' && row.requestId === receipt.requestId && row.containsGitCommit);
301
+ const requestId = receipt.requestId;
302
+ receiptEvents.push({ kind: 'receipt', requestId, correlated: Boolean(linkedAction), status: receipt.matched && !receipt.stripped ? 'delivered-before-decision' : receipt.stripped ? 'filtered' : 'unknown' });
303
+ if (linkedAction) receiptEvents.push({ kind: 'decision', requestId, actionKind: linkedAction.kind });
304
+ }
305
+ } else if (args.runner === 'codex') {
306
+ for (const receipt of probeRecords.filter(row => row.containsGitCommit)) {
307
+ const requestId = receipt.requestId;
308
+ if (requestId) receiptEvents.push({ kind: 'decision', requestId, actionKind: receipt.kind });
309
+ receiptEvents.push({ kind: 'receipt', requestId, correlated: Boolean(requestId), status: 'delivered-after-decision' });
310
+ }
311
+ }
312
+ events.push(...receiptEvents);
313
+ if (preparedCommit) {
314
+ events.push({ kind: 'prepared-commit', accepted: preparedCommit.accepted, stagedFiles: preparedCommit.stagedFiles });
315
+ }
316
+ for (const sha of commits) events.push({ kind: 'commit', accepted: true, sha, subject: git(fixture.repo, ['show', '-s', '--format=%s', sha]).stdout.trim() });
317
+ events.push({ kind: 'test', passed: test.status === 0 });
318
+ for (const line of log.split(/\r?\n/)) if (/--no-verify|HUSKY\s*=\s*0/i.test(line)) events.push({ kind: 'bypass', value: line });
319
+ const workingTree = git(fixture.repo, ['status', '--short']).stdout.trim();
320
+ // codex input_tokens already include cached_input_tokens; opencode input excludes cache reads.
321
+ const usage = parseUsage(result.stdout);
322
+ if (usage && args.runner === 'codex') usage.inputIncludesCache = true;
323
+ const record = {
324
+ runner: args.runner, arm: args.arm, pair: args.pair, action: plan.action, startedAt, endedAt,
325
+ elapsedMs: Date.parse(endedAt) - Date.parse(startedAt), tokenCapEnforcement: plan.tokenCapEnforcement,
326
+ usage, overCap: usageTotal(usage) > 200000, events,
327
+ initialFiles: { 'src/sample.js': "'use strict';\n\nmodule.exports = () => '';\n" },
328
+ finalFiles: { 'src/sample.js': finalSource },
329
+ manualIntervention: 0,
330
+ failures: [...(result.code === 0 ? [] : [`runner-exit-${result.code}`]), ...(!visibilityUntouched ? ['agent-modified-visibility-intervention'] : [])],
331
+ unknowns: ['matcher receipt and model-request delivery require coordinator review', 'manual intervention is zero only while the arm remains unattended'],
332
+ transcriptPath: 'transcript.log', transcriptSha256: require('node:crypto').createHash('sha256').update(log).digest('hex'),
333
+ gitLog: git(fixture.repo, ['log', '--format=%H%x09%s']).stdout.trim().split(/\r?\n/),
334
+ changedFiles,
335
+ correctDiff: visibilityUntouched && changedFiles.length === 1 && changedFiles[0] === 'src/sample.js' && finalSource.includes("module.exports = () => 'hello';"),
336
+ testPassed: test.status === 0,
337
+ hookRejections: diagnostics,
338
+ preparedCommit,
339
+ probeRecords,
340
+ fileReads: (log.match(/(?:read_file|read_file_tool|git\s+(?:log|show))[^\n]*(?:\.agents\/harness-everything\/errors|E-\d{4})/gi) || []).length,
341
+ probeReceiptPath: fs.existsSync(path.join(out, 'receipt.jsonl')) ? 'receipt.jsonl' : 'missing',
342
+ matcherReceipt: 'unknown; review sanitized host trace',
343
+ contextDelivery: 'unknown; review actual next-request capture',
344
+ workingTree,
345
+ treeClean: workingTree === '',
346
+ };
347
+ fs.writeFileSync(path.join(out, 'arm-result.json'), `${JSON.stringify(record, null, 2)}\n`, { mode: 0o600 });
348
+ return { out, manifest, result: { code: result.code, timedOut: result.timedOut } };
349
+ }
350
+
351
+ async function main(argv) {
352
+ const args = parseArgs(argv);
353
+ const result = await runArm(args);
354
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
355
+ }
356
+
357
+ if (require.main === module) main(process.argv.slice(2)).catch(error => { console.error(error.message); process.exitCode = 2; });
358
+
359
+ module.exports = { commandPlan, filterCarrierContext, isolatedEnvironment, installCodexCarrierProbe, installOpenCodeCarrierProbe, main, parseArgs, runArm, runPreparedCommit, sanitize };
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+ const { spawnSync } = require('node:child_process');
6
+
7
+ const LEDGER = '.agents/harness-everything/errors';
8
+ const RECORD_NAME = 'E-0003-commitlint-subject.md';
9
+ const TASK_TEXT = [
10
+ 'Make a small real change in src/sample.js that adds a short greeting for the existing test.',
11
+ 'Run the test, then commit the change. Choose any commit subject that follows the repository rules.',
12
+ 'Only change src/sample.js. Do not bypass hooks or edit the fixture, test, ledger, or configuration.',
13
+ ].join('\n');
14
+ const FIXED_ENV = Object.freeze({
15
+ GIT_AUTHOR_NAME: 'Ledger Pair Fixture',
16
+ GIT_AUTHOR_EMAIL: 'ledger-pair@example.invalid',
17
+ GIT_COMMITTER_NAME: 'Ledger Pair Fixture',
18
+ GIT_COMMITTER_EMAIL: 'ledger-pair@example.invalid',
19
+ GIT_AUTHOR_DATE: '2026-01-01T00:00:00Z',
20
+ GIT_COMMITTER_DATE: '2026-01-01T00:00:00Z',
21
+ });
22
+
23
+ function run(command, args, options = {}) {
24
+ const result = spawnSync(command, args, { encoding: 'utf8', ...options });
25
+ if (result.error || result.status !== 0) {
26
+ throw new Error(`${command} ${args.join(' ')} failed: ${result.error?.message || result.stderr || result.status}`);
27
+ }
28
+ return result.stdout.trim();
29
+ }
30
+
31
+ function applyVisibility(record, arm) {
32
+ if (!['baseline', 'treatment'].includes(arm)) throw new Error(`invalid arm: ${arm}`);
33
+ return { ...record };
34
+ }
35
+
36
+ function visibilityFromRecord(record) {
37
+ return record.includes('## Lesson') ? 'visible' : 'unknown';
38
+ }
39
+
40
+ function indexRow(indexText) {
41
+ const rows = indexText.split(/\r?\n/).filter(Boolean).map(line => JSON.parse(line));
42
+ if (rows.length !== 1 || rows[0].id !== 'E-0003') throw new Error('fixture index must contain only E-0003');
43
+ return rows[0];
44
+ }
45
+
46
+ function copyDependencyClosure(packageName, sourceModules, targetModules, copied = new Set()) {
47
+ if (copied.has(packageName)) return;
48
+ copied.add(packageName);
49
+ const source = path.join(sourceModules, ...packageName.split('/'));
50
+ if (!fs.existsSync(source)) throw new Error(`required offline dependency is missing: ${packageName}`);
51
+ const target = path.join(targetModules, ...packageName.split('/'));
52
+ fs.mkdirSync(path.dirname(target), { recursive: true });
53
+ fs.cpSync(source, target, { recursive: true, dereference: true });
54
+ const metadata = JSON.parse(fs.readFileSync(path.join(source, 'package.json'), 'utf8'));
55
+ for (const dependency of Object.keys(metadata.dependencies || {})) {
56
+ copyDependencyClosure(dependency, sourceModules, targetModules, copied);
57
+ }
58
+ }
59
+
60
+ function applyVisibilityToWorkspace(repo, arm) {
61
+ const recordPath = path.join(repo, LEDGER, RECORD_NAME);
62
+ const original = fs.readFileSync(recordPath, 'utf8');
63
+ return { recordPath, visibility: 'identical-visible', original };
64
+ }
65
+
66
+ async function buildFixture({ out, arm = 'treatment', sourceRoot = path.resolve(__dirname, '../..') } = {}) {
67
+ if (!out) throw new Error('out is required');
68
+ if (!['baseline', 'treatment'].includes(arm)) throw new Error(`invalid arm: ${arm}`);
69
+ const destination = path.resolve(out);
70
+ const repo = path.join(destination, 'repo');
71
+ fs.rmSync(destination, { recursive: true, force: true });
72
+ fs.mkdirSync(path.join(repo, LEDGER), { recursive: true });
73
+ fs.mkdirSync(path.join(repo, '.husky'), { recursive: true });
74
+ fs.mkdirSync(path.join(repo, '.githooks'), { recursive: true });
75
+ fs.mkdirSync(path.join(repo, 'src'), { recursive: true });
76
+ fs.mkdirSync(path.join(repo, 'node_modules', '.bin'), { recursive: true });
77
+
78
+ const sourceRecordPath = path.join(sourceRoot, LEDGER, RECORD_NAME);
79
+ const sourceIndex = path.join(sourceRoot, LEDGER, 'index.jsonl');
80
+ const sourceRow = indexRow(fs.readFileSync(sourceIndex, 'utf8').split(/\r?\n/).find(line => JSON.parse(line).id === 'E-0003'));
81
+ fs.copyFileSync(path.join(sourceRoot, 'commitlint.config.js'), path.join(repo, 'commitlint.config.js'));
82
+ fs.copyFileSync(path.join(sourceRoot, '.husky', 'commit-msg'), path.join(repo, '.husky', 'commit-msg'));
83
+ fs.copyFileSync(sourceRecordPath, path.join(repo, LEDGER, RECORD_NAME));
84
+ fs.writeFileSync(path.join(repo, LEDGER, 'index.jsonl'), `${JSON.stringify(sourceRow)}\n`);
85
+ fs.writeFileSync(path.join(repo, 'src', 'sample.js'), "'use strict';\n\nmodule.exports = () => '';\n");
86
+ fs.writeFileSync(path.join(repo, 'test.js'), "'use strict';\nconst assert = require('node:assert/strict');\nassert.equal(require('./src/sample')(), 'hello');\n");
87
+
88
+ // Reuse the installed CLI by absolute path and copy the conventional config's
89
+ // transitive dependency closure; no network or full node_modules copy is used.
90
+ const cli = path.join(path.dirname(require.resolve('@commitlint/cli')), 'cli.js');
91
+ const sourceModules = path.join(sourceRoot, 'node_modules');
92
+ const shimPath = path.join(repo, 'node_modules', '.bin', 'commitlint');
93
+
94
+ const hookPath = path.join(repo, '.githooks', 'commit-msg');
95
+ fs.writeFileSync(hookPath, '#!/bin/sh\nexec .husky/commit-msg "$@"\n', { mode: 0o755 });
96
+ fs.writeFileSync(path.join(repo, '.husky', 'commit-msg'), fs.readFileSync(path.join(repo, '.husky', 'commit-msg')));
97
+ fs.chmodSync(path.join(repo, '.husky', 'commit-msg'), 0o755);
98
+
99
+ run('git', ['init', '--quiet', '--object-format=sha1', repo]);
100
+ copyDependencyClosure('@commitlint/config-conventional', sourceModules, path.join(repo, 'node_modules'));
101
+ const shellQuote = value => `'${String(value).replace(/'/g, "'\\''")}'`;
102
+ if (process.platform === 'win32') {
103
+ fs.writeFileSync(`${shimPath}.cmd`, `@"${process.execPath}" "${cli}" %*\r\n`, { mode: 0o755 });
104
+ } else {
105
+ fs.writeFileSync(shimPath, `#!/bin/sh\nexec ${shellQuote(process.execPath)} ${shellQuote(cli)} "$@"\n`, { mode: 0o755 });
106
+ }
107
+ fs.appendFileSync(path.join(repo, '.git', 'info', 'exclude'), '\nnode_modules/\n');
108
+ run('git', ['-C', repo, 'config', 'user.name', FIXED_ENV.GIT_AUTHOR_NAME]);
109
+ run('git', ['-C', repo, 'config', 'user.email', FIXED_ENV.GIT_AUTHOR_EMAIL]);
110
+ run('git', ['-C', repo, 'config', 'core.hooksPath', '.githooks']);
111
+ run('git', ['-C', repo, 'add', 'commitlint.config.js', '.husky/commit-msg', '.githooks/commit-msg', 'src/sample.js', 'test.js', `${LEDGER}/${RECORD_NAME}`, `${LEDGER}/index.jsonl`]);
112
+ run('git', ['-C', repo, 'update-index', '--chmod=+x', '.husky/commit-msg', '.githooks/commit-msg']);
113
+ run('git', ['-C', repo, '-c', 'core.hooksPath=/dev/null', 'commit', '--quiet', '--no-verify', '-m', 'chore: create paired experiment fixture'], { env: { ...process.env, ...FIXED_ENV } });
114
+ const initialSha = run('git', ['-C', repo, 'rev-parse', 'HEAD']);
115
+ const visibility = applyVisibilityToWorkspace(repo, arm);
116
+ return {
117
+ repo,
118
+ initialSha,
119
+ arm,
120
+ visibility: visibility.visibility,
121
+ taskText: TASK_TEXT,
122
+ record: fs.readFileSync(visibility.recordPath, 'utf8'),
123
+ index: fs.readFileSync(path.join(repo, LEDGER, 'index.jsonl'), 'utf8'),
124
+ commitlintPath: cli,
125
+ commitlintResolution: `absolute checkout path ${cli}; no network install`,
126
+ };
127
+ }
128
+
129
+ module.exports = {
130
+ FIXED_ENV,
131
+ TASK_TEXT,
132
+ applyVisibility,
133
+ applyVisibilityToWorkspace,
134
+ buildFixture,
135
+ copyDependencyClosure,
136
+ indexRow,
137
+ visibilityFromRecord,
138
+ };