harness-everything 0.57.4 → 1.0.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/.releaserc.json +2 -0
- package/AGENTS.md +8 -2
- package/CHANGELOG.md +23 -0
- package/README.md +4 -4
- package/benchmarks/results/live-host/agy-2026-11-22/README.md +49 -0
- package/benchmarks/results/live-host/agy-2026-11-23/README.md +48 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/README.md +40 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/edit-state-final.json +11 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/events-2026-11-24.jsonl +103 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/host-version.txt +3 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/live-event-trace-probe.js +11 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/plugin-load-lines.txt +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/reminder-excerpt.txt +1 -0
- package/ci/doc-capability-consistency.test.js +15 -3
- package/ci/lib/opencode-v2-driver.js +169 -0
- package/ci/mechanism-2ao-plugin-sync.test.js +235 -2
- package/ci/mechanism-2n-opencode-plugin.test.js +387 -223
- package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +24 -15
- package/ci/mechanism-2u-issue-42-regressions.test.js +41 -2
- package/ci/mechanism-2w-platform-compatibility.test.js +29 -5
- package/ci/mechanism-2x-release-automation.test.js +3 -1
- package/ci/mechanism-30-opencode-plugin-loadability.test.js +78 -45
- package/ci/mechanism-338-opencode-async.test.js +367 -194
- package/ci/mechanism-341-opencode-lane.test.js +143 -183
- package/ci/mechanism-39-opencode-verify-outcomes.test.js +118 -86
- package/ci/mechanism-394-opencode-ledger-lesson.test.js +46 -97
- package/ci/mechanism-397-opencode-observations.test.js +58 -47
- package/ci/mechanism-453-opencode-v2-driver.test.js +51 -0
- package/ci/mechanism-453-opencode-v2-only-events.test.js +241 -0
- package/ci/mechanism-agy-hooks.test.js +1096 -0
- package/ci/mechanism-agy-plugin-package.test.js +76 -0
- package/ci/telemetry.test.js +31 -24
- package/docs/architecture.md +4 -2
- package/docs/platform-capabilities.md +62 -26
- package/docs/platform-compatibility.json +41 -6
- package/docs/system-one-observations.md +1 -1
- package/docs/telemetry.md +1 -1
- package/docs/troubleshooting.md +2 -2
- package/hooks/scripts/agy-post-tool.js +124 -0
- package/hooks/scripts/agy-pre-invocation.js +185 -0
- package/hooks/scripts/agy-pre-tool.js +158 -0
- package/hooks/scripts/agy-session-start.js +54 -0
- package/hooks/scripts/agy-stop.js +152 -0
- package/hooks/scripts/lib/agy-adapter-core.js +168 -0
- package/hooks/scripts/state-persist.js +50 -10
- package/opencode-plugin/README.md +60 -66
- package/opencode-plugin/index.mjs +11 -13
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +18 -0
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/agy-post-tool.js +124 -0
- package/plugins/harness-everything/hooks/scripts/agy-pre-invocation.js +185 -0
- package/plugins/harness-everything/hooks/scripts/agy-pre-tool.js +158 -0
- package/plugins/harness-everything/hooks/scripts/agy-session-start.js +54 -0
- package/plugins/harness-everything/hooks/scripts/agy-stop.js +152 -0
- package/plugins/harness-everything/hooks/scripts/lib/agy-adapter-core.js +168 -0
- package/plugins/harness-everything/hooks/scripts/state-persist.js +50 -10
- package/plugins/harness-everything/hooks.json +44 -0
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/rules/AGENTS.md +117 -0
- package/sbom.cdx.json +12 -12
- package/scripts/plugin-sync.js +105 -14
- package/scripts/sync-openai-plugin.js +16 -1
- package/scripts/sync-release-version.js +1 -0
|
@@ -6,8 +6,8 @@ const fs = require('node:fs');
|
|
|
6
6
|
const os = require('node:os');
|
|
7
7
|
const path = require('node:path');
|
|
8
8
|
const { spawnSync } = require('node:child_process');
|
|
9
|
-
const { pathToFileURL } = require('node:url');
|
|
10
9
|
const { test } = require('node:test');
|
|
10
|
+
const { createV2Driver } = require('./lib/opencode-v2-driver');
|
|
11
11
|
|
|
12
12
|
const ROOT = path.resolve(__dirname, '..');
|
|
13
13
|
const STOP_GATE = path.join(ROOT, 'hooks/scripts/workflow-stop-gate.js');
|
|
@@ -29,10 +29,7 @@ function runJson(script, cwd, input, env = {}) {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function
|
|
33
|
-
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-341-opencode-workspace-'));
|
|
34
|
-
const stateHome = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-341-opencode-state-'));
|
|
35
|
-
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-341-opencode-home-'));
|
|
32
|
+
function initWorkspace(root) {
|
|
36
33
|
fs.mkdirSync(path.join(root, '.agents/harness-everything'), { recursive: true });
|
|
37
34
|
fs.mkdirSync(path.join(root, 'docs/adr'), { recursive: true });
|
|
38
35
|
fs.writeFileSync(path.join(root, '.agents/harness-everything/project-docs.json'), JSON.stringify({ governed: [{ path: 'docs/adr/**', role: 'adr' }], domains: ['GRPH'] }, null, 2) + '\n');
|
|
@@ -43,6 +40,13 @@ function makeFixture() {
|
|
|
43
40
|
assert.equal(git(root, ['add', '-A']).status, 0);
|
|
44
41
|
assert.equal(git(root, ['-c', 'commit.gpgsign=false', 'commit', '-q', '-m', 'baseline']).status, 0);
|
|
45
42
|
fs.writeFileSync(path.join(root, 'docs/adr/GRPH-001.md'), '# GRPH-001 Retry\n\nCheckout MUST retry twice.\n');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function makeFixture() {
|
|
46
|
+
const root = fs.realpathSync.native(fs.mkdtempSync(path.join(os.tmpdir(), 'harness-341-opencode-workspace-')));
|
|
47
|
+
const stateHome = fs.realpathSync.native(fs.mkdtempSync(path.join(os.tmpdir(), 'harness-341-opencode-state-')));
|
|
48
|
+
const home = fs.realpathSync.native(fs.mkdtempSync(path.join(os.tmpdir(), 'harness-341-opencode-home-')));
|
|
49
|
+
initWorkspace(root);
|
|
46
50
|
process.env.HOME = home;
|
|
47
51
|
process.env.HARNESS_STATE_HOME = stateHome;
|
|
48
52
|
process.env.HARNESS_WORKSPACE_ROOT = root;
|
|
@@ -55,13 +59,14 @@ function makeFixture() {
|
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
function seedWorkflow(
|
|
59
|
-
const
|
|
62
|
+
function seedWorkflow(rootOrFixture, sessionId) {
|
|
63
|
+
const root = typeof rootOrFixture === 'string' ? rootOrFixture : rootOrFixture.root;
|
|
64
|
+
const payload = { session_id: sessionId, cwd: root, host_id: 'opencode' };
|
|
60
65
|
const { getSessionDir } = require(path.join(ROOT, 'hooks/scripts/lib/harness-state.js'));
|
|
61
|
-
const sessionDir = getSessionDir(
|
|
66
|
+
const sessionDir = getSessionDir(root, sessionId, payload);
|
|
62
67
|
const plan = { strategySelection: 'selected', tier: 'tier2', strategy: 'iterative-single' };
|
|
63
68
|
const context = {
|
|
64
|
-
root
|
|
69
|
+
root,
|
|
65
70
|
sessionId,
|
|
66
71
|
sessionDir,
|
|
67
72
|
file: path.join(sessionDir, 'workflow-run.json'),
|
|
@@ -102,68 +107,20 @@ function writeEditState(sessionDir, values) {
|
|
|
102
107
|
}));
|
|
103
108
|
}
|
|
104
109
|
|
|
105
|
-
function
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (closed) return Promise.resolve({ done: true });
|
|
120
|
-
return new Promise(resolve => waiters.push(resolve));
|
|
121
|
-
},
|
|
122
|
-
return() { closed = true; return Promise.resolve({ done: true }); },
|
|
123
|
-
};
|
|
124
|
-
signal.addEventListener('abort', () => {
|
|
125
|
-
closed = true;
|
|
126
|
-
while (waiters.length) waiters.shift()({ done: true });
|
|
127
|
-
}, { once: true });
|
|
128
|
-
return { [Symbol.asyncIterator]: () => iterator };
|
|
129
|
-
},
|
|
130
|
-
async dispatch(value) {
|
|
131
|
-
await new Promise(resolve => {
|
|
132
|
-
const item = { value, resolve };
|
|
133
|
-
if (waiters.length) {
|
|
134
|
-
if (last) { last.resolve(); last = null; }
|
|
135
|
-
last = item;
|
|
136
|
-
waiters.shift()({ value, done: false });
|
|
137
|
-
} else queued.push(item);
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async function startPlugin(workspace) {
|
|
144
|
-
const plugin = await import(pathToFileURL(path.join(ROOT, 'opencode-plugin/index.mjs')).href);
|
|
145
|
-
const registered = new Map();
|
|
146
|
-
const sessionHooks = new Map();
|
|
147
|
-
const stream = createEventStream();
|
|
148
|
-
const dispose = await plugin.default.setup({
|
|
149
|
-
location: { directory: workspace },
|
|
150
|
-
tool: { hook: async (name, callback) => registered.set(name, callback) },
|
|
151
|
-
session: {
|
|
152
|
-
get: async ({ sessionID }) => ({ id: sessionID, location: { directory: workspace } }),
|
|
153
|
-
hook: async (name, callback) => { sessionHooks.set(name, callback); return { dispose: async () => {} }; },
|
|
154
|
-
prompt: async () => ({}),
|
|
155
|
-
context: async () => [],
|
|
156
|
-
},
|
|
157
|
-
event: { subscribe: ({ signal }) => stream.subscribe(signal) },
|
|
158
|
-
});
|
|
159
|
-
return { registered, stream, dispose };
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async function waitForIdleConsumer(predicate) {
|
|
163
|
-
const deadline = Date.now() + 5000;
|
|
164
|
-
while (!predicate()) {
|
|
165
|
-
assert.ok(Date.now() < deadline, 'asynchronous idle consumer did not complete');
|
|
166
|
-
await new Promise(resolve => setTimeout(resolve, 20));
|
|
110
|
+
async function withV2DocFixture(fn) {
|
|
111
|
+
const d = await createV2Driver();
|
|
112
|
+
const pilotSaved = Object.fromEntries(['HARNESS_WORKSPACE_ROOT', 'HARNESS_DOC_RECONCILIATION_PILOT'].map(key => [key, process.env[key]]));
|
|
113
|
+
try {
|
|
114
|
+
initWorkspace(d.workspace);
|
|
115
|
+
process.env.HARNESS_WORKSPACE_ROOT = d.workspace;
|
|
116
|
+
process.env.HARNESS_DOC_RECONCILIATION_PILOT = '1';
|
|
117
|
+
return await fn(d);
|
|
118
|
+
} finally {
|
|
119
|
+
for (const [key, value] of Object.entries(pilotSaved)) {
|
|
120
|
+
if (value === undefined) delete process.env[key];
|
|
121
|
+
else process.env[key] = value;
|
|
122
|
+
}
|
|
123
|
+
await d.teardown();
|
|
167
124
|
}
|
|
168
125
|
}
|
|
169
126
|
|
|
@@ -198,78 +155,72 @@ test('existing Stop consumer writes a refused report without qualification', ()
|
|
|
198
155
|
});
|
|
199
156
|
|
|
200
157
|
test('OpenCode capture → idle Stop whole path is refused without live qualification', async () => {
|
|
201
|
-
const fixture = makeFixture();
|
|
202
158
|
const findings = [];
|
|
203
|
-
|
|
204
|
-
|
|
159
|
+
const pilot = require(PILOT);
|
|
160
|
+
const originalAssess = pilot.assess;
|
|
161
|
+
const assessmentSessions = [];
|
|
162
|
+
pilot.assess = function (context, ...args) {
|
|
163
|
+
assessmentSessions.push(context?.sessionId);
|
|
164
|
+
return originalAssess.call(this, context, ...args);
|
|
165
|
+
};
|
|
205
166
|
try {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
tool: 'edit', sessionID: sessionId, id: 'call-1', messageID: 'message-1',
|
|
221
|
-
status: 'completed', result: nativeResult,
|
|
222
|
-
input: { filePath: path.join(fixture.root, 'docs/adr/GRPH-001.md') },
|
|
223
|
-
});
|
|
224
|
-
await plugin.registered.get('execute.after')({
|
|
225
|
-
tool: 'bash', sessionID: sessionId, id: 'call-2', messageID: 'message-2',
|
|
226
|
-
status: 'completed', error: { name: 'NativeError', message: 'native command error', code: 'NATIVE_FAILURE' },
|
|
227
|
-
input: { command: 'doc-check' },
|
|
228
|
-
});
|
|
167
|
+
await withV2DocFixture(async d => {
|
|
168
|
+
const sessionId = 'native-v2-whole-path';
|
|
169
|
+
const { sessionDir } = seedWorkflow(d.workspace, sessionId);
|
|
170
|
+
const nativeResult = { output: 'private-result-body', metadata: { exit: 0 } };
|
|
171
|
+
await d.toolHook('execute.after')({
|
|
172
|
+
tool: 'edit', sessionID: sessionId, id: 'call-1', messageID: 'message-1',
|
|
173
|
+
status: 'completed', result: nativeResult,
|
|
174
|
+
input: { filePath: path.join(d.workspace, 'docs/adr/GRPH-001.md') },
|
|
175
|
+
});
|
|
176
|
+
await d.toolHook('execute.after')({
|
|
177
|
+
tool: 'bash', sessionID: sessionId, id: 'call-2', messageID: 'message-2',
|
|
178
|
+
status: 'completed', error: { name: 'NativeError', message: 'native command error', code: 'NATIVE_FAILURE' },
|
|
179
|
+
input: { command: 'doc-check' },
|
|
180
|
+
});
|
|
229
181
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
182
|
+
const journal = path.join(sessionDir, 'opencode-captures.jsonl');
|
|
183
|
+
let records = [];
|
|
184
|
+
if (fs.existsSync(journal)) {
|
|
185
|
+
const lines = fs.readFileSync(journal, 'utf8').trim().split(/\r?\n/);
|
|
186
|
+
records = lines.map(line => JSON.parse(line));
|
|
187
|
+
}
|
|
188
|
+
const canonical = JSON.stringify(canonicalJson(nativeResult));
|
|
189
|
+
const record = records[0];
|
|
190
|
+
const errorRecord = records[1];
|
|
191
|
+
if (records.length !== 2 || !record || record.hostId !== 'opencode' || record.session_id !== sessionId || record.call_id !== 'call-1' ||
|
|
192
|
+
record.message_id !== 'message-1' || record.status !== 'completed' || record.exit !== 0 ||
|
|
193
|
+
record.cwd !== undefined || record.result_digest !== crypto.createHash('sha256').update(canonical).digest('hex') ||
|
|
194
|
+
record.result_bytes !== Buffer.byteLength(canonical) || fs.readFileSync(journal, 'utf8').includes('private-result-body')) {
|
|
195
|
+
findings.push(`native result was not retained as one host-labelled digest-only record: ${JSON.stringify(record)}`);
|
|
196
|
+
}
|
|
197
|
+
if (!errorRecord || errorRecord.hostId !== 'opencode' || errorRecord.call_id !== 'call-2' ||
|
|
198
|
+
errorRecord.error?.name !== 'NativeError' || errorRecord.error?.message !== 'native command error' ||
|
|
199
|
+
errorRecord.error?.code !== 'NATIVE_FAILURE' || errorRecord.exit === 0) {
|
|
200
|
+
findings.push(`native error was not preserved as failure without fabricated exit zero: ${JSON.stringify(errorRecord)}`);
|
|
201
|
+
}
|
|
250
202
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
203
|
+
const reportPath = path.join(sessionDir, 'doc-reconciliation-pilot.json');
|
|
204
|
+
d.emit('session.execution.succeeded', sessionId);
|
|
205
|
+
await d.waitFor(
|
|
206
|
+
() => assessmentSessions.filter(id => id === sessionId).length === 1 && fs.existsSync(reportPath),
|
|
207
|
+
{ label: 'V2 completion Stop assessment and pilot report', timeoutMs: 8000 },
|
|
208
|
+
);
|
|
209
|
+
const report = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
|
|
210
|
+
if (assessmentSessions.filter(id => id === sessionId).length !== 1) {
|
|
211
|
+
findings.push(`idle Stop dispatch count=${assessmentSessions.filter(id => id === sessionId).length}, expected exactly one`);
|
|
212
|
+
}
|
|
213
|
+
if (!report || report.pilotCredit !== false || report.pilotStatus !== 'unresolved' || !report.diagnostics?.length) {
|
|
214
|
+
findings.push(`idle did not write the actual refused/unavailable report: ${JSON.stringify(report)}`);
|
|
215
|
+
}
|
|
216
|
+
assert.deepEqual(findings, []);
|
|
217
|
+
});
|
|
262
218
|
} finally {
|
|
263
|
-
|
|
264
|
-
if (originalAssess) require(PILOT).assess = originalAssess;
|
|
265
|
-
fixture.cleanup();
|
|
266
|
-
restoreEnv();
|
|
219
|
+
pilot.assess = originalAssess;
|
|
267
220
|
}
|
|
268
221
|
});
|
|
269
222
|
|
|
270
223
|
test('session idle dispatches the real consumer once across every existing early return', async () => {
|
|
271
|
-
const fixture = makeFixture();
|
|
272
|
-
let dispose;
|
|
273
224
|
const findings = [];
|
|
274
225
|
const pilot = require(PILOT);
|
|
275
226
|
const originalAssess = pilot.assess;
|
|
@@ -279,80 +230,89 @@ test('session idle dispatches the real consumer once across every existing early
|
|
|
279
230
|
return originalAssess.call(this, context, ...args);
|
|
280
231
|
};
|
|
281
232
|
try {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
233
|
+
await withV2DocFixture(async d => {
|
|
234
|
+
const cases = [
|
|
235
|
+
['follow-up-pending', { followUpPending: true }],
|
|
236
|
+
['follow-up-delivery-pending', { followUpDeliveryPending: true, followUpMessage: 'deliver once' }],
|
|
237
|
+
['no-verification-pending', { verificationPending: false, editsSinceVerification: 0 }],
|
|
238
|
+
['verification-succeeds', { verificationPending: true, editsSinceVerification: 1 }],
|
|
239
|
+
];
|
|
240
|
+
for (const [suffix, state] of cases) {
|
|
241
|
+
const sessionId = `idle-${suffix}`;
|
|
242
|
+
const { sessionDir } = seedWorkflow(d.workspace, sessionId);
|
|
243
|
+
writeEditState(sessionDir, state);
|
|
244
|
+
const reportPath = path.join(sessionDir, 'doc-reconciliation-pilot.json');
|
|
245
|
+
d.emit('session.execution.succeeded', sessionId);
|
|
246
|
+
await d.waitFor(
|
|
247
|
+
() => assessmentSessions.filter(id => id === sessionId).length === 1 && fs.existsSync(reportPath),
|
|
248
|
+
{ label: `${suffix} V2 completion Stop assessment`, timeoutMs: 8000 },
|
|
249
|
+
);
|
|
250
|
+
const report = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
|
|
251
|
+
if (assessmentSessions.filter(id => id === sessionId).length !== 1) {
|
|
252
|
+
findings.push(`${suffix}: consumer assessment count=${assessmentSessions.filter(id => id === sessionId).length}, expected exactly one`);
|
|
253
|
+
}
|
|
254
|
+
if (!report || report.pilotCredit !== false || report.pilotStatus !== 'unresolved') {
|
|
255
|
+
findings.push(`${suffix}: expected one refused/unavailable report, received ${JSON.stringify(report)}`);
|
|
256
|
+
}
|
|
300
257
|
}
|
|
301
|
-
|
|
302
|
-
|
|
258
|
+
const cleanupSession = 'idle-no-verification-pending';
|
|
259
|
+
d.emit('session.execution.succeeded', cleanupSession);
|
|
260
|
+
await d.waitFor(
|
|
261
|
+
() => assessmentSessions.filter(id => id === cleanupSession).length === 2,
|
|
262
|
+
{ label: 'second V2 completion Stop assessment after cleanup' },
|
|
263
|
+
);
|
|
264
|
+
if (assessmentSessions.filter(id => id === cleanupSession).length !== 2) {
|
|
265
|
+
findings.push(`finally did not release the per-session idle guard for a second event: ${assessmentSessions.filter(id => id === cleanupSession).length} assessments`);
|
|
303
266
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
await plugin.stream.dispatch({ type: 'session.idle', sessionID: cleanupSession });
|
|
307
|
-
await waitForIdleConsumer(() => assessmentSessions.filter(id => id === cleanupSession).length === 2);
|
|
308
|
-
if (assessmentSessions.filter(id => id === cleanupSession).length !== 2) {
|
|
309
|
-
findings.push(`finally did not release the per-session idle guard for a second event: ${assessmentSessions.filter(id => id === cleanupSession).length} assessments`);
|
|
310
|
-
}
|
|
311
|
-
assert.deepEqual(findings, []);
|
|
267
|
+
assert.deepEqual(findings, []);
|
|
268
|
+
});
|
|
312
269
|
} finally {
|
|
313
|
-
if (dispose) await dispose();
|
|
314
270
|
pilot.assess = originalAssess;
|
|
315
|
-
fixture.cleanup();
|
|
316
|
-
restoreEnv();
|
|
317
271
|
}
|
|
318
272
|
});
|
|
319
273
|
|
|
320
274
|
test('V1/no-status, pilot-OFF, no-workflow, and Claude host controls stay fail-closed', async () => {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
275
|
+
await withV2DocFixture(async d => {
|
|
276
|
+
const positiveSession = 'v2-positive-control';
|
|
277
|
+
const { sessionDir: positiveDir } = seedWorkflow(d.workspace, positiveSession);
|
|
278
|
+
await d.toolHook('execute.after')({
|
|
279
|
+
tool: 'edit', sessionID: positiveSession, id: 'pos-call', status: 'completed',
|
|
280
|
+
result: { output: 'ok', metadata: { exit: 0 } },
|
|
281
|
+
input: { filePath: path.join(d.workspace, 'docs/adr/GRPH-001.md') },
|
|
282
|
+
});
|
|
283
|
+
assert.equal(fs.existsSync(path.join(positiveDir, 'opencode-captures.jsonl')), true, 'positive control: V2 execute.after with status creates a native capture');
|
|
284
|
+
const positiveReport = path.join(positiveDir, 'doc-reconciliation-pilot.json');
|
|
285
|
+
d.emit('session.execution.succeeded', positiveSession);
|
|
286
|
+
await d.waitFor(() => fs.existsSync(positiveReport), { label: 'positive control pilot report', timeoutMs: 8000 });
|
|
326
287
|
|
|
327
288
|
const v1Session = 'v1-no-status';
|
|
328
|
-
const { sessionDir: v1Dir } = seedWorkflow(
|
|
329
|
-
await
|
|
330
|
-
tool: 'edit', sessionID: v1Session, id: 'v1-call', input: { filePath: path.join(
|
|
289
|
+
const { sessionDir: v1Dir } = seedWorkflow(d.workspace, v1Session);
|
|
290
|
+
await d.toolHook('execute.after')({
|
|
291
|
+
tool: 'edit', sessionID: v1Session, id: 'v1-call', input: { filePath: path.join(d.workspace, 'docs/adr/GRPH-001.md') },
|
|
331
292
|
});
|
|
293
|
+
await d.settled({ quietMs: 100 });
|
|
332
294
|
assert.equal(fs.existsSync(path.join(v1Dir, 'opencode-captures.jsonl')), false, 'V1/no-status output must not create a native capture');
|
|
333
295
|
|
|
334
296
|
const noWorkflow = 'no-workflow';
|
|
335
297
|
const { getSessionDir } = require(path.join(ROOT, 'hooks/scripts/lib/harness-state.js'));
|
|
336
|
-
const noWorkflowDir = getSessionDir(
|
|
337
|
-
|
|
298
|
+
const noWorkflowDir = getSessionDir(d.workspace, noWorkflow, { session_id: noWorkflow, cwd: d.workspace, host_id: 'opencode' });
|
|
299
|
+
d.emit('session.execution.succeeded', noWorkflow);
|
|
300
|
+
await d.settled({ quietMs: 150 });
|
|
338
301
|
assert.equal(fs.existsSync(path.join(noWorkflowDir, 'doc-reconciliation-pilot.json')), false, 'no workflow must not write a pilot report');
|
|
339
302
|
|
|
340
303
|
const offSession = 'pilot-off';
|
|
341
|
-
const { sessionDir: offDir } = seedWorkflow(
|
|
304
|
+
const { sessionDir: offDir } = seedWorkflow(d.workspace, offSession);
|
|
342
305
|
process.env.HARNESS_DOC_RECONCILIATION_PILOT = '0';
|
|
343
|
-
|
|
306
|
+
d.emit('session.execution.succeeded', offSession);
|
|
307
|
+
await d.settled({ quietMs: 150 });
|
|
344
308
|
assert.equal(fs.existsSync(path.join(offDir, 'doc-reconciliation-pilot.json')), false, 'pilot OFF must not write a reconciliation report');
|
|
345
309
|
|
|
346
310
|
const { createClaudeOriginProvider } = require(path.join(ROOT, 'hooks/scripts/lib/doc-reconciliation-provider.js'));
|
|
347
311
|
const claudeProvider = createClaudeOriginProvider({ hostId: 'opencode', sessionId: 'native-host-control' });
|
|
348
|
-
const claudeContext = claudeProvider.resolveContext({ workspaceRoot:
|
|
312
|
+
const claudeContext = claudeProvider.resolveContext({ workspaceRoot: d.workspace });
|
|
349
313
|
assert.equal(claudeContext.status, 'unavailable', 'OpenCode must not enter through Claude provider semantics');
|
|
350
314
|
assert.ok(claudeContext.diagnostics.some(item => item.code === 'unsupported-host'));
|
|
351
|
-
}
|
|
352
|
-
if (dispose) await dispose();
|
|
353
|
-
fixture.cleanup();
|
|
354
|
-
restoreEnv();
|
|
355
|
-
}
|
|
315
|
+
});
|
|
356
316
|
});
|
|
357
317
|
|
|
358
318
|
const OPENCODE_SESSION = 'provider-session';
|