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
@@ -1,54 +0,0 @@
1
- {
2
- "schema": "harness.doc-reconciliation.qualification.v1",
3
- "host": "claude-code",
4
- "hostVersion": "2.1.308",
5
- "captureRecordVersion": "claude-capture-record/1",
6
- "run": "Run 2b",
7
- "payloadKinds": {
8
- "PostToolUse": [
9
- "agent_id",
10
- "interrupted",
11
- "tool_use_id"
12
- ],
13
- "PreToolUse": [
14
- "agent_id",
15
- "tool_use_id"
16
- ],
17
- "SubagentStart": [
18
- "agent_id"
19
- ],
20
- "SubagentStop": [
21
- "agent_id"
22
- ]
23
- },
24
- "correlation": {
25
- "preToPostByToolUseId": true,
26
- "interruptedExplicit": true,
27
- "subagentStartStopSameAgent": true,
28
- "agentResultAliasCorrelated": true
29
- },
30
- "sanitizedCapture": {
31
- "file": "doc-reconciliation-capture.sanitized.jsonl",
32
- "sha256": "db4d8c85d2ba0fd06f53f455f31b125dd194e9a22cb337687bc0e295a16f02e5"
33
- },
34
- "outlineDispatchCapture": {
35
- "mapping": {
36
- "version": "claude-outline-dispatch-mapping/2",
37
- "promptField": "tool_input.prompt",
38
- "dispatchKey": "session_id+tool_use_id",
39
- "runInBackgroundField": "tool_input.run_in_background",
40
- "isolationPresenceField": "tool_input.isolation",
41
- "resultAgentIdField": "tool_response.agentId",
42
- "resultStatusField": "tool_response.status",
43
- "workerStartEvent": "SubagentStart",
44
- "workerStopEvent": "SubagentStop",
45
- "workerIdentity": "session_id+agent_id",
46
- "workerRootField": "cwd"
47
- },
48
- "file": "doc-reconciliation-outline-capture.sanitized.jsonl",
49
- "sha256": "6feb440af12aaf878a0bed5cb750f29e27d271a9add93001e151746980230b7f",
50
- "hostVersion": "2.1.312",
51
- "run": "run8",
52
- "baseline": "1bd0f805031c5577a6e7f72a9bc5b41618b71fc1"
53
- }
54
- }
@@ -1,239 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const crypto = require('crypto');
5
- const fs = require('fs');
6
- const path = require('path');
7
- const { getWorkspaceRoot, getSessionDir } = require('./lib/harness-state');
8
- const { canonical } = require('./lib/workflow-isolation');
9
-
10
- const INVENTORY_FILE = 'doc-reconciliation/outline-confirmation/inventory';
11
- const APPROVED_INVENTORY = 'benchmarks/results/live-host/claude-341-outline-dispatch-2026-10-28/inventory/2741bd4514d2cd68f57d93a2b3ce94cbe597ca62d30e26f0ca58e882df5b03c6.md';
12
-
13
- function git(root, args, buffer = false) {
14
- const { execFileSync } = require('child_process');
15
- return execFileSync('git', ['-C', root, ...args], { encoding: buffer ? null : 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
16
- }
17
-
18
- function readJson(file) { return JSON.parse(fs.readFileSync(file, 'utf8')); }
19
- function sha(bytes) { return crypto.createHash('sha256').update(bytes).digest('hex'); }
20
- function jsonBytes(value) { return Buffer.from(JSON.stringify(value, null, 2) + '\n'); }
21
- function same(left, right) { return JSON.stringify(left) === JSON.stringify(right); }
22
-
23
- function safeStatePath(sessionDir, relative, allowMissing = false) {
24
- const sessionRoot = fs.realpathSync.native(sessionDir);
25
- if (path.isAbsolute(relative) || relative.split(/[\\/]/).some(part => !part || part === '.' || part === '..')) {
26
- throw new Error('invalid-state-destination');
27
- }
28
- const destination = path.resolve(sessionRoot, relative);
29
- const within = path.relative(sessionRoot, destination);
30
- if (!within || within.startsWith('..' + path.sep) || within === '..' || path.isAbsolute(within)) throw new Error('state-destination-escape');
31
- let cursor = sessionRoot;
32
- const parts = relative.split(/[\\/]/);
33
- for (let index = 0; index < parts.length; index += 1) {
34
- cursor = path.join(cursor, parts[index]);
35
- try {
36
- const stat = fs.lstatSync(cursor);
37
- if (stat.isSymbolicLink() || (index < parts.length - 1 && !stat.isDirectory())
38
- || (index === parts.length - 1 && !stat.isFile())) throw new Error('state-destination-not-regular');
39
- } catch (error) {
40
- if (error.code !== 'ENOENT') throw error;
41
- if (!allowMissing) throw error;
42
- break;
43
- }
44
- }
45
- const parent = path.dirname(destination);
46
- if (fs.existsSync(parent) && fs.realpathSync.native(parent) !== path.resolve(sessionRoot, path.dirname(relative))) {
47
- throw new Error('state-destination-parent-alias');
48
- }
49
- return destination;
50
- }
51
-
52
- function writeNewStateFile(sessionDir, relative, bytes) {
53
- const file = safeStatePath(sessionDir, relative, true);
54
- fs.mkdirSync(path.dirname(file), { recursive: true });
55
- safeStatePath(sessionDir, relative, true);
56
- fs.writeFileSync(file, bytes, { flag: 'wx' });
57
- if (fs.realpathSync.native(path.dirname(file)) !== path.resolve(fs.realpathSync.native(sessionDir), path.dirname(relative))) {
58
- throw new Error('state-destination-parent-alias');
59
- }
60
- return file;
61
- }
62
-
63
- function loadProvider() { return require('./lib/doc-reconciliation-provider'); }
64
-
65
- function hostInvocation(sessionId, operation) {
66
- const root = canonical(getWorkspaceRoot());
67
- const sessionDir = getSessionDir(root, sessionId);
68
- const provider = loadProvider();
69
- const captures = provider.readCaptureView(sessionDir);
70
- if (captures.tampered) throw new Error('capture-view-tampered');
71
- const script = fs.realpathSync.native(__filename);
72
- const matched = captures.records.filter(record => {
73
- if (!record || record.event !== 'PreToolUse' || record.tool_name !== 'Bash'
74
- || record.session_id !== sessionId || record.agent_id !== undefined || !record.tool_use_id) return false;
75
- let cwd;
76
- try { cwd = canonical(record.cwd); } catch { return false; }
77
- if (cwd !== root) return false;
78
- const parsed = provider._internals.safeTokenize(record.command);
79
- if (!parsed.ok || parsed.tokens.length !== 5 || !['node', 'nodejs'].includes(parsed.tokens[0])) return false;
80
- let invoked;
81
- try { invoked = fs.realpathSync.native(path.resolve(cwd, parsed.tokens[1])); } catch { return false; }
82
- return invoked === script && parsed.tokens[2] === operation
83
- && parsed.tokens[3] === '--session-id' && parsed.tokens[4] === sessionId;
84
- });
85
- if (matched.length !== 1) throw new Error('unique-correlated-pre-invocation-required');
86
- const pre = matched[0];
87
- if (captures.records.some(record => record && record.ref !== pre.ref && record.session_id === sessionId
88
- && record.tool_use_id === pre.tool_use_id && ['PostToolUse', 'PostToolUseFailure'].includes(record.event))) {
89
- throw new Error('operation-already-completed');
90
- }
91
- return { root, sessionDir, provider, captures: captures.records, pre };
92
- }
93
-
94
- function loadRow17State(root, sessionDir) {
95
- const workflow = readJson(path.join(sessionDir, 'workflow-run.json'));
96
- const task = workflow.docReconciliationTask;
97
- const baseline = workflow.docReconciliationBaseline;
98
- if (workflow.strategy !== 'iterative-single' || workflow.state !== 'running' || !Number.isInteger(workflow.revision)
99
- || !task || task.schema !== 'harness.doc-reconciliation-task-pin.v1'
100
- || !same(task.requirementIds, ['adr-evid', 'verify-row17']) || task.taskId !== 'task-adr-evid+verify-row17'
101
- || task.sessionId !== workflow.sessionId || task.workflowId !== workflow.workflowId
102
- || !baseline || canonical(baseline.root) !== root || task.baselineRoot !== baseline.root
103
- || task.baselineCommit !== baseline.commit) throw new Error('row17-task-pin-invalid');
104
- return { workflow, task, baseline };
105
- }
106
-
107
- function inventoryBytes(provider) {
108
- const source = path.resolve(__dirname, '..', '..', APPROVED_INVENTORY);
109
- if (fs.existsSync(source)) return fs.readFileSync(source);
110
- const capture = path.join(__dirname, 'lib/doc-reconciliation-outline-capture.sanitized.jsonl');
111
- for (const line of fs.readFileSync(capture, 'utf8').split(/\r?\n/)) {
112
- if (!line) continue;
113
- const record = JSON.parse(line);
114
- const candidates = [record.tool_response?.content?.[0]?.text, record.tool_response?.file?.content, record.tool_response?.stdout];
115
- for (const value of candidates) {
116
- if (typeof value === 'string' && sha(Buffer.from(value)) === provider._internals.OUTLINE_INVENTORY_PIN.sha256) {
117
- return Buffer.from(value);
118
- }
119
- }
120
- }
121
- throw new Error('pinned-inventory-bytes-unavailable');
122
- }
123
-
124
- function inventory({ sessionId }) {
125
- const context = hostInvocation(sessionId, 'inventory');
126
- const { root, sessionDir, provider } = context;
127
- const { workflow, task, baseline } = loadRow17State(root, sessionDir);
128
- const head = git(root, ['rev-parse', '--verify', 'HEAD^{commit}']).trim();
129
- const tree = git(root, ['rev-parse', '--verify', 'HEAD^{tree}']).trim();
130
- if (head !== baseline.commit || tree !== baseline.tree || git(root, ['status', '--porcelain=v1', '-z', '--untracked-files=all'], true).length) {
131
- throw new Error('inventory-must-run-on-clean-baseline');
132
- }
133
- const expectedPin = provider._internals.OUTLINE_INVENTORY_PIN;
134
- const bytes = inventoryBytes(provider);
135
- const validated = provider._internals.validateOutlineInventoryPin({ bytes, pin: expectedPin, expectedPin });
136
- const row = provider._internals.resolveInventoryRow({ parsed: validated.parsed, pin: expectedPin }, '17');
137
- if (sha(bytes) !== expectedPin.sha256 || validated.state !== 'accepted' || row.state !== 'accepted' || row.row.domain !== 'EVID'
138
- || expectedPin.rowDomainMappings[0].approvalRef !== 'https://github.com/dyphn1/Harness-everything/issues/325#issuecomment-6706805112') {
139
- throw new Error('pinned-row17-inventory-invalid');
140
- }
141
- const inventoryRelative = `${INVENTORY_FILE}/${path.posix.basename(expectedPin.retainedArtifactPath)}`;
142
- const pinRelative = `${INVENTORY_FILE}/inventory-pin.json`;
143
- writeNewStateFile(sessionDir, inventoryRelative, bytes);
144
- writeNewStateFile(sessionDir, pinRelative, jsonBytes(expectedPin));
145
- return { operation: 'inventory', workflowId: workflow.workflowId, revision: workflow.revision, taskId: task.taskId,
146
- destinations: [inventoryRelative, pinRelative], sha256: expectedPin.sha256 };
147
- }
148
-
149
- function seal({ sessionId }) {
150
- const context = hostInvocation(sessionId, 'seal');
151
- const { root, sessionDir, provider, captures } = context;
152
- const { workflow, task, baseline } = loadRow17State(root, sessionDir);
153
- const head = git(root, ['rev-parse', '--verify', 'HEAD^{commit}']).trim();
154
- const tree = git(root, ['rev-parse', '--verify', 'HEAD^{tree}']).trim();
155
- if (head === baseline.commit || git(root, ['status', '--porcelain=v1', '-z', '--untracked-files=all'], true).length
156
- || git(root, ['merge-base', '--is-ancestor', baseline.commit, head]) !== '') throw new Error('seal-requires-clean-b-to-o-outline');
157
- const expectedPin = provider._internals.OUTLINE_INVENTORY_PIN;
158
- const inventoryRoot = path.join(sessionDir, INVENTORY_FILE);
159
- const pinFile = path.join(inventoryRoot, 'inventory-pin.json');
160
- const pinBytes = fs.readFileSync(pinFile);
161
- const pin = JSON.parse(pinBytes.toString('utf8'));
162
- const bytes = fs.readFileSync(path.join(inventoryRoot, path.posix.basename(expectedPin.retainedArtifactPath)));
163
- const inventory = provider._internals.validateOutlineInventoryPin({ bytes, pin, expectedPin });
164
- if (inventory.state !== 'accepted' || sha(pinBytes) !== sha(jsonBytes(expectedPin))) throw new Error('pinned-inventory-not-installed');
165
- const inventoryPath = `doc-reconciliation/outline-confirmation/inventory/${path.posix.basename(expectedPin.retainedArtifactPath)}`;
166
- const reviewEvents = captures.filter(record => record && record.event === 'SubagentStop' && record.agent_type === 'reviewer'
167
- && record.reviewVerdict === 'approve' && record.reviewSummary);
168
- const candidates = reviewEvents.filter(review => {
169
- const targets = Object.keys(review.reviewedArtifactDigests || {}).filter(relative => relative !== inventoryPath);
170
- return targets.length === 1 && review.reviewedArtifactDigests[inventoryPath] === sha(bytes);
171
- });
172
- if (candidates.length !== 1) throw new Error('unique-approved-outline-review-required');
173
- const review = candidates[0];
174
- const targetPaths = Object.keys(review.reviewedArtifactDigests).filter(relative => relative !== inventoryPath);
175
- const target = targetPaths[0];
176
- const targetBytes = git(root, ['show', `${head}:${target}`], true);
177
- const citation = provider._internals.parseOutlineCitation(targetBytes, target);
178
- const row = provider._internals.resolveInventoryRow(inventory, citation.rowId);
179
- const targetBlob = git(root, ['rev-parse', `${head}:${target}`]).trim();
180
- if (citation.state !== 'accepted' || citation.rowId !== '17' || citation.domain !== 'EVID'
181
- || row.state !== 'accepted' || row.row.domain !== 'EVID'
182
- || review.reviewedArtifactDigests[target] !== sha(targetBytes)) throw new Error('approved-outline-does-not-match-pinned-row17');
183
- const start = captures.filter(record => record && record.event === 'SubagentStart' && record.agent_id === review.agent_id);
184
- const launch = captures.filter(record => record && record.event === 'PostToolUse' && ['Task', 'Agent'].includes(record.tool_name)
185
- && record.agent_id === review.agent_id);
186
- if (start.length !== 1 || launch.length !== 1 || captures.indexOf(start[0]) >= captures.indexOf(review)
187
- || captures.indexOf(launch[0]) >= captures.indexOf(review)
188
- || start[0].outlineIdentity?.state !== 'accepted'
189
- || start[0].outlineIdentity.identity.outlineCommit !== head || start[0].outlineIdentity.identity.outlineTree !== tree
190
- || !provider.reviewRecordIndependent(review, captures, { author: sessionId,
191
- executors: provider.journalExecutors(captures, sessionId) })) throw new Error('outline-review-lifecycle-or-identity-invalid');
192
- const outlineDigests = { [target]: sha(targetBytes) };
193
- const attemptId = 'attempt-' + sha(review.ref).slice(0, 16);
194
- const attemptRelative = `doc-reconciliation/outline-confirmation/${task.taskId}/attempts/${attemptId}`;
195
- const attemptDir = path.join(sessionDir, attemptRelative);
196
- const lease = { schema: 'harness.outline-writer-lease.v1', id: 'lease-' + sha(review.ref).slice(0, 16),
197
- taskId: task.taskId, attemptId, principalId: sessionId, root, exclusive: true, active: true };
198
- const leaseRelative = `${attemptRelative}/writer-lease.json`;
199
- const leaseBytes = jsonBytes(lease);
200
- const leaseDigest = sha(leaseBytes);
201
- const reviewDigest = provider._internals.captureDigest(review);
202
- const handoff = {
203
- schema: 'harness.outline-handoff.v1', handoffId: 'handoff-' + sha(review.ref).slice(0, 16),
204
- taskId: task.taskId, attemptId, supersedesAttemptId: null, workspaceId: task.workspaceId,
205
- workflowId: workflow.workflowId, workflowRevision: workflow.revision, sessionId, hostId: 'claude-code',
206
- baseline: { root: baseline.root, commit: baseline.commit, tree: baseline.tree, configDigest: task.configDigest },
207
- configDigest: task.configDigest, targetPaths, draftWorktreeRoot: root,
208
- outline: { commit: head, tree, targetBlobs: { [target]: { blobOid: targetBlob, storedBytesSha256: sha(targetBytes) } } },
209
- inventory: { ...expectedPin, rowId: '17', domain: 'EVID', targetPaths },
210
- reviewCaptureRef: review.ref, reviewCaptureDigest: reviewDigest, reviewDigest: review.reviewDigest,
211
- coordinatorPrincipal: sessionId, writerLeaseId: lease.id, writerLeaseDigest: leaseDigest,
212
- draftDispatchToken: crypto.randomBytes(24).toString('hex'),
213
- };
214
- const validatedReview = provider._internals.validateOutlineReview({ handoff, attemptDir, captures, targetPaths,
215
- outlineDigests, inventory, sessionId });
216
- if (validatedReview.state !== 'accepted') throw new Error(validatedReview.reason || 'outline-review-invalid');
217
- const handoffRelative = `${attemptRelative}/handoff.json`;
218
- fs.mkdirSync(attemptDir, { recursive: true });
219
- writeNewStateFile(sessionDir, leaseRelative, leaseBytes);
220
- writeNewStateFile(sessionDir, handoffRelative, jsonBytes(handoff));
221
- return { operation: 'seal', workflowId: workflow.workflowId, revision: workflow.revision, taskId: task.taskId,
222
- attemptId, destinations: [leaseRelative, handoffRelative], handoff };
223
- }
224
-
225
- function main(argv) {
226
- const [operation, flag, sessionId, extra] = argv;
227
- if (!['inventory', 'seal'].includes(operation) || flag !== '--session-id' || !sessionId || extra !== undefined) {
228
- throw new Error('Usage: w6-state-operations.js <inventory|seal> --session-id <id>');
229
- }
230
- const result = operation === 'inventory' ? inventory({ sessionId }) : seal({ sessionId });
231
- process.stdout.write(JSON.stringify(result) + '\n');
232
- }
233
-
234
- if (require.main === module) {
235
- try { main(process.argv.slice(2)); }
236
- catch (error) { console.error('[W6 State Operation] ' + error.message); process.exitCode = 2; }
237
- }
238
-
239
- module.exports = { main };
@@ -1,112 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- // Research evaluation driver for the fine-tuned Laya bridge (#255 Phase 3).
4
- // It does NOT touch provider.js/resident.js (still cua-only): it starts the
5
- // laya resident server itself, scores cases through it, and feeds the
6
- // production decide()/evaluate() machinery. Usage:
7
- // score <cases.json> <manifest.json> <records.json> [workdir]
8
- // report <corpus.json> <records.json> <report.json> [--secondary-threshold T]
9
- // cases.json: { cases: [{ id, baseline, request }] } (request = holdout-style,
10
- // context + 13 catalog options). records.json matches evaluate() input.
11
- const fs = require('node:fs');
12
- const path = require('node:path');
13
- const net = require('node:net');
14
- const { spawn } = require('node:child_process');
15
- const { performance } = require('node:perf_hooks');
16
- const { evaluate } = require('../harness-everything/scripts/system-one/evaluate');
17
- const { decide } = require('../harness-everything/scripts/system-one/contract');
18
- const { decisionPolicy } = require('../harness-everything/scripts/system-one/provider');
19
-
20
- const ADAPTER = path.join(__dirname, '..', 'harness-everything', 'scripts', 'system-one', 'laya_adapter.py');
21
- const CALL_TIMEOUT_MS = 30000;
22
-
23
- function send(port, token, message) {
24
- return new Promise(resolve => {
25
- const socket = net.connect({ port, host: '127.0.0.1' });
26
- const chunks = [];
27
- const done = value => { socket.destroy(); resolve(value); };
28
- const timer = setTimeout(() => done({ ok: false, reason: 'timeout' }), CALL_TIMEOUT_MS);
29
- socket.on('connect', () => socket.end(`${JSON.stringify({ token, ...message })}\n`));
30
- socket.on('data', c => chunks.push(c));
31
- socket.on('end', () => { clearTimeout(timer);
32
- try { done(JSON.parse(Buffer.concat(chunks).toString('utf8'))); }
33
- catch (_) { done({ ok: false, reason: 'bad-reply' }); } });
34
- socket.on('error', () => { clearTimeout(timer); done({ ok: false, reason: 'io' }); });
35
- });
36
- }
37
-
38
- async function withServer(python, manifest, workdir, fn) {
39
- const manifestJson = JSON.stringify(manifest);
40
- const state = path.join(workdir, 'laya-research-state.json');
41
- const lock = path.join(workdir, 'laya-research-state.starting');
42
- for (const f of [state, lock]) try { fs.unlinkSync(f); } catch (_) { /* fresh */ }
43
- const child = spawn(python, [ADAPTER, '--serve', manifestJson, state, lock], { stdio: 'ignore' });
44
- const deadline = Date.now() + 120000;
45
- let info = null;
46
- while (Date.now() < deadline) {
47
- try { info = JSON.parse(fs.readFileSync(state, 'utf8')); if (info.port && info.token) break; } catch (_) { /* starting */ }
48
- if (child.exitCode !== null) throw new Error(`server exited during startup (code ${child.exitCode})`);
49
- await new Promise(r => setTimeout(r, 200));
50
- info = null;
51
- }
52
- if (!info) { child.kill('SIGKILL'); throw new Error('server did not become ready'); }
53
- try {
54
- return await fn(info);
55
- } finally {
56
- try { await send(info.port, info.token, { op: 'shutdown' }); } catch (_) { /* exiting */ }
57
- child.kill('SIGKILL');
58
- }
59
- }
60
-
61
- async function score(casesPath, manifestPath, recordsPath, workdir) {
62
- const { cases } = JSON.parse(fs.readFileSync(casesPath, 'utf8'));
63
- const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
64
- const policy = decisionPolicy(manifest.acceptance);
65
- const records = await withServer(manifest.python, manifest, workdir, async info => {
66
- const out = [];
67
- for (const c of cases) {
68
- const runs = [];
69
- for (let i = 0; i < 2; i++) {
70
- const start = performance.now();
71
- const reply = await send(info.port, info.token, { op: 'score', request: c.request });
72
- const latencyMs = performance.now() - start;
73
- let decision;
74
- let scores = null;
75
- if (reply.ok) {
76
- decision = decide(c.request, reply.response, policy);
77
- if (decision.selectedId === 'unclassified') {
78
- decision = { ...decision, status: 'abstain', reason: 'unclassified', selectedId: null };
79
- }
80
- if (['accepted', 'abstain'].includes(decision.status)) scores = reply.response.scores.map(s => s.probability);
81
- } else {
82
- decision = { status: 'unavailable', reason: reply.reason };
83
- }
84
- runs.push({ decision, scores, latencyMs, coldStart: false });
85
- }
86
- out.push({ id: c.id, baseline: c.baseline, runs });
87
- }
88
- return out;
89
- });
90
- fs.writeFileSync(recordsPath, `${JSON.stringify(records)}\n`);
91
- console.log(JSON.stringify({ cases: records.length }));
92
- }
93
-
94
- function report(corpusPath, recordsPath, reportPath, secondaryThreshold) {
95
- const corpus = JSON.parse(fs.readFileSync(corpusPath, 'utf8'));
96
- const records = JSON.parse(fs.readFileSync(recordsPath, 'utf8'));
97
- const result = evaluate(corpus, records, null, { secondaryThreshold });
98
- fs.writeFileSync(reportPath, `${JSON.stringify(result, null, 2)}\n`);
99
- console.log(JSON.stringify({ cases: result.cases, coverage: result.model.coverage,
100
- acceptedPrecision: result.model.acceptedPrecision, rolloutReady: result.rolloutReady }));
101
- }
102
-
103
- async function main() {
104
- const [mode, a, b, c, d] = process.argv.slice(2);
105
- if (mode === 'score' && a && b && c) return score(a, b, c, d || fs.mkdtempSync('/tmp/laya-eval-'));
106
- if (mode === 'report' && a && b && c) {
107
- const t = d === undefined ? undefined : Number((d.match(/^--secondary-threshold=(.+)$/) || [])[1]);
108
- return report(a, b, c, t);
109
- }
110
- throw new Error('usage: system-one-eval-laya.js (score <cases> <manifest> <records> [workdir] | report <corpus> <records> <report> [--secondary-threshold=T])');
111
- }
112
- main().catch(err => { console.error(`laya research eval failed: ${err.message}`); process.exitCode = 1; });