harness-everything 1.3.0 → 1.3.1

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 (125) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +6 -0
  4. package/ci/archive/325-prep/README.md +9 -2
  5. package/ci/archive/325-prep/doc-reconciliation-red.js +34 -8
  6. package/ci/fixtures/553-t2a/body-edit/base/.agents/harness-everything/project-docs.json +11 -0
  7. package/ci/fixtures/553-t2a/body-edit/base/docs/a.md +6 -0
  8. package/ci/fixtures/553-t2a/body-edit/base/docs/b.md +1 -0
  9. package/ci/fixtures/553-t2a/body-edit/candidate/docs/a.md +6 -0
  10. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  11. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/governed-index.md +19 -0
  12. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  13. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/governed-index.md +19 -0
  14. package/ci/fixtures/553-t2c/derived-regenerate-must/config.json +17 -0
  15. package/ci/fixtures/doc-obligations/derive/regression-pins.json +153 -0
  16. package/ci/fixtures/state-persist-post-tool-use/harness.js +206 -0
  17. package/ci/fixtures/state-persist-post-tool-use/off-handoff-golden.json +16 -0
  18. package/ci/fixtures/state-persist-post-tool-use/payload-post-tool-use-success.json +13 -0
  19. package/ci/fixtures/stop/fail-session-writes.js +109 -0
  20. package/ci/fixtures/workflow-contract/cases.json +3355 -0
  21. package/ci/fixtures/workflow-contract/wiring-cases.json +560 -0
  22. package/ci/lib/doc-reconciliation-prep-fixtures.js +4 -9
  23. package/ci/mechanism-2an-workflow-replay.test.js +324 -0
  24. package/ci/mechanism-2ax-doc-lifecycle.test.js +132 -0
  25. package/ci/mechanism-325-3a-doc-evidence.test.js +73 -0
  26. package/ci/mechanism-325-3a-doc-obligations.test.js +61 -0
  27. package/ci/mechanism-325-3b-preparation.test.js +208 -49
  28. package/ci/mechanism-325-3b-s1-review.test.js +20 -828
  29. package/ci/mechanism-325-3b-s3-providers.test.js +59 -0
  30. package/ci/mechanism-325-f3-derived-views.test.js +140 -0
  31. package/ci/mechanism-341-opencode-lane.test.js +164 -284
  32. package/ci/mechanism-35-verification-contract.test.js +246 -0
  33. package/ci/mechanism-365-step-edit-accounting.test.js +5 -6
  34. package/ci/mechanism-383-doc-glob-line-terminators.test.js +0 -30
  35. package/ci/mechanism-397-opencode-observations.test.js +151 -18
  36. package/ci/mechanism-553-e1-unhook-credit.test.js +328 -0
  37. package/ci/mechanism-553-p2a-claude-hooks.test.js +98 -0
  38. package/ci/mechanism-553-p3-plan-start.test.js +212 -0
  39. package/ci/mechanism-553-state-persist-post-tool-use.test.js +307 -0
  40. package/ci/mechanism-553-stop.test.js +427 -0
  41. package/ci/mechanism-553-t2a-derive.test.js +110 -0
  42. package/ci/mechanism-553-t2c-derive.test.js +94 -0
  43. package/ci/mechanism-e1-derived-regenerate.test.js +45 -206
  44. package/ci/mechanism-outline-sanitizer.test.js +0 -8
  45. package/ci/mechanism-pr-a-conflict-check.test.js +38 -305
  46. package/ci/mechanism-prb-outline-review.test.js +101 -3283
  47. package/docs/adr/DOCS-006-reconciliation-pilot.md +4 -2
  48. package/docs/adr/DOCS-008-obligation-abstraction-bounded-consumer.md +3 -3
  49. package/docs/doc-workflow-reconciliation.md +17 -2
  50. package/docs/document-lifecycle.md +6 -2
  51. package/docs/platform-capabilities.md +35 -5
  52. package/hooks/hooks.json +0 -46
  53. package/hooks/scripts/lib/workflow-obligations.js +0 -55
  54. package/hooks/scripts/state-persist.js +7 -95
  55. package/hooks/scripts/workflow-disposition.js +0 -2
  56. package/hooks/scripts/workflow-stop-gate.js +17 -30
  57. package/opencode-plugin/index.mjs +6 -70
  58. package/opencode-plugin/plugin.json +1 -1
  59. package/package.json +1 -1
  60. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  61. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  62. package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +0 -55
  63. package/plugins/harness-everything/hooks/scripts/state-persist.js +7 -95
  64. package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +0 -2
  65. package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +17 -30
  66. package/plugins/harness-everything/plugin.json +1 -1
  67. package/sbom.cdx.json +7 -7
  68. package/ci/fixtures/doc-obligations/reconciliation-s1/cases.json +0 -6854
  69. package/ci/fixtures/doc-obligations/reconciliation-s1/fail-session-writes.js +0 -116
  70. package/ci/fixtures/doc-obligations/reconciliation-s2a/harness.js +0 -507
  71. package/ci/fixtures/doc-obligations/reconciliation-s2a/run13-workflow-requirements.json +0 -42
  72. package/ci/fixtures/doc-obligations/reconciliation-s2a/vectors.json +0 -617
  73. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/harness.js +0 -415
  74. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-post-tool-use-success-minimal.json +0 -9
  75. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-start.json +0 -7
  76. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-freetext-reject.json +0 -11
  77. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-reject.json +0 -11
  78. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop.json +0 -11
  79. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-task-result.json +0 -19
  80. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-capture-only.json +0 -99
  81. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-legacy.json +0 -67
  82. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-concurrent-writers.json +0 -62
  83. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-lookalikes-runtime-mutations.json +0 -67
  84. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-malformed.json +0 -85
  85. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-normal-session.json +0 -74
  86. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-runtime-drift-later-npm-test.json +0 -58
  87. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-valid-direct-quoted-review.json +0 -85
  88. package/ci/fixtures/doc-obligations/reconciliation-s2b/f4/cases.json +0 -2267
  89. package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/cases.json +0 -1110
  90. package/ci/lib/doc-reconciliation-file-spy.js +0 -23
  91. package/ci/lib/doc-reconciliation-qualification-preload.js +0 -37
  92. package/ci/lib/doc-reconciliation-replay.js +0 -104
  93. package/ci/lib/doc-reconciliation-staged-tree.js +0 -102
  94. package/ci/mechanism-325-3b-h1-qualification.test.js +0 -206
  95. package/ci/mechanism-325-3b-s1.test.js +0 -188
  96. package/ci/mechanism-325-3b-s2a-core.test.js +0 -840
  97. package/ci/mechanism-325-3b-s2a-producer.test.js +0 -564
  98. package/ci/mechanism-325-3b-s2b-capture.test.js +0 -566
  99. package/ci/mechanism-325-3b-s2b-wiring.test.js +0 -679
  100. package/ci/mechanism-325-f4-invariants.test.js +0 -606
  101. package/ci/mechanism-325-f4-projections.test.js +0 -392
  102. package/ci/mechanism-325-f4-qualification.test.js +0 -228
  103. package/ci/mechanism-325-f4-trust-boundary.test.js +0 -880
  104. package/ci/mechanism-e1-dependency-artifact-scope.test.js +0 -657
  105. package/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  106. package/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  107. package/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  108. package/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  109. package/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  110. package/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  111. package/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  112. package/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  113. package/hooks/scripts/w6-state-operations.js +0 -239
  114. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  115. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  116. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  117. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  118. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  119. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  120. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  121. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  122. package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +0 -239
  123. package/scripts/system-one-eval-laya.js +0 -112
  124. /package/ci/fixtures/{doc-obligations/reconciliation-s2b/capture → state-persist-post-tool-use}/payload-post-tool-use-failure.json +0 -0
  125. /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,26 +0,0 @@
