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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/ci.yml +0 -82
- package/.github/workflows/doc-governance.yml +91 -0
- package/.github/workflows/release.yml +5 -2
- package/CHANGELOG.md +150 -115
- package/ci/mechanism-2ax-doc-lifecycle.test.js +142 -12
- package/ci/mechanism-prb-outline-review.test.js +783 -107
- package/ci/release-unreleased-heading.test.js +24 -0
- package/docs/doc-workflow-reconciliation.md +29 -16
- package/docs/document-lifecycle.md +19 -0
- package/docs/platform-capabilities.md +2 -0
- package/docs/repository-contract.md +1 -0
- package/hooks/scripts/lib/doc-reconciliation-pilot.js +12 -0
- package/hooks/scripts/lib/doc-reconciliation-provider.js +575 -12
- package/hooks/scripts/lib/workflow-obligations.js +8 -4
- package/hooks/scripts/state-persist.js +26 -7
- package/hooks/scripts/w6-state-operations.js +239 -0
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +2 -2
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +12 -0
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +575 -12
- package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +8 -4
- package/plugins/harness-everything/hooks/scripts/state-persist.js +26 -7
- package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +239 -0
- package/plugins/harness-everything/plugin.json +1 -1
- package/sbom.cdx.json +7 -7
- package/scripts/doc-governance-guard.js +31 -8
|
@@ -123,24 +123,52 @@ function outlineText({ id = null, complete = false, decisionPlaceholder = false,
|
|
|
123
123
|
function createOutlineFixture(options = {}) {
|
|
124
124
|
const generatedRoot = fs.mkdtempSync(path.join(options.rootDirectory || os.tmpdir(), 'prb-outline-fixture-'));
|
|
125
125
|
const root = options.preserveRootSpelling ? generatedRoot : canonical(generatedRoot);
|
|
126
|
+
const runtimeBase = options.runtimeLayout === 'packaged' ? path.join(ROOT, 'plugins/harness-everything') : ROOT;
|
|
127
|
+
const runtimeProvider = require(path.join(runtimeBase, 'hooks/scripts/lib/doc-reconciliation-provider.js'));
|
|
128
|
+
const runtimePilot = require(path.join(runtimeBase, 'hooks/scripts/lib/doc-reconciliation-pilot.js'));
|
|
126
129
|
const workspaceRoot = canonical(root);
|
|
127
130
|
const retainedInventory = options.retainedInventory === true;
|
|
128
131
|
const target = options.target || (retainedInventory ? 'docs/adr/EVID-001.md' : 'docs/adr/DOCS-001.md');
|
|
129
132
|
const rowId = options.rowId || (retainedInventory ? '17' : '20');
|
|
130
133
|
const domain = options.domain || (retainedInventory ? 'EVID' : 'DOCS');
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
let taskId = options.taskId || 'task-prb';
|
|
135
|
+
let attemptId = options.attemptId || 'attempt-1';
|
|
133
136
|
const sessionId = options.sessionId || 'author-session';
|
|
134
137
|
const stateHome = fs.mkdtempSync(path.join(os.tmpdir(), 'prb-outline-state-'));
|
|
135
138
|
const workerRoot = options.workerRootAlias
|
|
136
139
|
? `${root}${path.sep}..${path.sep}${path.basename(root)}` : root;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
140
|
+
let workflowId = 'workflow-prb';
|
|
141
|
+
let workflowRevision = 2;
|
|
142
|
+
const configValue = options.w6Producer
|
|
143
|
+
? { governed: [{ path: 'docs/adr/*.md', role: 'adr' }], domains: ['EVID'],
|
|
144
|
+
derived: [{ path: 'docs/governed-index.md', generator: 'node harness-everything/scripts/doc-lifecycle.js index --workspace . --config .agents/harness-everything/project-docs.json --all' }] }
|
|
145
|
+
: { governed: [{ path: options.governedPattern || 'docs/adr/*.md', role: 'adr' }], domains: [domain], derived: [] };
|
|
146
|
+
const config = JSON.stringify(configValue, null, 2) + '\n';
|
|
147
|
+
let configDigest = sha(config);
|
|
148
|
+
const inventoryBytes = retainedInventory
|
|
149
|
+
? fs.readFileSync(path.join(ROOT, 'benchmarks/results/live-host/claude-341-outline-dispatch-2026-10-28/inventory/2741bd4514d2cd68f57d93a2b3ce94cbe597ca62d30e26f0ca58e882df5b03c6.md'))
|
|
150
|
+
: Buffer.from(syntheticInventory);
|
|
151
|
+
const pinDigest = sha(inventoryBytes);
|
|
152
|
+
const expectedPin = retainedInventory ? internals.OUTLINE_INVENTORY_PIN : {
|
|
153
|
+
source: 'synthetic://approved-inventory', sha256: pinDigest, runId: 'synthetic-run', inputSha: 'abcdef012345',
|
|
154
|
+
approvalRef: { issue: 325, commentId: 'synthetic-comment', decision: 1 },
|
|
155
|
+
retainedArtifactPath: `inventory/${pinDigest}.md`,
|
|
156
|
+
};
|
|
157
|
+
if (retainedInventory) assert.strictEqual(pinDigest, expectedPin.sha256, 'retained inventory bytes must match the pinned digest');
|
|
141
158
|
fs.mkdirSync(path.join(root, '.agents/harness-everything'), { recursive: true });
|
|
142
159
|
fs.mkdirSync(path.dirname(path.join(root, target)), { recursive: true });
|
|
143
160
|
fs.writeFileSync(path.join(root, '.agents/harness-everything/project-docs.json'), config);
|
|
161
|
+
if (options.w6Producer) {
|
|
162
|
+
const taskScripts = path.join(root, 'harness-everything/scripts');
|
|
163
|
+
fs.mkdirSync(taskScripts, { recursive: true });
|
|
164
|
+
for (const name of ['doc-lifecycle.js', 'project-docs-resolver.js']) {
|
|
165
|
+
fs.copyFileSync(path.join(ROOT, 'harness-everything/scripts', name), path.join(taskScripts, name));
|
|
166
|
+
}
|
|
167
|
+
const generated = spawnSync(process.execPath, [path.join(taskScripts, 'doc-lifecycle.js'), 'index', '--workspace', root,
|
|
168
|
+
'--config', '.agents/harness-everything/project-docs.json', '--all'], { cwd: root, encoding: 'utf8' });
|
|
169
|
+
assert.strictEqual(generated.status, 0, `row-17 baseline index generation: ${generated.stderr || generated.stdout}`);
|
|
170
|
+
fs.writeFileSync(path.join(root, 'docs/governed-index.md'), generated.stdout);
|
|
171
|
+
}
|
|
144
172
|
if (options.targetExistsAtB) fs.writeFileSync(path.join(root, target),
|
|
145
173
|
`---\nid: DOCS-001\nstatus: proposed\n---\n\n## Decision\nAn existing B document.\n`);
|
|
146
174
|
if (options.unrelatedFileAtB) fs.writeFileSync(path.join(root, options.unrelatedFileAtB), 'unmodified at B\n');
|
|
@@ -165,15 +193,28 @@ function createOutlineFixture(options = {}) {
|
|
|
165
193
|
finally { if (priorStateHome === undefined) delete process.env.HARNESS_STATE_HOME; else process.env.HARNESS_STATE_HOME = priorStateHome; }
|
|
166
194
|
}
|
|
167
195
|
|
|
168
|
-
const requirementIds = ['prb'];
|
|
169
196
|
const workspaceId = 'ws-' + internals.digestText(internals.captureJson({ workspaceRoot: canonical(root) }));
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
197
|
+
let taskBinding = null;
|
|
198
|
+
const workflowOperationWitnesses = [];
|
|
199
|
+
if (options.workflowCli) {
|
|
200
|
+
const env = { ...process.env, HARNESS_STATE_HOME: stateHome, HARNESS_WORKSPACE_ROOT: root,
|
|
201
|
+
HARNESS_DOC_RECONCILIATION_PILOT: '1' };
|
|
202
|
+
const kernelRelative = runtimeBase === ROOT ? 'harness-everything/scripts/kernel-router.js' : 'skills/harness-everything/scripts/kernel-router.js';
|
|
203
|
+
const kernel = spawnSync(process.execPath, [path.join(runtimeBase, kernelRelative)], {
|
|
204
|
+
cwd: root, env, encoding: 'utf8', input: JSON.stringify({ session_id: sessionId, cwd: root,
|
|
205
|
+
prompt: 'Draft the row-17 EVID-001 verification-evidence ADR from an outline, generate the governed index, and verify both.' }),
|
|
206
|
+
});
|
|
207
|
+
assert.strictEqual(kernel.status, 0, `row-17 plan fixture route: ${kernel.stderr || kernel.stdout}`);
|
|
208
|
+
} else {
|
|
209
|
+
const requirementIds = ['prb'];
|
|
210
|
+
taskBinding = { schema: 'harness.doc-reconciliation-task-pin.v1', taskId, requirementIds,
|
|
211
|
+
requirementDigest: sha(JSON.stringify(requirementIds)), baselineCommit, baselineRoot: root,
|
|
212
|
+
configDigest, sessionId, workflowId, workspaceId };
|
|
213
|
+
writeJson(path.join(sessionDir, 'workflow-run.json'), {
|
|
214
|
+
workflowId, revision: workflowRevision, docReconciliationBaseline: { root, commit: baselineCommit, tree: baselineTree },
|
|
215
|
+
docReconciliationTask: taskBinding,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
177
218
|
|
|
178
219
|
let hookPreloader = null;
|
|
179
220
|
const hookDiagnostics = [];
|
|
@@ -190,6 +231,9 @@ function createOutlineFixture(options = {}) {
|
|
|
190
231
|
});
|
|
191
232
|
} catch { return []; }
|
|
192
233
|
}
|
|
234
|
+
function capturedRecordsAcrossSessions() {
|
|
235
|
+
return actualCaptureSessionDirs().flatMap(dir => runtimeProvider.readCaptureView(dir).records);
|
|
236
|
+
}
|
|
193
237
|
function logReviewHookDiagnostics() {
|
|
194
238
|
console.error('REVIEW-HOOK-CAPTURE-DIAGNOSTICS ' + JSON.stringify({
|
|
195
239
|
expectedSessionDir: sessionDir,
|
|
@@ -201,7 +245,7 @@ function createOutlineFixture(options = {}) {
|
|
|
201
245
|
if (!options.realHook) throw new Error('real state-persist capture was not enabled for this fixture');
|
|
202
246
|
if (usePreload && !hookPreloader) {
|
|
203
247
|
hookPreloader = path.join(stateHome, 'outline-test-preload.js');
|
|
204
|
-
const providerPath = path.join(
|
|
248
|
+
const providerPath = path.join(runtimeBase, 'hooks/scripts/lib/doc-reconciliation-provider.js');
|
|
205
249
|
fs.writeFileSync(hookPreloader, [
|
|
206
250
|
...(options.failPartialDispatchStorage ? [
|
|
207
251
|
"const fs=require('fs');",
|
|
@@ -224,7 +268,7 @@ function createOutlineFixture(options = {}) {
|
|
|
224
268
|
'}',
|
|
225
269
|
].join('\n'));
|
|
226
270
|
}
|
|
227
|
-
const child = spawnSync(process.execPath, [...(usePreload ? ['--require', hookPreloader] : []), path.join(
|
|
271
|
+
const child = spawnSync(process.execPath, [...(usePreload ? ['--require', hookPreloader] : []), path.join(runtimeBase, 'hooks/scripts/state-persist.js')], {
|
|
228
272
|
cwd: root, encoding: 'utf8', input: JSON.stringify(payload),
|
|
229
273
|
env: { ...process.env, HARNESS_STATE_HOME: stateHome, HARNESS_WORKSPACE_ROOT: root,
|
|
230
274
|
HARNESS_DOC_RECONCILIATION_PILOT: pilotEnabled ? '1' : '0' },
|
|
@@ -241,8 +285,112 @@ function createOutlineFixture(options = {}) {
|
|
|
241
285
|
if (payload.agent_type === 'reviewer' || payload.tool_use_id === 'review-dispatch') logReviewHookDiagnostics();
|
|
242
286
|
throw new Error(`state-persist failed open contract: ${child.stderr || child.stdout || child.status}`);
|
|
243
287
|
}
|
|
244
|
-
return
|
|
288
|
+
return runtimeProvider.readCaptureView(sessionDir).records;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function runWorkflowOperation(name, args, allowFailure = false) {
|
|
292
|
+
const controller = path.join(runtimeBase, 'hooks/scripts/workflow-disposition.js');
|
|
293
|
+
const handoffStateFile = path.join(sessionDir, 'handoff-state.json');
|
|
294
|
+
const beforeHandoffState = fs.existsSync(handoffStateFile) ? JSON.parse(fs.readFileSync(handoffStateFile, 'utf8')) : null;
|
|
295
|
+
const toolUseId = `w6-${name}-${sessionId}`;
|
|
296
|
+
const command = `node "${controller}" ${args.map(value => /[\s'"\\]/.test(value)
|
|
297
|
+
? `'${value.replace(/'/g, "'\\''")}'` : value).join(' ')}`;
|
|
298
|
+
const payload = { session_id: sessionId, cwd: root, hook_event_name: 'PreToolUse', tool_name: 'Bash',
|
|
299
|
+
tool_use_id: toolUseId, tool_input: { command } };
|
|
300
|
+
runHook(payload);
|
|
301
|
+
const child = spawnSync(process.execPath, [controller, ...args], { cwd: root,
|
|
302
|
+
env: { ...process.env, HARNESS_STATE_HOME: stateHome, HARNESS_WORKSPACE_ROOT: root,
|
|
303
|
+
HARNESS_DOC_RECONCILIATION_PILOT: '1' }, encoding: 'utf8' });
|
|
304
|
+
if (child.status !== 0 && allowFailure && name === 'step-verify') {
|
|
305
|
+
runHook({ ...payload, hook_event_name: 'PostToolUseFailure', is_interrupt: false,
|
|
306
|
+
error: child.stderr || child.stdout || `exit ${child.status}`, tool_response: { exitCode: child.status } });
|
|
307
|
+
const afterHandoffState = fs.existsSync(handoffStateFile) ? JSON.parse(fs.readFileSync(handoffStateFile, 'utf8')) : null;
|
|
308
|
+
workflowOperationWitnesses.push({ name, before: beforeHandoffState, after: afterHandoffState, exitCode: child.status });
|
|
309
|
+
return child.stdout;
|
|
310
|
+
}
|
|
311
|
+
assert.strictEqual(child.status, 0, `row-17 ${name}: ${child.stderr || child.stdout}`);
|
|
312
|
+
runHook({ ...payload, hook_event_name: 'PostToolUse',
|
|
313
|
+
tool_response: { exitCode: child.status, stdout: child.stdout, stderr: child.stderr, interrupted: false, status: 'completed' } });
|
|
314
|
+
const afterHandoffState = fs.existsSync(handoffStateFile) ? JSON.parse(fs.readFileSync(handoffStateFile, 'utf8')) : null;
|
|
315
|
+
workflowOperationWitnesses.push({ name, before: beforeHandoffState, after: afterHandoffState });
|
|
316
|
+
return child.stdout;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (options.workflowCli) {
|
|
320
|
+
const requirements = [
|
|
321
|
+
{ id: 'adr-evid', stepType: 'doc-change', summary: 'Draft the row-17 EVID-001 verification-evidence ADR.',
|
|
322
|
+
acceptance: 'A real proposed O is independently reviewed before the draft D; D is a strict descendant of O and changes only the ADR.' },
|
|
323
|
+
{ id: 'verify-row17', stepType: 'verification',
|
|
324
|
+
summary: 'Generate the governed index and verify the final ADR through one combined registered check and independent review.',
|
|
325
|
+
acceptance: 'All four combined-check capabilities and the ADR-only final review are captured before normal Stop reconciliation.' },
|
|
326
|
+
];
|
|
327
|
+
const operations = [
|
|
328
|
+
['plan', ['plan', '--session-id', sessionId, '--strategy', 'iterative-single', '--requirements-json', JSON.stringify(requirements),
|
|
329
|
+
'--evidence', 'row17 baseline witness']],
|
|
330
|
+
['start', ['start', '--session-id', sessionId]],
|
|
331
|
+
];
|
|
332
|
+
for (const [name, args] of operations) {
|
|
333
|
+
runWorkflowOperation(name, args);
|
|
334
|
+
}
|
|
335
|
+
const workflow = JSON.parse(fs.readFileSync(path.join(sessionDir, 'workflow-run.json'), 'utf8'));
|
|
336
|
+
workflowId = workflow.workflowId;
|
|
337
|
+
workflowRevision = workflow.revision;
|
|
338
|
+
taskBinding = workflow.docReconciliationTask;
|
|
339
|
+
taskId = taskBinding.taskId;
|
|
340
|
+
configDigest = taskBinding.configDigest;
|
|
341
|
+
assert.deepStrictEqual(taskBinding.requirementIds, ['adr-evid', 'verify-row17'], 'plan/start must create the declared row-17 task pin');
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function runW6Producer(operation) {
|
|
345
|
+
const producer = path.join(runtimeBase, 'hooks/scripts/w6-state-operations.js');
|
|
346
|
+
const toolUseId = `w6-${operation}-${sessionId}`;
|
|
347
|
+
const command = `node "${producer}" ${operation} --session-id "${sessionId}"`;
|
|
348
|
+
const payload = { session_id: sessionId, cwd: root, hook_event_name: 'PreToolUse', tool_name: 'Bash',
|
|
349
|
+
tool_use_id: toolUseId, tool_input: { command } };
|
|
350
|
+
runHook(payload);
|
|
351
|
+
const child = spawnSync(process.execPath, [producer, operation, '--session-id', sessionId], { cwd: root,
|
|
352
|
+
env: { ...process.env, HARNESS_STATE_HOME: stateHome, HARNESS_WORKSPACE_ROOT: root,
|
|
353
|
+
HARNESS_DOC_RECONCILIATION_PILOT: '1' }, encoding: 'utf8' });
|
|
354
|
+
if (child.status !== 0) {
|
|
355
|
+
runHook({ ...payload, hook_event_name: 'PostToolUseFailure', is_interrupt: false,
|
|
356
|
+
error: child.stderr || child.stdout || `exit ${child.status}`, tool_response: { exitCode: child.status } });
|
|
357
|
+
if (options.w6ExpectedProducerFailure) return { error: child.stderr || child.stdout || `exit ${child.status}`, exitCode: child.status };
|
|
358
|
+
throw new Error(`row-17 ${operation} producer: ${child.stderr || child.stdout}`);
|
|
359
|
+
}
|
|
360
|
+
if (operation === 'inventory' && options.w6ProducerFault === 'extra-state-destination') {
|
|
361
|
+
writeJson(path.join(sessionDir, 'unauthorized-state-change.json'), { operation: 'inventory' });
|
|
362
|
+
}
|
|
363
|
+
const post = { ...payload, hook_event_name: 'PostToolUse',
|
|
364
|
+
tool_response: { exitCode: child.status, stdout: child.stdout, stderr: child.stderr, interrupted: false, status: 'completed' } };
|
|
365
|
+
if (!(operation === 'inventory' && options.w6ProducerFault === 'missing-post')) runHook(post);
|
|
366
|
+
if (operation === 'inventory' && options.w6ProducerFault === 'duplicate-post') runHook(post);
|
|
367
|
+
return JSON.parse(child.stdout);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function runWorkerCommand(toolName, toolUseId, toolInput, command, execute) {
|
|
371
|
+
const payload = { session_id: sessionId, cwd: root, hook_event_name: 'PreToolUse', tool_name: toolName,
|
|
372
|
+
tool_use_id: toolUseId, agent_id: 'draft-worker', agent_type: 'worker', tool_input: toolInput };
|
|
373
|
+
runHook(payload);
|
|
374
|
+
const result = execute();
|
|
375
|
+
runHook({ ...payload, hook_event_name: 'PostToolUse', tool_response: {
|
|
376
|
+
exitCode: result.exitCode ?? 0, stdout: result.stdout || '', stderr: result.stderr || '', interrupted: false, status: 'completed',
|
|
377
|
+
} });
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function runReviewCapture(payload) {
|
|
382
|
+
runHook(payload);
|
|
245
383
|
}
|
|
384
|
+
let inventoryOperation = null;
|
|
385
|
+
let outsideInventoryPath = null;
|
|
386
|
+
if (options.w6ProducerFault === 'inventory-symlink') {
|
|
387
|
+
const inventoryParent = path.join(sessionDir, 'doc-reconciliation/outline-confirmation');
|
|
388
|
+
fs.mkdirSync(inventoryParent, { recursive: true });
|
|
389
|
+
outsideInventoryPath = path.join(stateHome, 'outside-inventory', 'unexpected.md');
|
|
390
|
+
fs.mkdirSync(path.dirname(outsideInventoryPath), { recursive: true });
|
|
391
|
+
fs.symlinkSync(path.dirname(outsideInventoryPath), path.join(inventoryParent, 'inventory'), 'dir');
|
|
392
|
+
}
|
|
393
|
+
if (options.w6Producer) inventoryOperation = runW6Producer('inventory');
|
|
246
394
|
|
|
247
395
|
const outlineBytes = Buffer.from(outlineText({
|
|
248
396
|
id: options.targetId,
|
|
@@ -268,7 +416,7 @@ function createOutlineFixture(options = {}) {
|
|
|
268
416
|
else output = execFileSync('git', ['status', '--porcelain'], { cwd: root, encoding: 'utf8' });
|
|
269
417
|
const postPayload = { ...payload, hook_event_name: 'PostToolUse', tool_response: { exitCode: 0, stdout: output } };
|
|
270
418
|
runHook(postPayload, true, false);
|
|
271
|
-
const records =
|
|
419
|
+
const records = runtimeProvider.readCaptureView(sessionDir).records;
|
|
272
420
|
const pre = preRecords.find(item => item.event === 'PreToolUse' && item.tool_use_id === toolUseId);
|
|
273
421
|
const post = records.find(item => item.event === 'PostToolUse' && item.tool_use_id === toolUseId);
|
|
274
422
|
assert.ok(pre && post, operation + ' operation has real PreToolUse and successful PostToolUse captures');
|
|
@@ -335,21 +483,14 @@ function createOutlineFixture(options = {}) {
|
|
|
335
483
|
let outlineTree = fixtureGit(root, ['rev-parse', 'HEAD^{tree}']);
|
|
336
484
|
let outlineBlob = fixtureGit(root, ['rev-parse', `HEAD:${target}`]);
|
|
337
485
|
|
|
338
|
-
const inventoryBytes = retainedInventory
|
|
339
|
-
? fs.readFileSync(path.join(ROOT, 'benchmarks/results/live-host/claude-341-outline-dispatch-2026-10-28/inventory/2741bd4514d2cd68f57d93a2b3ce94cbe597ca62d30e26f0ca58e882df5b03c6.md'))
|
|
340
|
-
: Buffer.from(syntheticInventory);
|
|
341
|
-
const pinDigest = sha(inventoryBytes);
|
|
342
|
-
const expectedPin = retainedInventory ? internals.OUTLINE_INVENTORY_PIN : {
|
|
343
|
-
source: 'synthetic://approved-inventory', sha256: pinDigest, runId: 'synthetic-run', inputSha: 'abcdef012345',
|
|
344
|
-
approvalRef: { issue: 325, commentId: 'synthetic-comment', decision: 1 },
|
|
345
|
-
retainedArtifactPath: `inventory/${pinDigest}.md`,
|
|
346
|
-
};
|
|
347
|
-
if (retainedInventory) assert.strictEqual(pinDigest, expectedPin.sha256, 'retained inventory bytes must match the pinned digest');
|
|
348
486
|
const outlineRoot = path.join(sessionDir, 'doc-reconciliation/outline-confirmation');
|
|
349
487
|
const inventoryDir = path.join(outlineRoot, 'inventory');
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
488
|
+
if (!options.w6Producer || !inventoryOperation?.operation) {
|
|
489
|
+
fs.rmSync(inventoryDir, { recursive: true, force: true });
|
|
490
|
+
fs.mkdirSync(inventoryDir, { recursive: true });
|
|
491
|
+
fs.writeFileSync(path.join(inventoryDir, `${pinDigest}.md`), inventoryBytes);
|
|
492
|
+
writeJson(path.join(inventoryDir, 'inventory-pin.json'), expectedPin);
|
|
493
|
+
}
|
|
353
494
|
|
|
354
495
|
|
|
355
496
|
const inventoryPath = `doc-reconciliation/outline-confirmation/inventory/${pinDigest}.md`;
|
|
@@ -402,53 +543,64 @@ function createOutlineFixture(options = {}) {
|
|
|
402
543
|
outlineBlob = fixtureGit(root, ['rev-parse', `HEAD:${target}`]);
|
|
403
544
|
}
|
|
404
545
|
runHook(reviewStopPayload);
|
|
405
|
-
const retained =
|
|
546
|
+
const retained = runtimeProvider.readCaptureView(sessionDir).records;
|
|
406
547
|
reviewResult = retained.find(item => item.event === 'PostToolUse' && item.tool_use_id === 'review-dispatch');
|
|
407
548
|
reviewStop = retained.find(item => item.event === 'SubagentStop' && item.agent_id === reviewerPrincipal);
|
|
408
549
|
} else {
|
|
409
|
-
reviewResult =
|
|
410
|
-
reviewStop =
|
|
550
|
+
reviewResult = runtimeProvider.buildCaptureRecord(reviewResultPayload, 'PostToolUse', root);
|
|
551
|
+
reviewStop = runtimeProvider.buildCaptureRecord(reviewStopPayload, 'SubagentStop', root);
|
|
411
552
|
reviewResult.observedIdentity = { workflowId, workflowRevision, baselinePin: { root, commit: baselineCommit }, taskPin: taskBinding };
|
|
412
553
|
reviewStop.observedIdentity = { workflowId, workflowRevision, baselinePin: { root, commit: baselineCommit }, taskPin: taskBinding };
|
|
413
554
|
if (!options.omitReviewerStart) {
|
|
414
|
-
reviewerStartRecord =
|
|
555
|
+
reviewerStartRecord = runtimeProvider.buildCaptureRecord(reviewerStartPayload, 'SubagentStart', root);
|
|
415
556
|
reviewerStartRecord.observedIdentity = reviewStop.observedIdentity;
|
|
416
557
|
// Same identity capture the hook applies at SubagentStart (state-persist persistPilotCapture).
|
|
417
|
-
reviewerStartRecord.outlineIdentity =
|
|
558
|
+
reviewerStartRecord.outlineIdentity = runtimeProvider.captureOutlineStartIdentity({ sessionDir });
|
|
418
559
|
}
|
|
419
560
|
}
|
|
420
561
|
if (!reviewStop || (!reviewResult && !options.omitReviewResult)) {
|
|
421
562
|
if (options.realHook) logReviewHookDiagnostics();
|
|
422
563
|
throw new Error('review hook captures were not retained');
|
|
423
564
|
}
|
|
424
|
-
const reviewRecordDigest =
|
|
425
|
-
?
|
|
565
|
+
const reviewRecordDigest = runtimeProvider._internals?.captureDigest
|
|
566
|
+
? runtimeProvider._internals.captureDigest(reviewStop)
|
|
426
567
|
: sha(JSON.stringify(reviewStop));
|
|
427
568
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
569
|
+
let attemptDir = path.join(outlineRoot, taskId, 'attempts', attemptId);
|
|
570
|
+
let lease;
|
|
571
|
+
let handoff;
|
|
572
|
+
if (options.w6Producer) {
|
|
573
|
+
const sealed = runW6Producer('seal');
|
|
574
|
+
attemptId = sealed.attemptId;
|
|
575
|
+
attemptDir = path.join(outlineRoot, taskId, 'attempts', attemptId);
|
|
576
|
+
lease = JSON.parse(fs.readFileSync(path.join(attemptDir, 'writer-lease.json'), 'utf8'));
|
|
577
|
+
handoff = JSON.parse(fs.readFileSync(path.join(attemptDir, 'handoff.json'), 'utf8'));
|
|
578
|
+
} else {
|
|
579
|
+
fs.mkdirSync(attemptDir, { recursive: true });
|
|
580
|
+
lease = { schema: 'harness.outline-writer-lease.v1', id: 'lease-1', taskId, attemptId,
|
|
581
|
+
principalId: sessionId, root: workerRoot, exclusive: true, active: true,
|
|
582
|
+
...(options.competingWriters ? { competingWriters: ['unknown-writer'] } : {}) };
|
|
583
|
+
writeJson(path.join(attemptDir, 'writer-lease.json'), lease);
|
|
584
|
+
const leaseDigest = sha(fs.readFileSync(path.join(attemptDir, 'writer-lease.json')));
|
|
585
|
+
handoff = {
|
|
586
|
+
schema: 'harness.outline-handoff.v1', handoffId: 'handoff-1', taskId, attemptId,
|
|
587
|
+
supersedesAttemptId: options.supersedesAttemptId || null,
|
|
588
|
+
workspaceId,
|
|
589
|
+
workflowId, workflowRevision, sessionId, hostId: 'claude-code',
|
|
590
|
+
baseline: { root, commit: baselineCommit, tree: baselineTree, configDigest },
|
|
591
|
+
configDigest, targetPaths: [target], draftWorktreeRoot: workerRoot,
|
|
592
|
+
outline: { commit: outlineCommit, tree: options.handoffTreeOverride ? 'f'.repeat(40) : outlineTree,
|
|
593
|
+
targetBlobs: { [target]: { blobOid: outlineBlob, storedBytesSha256: sha(outlineBytes) } } },
|
|
594
|
+
inventory: { ...expectedPin, rowId, domain, targetPaths: [target] },
|
|
595
|
+
reviewCaptureRef: reviewStop.ref, reviewCaptureDigest: reviewRecordDigest, reviewDigest: reviewStop.reviewDigest,
|
|
596
|
+
coordinatorPrincipal: sessionId, writerLeaseId: lease.id, writerLeaseDigest: leaseDigest,
|
|
597
|
+
draftDispatchToken: options.token || 'token-1',
|
|
598
|
+
...(options.handoffOverrides || {}),
|
|
599
|
+
};
|
|
600
|
+
if (!options.omitHandoff) writeJson(path.join(attemptDir, 'handoff.json'), handoff);
|
|
601
|
+
}
|
|
602
|
+
const dispatchToken = options.token || (options.w6Producer ? handoff.draftDispatchToken : 'token-1');
|
|
603
|
+
const marker = `HARNESS_OUTLINE_DISPATCH_V1 taskId=${taskId} attemptId=${attemptId} token=${dispatchToken} workerRoot=${options.markerRoot || workerRoot}`;
|
|
452
604
|
|
|
453
605
|
const payload = {
|
|
454
606
|
session_id: sessionId, cwd: root, hook_event_name: 'PreToolUse', tool_name: 'Task',
|
|
@@ -468,11 +620,11 @@ function createOutlineFixture(options = {}) {
|
|
|
468
620
|
}
|
|
469
621
|
runInterleaved(interleave.beforeDispatch);
|
|
470
622
|
runHook(payload);
|
|
471
|
-
const retained =
|
|
623
|
+
const retained = runtimeProvider.readCaptureView(sessionDir).records;
|
|
472
624
|
capture = retained.find(item => item.event === 'PreToolUse' && item.tool_use_id === payload.tool_use_id);
|
|
473
625
|
reviewCaptures = retained.filter(item => item !== capture);
|
|
474
626
|
} else {
|
|
475
|
-
capture =
|
|
627
|
+
capture = runtimeProvider.buildCaptureRecord(payload, 'PreToolUse', root);
|
|
476
628
|
capture.observedIdentity = { workflowId, workflowRevision, baselinePin: { root, commit: baselineCommit }, taskPin: taskBinding };
|
|
477
629
|
reviewCaptures = options.omitReview ? [] : [...(reviewerStartRecord ? [reviewerStartRecord] : []), reviewResult, reviewStop];
|
|
478
630
|
}
|
|
@@ -500,17 +652,17 @@ function createOutlineFixture(options = {}) {
|
|
|
500
652
|
let workerStart;
|
|
501
653
|
if (options.realHook) {
|
|
502
654
|
runHook(workerStartPayload);
|
|
503
|
-
workerStart =
|
|
655
|
+
workerStart = runtimeProvider.readCaptureView(sessionDir).records.find(item => item.event === 'SubagentStart'
|
|
504
656
|
&& item.agent_id === workerStartPayload.agent_id);
|
|
505
657
|
} else {
|
|
506
|
-
workerStart =
|
|
658
|
+
workerStart = runtimeProvider.buildCaptureRecord(workerStartPayload, 'SubagentStart', root);
|
|
507
659
|
workerStart.observedIdentity = capture.observedIdentity;
|
|
508
660
|
}
|
|
509
661
|
const extraCaptures = [];
|
|
510
662
|
|
|
511
663
|
function dispatchAgain({ toolUseId = capture.tool_use_id, prompt = payload.tool_input.prompt } = {}) {
|
|
512
664
|
const extraPayload = { ...payload, tool_use_id: toolUseId, tool_input: { prompt, run_in_background: false } };
|
|
513
|
-
const extra =
|
|
665
|
+
const extra = runtimeProvider.buildCaptureRecord(extraPayload, 'PreToolUse', root);
|
|
514
666
|
extra.observedIdentity = capture.observedIdentity;
|
|
515
667
|
if (internals.captureOutlineDispatch) {
|
|
516
668
|
extra.outlineDispatch = internals.captureOutlineDispatch({
|
|
@@ -522,16 +674,62 @@ function createOutlineFixture(options = {}) {
|
|
|
522
674
|
return extra;
|
|
523
675
|
}
|
|
524
676
|
|
|
525
|
-
function finishDraft({ draft = true, nonDescendant = false, finalReview = false,
|
|
677
|
+
function finishDraft({ draft = true, nonDescendant = false, finalReview = false, completeWorkflow = false,
|
|
678
|
+
allowDispositionFailure = false, baselineRoot = root,
|
|
526
679
|
omitWorkerStart = false, omitWorkerResult = false, omitWorkerStop = false, tamperHandoff = false,
|
|
527
680
|
providerSessionId = sessionId, providerTaskId = taskId, providerBaseline = { root, commit: baselineCommit },
|
|
528
681
|
runPilot = false, handAuthoredCapture = false, removeSeam = false, mutateAfterFinalReview = false,
|
|
682
|
+
workerCompletionOrder = 'result-stop', workerResultAfterFinalReview = false, workerStopAfterFinalReview = false,
|
|
683
|
+
finalReviewCompletionOrder = 'result-stop', finalReviewFailure = null, reviewLaunchBeforeWorkerClosure = false,
|
|
529
684
|
postWorkerCaptures = [], afterWorkerStop = [] } = {}) {
|
|
530
685
|
if (draft) {
|
|
531
|
-
if (
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
686
|
+
if (options.w6Producer) {
|
|
687
|
+
const finalAdr = `---\nid: ${domain}-001\nstatus: proposed\n---\n\n# ${domain}-001\n\n## Decision\nFinal evidence decision for row ${rowId}.\n`;
|
|
688
|
+
runWorkerCommand('Write', 'w6-draft-write', { file_path: path.join(root, target), content: finalAdr }, null, () => {
|
|
689
|
+
fs.writeFileSync(path.join(root, target), finalAdr);
|
|
690
|
+
return { exitCode: 0 };
|
|
691
|
+
});
|
|
692
|
+
const indexCommand = 'node harness-everything/scripts/doc-lifecycle.js index --workspace . --config .agents/harness-everything/project-docs.json --all > docs/governed-index.md';
|
|
693
|
+
runWorkerCommand('Bash', 'w6-index-generate', { command: indexCommand }, indexCommand, () => {
|
|
694
|
+
const generated = spawnSync(process.execPath, [path.join(root, 'harness-everything/scripts/doc-lifecycle.js'), 'index',
|
|
695
|
+
'--workspace', root, '--config', '.agents/harness-everything/project-docs.json', '--all'], { cwd: root, encoding: 'utf8' });
|
|
696
|
+
assert.strictEqual(generated.status, 0, `row-17 D index generation: ${generated.stderr || generated.stdout}`);
|
|
697
|
+
fs.writeFileSync(path.join(root, 'docs/governed-index.md'), generated.stdout);
|
|
698
|
+
return { exitCode: generated.status, stdout: '' };
|
|
699
|
+
});
|
|
700
|
+
const addCommand = `git add -- ${target} docs/governed-index.md`;
|
|
701
|
+
runWorkerCommand('Bash', 'w6-index-stage', { command: addCommand }, addCommand, () => {
|
|
702
|
+
fixtureGit(root, ['add', '--', target, 'docs/governed-index.md']);
|
|
703
|
+
return { exitCode: 0 };
|
|
704
|
+
});
|
|
705
|
+
const commitCommand = 'git commit -m "draft EVID ADR and index"';
|
|
706
|
+
runWorkerCommand('Bash', 'w6-index-commit', { command: commitCommand }, commitCommand, () => {
|
|
707
|
+
fixtureGit(root, ['commit', '-q', '-m', 'draft EVID ADR and index']);
|
|
708
|
+
return { exitCode: 0 };
|
|
709
|
+
});
|
|
710
|
+
const check = runtimeBase === ROOT ? path.join(runtimeBase, 'harness-everything/scripts/doc-check.js')
|
|
711
|
+
: path.join(runtimeBase, 'skills/harness-everything/scripts/doc-check.js');
|
|
712
|
+
const checkArgs = ['check', '--workspace', root, '--config', '.agents/harness-everything/project-docs.json',
|
|
713
|
+
'--changed-path', target, '--base', baselineCommit, '--derived-view', 'docs/governed-index.md', '--conflict-assessment'];
|
|
714
|
+
const checkCommand = `node ${shellWord(check)} ${checkArgs.map(value => shellWord(value)).join(' ')}`;
|
|
715
|
+
const resolvedCheck = runtimeProvider.resolveDocCheckInvocation(checkCommand, root);
|
|
716
|
+
assert.strictEqual(resolvedCheck.kind, 'accepted', `installed combined-check resolution: ${JSON.stringify({ checkCommand, resolvedCheck })}`);
|
|
717
|
+
const checked = runWorkerCommand('Bash', 'w6-combined-check', { command: checkCommand }, checkCommand, () => {
|
|
718
|
+
const result = spawnSync(process.execPath, [check, ...checkArgs], { cwd: root, encoding: 'utf8' });
|
|
719
|
+
assert.strictEqual(result.status, 0, `row-17 combined check: ${result.stderr || result.stdout}`);
|
|
720
|
+
const report = JSON.parse(result.stdout);
|
|
721
|
+
for (const capability of ['doc-lint', 'link-check', 'derived-regenerate', 'conflict-check']) {
|
|
722
|
+
assert.strictEqual(report.capabilities?.[capability]?.state, 'pass', `combined check ${capability} must pass`);
|
|
723
|
+
}
|
|
724
|
+
return { exitCode: result.status, stdout: result.stdout, stderr: result.stderr };
|
|
725
|
+
});
|
|
726
|
+
assert.ok(checked.stdout, 'combined check host result retains its real report');
|
|
727
|
+
} else {
|
|
728
|
+
if (fs.lstatSync(path.join(root, target)).isSymbolicLink()) fs.unlinkSync(path.join(root, target));
|
|
729
|
+
fs.writeFileSync(path.join(root, target), `---\nid: ${domain}-001\nstatus: proposed\n---\n\n## Decision\nFinal D for row ${rowId}.\n`);
|
|
730
|
+
fixtureGit(root, ['add', '-A']);
|
|
731
|
+
fixtureGit(root, ['commit', '-q', '-m', 'D final draft']);
|
|
732
|
+
}
|
|
535
733
|
}
|
|
536
734
|
if (nonDescendant) {
|
|
537
735
|
fixtureGit(root, ['checkout', '--orphan', 'unrelated']);
|
|
@@ -549,40 +747,90 @@ function createOutlineFixture(options = {}) {
|
|
|
549
747
|
changed.outline.tree = 'f'.repeat(40);
|
|
550
748
|
writeJson(handoffFile, changed);
|
|
551
749
|
}
|
|
750
|
+
const workerResultPayload = {
|
|
751
|
+
session_id: sessionId, cwd: root, hook_event_name: 'PostToolUse', tool_name: 'Task',
|
|
752
|
+
tool_use_id: capture.tool_use_id, tool_input: { command: 'Task' },
|
|
753
|
+
tool_response: { agentId: options.workerPrincipal || 'draft-worker', interrupted: false, status: 'completed' },
|
|
754
|
+
};
|
|
755
|
+
const workerStopPayload = {
|
|
756
|
+
session_id: sessionId, cwd: root, hook_event_name: 'SubagentStop',
|
|
757
|
+
agent_id: options.workerPrincipal || 'draft-worker', agent_type: 'worker',
|
|
758
|
+
};
|
|
759
|
+
const finalReviewer = 'final-reviewer';
|
|
760
|
+
const finalReviewPrePayload = {
|
|
761
|
+
session_id: sessionId, cwd: root, hook_event_name: 'PreToolUse', tool_name: 'Task',
|
|
762
|
+
tool_use_id: 'final-review-dispatch', tool_input: { prompt: 'Review the final ADR.' },
|
|
763
|
+
};
|
|
764
|
+
const finalReviewStartPayload = { session_id: sessionId, cwd: root, hook_event_name: 'SubagentStart',
|
|
765
|
+
agent_id: finalReviewer, agent_type: 'reviewer' };
|
|
766
|
+
const finalResultPayload = {
|
|
767
|
+
session_id: sessionId, cwd: root, hook_event_name: 'PostToolUse', tool_name: 'Task',
|
|
768
|
+
tool_use_id: 'final-review-dispatch', tool_input: { command: 'Task' },
|
|
769
|
+
tool_response: { agentId: finalReviewer, interrupted: false, status: 'completed' },
|
|
770
|
+
};
|
|
771
|
+
const finalStopPayload = {
|
|
772
|
+
session_id: sessionId, cwd: root, hook_event_name: 'SubagentStop', agent_id: finalReviewer,
|
|
773
|
+
agent_type: 'reviewer',
|
|
774
|
+
last_assistant_message: `Review verdict: approve\nReviewed artifact: ${target} sha256:${sha(draftBytes)}\nSummary: Final candidate reviewed.`,
|
|
775
|
+
};
|
|
776
|
+
const finalFailurePayload = finalReviewFailure && {
|
|
777
|
+
session_id: finalReviewFailure.sessionId || sessionId, cwd: root, hook_event_name: 'PostToolUseFailure', tool_name: 'Task',
|
|
778
|
+
tool_use_id: finalReviewFailure.toolUseId || 'final-review-dispatch', tool_input: { command: 'Task' },
|
|
779
|
+
is_interrupt: false, error: 'injected final-review failure', tool_response: { exitCode: 1, interrupted: false, status: 'failed' },
|
|
780
|
+
};
|
|
781
|
+
if (finalReviewFailure) assert.ok(['before-success', 'after-success'].includes(finalReviewFailure.order),
|
|
782
|
+
'final-review failure fixture must declare its order relative to success');
|
|
783
|
+
const emitFinalReviewFailure = () => { if (finalFailurePayload) runHook(finalFailurePayload); };
|
|
784
|
+
let finalReviewPreCaptured = false;
|
|
552
785
|
if (options.realHook) {
|
|
553
|
-
if (
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
})
|
|
786
|
+
if (finalReview && reviewLaunchBeforeWorkerClosure) {
|
|
787
|
+
runHook(finalReviewPrePayload);
|
|
788
|
+
finalReviewPreCaptured = true;
|
|
789
|
+
}
|
|
790
|
+
if (workerResultAfterFinalReview) {
|
|
791
|
+
if (!omitWorkerStop) runHook(workerStopPayload);
|
|
792
|
+
} else if (workerStopAfterFinalReview) {
|
|
793
|
+
if (!omitWorkerResult) runHook(workerResultPayload);
|
|
794
|
+
} else if (workerCompletionOrder === 'stop-result') {
|
|
795
|
+
if (!omitWorkerStop) runHook(workerStopPayload);
|
|
796
|
+
if (!omitWorkerResult) runHook(workerResultPayload);
|
|
797
|
+
} else {
|
|
798
|
+
if (!omitWorkerResult) runHook(workerResultPayload);
|
|
799
|
+
if (!omitWorkerStop) runHook(workerStopPayload);
|
|
800
|
+
}
|
|
562
801
|
for (const make of afterWorkerStop) runHook(make({ root, sessionId, target }));
|
|
563
802
|
}
|
|
564
803
|
if (finalReview) {
|
|
565
|
-
const finalReviewer = 'final-reviewer';
|
|
566
|
-
const finalResultPayload = {
|
|
567
|
-
session_id: sessionId, cwd: root, hook_event_name: 'PostToolUse', tool_name: 'Task',
|
|
568
|
-
tool_use_id: 'final-review-dispatch', tool_input: { command: 'Task' },
|
|
569
|
-
tool_response: { agentId: finalReviewer, interrupted: false, status: 'completed' },
|
|
570
|
-
};
|
|
571
|
-
const finalStopPayload = {
|
|
572
|
-
session_id: sessionId, cwd: root, hook_event_name: 'SubagentStop', agent_id: finalReviewer,
|
|
573
|
-
last_assistant_message: `Review verdict: approve\nReviewed artifact: ${target} sha256:${sha(draftBytes)}\nSummary: Final candidate reviewed.`,
|
|
574
|
-
};
|
|
575
804
|
if (options.realHook) {
|
|
576
|
-
runHook(
|
|
577
|
-
|
|
805
|
+
if (!finalReviewPreCaptured) runHook(finalReviewPrePayload);
|
|
806
|
+
runReviewCapture(finalReviewStartPayload);
|
|
807
|
+
if (finalReviewFailure?.order === 'before-success') emitFinalReviewFailure();
|
|
808
|
+
if (finalReviewCompletionOrder === 'stop-result') {
|
|
809
|
+
runHook(finalStopPayload);
|
|
810
|
+
runHook(finalResultPayload);
|
|
811
|
+
} else {
|
|
812
|
+
runHook(finalResultPayload);
|
|
813
|
+
runHook(finalStopPayload);
|
|
814
|
+
}
|
|
815
|
+
if (finalReviewFailure?.order === 'after-success') emitFinalReviewFailure();
|
|
578
816
|
} else {
|
|
579
|
-
const finalResult =
|
|
580
|
-
const finalStop =
|
|
817
|
+
const finalResult = runtimeProvider.buildCaptureRecord(finalResultPayload, 'PostToolUse', root);
|
|
818
|
+
const finalStop = runtimeProvider.buildCaptureRecord(finalStopPayload, 'SubagentStop', root);
|
|
581
819
|
finalResult.observedIdentity = capture.observedIdentity;
|
|
582
820
|
finalStop.observedIdentity = capture.observedIdentity;
|
|
583
821
|
extraCaptures.push(finalResult, finalStop);
|
|
584
822
|
}
|
|
585
823
|
}
|
|
824
|
+
if (options.realHook && workerResultAfterFinalReview && !omitWorkerResult) runHook(workerResultPayload);
|
|
825
|
+
if (options.realHook && workerStopAfterFinalReview && !omitWorkerStop) runHook(workerStopPayload);
|
|
826
|
+
if (completeWorkflow) {
|
|
827
|
+
runWorkflowOperation('step-adr', ['step', '--session-id', sessionId, '--step-id', 'adr-evid',
|
|
828
|
+
'--disposition', 'pass', '--evidence', 'Independent final ADR review completed']);
|
|
829
|
+
runWorkflowOperation('binding-verify', ['binding', '--session-id', sessionId, '--step-id', 'verify-row17',
|
|
830
|
+
'--binding-id', 'verification-loop', '--disposition', 'loaded', '--evidence', 'Read the verification-loop skill and ran the combined checker']);
|
|
831
|
+
runWorkflowOperation('step-verify', ['step', '--session-id', sessionId, '--step-id', 'verify-row17',
|
|
832
|
+
'--disposition', 'pass', '--evidence', 'Combined checker and independent final review completed'], allowDispositionFailure);
|
|
833
|
+
}
|
|
586
834
|
if (mutateAfterFinalReview) {
|
|
587
835
|
fs.writeFileSync(path.join(root, target), `---\nid: DOCS-001\nstatus: proposed\n---\n\n## Decision\nChanged after final review.\n`);
|
|
588
836
|
fixtureGit(root, ['add', '-A']);
|
|
@@ -591,12 +839,12 @@ function createOutlineFixture(options = {}) {
|
|
|
591
839
|
draftBytes = fs.readFileSync(path.join(root, target));
|
|
592
840
|
}
|
|
593
841
|
const captures = options.realHook
|
|
594
|
-
?
|
|
595
|
-
: [...reviewCaptures, capture, ...extraCaptures, ...(!omitWorkerStart ? [workerStart] : []), ...(!omitWorkerResult ? [
|
|
842
|
+
? runtimeProvider.readCaptureView(sessionDir).records
|
|
843
|
+
: [...reviewCaptures, capture, ...extraCaptures, ...(!omitWorkerStart ? [workerStart] : []), ...(!omitWorkerResult ? [runtimeProvider.buildCaptureRecord({
|
|
596
844
|
session_id: sessionId, cwd: root, hook_event_name: 'PostToolUse', tool_name: 'Task',
|
|
597
845
|
tool_use_id: capture.tool_use_id, tool_input: { command: 'Task' },
|
|
598
846
|
tool_response: { agentId: options.workerPrincipal || 'draft-worker', interrupted: false, status: 'completed' },
|
|
599
|
-
}, 'PostToolUse', root)] : []), ...(!omitWorkerStop ? [
|
|
847
|
+
}, 'PostToolUse', root)] : []), ...(!omitWorkerStop ? [runtimeProvider.buildCaptureRecord({
|
|
600
848
|
session_id: sessionId, cwd: root, hook_event_name: 'SubagentStop', agent_id: options.workerPrincipal || 'draft-worker', agent_type: 'worker',
|
|
601
849
|
}, 'SubagentStop', root)] : []), ...postWorkerCaptures];
|
|
602
850
|
const qualification = options.noFakeQualification ? undefined : { source: 'fake-test-fixture', faked: true, toolUseIdPopulated: true,
|
|
@@ -610,7 +858,7 @@ function createOutlineFixture(options = {}) {
|
|
|
610
858
|
dispatchInputDigest: sha('candidate-authored') } };
|
|
611
859
|
writeJson(path.join(sessionDir, 'doc-reconciliation-capture.json'), { version: 1, records: [forged] });
|
|
612
860
|
}
|
|
613
|
-
const origin =
|
|
861
|
+
const origin = runtimeProvider.createClaudeOriginProvider({
|
|
614
862
|
hostId: 'claude-code', sessionId: providerSessionId, workspaceRoot: root, workflowId, workflowRevision, taskId: providerTaskId,
|
|
615
863
|
principals: { author: providerSessionId, executors: [] }, baseline: providerBaseline,
|
|
616
864
|
captures, sessionDir, taskBinding,
|
|
@@ -625,19 +873,21 @@ function createOutlineFixture(options = {}) {
|
|
|
625
873
|
let pilotResult = null;
|
|
626
874
|
if (runPilot) {
|
|
627
875
|
const previousSwitch = process.env.HARNESS_DOC_RECONCILIATION_PILOT;
|
|
628
|
-
const previousFactory =
|
|
629
|
-
|
|
876
|
+
const previousFactory = runtimeProvider.createClaudeOriginProvider;
|
|
877
|
+
runtimeProvider.createClaudeOriginProvider = input => previousFactory({ ...input,
|
|
630
878
|
...(qualification ? { qualification, outlineFixture: { expectedPin } } : {}), taskBinding });
|
|
631
879
|
process.env.HARNESS_DOC_RECONCILIATION_PILOT = '1';
|
|
632
|
-
const
|
|
880
|
+
const actualWorkflow = options.workflowCli ? JSON.parse(fs.readFileSync(path.join(sessionDir, 'workflow-run.json'), 'utf8')) : null;
|
|
881
|
+
const actualSet = options.workflowCli ? JSON.parse(fs.readFileSync(path.join(sessionDir, 'workflow-obligations.json'), 'utf8')) : null;
|
|
882
|
+
const context = { root, sessionId, sessionDir, activeHost: 'claude-code', workflow: actualWorkflow || {
|
|
633
883
|
workflowId, revision: workflowRevision, strategy: 'iterative-single', state: 'running',
|
|
634
884
|
docReconciliationBaseline: { root: baselineRoot, commit: baselineCommit, tree: baselineTree }, docReconciliationTask: taskBinding,
|
|
635
885
|
} };
|
|
636
886
|
try {
|
|
637
|
-
pilotResult =
|
|
887
|
+
pilotResult = runtimePilot.assess(context, actualSet || { strategy: 'iterative-single', stepBindingsEnabled: true,
|
|
638
888
|
requirements: [{ id: 'prb', summary: 'produce an ADR', acceptance: 'outline review precedes drafting' }] });
|
|
639
889
|
} finally {
|
|
640
|
-
|
|
890
|
+
runtimeProvider.createClaudeOriginProvider = previousFactory;
|
|
641
891
|
if (previousSwitch === undefined) delete process.env.HARNESS_DOC_RECONCILIATION_PILOT;
|
|
642
892
|
else process.env.HARNESS_DOC_RECONCILIATION_PILOT = previousSwitch;
|
|
643
893
|
}
|
|
@@ -649,7 +899,8 @@ function createOutlineFixture(options = {}) {
|
|
|
649
899
|
baselineCommit, baselineTree, outlineCommit, outlineTree, outlineBlob, outlineBytes, configDigest,
|
|
650
900
|
indexAfterCapturedAdd, indexAfterOutlineCommit,
|
|
651
901
|
expectedPin, taskBinding, attemptDir, handoff, payload, capture, reviewCaptures, workerStart,
|
|
652
|
-
extraCaptures, dispatchAgain, finishDraft, runHook, stateHome,
|
|
902
|
+
extraCaptures, dispatchAgain, finishDraft, runHook, capturedRecordsAcrossSessions, stateHome, inventoryOperation, workflowOperationWitnesses,
|
|
903
|
+
runtimeProvider, runtimePilot, outsideInventoryPath,
|
|
653
904
|
faultMarker: path.join(stateHome, 'prb-partial-dispatch-faults-used'),
|
|
654
905
|
cleanup: () => {
|
|
655
906
|
fs.rmSync(root, { recursive: true, force: true });
|
|
@@ -786,6 +1037,77 @@ test('pilot offers structured SubagentStop reviews only and preserves drafter in
|
|
|
786
1037
|
fs.rmSync(sessionDir, { recursive: true, force: true });
|
|
787
1038
|
});
|
|
788
1039
|
|
|
1040
|
+
test('review-step rejects a correlated launch failure while keeping positive controls', () => {
|
|
1041
|
+
const stateHome = fs.mkdtempSync(path.join(os.tmpdir(), 'prb-review-step-'));
|
|
1042
|
+
const previousStateHome = process.env.HARNESS_STATE_HOME;
|
|
1043
|
+
const previousWorkspaceRoot = process.env.HARNESS_WORKSPACE_ROOT;
|
|
1044
|
+
process.env.HARNESS_STATE_HOME = stateHome;
|
|
1045
|
+
process.env.HARNESS_WORKSPACE_ROOT = ROOT;
|
|
1046
|
+
const { getSessionDir } = require(path.join(ROOT, 'hooks/scripts/lib/harness-state.js'));
|
|
1047
|
+
const kernel = path.join(ROOT, 'harness-everything/scripts/kernel-router.js');
|
|
1048
|
+
const controller = path.join(ROOT, 'hooks/scripts/workflow-disposition.js');
|
|
1049
|
+
const run = (script, args = [], input) => spawnSync(process.execPath, [script, ...args], {
|
|
1050
|
+
cwd: ROOT, encoding: 'utf8', input,
|
|
1051
|
+
env: { ...process.env, HARNESS_DOC_RECONCILIATION_PILOT: '1' },
|
|
1052
|
+
});
|
|
1053
|
+
function scenario(sessionId, failureToolUseId) {
|
|
1054
|
+
const payload = { session_id: sessionId, cwd: ROOT, prompt: 'Fix this checkout bug and add a regression test.' };
|
|
1055
|
+
assert.strictEqual(run(kernel, [], JSON.stringify(payload)).status, 0, 'route reaches the workflow controller');
|
|
1056
|
+
const sessionDir = getSessionDir(ROOT, sessionId, payload);
|
|
1057
|
+
const requirements = JSON.stringify([
|
|
1058
|
+
{ id: 'req-review', stepType: 'review', summary: 'Review the checkout change', acceptance: 'independent review is captured' },
|
|
1059
|
+
{ id: 'req-verify', stepType: 'verification', summary: 'Verify the review', acceptance: 'objective evidence exists' },
|
|
1060
|
+
]);
|
|
1061
|
+
assert.strictEqual(run(controller, ['plan', '--session-id', sessionId, '--requirements-json', requirements,
|
|
1062
|
+
'--strategy', 'iterative-single', '--evidence', 'review-step result-correlation fixture']).status, 0);
|
|
1063
|
+
assert.strictEqual(run(controller, ['start', '--session-id', sessionId]).status, 0);
|
|
1064
|
+
const workflow = JSON.parse(fs.readFileSync(path.join(sessionDir, 'workflow-run.json'), 'utf8'));
|
|
1065
|
+
const observedIdentity = { workflowId: workflow.workflowId, workflowRevision: workflow.revision,
|
|
1066
|
+
...(workflow.docReconciliationBaseline ? { baselinePin: workflow.docReconciliationBaseline } : {}) };
|
|
1067
|
+
const records = [
|
|
1068
|
+
provider.buildCaptureRecord({ session_id: sessionId, cwd: ROOT, hook_event_name: 'PostToolUse', tool_name: 'Task',
|
|
1069
|
+
tool_use_id: 'review-launch', tool_response: { agentId: 'independent-reviewer', interrupted: false, status: 'completed' } }, 'PostToolUse', ROOT),
|
|
1070
|
+
provider.buildCaptureRecord({ session_id: sessionId, cwd: ROOT, hook_event_name: 'SubagentStop',
|
|
1071
|
+
agent_id: 'independent-reviewer', agent_type: 'reviewer',
|
|
1072
|
+
last_assistant_message: `Review verdict: approve\nReviewed artifact: README.md sha256:${'a'.repeat(64)}\nSummary: Independent review completed.` }, 'SubagentStop', ROOT),
|
|
1073
|
+
];
|
|
1074
|
+
for (const record of records) {
|
|
1075
|
+
record.observedIdentity = observedIdentity;
|
|
1076
|
+
provider.writeImmutableEvent(sessionDir, record);
|
|
1077
|
+
}
|
|
1078
|
+
let failure;
|
|
1079
|
+
if (failureToolUseId) {
|
|
1080
|
+
failure = provider.buildCaptureRecord({ session_id: sessionId, cwd: ROOT, hook_event_name: 'PostToolUseFailure',
|
|
1081
|
+
tool_name: 'Task', tool_use_id: failureToolUseId, tool_input: { command: 'Task' },
|
|
1082
|
+
is_interrupt: false, error: 'injected launch failure' }, 'PostToolUseFailure', ROOT);
|
|
1083
|
+
provider.writeImmutableEvent(sessionDir, failure);
|
|
1084
|
+
}
|
|
1085
|
+
provider.rebuildJournalView(sessionDir);
|
|
1086
|
+
const result = run(controller, ['step', '--session-id', sessionId, '--step-id', 'req-review', '--disposition', 'pass',
|
|
1087
|
+
'--evidence', 'independent review was captured']);
|
|
1088
|
+
return { result, failure, state: JSON.parse(fs.readFileSync(path.join(sessionDir, 'workflow-obligations.json'), 'utf8')) };
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
try {
|
|
1092
|
+
const matching = scenario('prb-review-matching-failure', 'review-launch');
|
|
1093
|
+
assert.strictEqual(matching.failure.session_id, 'prb-review-matching-failure');
|
|
1094
|
+
assert.strictEqual(matching.failure.tool_use_id, 'review-launch');
|
|
1095
|
+
assert.strictEqual(matching.failure.agent_id, undefined, 'failure-side agent_id is absent');
|
|
1096
|
+
assert.notStrictEqual(matching.result.status, 0, 'matching launch failure rejects review step PASS');
|
|
1097
|
+
assert.match(matching.result.stderr, /review pending/);
|
|
1098
|
+
assert.strictEqual(matching.state.activeStepId, 'req-review');
|
|
1099
|
+
assert.strictEqual(scenario('prb-review-success-only', null).result.status, 0, 'success-only review remains accepted');
|
|
1100
|
+
assert.strictEqual(scenario('prb-review-unmatched-failure', 'other-launch').result.status, 0,
|
|
1101
|
+
'unmatched failure remains accepted');
|
|
1102
|
+
} finally {
|
|
1103
|
+
if (previousStateHome === undefined) delete process.env.HARNESS_STATE_HOME;
|
|
1104
|
+
else process.env.HARNESS_STATE_HOME = previousStateHome;
|
|
1105
|
+
if (previousWorkspaceRoot === undefined) delete process.env.HARNESS_WORKSPACE_ROOT;
|
|
1106
|
+
else process.env.HARNESS_WORKSPACE_ROOT = previousWorkspaceRoot;
|
|
1107
|
+
fs.rmSync(stateHome, { recursive: true, force: true });
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
|
|
789
1111
|
test('generic successful execution or waiver cannot pass outline-confirmation', () => {
|
|
790
1112
|
const target = 'docs/adr/DOCS-001.md';
|
|
791
1113
|
const digest = sha('final D bytes');
|
|
@@ -1813,6 +2135,360 @@ test('overwriting a dispatched predecessor handoff invalidates the retained atte
|
|
|
1813
2135
|
} finally { fixture.cleanup(); }
|
|
1814
2136
|
});
|
|
1815
2137
|
|
|
2138
|
+
test('W6 whole row-17 path accepts captured state operations through source and packaged producers', () => {
|
|
2139
|
+
const completionOrders = [
|
|
2140
|
+
{ runtimeLayout: 'source', workerCompletionOrder: 'result-stop', finalReviewCompletionOrder: 'result-stop' },
|
|
2141
|
+
{ runtimeLayout: 'packaged', workerCompletionOrder: 'stop-result', finalReviewCompletionOrder: 'stop-result' },
|
|
2142
|
+
];
|
|
2143
|
+
for (const { runtimeLayout, workerCompletionOrder, finalReviewCompletionOrder } of completionOrders) {
|
|
2144
|
+
const fixture = createOutlineFixture({ realHook: true, retainedInventory: true, workflowCli: true, w6Producer: true,
|
|
2145
|
+
runtimeLayout, sessionId: `w6-${runtimeLayout}`, preOutlineOperation: 'write', capturedOutlineCommit: true });
|
|
2146
|
+
try {
|
|
2147
|
+
assert.strictEqual(fixture.inventoryOperation?.operation, 'inventory', `${runtimeLayout}: actual inventory producer ran at B`);
|
|
2148
|
+
const completed = fixture.finishDraft({ finalReview: true, completeWorkflow: true, runPilot: true,
|
|
2149
|
+
workerCompletionOrder, finalReviewCompletionOrder });
|
|
2150
|
+
assert.strictEqual(completed.result.status, 'accepted',
|
|
2151
|
+
`${runtimeLayout}: captured row-17 state writers retain outline credit: ${JSON.stringify(completed.result.diagnostics)}`);
|
|
2152
|
+
assert.strictEqual(completed.pilot?.report?.pilotCredit, true,
|
|
2153
|
+
`${runtimeLayout}: post-operation pilot assessment is complete: ${JSON.stringify({
|
|
2154
|
+
status: completed.pilot?.report?.pilotStatus, credit: completed.pilot?.report?.pilotCredit,
|
|
2155
|
+
unsatisfied: completed.pilot?.report?.unsatisfied, diagnostics: completed.pilot?.report?.diagnostics,
|
|
2156
|
+
outlineEvidence: completed.pilot?.report?.outlineEvidence,
|
|
2157
|
+
workflow: JSON.parse(fs.readFileSync(path.join(fixture.sessionDir, 'workflow-run.json'), 'utf8')).state,
|
|
2158
|
+
requirements: JSON.parse(fs.readFileSync(path.join(fixture.sessionDir, 'workflow-obligations.json'), 'utf8')).requirements.map(row => [row.id, row.status]),
|
|
2159
|
+
})}`);
|
|
2160
|
+
assert.strictEqual(completed.pilot?.report?.outlineEvidence?.outcome, 'pass');
|
|
2161
|
+
assert.notStrictEqual(completed.draftCommit, fixture.outlineCommit, 'D is a strict descendant of O');
|
|
2162
|
+
assert.deepStrictEqual(fixtureGit(fixture.root, ['diff-tree', '--no-commit-id', '--name-only', '-r', completed.draftCommit])
|
|
2163
|
+
.split('\n').filter(Boolean).sort(), [fixture.target, 'docs/governed-index.md'].sort(),
|
|
2164
|
+
'the correlated worker commits the ADR and generated index together');
|
|
2165
|
+
const captures = provider.readCaptureView(fixture.sessionDir).records;
|
|
2166
|
+
const stateCommands = captures.filter(item => item.event === 'PreToolUse' && item.stateOperation?.schema === 'harness.w6-state-operation.v1');
|
|
2167
|
+
assert.deepStrictEqual(stateCommands.map(item => item.stateOperation.operation),
|
|
2168
|
+
['plan', 'start', 'inventory', 'seal', 'step-adr', 'binding-verify', 'step-verify'],
|
|
2169
|
+
`${runtimeLayout}: retained journal keeps every bounded operation in phase order`);
|
|
2170
|
+
const decision = provider._internals.evaluateW6StateOperations(captures, fixture.sessionDir);
|
|
2171
|
+
assert.strictEqual(decision.complete, true, `${runtimeLayout}: shared validator accepts the complete operation sequence`);
|
|
2172
|
+
assert.ok(decision.results.length > 0 && decision.results.every(item => item.accepted),
|
|
2173
|
+
`${runtimeLayout}: every captured writer disposition is accepted`);
|
|
2174
|
+
const finalReviewStop = captures.find(item => item.event === 'SubagentStop' && item.agent_id === 'final-reviewer');
|
|
2175
|
+
assert.ok(finalReviewStop, `${runtimeLayout}: final reviewer Stop was captured`);
|
|
2176
|
+
assert.strictEqual(completed.origin.resolveEvent({ reference: `${finalReviewStop.ref}#quality-review`, identity: completed.identity }).status,
|
|
2177
|
+
'accepted', `${runtimeLayout}: final quality review remains independently accepted`);
|
|
2178
|
+
const verifyState = fixture.workflowOperationWitnesses.find(item => item.name === 'step-verify');
|
|
2179
|
+
assert.ok(verifyState?.before && verifyState?.after, `${runtimeLayout}: verify disposition has host state before and after`);
|
|
2180
|
+
for (const field of ['lastEditAt', 'lastVerifyAt', 'lastGenericVerifyAt', 'lastDocVerifyAt']) {
|
|
2181
|
+
assert.strictEqual(verifyState.before[field], verifyState.after[field], `${runtimeLayout}: state-only verification disposition preserves ${field}`);
|
|
2182
|
+
}
|
|
2183
|
+
const stop = spawnSync(process.execPath, [path.join(runtimeLayout === 'source' ? ROOT : path.join(ROOT, 'plugins/harness-everything'),
|
|
2184
|
+
'hooks/scripts/workflow-stop-gate.js')], { cwd: fixture.root, encoding: 'utf8',
|
|
2185
|
+
input: JSON.stringify({ session_id: fixture.sessionId, cwd: fixture.root, hook_event_name: 'Stop' }),
|
|
2186
|
+
env: { ...process.env, HARNESS_STATE_HOME: fixture.stateHome, HARNESS_WORKSPACE_ROOT: fixture.root,
|
|
2187
|
+
HARNESS_DOC_RECONCILIATION_PILOT: '1' } });
|
|
2188
|
+
assert.strictEqual(stop.status, 0, `${runtimeLayout}: normal Stop stays fail-open: ${stop.stderr}`);
|
|
2189
|
+
const workflow = JSON.parse(fs.readFileSync(path.join(fixture.sessionDir, 'workflow-run.json'), 'utf8'));
|
|
2190
|
+
const report = JSON.parse(fs.readFileSync(path.join(fixture.sessionDir, 'doc-reconciliation-pilot.json'), 'utf8'));
|
|
2191
|
+
assert.strictEqual(workflow.state, 'satisfied', `${runtimeLayout}: real Stop reconciliation resolves the workflow; unresolved=${JSON.stringify(workflow.unresolved)}; stop=${stop.stderr}; pilot=${JSON.stringify({
|
|
2192
|
+
status: report.pilotStatus, credit: report.pilotCredit, unsatisfied: report.unsatisfied, diagnostics: report.diagnostics,
|
|
2193
|
+
})}; editVerify=${JSON.stringify(fixture.workflowOperationWitnesses.map(item => ({ name: item.name,
|
|
2194
|
+
before: [item.before?.lastEditAt, item.before?.lastVerifyAt], after: [item.after?.lastEditAt, item.after?.lastVerifyAt] })))}; final=${JSON.stringify(JSON.parse(fs.readFileSync(path.join(fixture.sessionDir, 'handoff-state.json'), 'utf8')))} `);
|
|
2195
|
+
assert.strictEqual(report.pilotCredit, true, `${runtimeLayout}: completed host operation results earn final pilot credit`);
|
|
2196
|
+
} finally { fixture.cleanup(); }
|
|
2197
|
+
}
|
|
2198
|
+
});
|
|
2199
|
+
|
|
2200
|
+
test('W6 rejects final-review launch before both correlated worker completion surfaces', () => {
|
|
2201
|
+
for (const scenario of [
|
|
2202
|
+
{ name: 'worker result', options: { workerResultAfterFinalReview: true } },
|
|
2203
|
+
{ name: 'worker Stop', options: { workerStopAfterFinalReview: true } },
|
|
2204
|
+
]) {
|
|
2205
|
+
const fixture = createOutlineFixture({ realHook: true, retainedInventory: true, workflowCli: true, w6Producer: true,
|
|
2206
|
+
runtimeLayout: 'source', sessionId: `w6-late-${scenario.name.replace(' ', '-')}`, preOutlineOperation: 'write', capturedOutlineCommit: true });
|
|
2207
|
+
try {
|
|
2208
|
+
const completed = fixture.finishDraft({ finalReview: true, completeWorkflow: true, ...scenario.options,
|
|
2209
|
+
finalReviewCompletionOrder: 'stop-result', allowDispositionFailure: true, runPilot: true });
|
|
2210
|
+
assert.notStrictEqual(completed.result.status, 'accepted',
|
|
2211
|
+
`late ${scenario.name} cannot authorize W6 outline credit: ${JSON.stringify(completed.result)}`);
|
|
2212
|
+
assert.notStrictEqual(completed.pilot?.report?.outlineEvidence?.outcome, 'pass',
|
|
2213
|
+
`the final consumer withholds outline credit after the late ${scenario.name}`);
|
|
2214
|
+
const captures = fixture.runtimeProvider.readCaptureView(fixture.sessionDir).records;
|
|
2215
|
+
const decision = fixture.runtimeProvider._internals.evaluateW6StateOperations(captures, fixture.sessionDir);
|
|
2216
|
+
assert.strictEqual(decision.complete, false, `late ${scenario.name} cannot complete the W6 writer disposition`);
|
|
2217
|
+
const finalReviewStop = captures.find(item => item.event === 'SubagentStop' && item.agent_id === 'final-reviewer');
|
|
2218
|
+
const finalReview = completed.origin.resolveEvent({ reference: `${finalReviewStop.ref}#quality-review`, identity: completed.identity });
|
|
2219
|
+
assert.notStrictEqual(finalReview.status, 'accepted', 'task-scoped final quality review is not eligible');
|
|
2220
|
+
assert.strictEqual(completed.pilot?.report?.pilotCredit, false, 'pilot credit stays withheld');
|
|
2221
|
+
} finally { fixture.cleanup(); }
|
|
2222
|
+
}
|
|
2223
|
+
});
|
|
2224
|
+
|
|
2225
|
+
test('outline-backed no-W6 task rejects final quality review launched before worker result', () => {
|
|
2226
|
+
const fixture = createOutlineFixture({ realHook: true, runtimeLayout: 'source', sessionId: 'no-w6-late-worker-result' });
|
|
2227
|
+
try {
|
|
2228
|
+
const completed = fixture.finishDraft({ finalReview: true, workerResultAfterFinalReview: true,
|
|
2229
|
+
finalReviewCompletionOrder: 'stop-result', runPilot: true });
|
|
2230
|
+
const finalReviewStop = completed.captures.find(item => item.event === 'SubagentStop' && item.agent_id === 'final-reviewer');
|
|
2231
|
+
const finalReview = completed.origin.resolveEvent({ reference: `${finalReviewStop.ref}#quality-review`, identity: completed.identity });
|
|
2232
|
+
assert.notStrictEqual(finalReview.status, 'accepted',
|
|
2233
|
+
`the outline-backed sibling lane must share worker closure eligibility: ${JSON.stringify(finalReview)}`);
|
|
2234
|
+
assert.strictEqual(completed.pilot?.report?.outlineEvidence?.outcome, 'pass',
|
|
2235
|
+
'the earlier O review remains a separate accepted outline result');
|
|
2236
|
+
assert.ok(!completed.pilot?.report?.acceptedRefs?.some(ref => ref === `${finalReviewStop.ref}#quality-review`),
|
|
2237
|
+
'the early final review is absent from accepted pilot evidence');
|
|
2238
|
+
assert.strictEqual(completed.pilot?.report?.pilotCredit, false,
|
|
2239
|
+
'the sibling lane cannot use an early final review for pilot credit');
|
|
2240
|
+
} finally { fixture.cleanup(); }
|
|
2241
|
+
});
|
|
2242
|
+
|
|
2243
|
+
test('outline-backed no-W6 positive final review accepts both callback orders through source and package', () => {
|
|
2244
|
+
const completionOrders = [
|
|
2245
|
+
{ runtimeLayout: 'source', workerCompletionOrder: 'result-stop', finalReviewCompletionOrder: 'stop-result' },
|
|
2246
|
+
{ runtimeLayout: 'packaged', workerCompletionOrder: 'stop-result', finalReviewCompletionOrder: 'result-stop' },
|
|
2247
|
+
];
|
|
2248
|
+
for (const { runtimeLayout, workerCompletionOrder, finalReviewCompletionOrder } of completionOrders) {
|
|
2249
|
+
const fixture = createOutlineFixture({ realHook: true, runtimeLayout, sessionId: `no-w6-${runtimeLayout}` });
|
|
2250
|
+
try {
|
|
2251
|
+
const completed = fixture.finishDraft({ finalReview: true, workerCompletionOrder, finalReviewCompletionOrder, runPilot: true });
|
|
2252
|
+
const finalReviewStop = completed.captures.find(item => item.event === 'SubagentStop' && item.agent_id === 'final-reviewer');
|
|
2253
|
+
const finalReview = completed.origin.resolveEvent({ reference: `${finalReviewStop.ref}#quality-review`, identity: completed.identity });
|
|
2254
|
+
assert.strictEqual(finalReview.status, 'accepted', `${runtimeLayout}: completed task-scoped final review is eligible`);
|
|
2255
|
+
assert.strictEqual(completed.pilot?.report?.outlineEvidence?.outcome, 'pass', `${runtimeLayout}: O review remains accepted`);
|
|
2256
|
+
assert.ok(completed.pilot?.report?.acceptedRefs?.includes(`${finalReviewStop.ref}#quality-review`),
|
|
2257
|
+
`${runtimeLayout}: the final review reaches the no-W6 pilot seam`);
|
|
2258
|
+
assert.strictEqual(completed.pilot?.report?.pilotCredit, false,
|
|
2259
|
+
`${runtimeLayout}: unrelated outstanding MUSTs still withhold full pilot credit`);
|
|
2260
|
+
} finally { fixture.cleanup(); }
|
|
2261
|
+
}
|
|
2262
|
+
});
|
|
2263
|
+
|
|
2264
|
+
test('matching final-review failures veto W6 eligibility and disposition in either callback order', () => {
|
|
2265
|
+
const observations = [];
|
|
2266
|
+
for (const { order, runtimeLayout } of [
|
|
2267
|
+
{ order: 'before-success', runtimeLayout: 'source' },
|
|
2268
|
+
{ order: 'after-success', runtimeLayout: 'packaged' },
|
|
2269
|
+
]) {
|
|
2270
|
+
const fixture = createOutlineFixture({ realHook: true, retainedInventory: true, workflowCli: true, w6Producer: true,
|
|
2271
|
+
runtimeLayout, sessionId: `w6-failure-${order}`, preOutlineOperation: 'write', capturedOutlineCommit: true });
|
|
2272
|
+
try {
|
|
2273
|
+
const completed = fixture.finishDraft({ finalReview: true, completeWorkflow: true, runPilot: true,
|
|
2274
|
+
allowDispositionFailure: true, finalReviewFailure: { order }, finalReviewCompletionOrder: 'result-stop' });
|
|
2275
|
+
const finalReviewStop = completed.captures.find(item => item.event === 'SubagentStop' && item.agent_id === 'final-reviewer');
|
|
2276
|
+
const finalReview = completed.origin.resolveEvent({ reference: `${finalReviewStop.ref}#quality-review`, identity: completed.identity });
|
|
2277
|
+
const failure = completed.captures.find(item => item.event === 'PostToolUseFailure'
|
|
2278
|
+
&& item.session_id === fixture.sessionId && item.tool_use_id === 'final-review-dispatch');
|
|
2279
|
+
assert.ok(failure, `${runtimeLayout}/${order}: failure was captured through state-persist`);
|
|
2280
|
+
assert.strictEqual(failure.agent_id, undefined, `${runtimeLayout}/${order}: failure-side agent_id is absent`);
|
|
2281
|
+
observations.push({ runtimeLayout, order, finalReviewStatus: finalReview.status,
|
|
2282
|
+
outlineOutcome: completed.pilot?.report?.outlineEvidence?.outcome, pilotCredit: completed.pilot?.report?.pilotCredit });
|
|
2283
|
+
} finally { fixture.cleanup(); }
|
|
2284
|
+
}
|
|
2285
|
+
assert.ok(observations.every(item => item.finalReviewStatus !== 'accepted'
|
|
2286
|
+
&& item.outlineOutcome !== 'pass' && item.pilotCredit === false),
|
|
2287
|
+
`matching failure before/after success must veto final-review eligibility, outline outcome and pilot credit: ${JSON.stringify(observations)}`);
|
|
2288
|
+
});
|
|
2289
|
+
|
|
2290
|
+
test('matching final-review failures veto the no-W6 final review in either callback order', () => {
|
|
2291
|
+
const observations = [];
|
|
2292
|
+
for (const { order, runtimeLayout } of [
|
|
2293
|
+
{ order: 'before-success', runtimeLayout: 'packaged' },
|
|
2294
|
+
{ order: 'after-success', runtimeLayout: 'source' },
|
|
2295
|
+
]) {
|
|
2296
|
+
const fixture = createOutlineFixture({ realHook: true, runtimeLayout, sessionId: `no-w6-failure-${order}` });
|
|
2297
|
+
try {
|
|
2298
|
+
const completed = fixture.finishDraft({ finalReview: true, runPilot: true,
|
|
2299
|
+
finalReviewFailure: { order }, finalReviewCompletionOrder: 'stop-result' });
|
|
2300
|
+
const finalReviewStop = completed.captures.find(item => item.event === 'SubagentStop' && item.agent_id === 'final-reviewer');
|
|
2301
|
+
const finalReview = completed.origin.resolveEvent({ reference: `${finalReviewStop.ref}#quality-review`, identity: completed.identity });
|
|
2302
|
+
const failure = completed.captures.find(item => item.event === 'PostToolUseFailure'
|
|
2303
|
+
&& item.session_id === fixture.sessionId && item.tool_use_id === 'final-review-dispatch');
|
|
2304
|
+
assert.ok(failure, `${runtimeLayout}/${order}: failure was captured through state-persist`);
|
|
2305
|
+
assert.strictEqual(failure.agent_id, undefined, `${runtimeLayout}/${order}: failure-side agent_id is absent`);
|
|
2306
|
+
observations.push({ runtimeLayout, order, finalReviewStatus: finalReview.status,
|
|
2307
|
+
outlineOutcome: completed.pilot?.report?.outlineEvidence?.outcome, pilotCredit: completed.pilot?.report?.pilotCredit });
|
|
2308
|
+
} finally { fixture.cleanup(); }
|
|
2309
|
+
}
|
|
2310
|
+
assert.ok(observations.every(item => item.finalReviewStatus !== 'accepted'
|
|
2311
|
+
&& item.outlineOutcome === 'pass' && item.pilotCredit === false),
|
|
2312
|
+
`matching failure before/after success must veto final review while retaining the separate O outcome: ${JSON.stringify(observations)}`);
|
|
2313
|
+
});
|
|
2314
|
+
|
|
2315
|
+
test('unmatched final-review failures do not poison a valid W6 launch', () => {
|
|
2316
|
+
for (const scenario of [
|
|
2317
|
+
{ name: 'other session', runtimeLayout: 'source', failure: { sessionId: 'unrelated-review-session' } },
|
|
2318
|
+
{ name: 'other tool-use ID', runtimeLayout: 'packaged', failure: { toolUseId: 'unrelated-review-tool' } },
|
|
2319
|
+
]) {
|
|
2320
|
+
const fixture = createOutlineFixture({ realHook: true, retainedInventory: true, workflowCli: true, w6Producer: true,
|
|
2321
|
+
runtimeLayout: scenario.runtimeLayout, sessionId: `w6-unmatched-${scenario.name.replaceAll(' ', '-')}`,
|
|
2322
|
+
preOutlineOperation: 'write', capturedOutlineCommit: true });
|
|
2323
|
+
try {
|
|
2324
|
+
const completed = fixture.finishDraft({ finalReview: true, completeWorkflow: true, runPilot: true,
|
|
2325
|
+
finalReviewFailure: { order: 'after-success', ...scenario.failure } });
|
|
2326
|
+
const finalReviewStop = completed.captures.find(item => item.event === 'SubagentStop' && item.agent_id === 'final-reviewer');
|
|
2327
|
+
const finalReview = completed.origin.resolveEvent({ reference: `${finalReviewStop.ref}#quality-review`, identity: completed.identity });
|
|
2328
|
+
const failure = fixture.capturedRecordsAcrossSessions().find(item => item.event === 'PostToolUseFailure'
|
|
2329
|
+
&& item.session_id === (scenario.failure.sessionId || fixture.sessionId)
|
|
2330
|
+
&& item.tool_use_id === (scenario.failure.toolUseId || 'final-review-dispatch'));
|
|
2331
|
+
assert.ok(failure, `${scenario.name}: unmatched failure was captured through state-persist`);
|
|
2332
|
+
assert.strictEqual(failure.agent_id, undefined, `${scenario.name}: failure-side agent_id is absent`);
|
|
2333
|
+
assert.strictEqual(finalReview.status, 'accepted', `${scenario.name}: valid final review remains eligible`);
|
|
2334
|
+
assert.strictEqual(completed.result.status, 'accepted', `${scenario.name}: outline result remains accepted`);
|
|
2335
|
+
assert.strictEqual(completed.pilot?.report?.outlineEvidence?.outcome, 'pass', `${scenario.name}: outline outcome remains pass`);
|
|
2336
|
+
assert.strictEqual(completed.pilot?.report?.pilotCredit, true, `${scenario.name}: valid launch retains pilot credit`);
|
|
2337
|
+
} finally { fixture.cleanup(); }
|
|
2338
|
+
}
|
|
2339
|
+
});
|
|
2340
|
+
|
|
2341
|
+
test('outline-backed no-W6 final review rejects a worker Stop that arrives after launch', () => {
|
|
2342
|
+
const fixture = createOutlineFixture({ realHook: true, runtimeLayout: 'source', sessionId: 'no-w6-late-worker-stop' });
|
|
2343
|
+
try {
|
|
2344
|
+
const completed = fixture.finishDraft({ finalReview: true, workerStopAfterFinalReview: true,
|
|
2345
|
+
finalReviewCompletionOrder: 'stop-result', runPilot: true });
|
|
2346
|
+
const finalReviewStop = completed.captures.find(item => item.event === 'SubagentStop' && item.agent_id === 'final-reviewer');
|
|
2347
|
+
const finalReview = completed.origin.resolveEvent({ reference: `${finalReviewStop.ref}#quality-review`, identity: completed.identity });
|
|
2348
|
+
assert.notStrictEqual(finalReview.status, 'accepted', 'a late worker Stop cannot retroactively authorize the launch');
|
|
2349
|
+
assert.ok(!completed.pilot?.report?.acceptedRefs?.includes(`${finalReviewStop.ref}#quality-review`));
|
|
2350
|
+
assert.strictEqual(completed.pilot?.report?.pilotCredit, false);
|
|
2351
|
+
} finally { fixture.cleanup(); }
|
|
2352
|
+
});
|
|
2353
|
+
|
|
2354
|
+
test('W6 requires a captured final-review launch to follow worker closure even when its Start is later', () => {
|
|
2355
|
+
const fixture = createOutlineFixture({ realHook: true, retainedInventory: true, workflowCli: true, w6Producer: true,
|
|
2356
|
+
runtimeLayout: 'source', sessionId: 'w6-early-review-pre', preOutlineOperation: 'write', capturedOutlineCommit: true });
|
|
2357
|
+
try {
|
|
2358
|
+
const completed = fixture.finishDraft({ finalReview: true, completeWorkflow: true,
|
|
2359
|
+
reviewLaunchBeforeWorkerClosure: true, allowDispositionFailure: true, runPilot: true });
|
|
2360
|
+
assert.notStrictEqual(completed.result.status, 'accepted',
|
|
2361
|
+
'a late SubagentStart cannot hide a final-review PreToolUse captured before worker closure');
|
|
2362
|
+
assert.notStrictEqual(completed.pilot?.report?.outlineEvidence?.outcome, 'pass');
|
|
2363
|
+
assert.strictEqual(completed.pilot?.report?.pilotCredit, false);
|
|
2364
|
+
} finally { fixture.cleanup(); }
|
|
2365
|
+
});
|
|
2366
|
+
|
|
2367
|
+
test('W6 state operation identity, phase, schema, and destination drift withhold pilot credit', () => {
|
|
2368
|
+
const fixture = createOutlineFixture({ realHook: true, retainedInventory: true, workflowCli: true, w6Producer: true,
|
|
2369
|
+
runtimeLayout: 'source', sessionId: 'w6-negative-identity', preOutlineOperation: 'write', capturedOutlineCommit: true });
|
|
2370
|
+
const previousSwitch = process.env.HARNESS_DOC_RECONCILIATION_PILOT;
|
|
2371
|
+
const originalFactory = fixture.runtimeProvider.createClaudeOriginProvider;
|
|
2372
|
+
try {
|
|
2373
|
+
const completed = fixture.finishDraft({ finalReview: true, completeWorkflow: true, runPilot: true });
|
|
2374
|
+
assert.strictEqual(completed.pilot && completed.pilot.report.pilotCredit, true, 'positive control: exact captured operation fields credit');
|
|
2375
|
+
fixture.runtimeProvider.createClaudeOriginProvider = input => originalFactory({ ...input,
|
|
2376
|
+
qualification: { source: 'fake-test-fixture', faked: true, toolUseIdPopulated: true,
|
|
2377
|
+
agentIdPopulated: true, outlineDispatchCaptureVerified: true }, outlineFixture: { expectedPin: fixture.expectedPin },
|
|
2378
|
+
taskBinding: fixture.taskBinding });
|
|
2379
|
+
process.env.HARNESS_DOC_RECONCILIATION_PILOT = '1';
|
|
2380
|
+
const view = fixture.runtimeProvider.readCaptureView(fixture.sessionDir);
|
|
2381
|
+
const inventoryPre = view.records.find(item => item.event === 'PreToolUse' && item.stateOperation && item.stateOperation.operation === 'inventory');
|
|
2382
|
+
assert.ok(inventoryPre, 'real inventory PreToolUse capture exists');
|
|
2383
|
+
const eventDir = path.join(fixture.sessionDir, 'doc-reconciliation-capture');
|
|
2384
|
+
const eventFile = fs.readdirSync(eventDir).map(name => path.join(eventDir, name))
|
|
2385
|
+
.find(file => JSON.parse(fs.readFileSync(file, 'utf8')).ref === inventoryPre.ref);
|
|
2386
|
+
assert.ok(eventFile, 'inventory PreToolUse has an immutable event file');
|
|
2387
|
+
const original = fs.readFileSync(eventFile);
|
|
2388
|
+
const context = { root: fixture.root, sessionId: fixture.sessionId, sessionDir: fixture.sessionDir, activeHost: 'claude-code',
|
|
2389
|
+
workflow: JSON.parse(fs.readFileSync(path.join(fixture.sessionDir, 'workflow-run.json'), 'utf8')) };
|
|
2390
|
+
const set = JSON.parse(fs.readFileSync(path.join(fixture.sessionDir, 'workflow-obligations.json'), 'utf8'));
|
|
2391
|
+
for (const [field, value] of [
|
|
2392
|
+
['principalId', 'draft-worker'],
|
|
2393
|
+
['sessionId', 'other-session'],
|
|
2394
|
+
['workflowId', 'other-workflow'],
|
|
2395
|
+
['phase', 'post-final-review'],
|
|
2396
|
+
['destinations', ['workflow-run.json']],
|
|
2397
|
+
['schema', 'harness.unrecognized-state-operation.v1'],
|
|
2398
|
+
]) {
|
|
2399
|
+
const changed = JSON.parse(original.toString('utf8'));
|
|
2400
|
+
changed.stateOperation[field] = value;
|
|
2401
|
+
writeJson(eventFile, changed);
|
|
2402
|
+
fixture.runtimeProvider.rebuildJournalView(fixture.sessionDir);
|
|
2403
|
+
const assessment = fixture.runtimePilot.assess(context, set);
|
|
2404
|
+
assert.strictEqual(assessment.withhold, true, 'changed ' + field + ' cannot authorize the captured operation');
|
|
2405
|
+
assert.strictEqual(assessment.report.pilotCredit, false, 'changed ' + field + ' withholds pilot credit');
|
|
2406
|
+
assert.notStrictEqual(assessment.report.outlineEvidence && assessment.report.outlineEvidence.outcome, 'pass',
|
|
2407
|
+
'changed ' + field + ' withholds outline credit');
|
|
2408
|
+
fs.writeFileSync(eventFile, original);
|
|
2409
|
+
fixture.runtimeProvider.rebuildJournalView(fixture.sessionDir);
|
|
2410
|
+
}
|
|
2411
|
+
const restored = fixture.runtimePilot.assess(context, set);
|
|
2412
|
+
assert.strictEqual(restored.withhold, false, 'restored positive control returns to the same production consumer');
|
|
2413
|
+
assert.strictEqual(restored.report.pilotCredit, true, 'restored exact state-operation evidence credits');
|
|
2414
|
+
} finally {
|
|
2415
|
+
fixture.runtimeProvider.createClaudeOriginProvider = originalFactory;
|
|
2416
|
+
if (previousSwitch === undefined) delete process.env.HARNESS_DOC_RECONCILIATION_PILOT;
|
|
2417
|
+
else process.env.HARNESS_DOC_RECONCILIATION_PILOT = previousSwitch;
|
|
2418
|
+
fixture.cleanup();
|
|
2419
|
+
}
|
|
2420
|
+
});
|
|
2421
|
+
|
|
2422
|
+
test('W6 rejects extra destinations, replayed results, and missing host completion', () => {
|
|
2423
|
+
for (const fault of ['extra-state-destination', 'duplicate-post', 'missing-post', 'inventory-symlink']) {
|
|
2424
|
+
if (fault === 'inventory-symlink') {
|
|
2425
|
+
const unavailable = symlinkUnavailable('dir');
|
|
2426
|
+
if (unavailable) return { unchecked: `directory symlink escape control unavailable (${unavailable})` };
|
|
2427
|
+
}
|
|
2428
|
+
const fixture = createOutlineFixture({ realHook: true, retainedInventory: true, workflowCli: true, w6Producer: true,
|
|
2429
|
+
w6ProducerFault: fault, w6ExpectedProducerFailure: fault === 'inventory-symlink',
|
|
2430
|
+
sessionId: 'w6-negative-' + fault, preOutlineOperation: 'write', capturedOutlineCommit: true });
|
|
2431
|
+
try {
|
|
2432
|
+
if (fault === 'inventory-symlink') {
|
|
2433
|
+
assert.ok(fixture.inventoryOperation?.error, 'symlinked destination makes the producer fail before writing');
|
|
2434
|
+
assert.strictEqual(fs.existsSync(fixture.outsideInventoryPath), false, 'the outside destination receives no file');
|
|
2435
|
+
}
|
|
2436
|
+
const completed = fixture.finishDraft({ finalReview: true, completeWorkflow: true, allowDispositionFailure: true, runPilot: true });
|
|
2437
|
+
assert.notStrictEqual(completed.result.status, 'accepted', fault + ': unsupported operation effect cannot credit outline');
|
|
2438
|
+
assert.notStrictEqual(completed.pilot && completed.pilot.report.outlineEvidence && completed.pilot.report.outlineEvidence.outcome,
|
|
2439
|
+
'pass', fault + ': final consumer withholds outline credit');
|
|
2440
|
+
const captures = fixture.runtimeProvider.readCaptureView(fixture.sessionDir).records;
|
|
2441
|
+
const decision = fixture.runtimeProvider._internals.evaluateW6StateOperations(captures, fixture.sessionDir);
|
|
2442
|
+
const inventory = decision.results.find(item => item.operation === 'inventory');
|
|
2443
|
+
assert.strictEqual(inventory && inventory.accepted, false, fault + ': shared validator rejects inventory effect/result');
|
|
2444
|
+
} finally { fixture.cleanup(); }
|
|
2445
|
+
}
|
|
2446
|
+
});
|
|
2447
|
+
|
|
2448
|
+
test('W6 shell boundary rejects compound writer activity even when the task tree is restored', () => {
|
|
2449
|
+
const fixture = createOutlineFixture({ realHook: true, retainedInventory: true, workflowCli: true, w6Producer: true,
|
|
2450
|
+
sessionId: 'w6-negative-compound', preOutlineOperation: 'write', capturedOutlineCommit: true });
|
|
2451
|
+
try {
|
|
2452
|
+
const helper = path.join(ROOT, 'hooks/scripts/w6-state-operations.js');
|
|
2453
|
+
const plain = 'node "' + helper + '" seal --session-id "' + fixture.sessionId + '"';
|
|
2454
|
+
const compound = plain + '; printf mutated > .agents/harness-everything/project-docs.json; git checkout -- .agents/harness-everything/project-docs.json';
|
|
2455
|
+
const previousStateHome = process.env.HARNESS_STATE_HOME;
|
|
2456
|
+
process.env.HARNESS_STATE_HOME = fixture.stateHome;
|
|
2457
|
+
try {
|
|
2458
|
+
assert.strictEqual(fixture.runtimeProvider.isW6StateCommand(plain, fixture.root, fixture.root,
|
|
2459
|
+
{ toolName: 'Bash', sessionId: fixture.sessionId }), true, 'positive control: exact installed producer resolves');
|
|
2460
|
+
assert.strictEqual(fixture.runtimeProvider.isW6StateCommand(compound, fixture.root, fixture.root,
|
|
2461
|
+
{ toolName: 'Bash', sessionId: fixture.sessionId }), false, 'compound trailing work is outside the fixed operation');
|
|
2462
|
+
} finally {
|
|
2463
|
+
if (previousStateHome === undefined) delete process.env.HARNESS_STATE_HOME;
|
|
2464
|
+
else process.env.HARNESS_STATE_HOME = previousStateHome;
|
|
2465
|
+
}
|
|
2466
|
+
const file = path.join(fixture.root, '.agents/harness-everything/project-docs.json');
|
|
2467
|
+
const original = fs.readFileSync(file);
|
|
2468
|
+
const payload = { session_id: fixture.sessionId, cwd: fixture.root, hook_event_name: 'PreToolUse', tool_name: 'Bash',
|
|
2469
|
+
tool_use_id: 'w6-compound-writer', tool_input: { command: compound } };
|
|
2470
|
+
fixture.runHook(payload);
|
|
2471
|
+
const rejectedProducer = spawnSync(process.execPath, [helper, 'seal', '--session-id', fixture.sessionId], {
|
|
2472
|
+
cwd: fixture.root, encoding: 'utf8', env: { ...process.env, HARNESS_STATE_HOME: fixture.stateHome,
|
|
2473
|
+
HARNESS_WORKSPACE_ROOT: fixture.root, HARNESS_DOC_RECONCILIATION_PILOT: '1' },
|
|
2474
|
+
});
|
|
2475
|
+
assert.strictEqual(rejectedProducer.status, 2, 'the installed producer refuses a compound host command');
|
|
2476
|
+
fs.writeFileSync(file, 'mutated\n');
|
|
2477
|
+
fs.writeFileSync(file, original);
|
|
2478
|
+
fixture.runHook({ ...payload, hook_event_name: 'PostToolUse',
|
|
2479
|
+
tool_response: { exitCode: 0, stdout: '', interrupted: false, status: 'completed' } });
|
|
2480
|
+
assert.deepStrictEqual(fs.readFileSync(file), original, 'the negative restores the exact task-tree bytes');
|
|
2481
|
+
const writer = fixture.runtimeProvider.readCaptureView(fixture.sessionDir).records.find(item => item.tool_use_id === payload.tool_use_id);
|
|
2482
|
+
assert.ok(writer && !writer.stateOperation, 'compound invocation receives no bounded operation record');
|
|
2483
|
+
const completed = fixture.finishDraft({ finalReview: true, completeWorkflow: true,
|
|
2484
|
+
allowDispositionFailure: true, runPilot: true });
|
|
2485
|
+
assert.notStrictEqual(completed.result.status, 'accepted', 'an unrecognized compound writer cannot earn outline credit');
|
|
2486
|
+
assert.ok(completed.result.diagnostics && completed.result.diagnostics.some(item =>
|
|
2487
|
+
['outline-writer-activity-ambiguous', 'outline-state-operation-unresolved'].includes(item.code)),
|
|
2488
|
+
'unknown compound writer or missing bounded state path stays visible');
|
|
2489
|
+
} finally { fixture.cleanup(); }
|
|
2490
|
+
});
|
|
2491
|
+
|
|
1816
2492
|
test('captured pre-O coordinator Write of the pinned target earns outline credit, like the paired read-only control', () => {
|
|
1817
2493
|
const legs = [];
|
|
1818
2494
|
for (const [name, operation, sessionId] of [
|
|
@@ -2144,8 +2820,8 @@ test('writer-policy negative controls withhold outline credit through the real h
|
|
|
2144
2820
|
interleave: { beforeDispatch: [writerRecord({ toolUseId: 'pre-outline-write-coordinator-writer-session' })] } }, [WRITER_AMBIGUOUS]],
|
|
2145
2821
|
['reviewer writes during review', { interleave: { duringReview: [writerRecord({ toolUseId: 'nc-reviewer', agentId: 'outline-reviewer' })] } }, [WRITER_AMBIGUOUS]],
|
|
2146
2822
|
['reviewer is the coordinator', { reviewerPrincipal: 'author-session' }, [SEAM_UNRESOLVED]],
|
|
2147
|
-
//
|
|
2148
|
-
['reviewer is the draft worker', { reviewerPrincipal: 'draft-worker' }, ['outline-review-
|
|
2823
|
+
// Multiple launch results for the same reviewer make its independent result decision ambiguous.
|
|
2824
|
+
['reviewer is the draft worker', { reviewerPrincipal: 'draft-worker' }, ['outline-review-not-independent']],
|
|
2149
2825
|
['missing reviewer lifecycle', { omitReviewResult: true }, [SEAM_UNRESOLVED]],
|
|
2150
2826
|
['review digest mismatch at dispatch', { handoffOverrides: { reviewDigest: 'f'.repeat(64) } }, [SEAM_UNRESOLVED]],
|
|
2151
2827
|
['task mismatch at dispatch', { handoffOverrides: { taskId: 'task-other' } }, [SEAM_UNRESOLVED]],
|