harness-everything 0.49.0 → 0.51.0

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 (29) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/workflows/ci.yml +0 -82
  4. package/.github/workflows/doc-governance.yml +91 -0
  5. package/.github/workflows/release.yml +5 -2
  6. package/CHANGELOG.md +150 -115
  7. package/ci/mechanism-2ax-doc-lifecycle.test.js +142 -12
  8. package/ci/mechanism-prb-outline-review.test.js +783 -107
  9. package/ci/release-unreleased-heading.test.js +24 -0
  10. package/docs/doc-workflow-reconciliation.md +29 -16
  11. package/docs/document-lifecycle.md +19 -0
  12. package/docs/platform-capabilities.md +2 -0
  13. package/docs/repository-contract.md +1 -0
  14. package/hooks/scripts/lib/doc-reconciliation-pilot.js +12 -0
  15. package/hooks/scripts/lib/doc-reconciliation-provider.js +575 -12
  16. package/hooks/scripts/lib/workflow-obligations.js +8 -4
  17. package/hooks/scripts/state-persist.js +26 -7
  18. package/hooks/scripts/w6-state-operations.js +239 -0
  19. package/opencode-plugin/plugin.json +1 -1
  20. package/package.json +2 -2
  21. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  22. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +12 -0
  23. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +575 -12
  24. package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +8 -4
  25. package/plugins/harness-everything/hooks/scripts/state-persist.js +26 -7
  26. package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +239 -0
  27. package/plugins/harness-everything/plugin.json +1 -1
  28. package/sbom.cdx.json +7 -7
  29. package/scripts/doc-governance-guard.js +31 -8
@@ -668,10 +668,14 @@ function updateStep(context, stepId, disposition, options = {}) {
668
668
  throw new Error('resolve active-step bindings before passing the step: ' + ids.join(', '));
669
669
  }
670
670
  }