1
- {"run":"1","source":"wrapper-stdin","wrapperLabel":"PreToolUse","event":"PreToolUse","tool_use_id":"<tool-use-1>","payload":{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_use_id":"<tool-use-1>","session_id":"<session-1>","prompt_id":"<prompt-1>","tool_input_command":"node <scratch>/plugin/harness-everything/scripts/doc-check.js check --workspace <scratch>/project --config .agents/harness-everything/project-docs.json --changed-path docs/a.md","cwd":"<scratch>/project","transcript_path":"<home-path>"}}
2
- {"run":"2a","source":"wrapper-stdin","wrapperLabel":"PreToolUse","event":"PreToolUse","tool_use_id":"<tool-use-2>","payload":{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_use_id":"<tool-use-2>","session_id":"<session-2>","prompt_id":"<prompt-2>","tool_input_command":"node <scratch>/plugin/harness-everything/scripts/doc-check.js check --workspace <scratch>/project --config .agents/harness-everything/project-docs.json --changed-path docs/a.md","cwd":"<scratch>/project","transcript_path":"<home-path>"}}
3
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"PreToolUse","event":"PreToolUse","tool_use_id":"<tool-use-3>","payload":{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_use_id":"<tool-use-3>","session_id":"<session-3>","prompt_id":"<prompt-3>","tool_input_command":"node \"<scratch>/plugin/harness-everything/scripts/doc-check.js\" check --workspace <scratch>/project --config .agents/harness-everything/project-docs.json --changed-path docs/a.md","cwd":"<scratch>/project","transcript_path":"<home-path>"}}
4
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"PostToolUse","event":"PostToolUse","tool_use_id":"<tool-use-3>","interrupted":false,"payload":{"hook_event_name":"PostToolUse","tool_name":"Bash","tool_use_id":"<tool-use-3>","session_id":"<session-3>","prompt_id":"<prompt-3>","tool_input_command":"node \"<scratch>/plugin/harness-everything/scripts/doc-check.js\" check --workspace <scratch>/project --config .agents/harness-everything/project-docs.json --changed-path docs/a.md","cwd":"<scratch>/project","transcript_path":"<home-path>","tool_response":{"keys":["interrupted","isImage","noOutputExpected","stderr","stdout"],"interrupted":false,"digest":"sha256:22cd89eb079e65f996432f65cfd9bed1a29366def8f3f8af9af94c26c60bd1f5"}}}
5
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"PreToolUse","event":"PreToolUse","tool_use_id":"<tool-use-4>","payload":{"hook_event_name":"PreToolUse","tool_name":"Agent","tool_use_id":"<tool-use-4>","session_id":"<session-3>","prompt_id":"<prompt-3>","cwd":"<scratch>/project","transcript_path":"<home-path>"}}
6
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"SubagentStart","event":"SubagentStart","agent_id":"<agent-1>","payload":{"hook_event_name":"SubagentStart","session_id":"<session-3>","prompt_id":"<prompt-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","cwd":"<scratch>/project","transcript_path":"<home-path>"}}
7
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"PreToolUse","event":"PreToolUse","tool_use_id":"<tool-use-5>","agent_id":"<agent-1>","payload":{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_use_id":"<tool-use-5>","session_id":"<session-3>","prompt_id":"<prompt-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","tool_input_command":"cat docs/a.md && git diff docs/a.md && shasum -a 256 docs/a.md","cwd":"<scratch>/project","transcript_path":"<home-path>"}}
8
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"PreToolUse","event":"PreToolUse","tool_use_id":"<tool-use-6>","agent_id":"<agent-1>","payload":{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_use_id":"<tool-use-6>","session_id":"<session-3>","prompt_id":"<prompt-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","tool_input_command":"git diff docs/a.md","cwd":"<scratch>/project","transcript_path":"<home-path>"}}
9
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"PostToolUse","event":"PostToolUse","tool_use_id":"<tool-use-6>","agent_id":"<agent-1>","interrupted":false,"payload":{"hook_event_name":"PostToolUse","tool_name":"Bash","tool_use_id":"<tool-use-6>","session_id":"<session-3>","prompt_id":"<prompt-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","tool_input_command":"git diff docs/a.md","cwd":"<scratch>/project","transcript_path":"<home-path>","tool_response":{"keys":["interrupted","isImage","noOutputExpected","stderr","stdout"],"interrupted":false,"digest":"sha256:5ff449b9366059bd45c22c411728c93b8c4b5d5a083f1243c7882279b8b2e656"}}}
10
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"PreToolUse","event":"PreToolUse","tool_use_id":"<tool-use-7>","agent_id":"<agent-1>","payload":{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_use_id":"<tool-use-7>","session_id":"<session-3>","prompt_id":"<prompt-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","tool_input_command":"ls docs; grep -rni retr . --include=*.md","cwd":"<scratch>/project","transcript_path":"<home-path>"}}
11
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"PostToolUse","event":"PostToolUse","tool_use_id":"<tool-use-7>","agent_id":"<agent-1>","interrupted":false,"payload":{"hook_event_name":"PostToolUse","tool_name":"Bash","tool_use_id":"<tool-use-7>","session_id":"<session-3>","prompt_id":"<prompt-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","tool_input_command":"ls docs; grep -rni retr . --include=*.md","cwd":"<scratch>/project","transcript_path":"<home-path>","tool_response":{"keys":["interrupted","isImage","noOutputExpected","returnCodeInterpretation","stderr","stdout"],"interrupted":false,"digest":"sha256:f4f1baf50b0770a29763b15493f7c7f315321f5c2c92b5288b18d20c3480f97a"}}}
12
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"SubagentStop","event":"SubagentStop","agent_id":"<agent-1>","payload":{"hook_event_name":"SubagentStop","session_id":"<session-3>","prompt_id":"<prompt-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","cwd":"<scratch>/project","transcript_path":"<home-path>","agent_transcript_path":"<home-path>","last_assistant_message":"Review verdict: approve\n\nSummary: The only change to `docs/a.md` is \"retries once\" becoming \"retries twice\". The front matter is intact, and the link to `b.md` resolves because that file exists. Nothing else in the repo mentions retries, so I found no contradiction. I could not check the \"twice\" claim against the code, since this repo has no code or other source for it. I also couldn't compute a SHA-256, because the shell blocked `shasum`.\n\nReviewed artifact digest: `<scratch>/project/docs/a.md`, the working-tree version, uncommitted on top of baseline 8648a71. The identifying content is the diff hunk `@@ -3,4 +3,4 @@`, with the blob change `0936062..3bea475`. The body line is \"The checkout retries twice. See [b](b.md).\""}}
13
- {"run":"2b","source":"wrapper-stdin","wrapperLabel":"PostToolUse","event":"PostToolUse","tool_use_id":"<tool-use-4>","payload":{"hook_event_name":"PostToolUse","tool_name":"Agent","tool_use_id":"<tool-use-4>","session_id":"<session-3>","prompt_id":"<prompt-3>","cwd":"<scratch>/project","transcript_path":"<home-path>","tool_response":{"keys":["agentId","agentType","canContinueAgent","content","harnessNoteCount","harnessSectionHash","harnessTailCount","prompt","resolvedModel","status","toolStats","totalDurationMs","totalTokens","totalToolUseCount","usage"],"status":"completed","agentId":"<agent-1>","digest":"sha256:f035f2ed002f3dc6827f3109a8fdbc99ae439472bc504fc4d460b5bf0ac4204e"}}}
14
- {"run":"1","source":"journal-record","event":"PreToolUse","tool_use_id":"<tool-use-1>","record":{"captureId":"<capture-1>","event":"PreToolUse","tool_use_id":"<tool-use-1>","session_id":"<session-1>","command":"node <scratch>/plugin/harness-everything/scripts/doc-check.js check --workspace <scratch>/project --config .agents/harness-everything/project-docs.json --changed-path docs/a.md","cwd":"<scratch>/project","responseDigest":"eb045d78d273107348b0300c01d29b7552d622abbc6faf81b3ec55359aa9950c"}}
15
- {"run":"1","source":"journal-record","event":"PreToolUse","tool_use_id":"<tool-use-1>","record":{"captureId":"<capture-2>","event":"PreToolUse","tool_use_id":"<tool-use-1>","session_id":"<session-1>","command":"node <scratch>/plugin/harness-everything/scripts/doc-check.js check --workspace <scratch>/project --config .agents/harness-everything/project-docs.json --changed-path docs/a.md","cwd":"<scratch>/project","responseDigest":"eb045d78d273107348b0300c01d29b7552d622abbc6faf81b3ec55359aa9950c"}}
16
- {"run":"2b","source":"journal-record","event":"PreToolUse","tool_use_id":"<tool-use-3>","record":{"captureId":"<capture-3>","event":"PreToolUse","tool_use_id":"<tool-use-3>","session_id":"<session-3>","command":"node \"<scratch>/plugin/harness-everything/scripts/doc-check.js\" check --workspace <scratch>/project --config .agents/harness-everything/project-docs.json --changed-path docs/a.md","cwd":"<scratch>/project","responseDigest":"eb045d78d273107348b0300c01d29b7552d622abbc6faf81b3ec55359aa9950c"}}
17
- {"run":"2b","source":"journal-record","event":"PostToolUse","tool_use_id":"<tool-use-3>","interrupted":false,"record":{"captureId":"<capture-4>","event":"PostToolUse","tool_use_id":"<tool-use-3>","session_id":"<session-3>","command":"node \"<scratch>/plugin/harness-everything/scripts/doc-check.js\" check --workspace <scratch>/project --config .agents/harness-everything/project-docs.json --changed-path docs/a.md","cwd":"<scratch>/project","interrupted":false,"responseDigest":"80ccfae628fb7127a06592ddb8439b864093a34d1b11007d5b137fbc6f95fcef"}}
18
- {"run":"2b","source":"journal-record","event":"PreToolUse","tool_use_id":"<tool-use-4>","record":{"captureId":"<capture-5>","event":"PreToolUse","tool_use_id":"<tool-use-4>","session_id":"<session-3>","cwd":"<scratch>/project","responseDigest":"eb045d78d273107348b0300c01d29b7552d622abbc6faf81b3ec55359aa9950c"}}
19
- {"run":"2b","source":"journal-record","event":"SubagentStart","agent_id":"<agent-1>","record":{"captureId":"<capture-6>","event":"SubagentStart","session_id":"<session-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","cwd":"<scratch>/project","responseDigest":"eb045d78d273107348b0300c01d29b7552d622abbc6faf81b3ec55359aa9950c"}}
20
- {"run":"2b","source":"journal-record","event":"PreToolUse","tool_use_id":"<tool-use-5>","agent_id":"<agent-1>","record":{"captureId":"<capture-7>","event":"PreToolUse","tool_use_id":"<tool-use-5>","session_id":"<session-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","command":"cat docs/a.md && git diff docs/a.md && shasum -a 256 docs/a.md","cwd":"<scratch>/project","responseDigest":"eb045d78d273107348b0300c01d29b7552d622abbc6faf81b3ec55359aa9950c"}}
21
- {"run":"2b","source":"journal-record","event":"PreToolUse","tool_use_id":"<tool-use-6>","agent_id":"<agent-1>","record":{"captureId":"<capture-8>","event":"PreToolUse","tool_use_id":"<tool-use-6>","session_id":"<session-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","command":"git diff docs/a.md","cwd":"<scratch>/project","responseDigest":"eb045d78d273107348b0300c01d29b7552d622abbc6faf81b3ec55359aa9950c"}}
22
- {"run":"2b","source":"journal-record","event":"PostToolUse","tool_use_id":"<tool-use-6>","agent_id":"<agent-1>","interrupted":false,"record":{"captureId":"<capture-9>","event":"PostToolUse","tool_use_id":"<tool-use-6>","session_id":"<session-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","command":"git diff docs/a.md","cwd":"<scratch>/project","interrupted":false,"responseDigest":"f8770735e00cf9d10b07d43d91379c17ab2ca5444610dd3d5944b52912d13369"}}
23
- {"run":"2b","source":"journal-record","event":"PreToolUse","tool_use_id":"<tool-use-7>","agent_id":"<agent-1>","record":{"captureId":"<capture-10>","event":"PreToolUse","tool_use_id":"<tool-use-7>","session_id":"<session-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","command":"ls docs; grep -rni retr . --include=*.md","cwd":"<scratch>/project","responseDigest":"eb045d78d273107348b0300c01d29b7552d622abbc6faf81b3ec55359aa9950c"}}
24
- {"run":"2b","source":"journal-record","event":"PostToolUse","tool_use_id":"<tool-use-7>","agent_id":"<agent-1>","interrupted":false,"record":{"captureId":"<capture-11>","event":"PostToolUse","tool_use_id":"<tool-use-7>","session_id":"<session-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","command":"ls docs; grep -rni retr . --include=*.md","cwd":"<scratch>/project","interrupted":false,"responseDigest":"4a1d1e23f6b3c88bbc86f5960e2492acc61d65201a9cea4863610c068beb907c"}}
25
- {"run":"2b","source":"journal-record","event":"SubagentStop","agent_id":"<agent-1>","record":{"captureId":"<capture-12>","event":"SubagentStop","session_id":"<session-3>","agent_id":"<agent-1>","agent_type":"doc-reviewer","cwd":"<scratch>/project","reviewVerdict":"approve","reviewSummary":"Summary: The only change to `docs/a.md` is \"retries once\" becoming \"retries twice\". The front matter is intact, and the link to `b.md` resolves because that file exists. Nothing else in the repo mentions retries, so I found no contradiction. I could not check the \"twice\" claim against the code, since this repo has no code or other source for it. I also couldn't compute a SHA-256, because the shell blocked `shasum`.\n\n\nReviewed artifact digest: `<scratch>/project/docs/a.md`, the working-tree version, uncommitted on top of baseline 8648a71. The identifying content is the diff hunk `@@ -3,4 +3,4 @@`, with the blob change `0936062..3bea475`. The body line is \"The checkout retries twice. See [b](b.md).\"","responseDigest":"eb045d78d273107348b0300c01d29b7552d622abbc6faf81b3ec55359aa9950c"}}
26
- {"run":"2b","source":"journal-record","event":"PostToolUse","tool_use_id":"<tool-use-4>","agent_id":"<agent-1>","record":{"captureId":"<capture-13>","event":"PostToolUse","tool_use_id":"<tool-use-4>","session_id":"<session-3>","agent_id":"<agent-1>","cwd":"<scratch>/project","responseDigest":"51be05fc9c852f14829a9e01ccd0b2d9d743e0d16c237de69db752d100fad0dc"}}