Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: cover malformed startup termination guards

Adam Eivy5f1de5d32a40
diff --git a/server/cos-runner/tuiSentinel.test.js b/server/cos-runner/tuiSentinel.test.js
index 6b067729d6..9b14c71209 100644
--- a/server/cos-runner/tuiSentinel.test.js
+++ b/server/cos-runner/tuiSentinel.test.js
@@ -87,9 +87,9 @@ async function spawnTui(sentinel = {}, { trackPromptSubmission = true } = {}) {
await routes.get('/agents')({}, response);
return response.json.mock.calls[0][0][0];
};
- const stopStartup = async () => {
- const response = { json: vi.fn() };
- await routes.get('/terminate/:agentId')({ params: { agentId: 'agent-1' }, body: { onlyIfPromptUnsubmitted: true } }, response);
+ const stopStartup = async (onlyIfPromptUnsubmitted = true) => {
+ const response = { json: vi.fn(), status: vi.fn().mockReturnThis() };
+ await routes.get('/terminate/:agentId')({ params: { agentId: 'agent-1' }, body: { onlyIfPromptUnsubmitted } }, response);
return response.json.mock.calls[0][0];
};
return { access, child, stopWatching, fireSentinel, socket, listing, stopStartup, killProcessTree };
@@ -135,6 +135,12 @@ describe('cos-runner TUI startup recovery receipt', () => {
expect(await run.stopStartup()).toMatchObject({ terminated: false });
expect(run.killProcessTree).not.toHaveBeenCalled();
});
+
+ it('rejects a malformed guard instead of falling through to unconditional termination', async () => {
+ const run = await spawnTui();
+ expect(await run.stopStartup('true')).toMatchObject({ error: expect.stringContaining('onlyIfPromptUnsubmitted') });
+ expect(run.killProcessTree).not.toHaveBeenCalled();
+ });
});
describe('cos-runner TUI completion sentinel (#3202)', () => {