import test from 'node:test'; import assert from 'node:assert/strict'; import { runPeer } from '../dev/fake-backend.js'; for (const mode of ['happy', 'no-artifacts', 'empty-file', 'skip', 'delayed', 'background', 'spaces', 'confluence-error']) { test(`real SDK and native tools over public wire: ${mode}`, async () => { assert((await runPeer({ mode })).complete); }); } for (const mode of ['upstream-failure', 'bad-reply', 'duplicate', 'eof-model', 'context-limit', 'output-limit', 'zero-text']) { test(`scripted peer failure: ${mode}`, async () => { const result = await runPeer({ mode }); assert(!result.complete); if (mode !== 'eof-model') assert(result.failure, result.stderr); assert(!JSON.stringify(result.failure).includes('DUMMY_PRIVATE')); }); } test('host supervisor leaves sibling processes alive', async t => { const { spawn } = await import('node:child_process'); const sibling = spawn('sleep', ['10']); t.after(() => sibling.kill('SIGTERM')); assert((await runPeer()).complete); assert.equal(sibling.exitCode, null); assert.equal(sibling.signalCode, null); }); test('failure entrypoint flushes an active large line and error through a slow peer', async () => { const result = await runPeer({ mode: 'failure-during-collection' }); assert(!result.complete); assert.equal(result.failure.code, 'invalid_input'); const outgoing = result.transcript.filter(f => f.id.startsWith('a_')); assert.deepEqual(outgoing.slice(-2).map(f => f.type), ['collection_start', 'error']); assert(outgoing.at(-2).payload.markdown.length > 1024 * 1024); });