fix(mission): stop command loop on terminal state
This commit is contained in:
1 parent
a5667374bf
commit
58b66b1e60
2 files changed
+28
-2
No files matched your search
@@ -397,6 +397,28 @@ describe('Wedged-dispatch timeout backstop', () => {
|
|||||||
expect(op.getSummary().failedTasks).toBe(1);
|
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 () => {
|
it('a wedged mission reaches phase advancement once the per-dispatch backstop fires', async () => {
|
||||||
// Tiny backstop so the test is fast and deterministic.
|
// Tiny backstop so the test is fast and deterministic.
|
||||||
const prev = process.env.T3MP3ST_TASK_TIMEOUT_MS;
|
const prev = process.env.T3MP3ST_TASK_TIMEOUT_MS;
|
||||||
|
|||||||
+6
-2
@@ -496,8 +496,12 @@ export class TempestCommand extends EventEmitter<CommandEvents> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Forward mission events
|
// Forward mission events
|
||||||
this.mission.on('mission:completed', (_mission) => {
|
this.mission.on('mission:completed', () => {
|
||||||
// Could trigger reporting here
|
this.stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.mission.on('mission:aborted', () => {
|
||||||
|
this.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.mission.on('mission:phase_changed', ({ mission, newPhase }) => {
|
this.mission.on('mission:phase_changed', ({ mission, newPhase }) => {
|
||||||
|
|||||||
Reference in new issue
Block a user