import assert from 'node:assert/strict'; import test from 'node:test'; import { buildPiggySystemPrompt } from '../src/agent/prompt'; import { assertPigToolBoundary } from '../src/chat'; /** * What is left of this file after the harness swap. * * The hand-rolled loop that used to be tested here — the SSE reader, the * tool-call assembler, the retry budget — belongs to Prime Agent now, and its * tests went with it. Two things did not move, and both are the sort that fail * silently rather than loudly. */ test('ambient coding tools are rejected at the boundary', () => { assert.throws( () => assertPigToolBoundary([{ name: 'pig_get_idle_capacity' }, { name: 'bash' }]), /outside the PIG tool boundary/, ); // A tool that starts pig_ but reads like a filesystem is refused too: the // prefix is a convention, and a convention alone is not a boundary. assert.throws(() => assertPigToolBoundary([{ name: 'pig_file_write' }]), /outside the PIG tool boundary/); assert.throws(() => assertPigToolBoundary([{ name: 'pig_shell_exec' }]), /outside the PIG tool boundary/); assert.doesNotThrow(() => assertPigToolBoundary([{ name: 'pig_get_idle_capacity' }, { name: 'pig_log_activity' }]), ); }); test('the prompt Piggy actually runs on still states the units rule and the margin definitions', () => { const prompt = buildPiggySystemPrompt({ mode: 'read_only' }); // The whole point: 189 spoken as "$189 per GPU-hour" is a hundredfold error // on the number everyone in the room is watching. This assertion survived the // move from the retired chat loop to `agent/prompt.ts` because the failure it // guards against did not. assert.match(prompt, /ends in Cents is an integer number of US cents/i); assert.match(prompt, /costPerGpuHourCents: 189 is \$1\.89 per GPU-hour/); assert.match(prompt, /ends in Pct, and utilisation, is a share between 0 and 1/); // Margin against sold hours only would report a losing block as healthy. assert.match(prompt, /revenue minus the FULL cost of the commitment/); assert.match(prompt, /REMAINING unsold hours must fetch/); // And the stock harness preamble, which introduces a coding assistant with a // filesystem, must be gone rather than merely appended to. assert.match(prompt, /no shell, filesystem, browser, code execution, or hidden tools/i); assert.doesNotMatch(prompt, /coding assistant/i); });