Oregami
Repositories/oxedyne/daimond

oxedyne/daimond/dev/shot_governor.mjs

2.0 KiB, 1 run

created by r2519314175:153, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1// shot_governor.mjs — a visual capture of the spend gate in the real app.
2//
3// Drives a Diamond conductor into a large fan-out (60 spawn_agent calls in one
4// steer) and captures the predictive gate modal it raises BEFORE any worker
5// runs — the "fifty agents in a blink" case, stopped at the door. Then a small
6// fan-out to show it clears silently.
7//
8// Needs dev/serve.mjs (DAIMOND_PORT, default 8777) and dev/mockllm.mjs
9// (DAIMOND_MOCK_PORT, default 9099).
10import { open, shot } from './harness.mjs';
11
12const s = await open({ name: 'governor-shot', signIn: true, connect: true });
13const { page } = s;
14
15// A fresh Diamond through the real UI.
16await page.click('#new-diamond-btn');
17await page.waitForSelector('.dlg-input', { timeout: 8000 });
18await page.fill('.dlg-input', 'Audit the codebase');
19await page.click('.dlg-ok');
20await page.waitForSelector('#steer-input', { timeout: 10000 });
21await page.waitForTimeout(400);
22
23// A conductor turn that dispatches 60 agents at once.
24const specs = [];
25for (let i = 0; i < 60; i++) specs.push(`spawn_agent {"name":"a${i}","task":"inspect module ${i}"}`);
26const steer = '@tools ' + specs.join(' ;; ');
27await page.fill('#steer-input', steer);
28await page.click('#steer-send');
29
30// The gate should raise the app's confirm modal before dispatch.
31const gate = await page.waitForSelector('.dlg-card, .dialog, [class*="dlg"]', { timeout: 15000 }).catch(() => null);
32await page.waitForTimeout(400);
33const modalText = await page.evaluate(() => {
34 const el = document.querySelector('.dlg-card, .dialog, [class*="dlg"]');
35 return el ? el.innerText.replace(/\s+/g, ' ').trim() : '(no modal found)';
36});
37console.log('GATE MODAL:', modalText);
38await shot(s, 'governor-gate-60');
39
40// Decline it: nothing should be dispatched.
41const cancel = await page.$('.dlg-cancel, .dlg-no, button[data-role="cancel"]');
42if (cancel) await cancel.click();
43else await page.keyboard.press('Escape');
44await page.waitForTimeout(500);
45await shot(s, 'governor-after-decline');
46
47await s.close();
48console.log('done — screenshots written');