fix(mission): stop command loop on terminal state

This commit is contained in:
Tyson Rudd committed 2026-07-05 21:19:59 -06:00
1 parent a5667374bf
commit 58b66b1e60
2 files changed
+28 -2

No files matched your search

+22
View File
@@ -397,6 +397,28 @@ describe('Wedged-dispatch timeout backstop', () => {
expect(op.getSummary().failedTasks).toBe(1);
});
it('mission completion stops the command loop so status/timer do not stay active', async () => {
const mod = await import('../index.js');
const command = new mod.TempestCommand({
name: 'Lifecycle Op',
llm: { provider: 'mock', model: 'mock-model' },
});
let stopped = false;
command.on('command:stopped', () => { stopped = true; });
command.start();
const mission = command.mission.getActiveMission();
expect(mission).toBeDefined();
expect(command.getStatus().running).toBe(true);
command.mission.completeMission(mission!.id);
expect(command.getStatus().running).toBe(false);
expect(command.mission.getActiveMission()).toBeUndefined();
expect(stopped).toBe(true);
});
it('a wedged mission reaches phase advancement once the per-dispatch backstop fires', async () => {
// Tiny backstop so the test is fast and deterministic.
const prev = process.env.T3MP3ST_TASK_TIMEOUT_MS;
+6 -2
View File
@@ -496,8 +496,12 @@ export class TempestCommand extends EventEmitter<CommandEvents> {
});
// Forward mission events
this.mission.on('mission:completed', (_mission) => {
// Could trigger reporting here
this.mission.on('mission:completed', () => {
this.stop();
});
this.mission.on('mission:aborted', () => {
this.stop();
});
this.mission.on('mission:phase_changed', ({ mission, newPhase }) => {