Pinned pi SDK 0.85.1 bridge, Python supervisor, artifact exporter, scripted backend peer, image checks and boundary checks under agent/**. Review findings F1-F3 are recorded in docs/implementation/PI_AGENT_REVIEW.md.
39 lines
2.6 KiB
TypeScript
39 lines
2.6 KiB
TypeScript
import { spawn, execFileSync } from 'node:child_process';
|
|
import assert from 'node:assert/strict';
|
|
import { dockerFlags, runPeer } from './fake-backend.js';
|
|
const image = process.argv[2] || 'confluence-pi-agent:rev1';
|
|
const security = JSON.parse(execFileSync('docker', ['info', '--format', '{{json .SecurityOptions}}'], { encoding: 'utf8' }));
|
|
assert(security.includes('name=rootless'), 'A rootless Docker daemon is required');
|
|
console.log('rootless daemon verified');
|
|
for (const mode of ['happy', 'happy', 'no-artifacts', 'empty-file', 'skip', 'background', 'isolation', 'isolation']) {
|
|
const result = await runPeer({ image, mode });
|
|
assert(result.complete, JSON.stringify(result.failure) + result.stderr);
|
|
console.log(`PASS image ${mode}`);
|
|
}
|
|
for (const mode of ['upstream-failure', 'bad-reply', 'duplicate', 'eof-model', 'eof-collection', 'eof-begin', 'eof-end', 'context-limit', 'output-limit', 'stalled-model', 'stalled-collection', 'stop-bridge', 'failure-during-collection']) {
|
|
const started = Date.now();
|
|
const result = await runPeer({ image, mode, timeoutMs: ['stalled-model', 'stalled-collection', 'stop-bridge'].includes(mode) ? 1500 : 10000 });
|
|
assert(!result.complete);
|
|
if (mode === 'failure-during-collection') assert.deepEqual(result.transcript.filter(f => f.id.startsWith('a_')).slice(-2).map(f => f.type), ['collection_start', 'error']);
|
|
if (['stalled-model', 'stalled-collection', 'stop-bridge'].includes(mode)) assert(Date.now() - started < 5000, 'Independent deadline failed');
|
|
console.log(`PASS image failure ${mode}`);
|
|
}
|
|
// An unchanged 180-second process-start deadline, with no start frame at all.
|
|
const name = `pi-no-start-${process.pid}`;
|
|
const child = spawn('docker', ['run', '--name', name, ...dockerFlags, image], { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
child.stdout.resume(); child.stderr.resume();
|
|
const started = Date.now();
|
|
const timeout = setTimeout(() => { execFileSync('docker', ['rm', '-f', name]); }, 190000);
|
|
console.log('checking unchanged 180-second missing-start deadline');
|
|
const progress = setInterval(() => console.log(`missing-start check: ${Math.floor((Date.now() - started) / 1000)}s elapsed`), 30000);
|
|
try {
|
|
const code = await new Promise(resolve => child.on('exit', resolve));
|
|
assert.notEqual(code, 0);
|
|
assert(Date.now() - started >= 175000 && Date.now() - started < 185000, 'Missing-start lifetime was not enforced');
|
|
console.log('PASS image missing-start lifetime');
|
|
} finally {
|
|
clearTimeout(timeout); clearInterval(progress); child.stdin.destroy();
|
|
spawn('docker', ['rm', '-f', name], { stdio: 'ignore' });
|
|
}
|
|
console.log(execFileSync('docker', ['image', 'inspect', image, '--format', '{{.Id}}'], { encoding: 'utf8' }).trim());
|