671
- if (disposition === 'pass' && step.stepType === 'verification'
672
- && require('./doc-reconciliation-pilot').assess(context, loaded.set).withhold) {
673
- withholdPilotVerification(context, loaded.set);
674
- throw new Error('document verification pending: S1 grants no document credit');
671
+ if (disposition === 'pass' && step.stepType === 'verification') {
672
+ const inFlightW6ToolUseId = require('./doc-reconciliation-provider').pendingW6VerificationInvocation(context);
673
+ const assessment = require('./doc-reconciliation-pilot').assess(context, loaded.set,
674
+ inFlightW6ToolUseId ? { allowInFlightW6ToolUseId: inFlightW6ToolUseId } : {});
675
+ if (assessment.withhold) {
676
+ withholdPilotVerification(context, loaded.set);
677
+ throw new Error('document verification pending: S1 grants no document credit');
678
+ }
675
679
  }
676
680
  // Review-mode refusal (pilot ON only): a self-authored or non-independent review PASS stays pending.
677
681
  if (disposition === 'pass' && step.stepType === 'review') {
@@ -86,6 +86,8 @@ function processState(payload) {
86
86
  const isSuccessEvent = hookEvent === 'PostToolUse';
87
87
  const isFailed = hookEvent === 'PostToolUseFailure' || (exitCode !== undefined && exitCode !== 0) || (!isSuccessEvent && exitCode === undefined && stderrSignal);
88
88
  const toolName = payload.tool_name || payload.tool || 'command';
89
+ let editAfterCapture = false;
90
+ let stateOnlyCandidate = false;
89
91
  if (isFailed) {
90
92
  let output = (stderrSignal ? stderr : stdout) || payload.output || '';
91
93
  if (output.length > 500) output = '...' + output.slice(-500);
@@ -99,20 +101,26 @@ function processState(payload) {
99
101
  const command = (payload.tool_input && payload.tool_input.command) || '';
100
102
  if (isShell) {
101
103
  const commandClass = classifyShell(command);
102
- const metadataStep = !isFailed && (isSuccessEvent || exitCode === 0)
104
+ const pilotEnabled = process.env.HARNESS_DOC_RECONCILIATION_PILOT === '1';
105
+ const docCheck = pilotEnabled ? require('./lib/doc-reconciliation-provider') : null;
106
+ stateOnlyCandidate = Boolean(docCheck && typeof payload.cwd === 'string' && payload.cwd
107
+ && docCheck.isW6StateCommand(command, payload.cwd, root,
108
+ { toolName, sessionId, agentId: payload.agent_id }));
109
+ const metadataStep = !stateOnlyCandidate && !isFailed && (isSuccessEvent || exitCode === 0)
103
110
  && isSuccessfulMetadataStep(command, cwdOf(payload, root));
104
- if (!metadataStep && commandClass !== 'read-only' && commandClass !== 'worktree-setup') state.lastEditAt = Date.now();
111
+ if (!metadataStep && commandClass !== 'read-only' && commandClass !== 'worktree-setup') {
112
+ if (stateOnlyCandidate) editAfterCapture = true;
113
+ else state.lastEditAt = Date.now();
114
+ }
105
115
  // Verification evidence needs a confirmed success: a PostToolUse event or an explicit zero exit.
106
116
  // Pilot ON only: a registered, argv-validated doc-check that resolves to this install's own runtime is the document
107
117
  // verification evidence, and only at the shipped pin (R3-02). Any other path earns no verification evidence. OFF stays legacy.
108
- const pilotEnabled = process.env.HARNESS_DOC_RECONCILIATION_PILOT === '1';
109
- const docCheck = pilotEnabled ? require('./lib/doc-reconciliation-provider') : null;
110
118
  const installedCheck = docCheck && docCheck.registeredInstalledCheck(command, cwdOf(payload, root));
111
119
  const docCheckCandidate = installedCheck && installedCheck.kind !== 'not-candidate';
112
120
  const pinCheckable = installedCheck && installedCheck.installed
113
121
  && (installedCheck.kind === 'accepted' || installedCheck.reason === 'implementation-pin-mismatch');
114
122
  // A non-candidate that is compound or names the checker is not generic verification (trustRisk); the scanner miss does not clear it.
115
- const verifies = docCheckCandidate
123
+ const verifies = stateOnlyCandidate ? false : docCheckCandidate
116
124
  ? Boolean(pinCheckable) && docCheck.fileDigest(installedCheck.installed) === docCheck.SHIPPED_DOC_CHECK_DIGEST
117
125
  : !(pilotEnabled && docCheck.trustRisk(command)) && isVerificationShell(command, { cwd: cwdOf(payload, root), root });
118
126
  if (!isFailed && (isSuccessEvent || exitCode === 0) && verifies) {
@@ -130,6 +138,17 @@ function processState(payload) {
130
138
  fs.writeFileSync(stateFile, JSON.stringify(state, null, 2), 'utf8');
131
139
  observeTool(payload);
132
140
  persistPilotCapture(payload, captureEventName, sessionId, root);
141
+ if (editAfterCapture) {
142
+ const pilotEnabled = process.env.HARNESS_DOC_RECONCILIATION_PILOT === '1';
143
+ const docCheck = pilotEnabled ? require('./lib/doc-reconciliation-provider') : null;
144
+ const captures = docCheck && docCheck.readCaptureView(getSessionDir(root, sessionId));
145
+ const verifiedStateOnly = stateOnlyCandidate && docCheck && captures && !captures.tampered
146
+ && docCheck.isVerifiedW6StateOperation(captures.records, getSessionDir(root, sessionId), payload.tool_use_id);
147
+ if (!verifiedStateOnly) {
148
+ state.lastEditAt = Date.now();
149
+ fs.writeFileSync(stateFile, JSON.stringify(state, null, 2), 'utf8');
150
+ }
151
+ }
133
152
  } catch (_) {}
134
153
  process.exit(0);
135
154
  }
@@ -142,9 +161,9 @@ function persistPilotCapture(payload, eventName, sessionId, root) {
142
161
  if (!payload || process.env.HARNESS_DOC_RECONCILIATION_PILOT !== '1') return;
143
162
  if (PILOT_CAPTURE_EVENT_NAMES.indexOf(eventName) === -1) return;
144
163
  const provider = require('./lib/doc-reconciliation-provider');
145
- const entry = provider.buildCaptureRecord(payload, eventName, root);
146
- if (!entry) return;
147
164
  const sessionDir = getSessionDir(root, sessionId);
165
+ const entry = provider.buildCaptureRecord(payload, eventName, root, { sessionDir });
166
+ if (!entry) return;
148
167
  // Observation-time identity: the workflow and pin in force when the host event was captured.
149
168
  const observed = provider.observedIdentityFor(sessionDir);
150
169
  if (observed) entry.observedIdentity = observed;
@@ -0,0 +1,239 @@
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,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "harness-everything",
4
- "version": "0.49.0",
4
+ "version": "0.51.0",
5
5
  "description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
6
6
  "author": {
7
7
  "name": "Miya Daniel",
package/sbom.cdx.json CHANGED
@@ -2,23 +2,23 @@
2
2
  "$schema": "https://cyclonedx.org/schema/bom-1.7.schema.json",
3
3
  "bomFormat": "CycloneDX",
4
4
  "specVersion": "1.7",
5
- "serialNumber": "urn:uuid:962b7322-7ab3-5bae-8399-c8e93c5d6717",
5
+ "serialNumber": "urn:uuid:b8bf6ee5-f127-5813-a3c9-1284d50c66c0",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-11-08T20:01:04.125Z",
8
+ "timestamp": "2026-11-11T03:11:38.812Z",
9
9
  "tools": [
10
10
  {
11
11
  "vendor": "Harness Everything",
12
12
  "name": "generate-sbom.js",
13
- "version": "0.49.0"
13
+ "version": "0.51.0"
14
14
  }
15
15
  ],
16
16
  "component": {
17
17
  "type": "application",
18
- "bom-ref": "pkg:npm/harness-everything@0.49.0",
18
+ "bom-ref": "pkg:npm/harness-everything@0.51.0",
19
19
  "name": "harness-everything",
20
- "version": "0.49.0",
21
- "purl": "pkg:npm/harness-everything@0.49.0"
20
+ "version": "0.51.0",
21
+ "purl": "pkg:npm/harness-everything@0.51.0"
22
22
  }
23
23
  },
24
24
  "components": [
@@ -2033,7 +2033,7 @@
2033
2033
  ]
2034
2034
  },
2035
2035
  {
2036
- "ref": "pkg:npm/harness-everything@0.49.0",
2036
+ "ref": "pkg:npm/harness-everything@0.51.0",
2037
2037
  "dependsOn": [
2038
2038
  "pkg:npm/%40commitlint/cli@19.8.1",
2039
2039
  "pkg:npm/%40commitlint/config-conventional@19.8.1",
@@ -17,15 +17,19 @@ const TRUST_SURFACE_PATHS = [
17
17
  'plugins/harness-everything/skills/harness-everything/scripts/project-docs-resolver.js',
18
18
  '.agents/harness-everything/project-docs.json',
19
19
  '.agents/harness-everything/document-inventory.json',
20
- '.github/workflows/ci.yml',
20
+ '.agents/harness-everything/errors/README.md',
21
+ '.github/workflows/doc-governance.yml',
21
22
  'package.json',
22
23
  'self-evolve/scripts/self-regression.js',
23
24
  'ci/mechanism-test.js',
24
25
  'ci/mutation-check.js',
25
26
  'ci/lib/isolated-test-process.js',
26
27
  'ci/test-helper.js',
28
+ 'scripts/errors-sync.js',
27
29
  'scripts/verify-all.js'
28
30
  ];
31
+ const MEMBERSHIP_ONLY_PATHS = ['AGENTS.md', 'SECURITY.md', 'CODE_OF_CONDUCT.md', 'PRIVACY.md', 'TERMS.md', 'docs/document-lifecycle.md'];
32
+ const MEMBERSHIP_ONLY_PREFIXES = ['docs/policy/', 'docs/prd/'];
29
33
  const TRUST_SURFACE_PREFIXES = ['ci/fixtures/doc-lifecycle/scenarios/'];
30
34
 
31
35
  function sha256(bytes) {
@@ -207,9 +211,25 @@ function sameIdentity(left, right) {
207
211
  return stable(identity(left)) === stable(identity(right));
208
212
  }
209
213
 
214
+ function sameMembership(left, right) {
215
+ if (!left || !right) return left === right;
216
+ return regularBlob(left) && regularBlob(right) && left.mode === right.mode;
217
+ }
218
+
210
219
  function trustSurfacePaths(baseTree, candidateTree) {
211
220
  const fixed = TRUST_SURFACE_PATHS.map(relativePath => ({ key: pathKey(relativePath), path: relativePath }));
212
- const fixedKeys = new Set(fixed.map(item => item.key));
221
+ const membershipPaths = new Map(MEMBERSHIP_ONLY_PATHS.map(relativePath => [pathKey(relativePath), relativePath]));
222
+ for (const sourceTree of [baseTree, candidateTree]) {
223
+ for (const [key, entry] of sourceTree) {
224
+ if (MEMBERSHIP_ONLY_PREFIXES.some(prefix => entry.pathBytes.subarray(0, Buffer.byteLength(prefix)).equals(Buffer.from(prefix)))) {
225
+ membershipPaths.set(key, pathText(entry.pathBytes));
226
+ }
227
+ }
228
+ }
229
+ const membership = [...membershipPaths]
230
+ .sort(([left], [right]) => Buffer.compare(Buffer.from(left, 'base64'), Buffer.from(right, 'base64')))
231
+ .map(([key, path]) => ({ key, path, membershipOnly: true }));
232
+ const fixedKeys = new Set([...fixed, ...membership].map(item => item.key));
213
233
  const fixtureEntries = new Map();
214
234
  for (const sourceTree of [baseTree, candidateTree]) {
215
235
  for (const [key, entry] of sourceTree) {
@@ -220,7 +240,7 @@ function trustSurfacePaths(baseTree, candidateTree) {
220
240
  const fixtures = [...fixtureEntries]
221
241
  .sort(([left], [right]) => Buffer.compare(Buffer.from(left, 'base64'), Buffer.from(right, 'base64')))
222
242
  .map(([key, path]) => ({ key, path }));
223
- return [...fixed, ...fixtures];
243
+ return [...fixed, ...membership, ...fixtures];
224
244
  }
225
245
 
226
246
  function documentPath(pathBytes) {
@@ -278,7 +298,7 @@ function checkConfiguredPaths(baseTree, candidateTree, config) {
278
298
  const after = candidateMembers.get(key) || null;
279
299
  const entry = before || after;
280
300
  const sameRegularMode = regularBlob(before) && regularBlob(after) && before.mode === after.mode;
281
- const revised = kind === 'governed' && sameRegularMode && before.oid !== after.oid;
301
+ const revised = sameRegularMode && before.oid !== after.oid;
282
302
  const identityPreserved = sameRegularMode && before.oid === after.oid;
283
303
  const memberPath = pathText(entry.pathBytes);
284
304
  details.push({
@@ -286,10 +306,12 @@ function checkConfiguredPaths(baseTree, candidateTree, config) {
286
306
  ...(glob ? { pattern: record.path } : {}),
287
307
  path: memberPath,
288
308
  ...(memberPath === null ? { pathBase64: key } : {}),
289
- state: revised ? 'revised' : identityPreserved ? 'pass' : 'review_required',
309
+ state: kind === 'derived' ? 'pass' : revised ? 'revised' : identityPreserved ? 'pass' : 'review_required',
290
310
  base: identity(before),
291
311
  candidate: identity(after),
292
- ...(revised ? { reason: 'Content revisions are tracked by Git identity but are not semantically validated by the guard.' } : {})
312
+ ...(kind === 'derived' && !sameIdentity(before, after)
313
+ ? { reason: 'Generated-view changes are left to ordinary regenerate-equals CI.' }
314
+ : revised ? { reason: 'Content revisions are tracked by Git identity but are not semantically validated by the guard.' } : {})
293
315
  });
294
316
  }
295
317
  }
@@ -373,10 +395,11 @@ function run(argv) {
373
395
  report.policyPreservation.state = [report.policyPreservation.governed, report.policyPreservation.derived, report.policyPreservation.configuredPaths]
374
396
  .some(item => item.state !== 'pass') ? 'review_required' : 'pass';
375
397
 
376
- report.trustSurface.paths = trustSurfacePaths(baseTree, candidateTree).map(({ key, path }) => {
398
+ report.trustSurface.paths = trustSurfacePaths(baseTree, candidateTree).map(({ key, path, membershipOnly }) => {
377
399
  const before = baseTree.get(key);
378
400
  const after = candidateTree.get(key);
379
- return { path, ...(path === null ? { pathBase64: key } : {}), base: identity(before), candidate: identity(after), changed: !sameIdentity(before, after) };
401
+ const changed = membershipOnly ? !sameMembership(before, after) : !sameIdentity(before, after);
402
+ return { path, ...(path === null ? { pathBase64: key } : {}), base: identity(before), candidate: identity(after), changed };
380
403
  });
381
404
  report.trustSurface.changed = report.trustSurface.paths.filter(item => item.changed);
382
405
  report.trustSurface.state = report.trustSurface.changed.length ? 'review_required' : 'pass';