Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(sentinel): refresh health through sentinel run [A6,H16]

Corey Olson54b83e6fe275
diff --git a/src/serve-sentinel.js b/src/serve-sentinel.js
index 2ead76ba..d3bcf200 100644
--- a/src/serve-sentinel.js
+++ b/src/serve-sentinel.js
@@ -14,10 +14,10 @@ function sentinelRunsFor(root) {
return healthSentinelEnabled(loadConfig(root));
}
-/** Run the ordinary ordered resume path in one owned child and drain it on view shutdown. */
-function resumeBoard(root, signal) {
+/** Run the ordinary ordered sentinel path in one owned child and drain it on view shutdown. */
+function refreshBoard(root, signal) {
return new Promise((resolve, reject) => {
- const child = spawn(process.execPath, [CLI, 'resume', '--json'], {
+ const child = spawn(process.execPath, [CLI, 'sentinel', 'run', '--json'], {
cwd: root, env: process.env, stdio: 'ignore', signal,
});
let timer;
@@ -30,14 +30,14 @@ function resumeBoard(root, signal) {
child.once('error', error => { if (error.name !== 'AbortError') reject(error); });
child.once('close', code => {
clearTimeout(timer); signal.removeEventListener('abort', stopping);
- if (code && !signal.aborted) reject(new Error(`health sentinel resume exited ${code}`));
+ if (code && !signal.aborted) reject(new Error(`health sentinel refresh exited ${code}`));
else resolve();
});
});
}
-/** Start after the view listens; scans use ordinary resume so each board's off switch and ordering apply. */
-export function startServeSentinel({ projectRoot, run = resumeBoard, projects = listProjects,
+/** Start after the view listens; scans use the ordinary sentinel command so each board's off switch and ordering apply. */
+export function startServeSentinel({ projectRoot, run = refreshBoard, projects = listProjects,
every = setInterval, cancel = clearInterval, enabled = sentinelRunsFor, onError = () => {} } = {}) {
const lifetime = new AbortController();
let pending = null;
diff --git a/test/health-sentinel-background.test.js b/test/health-sentinel-background.test.js
index 9f20d46c..df075cd9 100644
--- a/test/health-sentinel-background.test.js
+++ b/test/health-sentinel-background.test.js
@@ -84,7 +84,7 @@ import { frozenCriterion, loadSpec } from '../src/spec.js';
test('the actual background sentinel scans once, honors off switches and drains its child [A6,H16]', { timeout: 60_000 }, async t => { // budget: private worker startup, explicit callback probes and graceful owned shutdown, not a latency target.
const { box, repo, port } = await backgroundBox(t, 'sentinel-integration');
const probe = join(box.dir, 'sentinel-probe.mjs'), log = join(box.dir, 'sentinel-probe.jsonl');
- const hold = join(box.dir, 'hold-next-resume');
+ const hold = join(box.dir, 'hold-next-sentinel');
writeFileSync(probe, [
"import { appendFileSync, existsSync } from 'node:fs';",
`const log=${JSON.stringify(log)},hold=${JSON.stringify(hold)};`,
@@ -93,7 +93,7 @@ test('the actual background sentinel scans once, honors off switches and drains
"globalThis.setInterval=(callback,ms,...args)=>{const timer=every(callback,ms,...args);if(ms===600000){tick=callback;timers.set(timer,ms);record({kind:'sentinel-interval',ms});}return timer;};",
"globalThis.clearInterval=timer=>{if(timers.has(timer))record({kind:'sentinel-cancel',ms:timers.get(timer)});return cancel(timer);};",
"if(process.argv.includes('view'))process.on('SIGUSR2',async()=>{record({kind:'explicit-tick-start'});try{if(!tick)throw new Error('No sentinel callback');await tick();record({kind:'explicit-tick-finished'});}catch(error){record({kind:'explicit-tick-failed',error:error.message});}});",
- "if(process.argv.includes('resume')&&existsSync(hold)){record({kind:'held-resume'});await new Promise(done=>setTimeout(done,60000));}", // budget: a test-only hold before CLI execution, terminated by the observer's owned shutdown.
+ "if(process.argv.includes('sentinel')&&process.argv.includes('run')&&existsSync(hold)){record({kind:'held-sentinel'});await new Promise(done=>setTimeout(done,60000));}", // budget: a test-only hold before CLI execution, terminated by the observer's owned shutdown.
].join('\n'));
box.env.NODE_OPTIONS = `${box.env.NODE_OPTIONS ?? ''} --import=${probe}`.trim();
const init = box.run(repo, 'init');
@@ -152,7 +152,7 @@ test('the actual background sentinel scans once, honors off switches and drains
writeFileSync(settingsFile, JSON.stringify(settings));
await tick();
const first = receipts();
- assert.equal(first.notices.length, 2, 'the actual worker child resumes the real board and publishes its finding');
+ assert.equal(first.notices.length, 2, 'the actual worker child scans the real board and publishes its finding');
assert.deepEqual(first.notices.map(row => row.shout_to).sort(), ['coordinator', builder].sort());
assert.equal(first.scans.length, 1);
assert.ok(first.notices.every(row => row.shout_text.includes('CLAIM_LAPSED')));
@@ -165,15 +165,15 @@ test('the actual background sentinel scans once, honors off switches and drains
assert.equal(receipts().notices.filter(row => row.shout_text.startsWith('Resolved:')).length, 2);
writeFileSync(hold, 'hold the next owned child before CLI execution');
process.kill(worker.pid, 'SIGUSR2');
- await until(() => observations().some(row => row.kind === 'held-resume'), 'the observer has one actual owned child in flight');
- const child = observations().find(row => row.kind === 'held-resume');
+ await until(() => observations().some(row => row.kind === 'held-sentinel'), 'the observer has one actual owned child in flight');
+ const child = observations().find(row => row.kind === 'held-sentinel');
assert.equal(child.cwd, repo);
assert.equal(child.uid, process.getuid?.());
assert.ok(alive(child.pid));
await stopView(worker.pid);
- await until(() => !alive(child.pid), 'view shutdown drains the exact active resume child');
+ await until(() => !alive(child.pid), 'view shutdown drains the exact active sentinel child');
assert.equal(workerEvents('sentinel-cancel').length, 1, 'view close cancels its one timer');
console.log('BACKGROUND_SENTINEL_PROOF', JSON.stringify({ workerPid: worker.pid, childPid: child.pid, timers: 1,
intervalMs: 600_000, explicitCallbackInvocations: workerEvents('explicit-tick-start').length,
- notices: 4, ownedChildDrained: true, scope: 'actual init/detached worker and child resume; native schedule unchanged; no elapsed ten-minute claim' }));
+ notices: 4, ownedChildDrained: true, scope: 'actual init/detached worker and child sentinel run; native schedule unchanged; no elapsed ten-minute claim' }));
});