gestalt-mobile 0.68.0 → 0.68.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -591,6 +591,143 @@ async function orgPlanActivationFixture() {
|
|
|
591
591
|
}
|
|
592
592
|
describe('production composition', () => {
|
|
593
593
|
describeCompositionConcern('autopilot', () => {
|
|
594
|
+
it('starts one root recovery after an executor wake encounters a superseded issued command', async () => {
|
|
595
|
+
const timers = [];
|
|
596
|
+
let coordinator;
|
|
597
|
+
let childWorking = true;
|
|
598
|
+
let rootThreadId = 'thread-1';
|
|
599
|
+
const fixture = await createProductionAutopilotFixture({
|
|
600
|
+
activitySchedule: () => () => { },
|
|
601
|
+
autopilotActivity: (sessionId) => {
|
|
602
|
+
const observedAt = new Date().toISOString();
|
|
603
|
+
return {
|
|
604
|
+
sessionId,
|
|
605
|
+
rootThreadId,
|
|
606
|
+
root: {
|
|
607
|
+
state: 'idle',
|
|
608
|
+
reason: 'turnCompleted',
|
|
609
|
+
observedAt,
|
|
610
|
+
lastActivityAt: observedAt,
|
|
611
|
+
},
|
|
612
|
+
subagents: [
|
|
613
|
+
{
|
|
614
|
+
id: 'child-1',
|
|
615
|
+
threadId: 'child-1',
|
|
616
|
+
taskPath: '/root/l1',
|
|
617
|
+
canonicalTaskName: 'l1',
|
|
618
|
+
canonicalPosition: 'L1',
|
|
619
|
+
continuationGeneration: 1,
|
|
620
|
+
outcome: 'partial',
|
|
621
|
+
ownedProcesses: [],
|
|
622
|
+
state: childWorking ? 'working' : 'idle',
|
|
623
|
+
reason: childWorking ? 'turnActive' : 'turnCompleted',
|
|
624
|
+
observedAt,
|
|
625
|
+
lastActivityAt: observedAt,
|
|
626
|
+
},
|
|
627
|
+
],
|
|
628
|
+
aggregateSubagents: childWorking ? 'working' : 'idle',
|
|
629
|
+
confidence: 'fresh',
|
|
630
|
+
};
|
|
631
|
+
},
|
|
632
|
+
onAutopilotCoordinator: (value) => {
|
|
633
|
+
coordinator = value;
|
|
634
|
+
},
|
|
635
|
+
autopilotSchedule: (callback) => {
|
|
636
|
+
const timer = { callback, cancelled: false, fired: false };
|
|
637
|
+
timers.push(timer);
|
|
638
|
+
return () => {
|
|
639
|
+
timer.cancelled = true;
|
|
640
|
+
};
|
|
641
|
+
},
|
|
642
|
+
});
|
|
643
|
+
onTestFinished(() => fixture.app.close());
|
|
644
|
+
rootThreadId = (await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json()
|
|
645
|
+
.threadId;
|
|
646
|
+
expect(coordinator.reconcileExecutorBinding(fixture.sessionId).status).toBe('ready');
|
|
647
|
+
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
648
|
+
onTestFinished(() => database.close());
|
|
649
|
+
const store = new SqliteAutopilotStore(database);
|
|
650
|
+
const state = store.find(fixture.sessionId);
|
|
651
|
+
const executor = state.executor;
|
|
652
|
+
const commandId = createHash('sha256')
|
|
653
|
+
.update(JSON.stringify([
|
|
654
|
+
state.planIdentity,
|
|
655
|
+
state.planFingerprint,
|
|
656
|
+
executor.canonicalPosition,
|
|
657
|
+
executor.canonicalTaskName,
|
|
658
|
+
executor.taskPath,
|
|
659
|
+
executor.threadId,
|
|
660
|
+
2,
|
|
661
|
+
'partial',
|
|
662
|
+
]))
|
|
663
|
+
.digest('hex');
|
|
664
|
+
store.save({
|
|
665
|
+
...state,
|
|
666
|
+
executor: {
|
|
667
|
+
...executor,
|
|
668
|
+
commands: [
|
|
669
|
+
{
|
|
670
|
+
commandId,
|
|
671
|
+
status: 'superseded',
|
|
672
|
+
planIdentity: state.planIdentity,
|
|
673
|
+
planFingerprint: state.planFingerprint,
|
|
674
|
+
canonicalPosition: executor.canonicalPosition,
|
|
675
|
+
canonicalTaskName: executor.canonicalTaskName,
|
|
676
|
+
taskPath: executor.taskPath,
|
|
677
|
+
threadId: executor.threadId,
|
|
678
|
+
generation: 2,
|
|
679
|
+
trigger: 'partial',
|
|
680
|
+
createdAt: state.updatedAt,
|
|
681
|
+
updatedAt: state.updatedAt,
|
|
682
|
+
},
|
|
683
|
+
],
|
|
684
|
+
},
|
|
685
|
+
});
|
|
686
|
+
expect(coordinator.registerProactiveWait(fixture.sessionId, {
|
|
687
|
+
id: 'executor-report',
|
|
688
|
+
leaseId: 'executor-lease',
|
|
689
|
+
maxWaitMs: 60_000,
|
|
690
|
+
wakeConditions: ['executorChanged'],
|
|
691
|
+
})).toBe(true);
|
|
692
|
+
childWorking = false;
|
|
693
|
+
coordinator.activityChanged(fixture.sessionId);
|
|
694
|
+
const starts = () => fixture.handles
|
|
695
|
+
.flatMap((handle) => handle.requests)
|
|
696
|
+
.filter((request) => request.method === 'turn/start');
|
|
697
|
+
for (let attempt = 0; attempt < 8 && starts().length === 0; attempt++) {
|
|
698
|
+
const timer = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
699
|
+
expect(timer).toBeDefined();
|
|
700
|
+
timer.fired = true;
|
|
701
|
+
timer.callback();
|
|
702
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
703
|
+
}
|
|
704
|
+
await vi.waitFor(() => expect(starts()).toHaveLength(1));
|
|
705
|
+
expect(starts()[0].params.threadId).toBe(rootThreadId);
|
|
706
|
+
expect(store.find(fixture.sessionId).executor.commands[0]).toMatchObject({
|
|
707
|
+
commandId,
|
|
708
|
+
status: 'superseded',
|
|
709
|
+
});
|
|
710
|
+
for (const timer of timers.filter((candidate) => candidate.fired))
|
|
711
|
+
timer.callback();
|
|
712
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
713
|
+
expect(starts()).toHaveLength(1);
|
|
714
|
+
const trace = exportControlPlaneTrace(join(fixture.dataDir, 'relay.sqlite'), fixture.sessionId);
|
|
715
|
+
const wake = trace.events.find((event) => event.type === 'autopilot.wait-woken');
|
|
716
|
+
expect(wake.payload.leaseId).toBe('executor-lease');
|
|
717
|
+
const transitions = trace.events
|
|
718
|
+
.filter((event) => event.sequence > wake.sequence &&
|
|
719
|
+
[
|
|
720
|
+
'autopilot.continuation-scheduled',
|
|
721
|
+
'autopilot.control-issued',
|
|
722
|
+
'autopilot.turn-started',
|
|
723
|
+
].includes(event.type))
|
|
724
|
+
.map((event) => event.type);
|
|
725
|
+
expect(transitions).toEqual([
|
|
726
|
+
'autopilot.continuation-scheduled',
|
|
727
|
+
'autopilot.control-issued',
|
|
728
|
+
'autopilot.turn-started',
|
|
729
|
+
]);
|
|
730
|
+
});
|
|
594
731
|
it('persists a bounded executor after 64 exited results and new active work, including a plan watcher update', async () => {
|
|
595
732
|
const handles = [];
|
|
596
733
|
const launch = liveAppServer(handles);
|
|
@@ -3122,11 +3122,14 @@ export class AutopilotCoordinator {
|
|
|
3122
3122
|
if (this.authoritativeExecutorActive(state, retained.plan, this.deps.activity(state.sessionId)))
|
|
3123
3123
|
return false;
|
|
3124
3124
|
const planFingerprint = fingerprint(retained.plan);
|
|
3125
|
-
// Issued is not accepted. A
|
|
3126
|
-
//
|
|
3127
|
-
//
|
|
3128
|
-
//
|
|
3129
|
-
|
|
3125
|
+
// Issued is not accepted. A plan change can supersede that command, then
|
|
3126
|
+
// return to the same fingerprint after dependency repair. Neither that
|
|
3127
|
+
// transition nor a later wait resolves the original dispatch ambiguity.
|
|
3128
|
+
// Hand diagnosis back to root instead of selecting a command that replay
|
|
3129
|
+
// protection will refuse to issue again. Proven unissued commands remain
|
|
3130
|
+
// eligible for a new fenced attempt.
|
|
3131
|
+
return Boolean(executor.commands?.some((command) => (command.status === 'issued' ||
|
|
3132
|
+
(command.status === 'superseded' && !command.supersededBeforeIssue)) &&
|
|
3130
3133
|
!command.processAction &&
|
|
3131
3134
|
command.planIdentity === retained.identity &&
|
|
3132
3135
|
command.planFingerprint === planFingerprint &&
|