gestalt-mobile 0.44.3 → 0.44.4
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.
|
@@ -2104,6 +2104,84 @@ describe('production composition', () => {
|
|
|
2104
2104
|
.filter((call) => call === 'turn/start')).toHaveLength(1));
|
|
2105
2105
|
await fixture.app.close();
|
|
2106
2106
|
});
|
|
2107
|
+
it('continues the same unloaded executor once after authoritative roster recovery', async () => {
|
|
2108
|
+
const handles = [];
|
|
2109
|
+
const launch = liveAppServer(handles);
|
|
2110
|
+
let unavailable = true;
|
|
2111
|
+
const timers = [];
|
|
2112
|
+
const fixture = await createProductionAutopilotFixture({
|
|
2113
|
+
activitySchedule: () => () => { },
|
|
2114
|
+
autopilotSchedule: (callback) => {
|
|
2115
|
+
const timer = { callback, cancelled: false, fired: false };
|
|
2116
|
+
timers.push(timer);
|
|
2117
|
+
return () => {
|
|
2118
|
+
timer.cancelled = true;
|
|
2119
|
+
};
|
|
2120
|
+
},
|
|
2121
|
+
launchAppServer: () => {
|
|
2122
|
+
const server = launch();
|
|
2123
|
+
handles.at(-1).respond = (method) => {
|
|
2124
|
+
if (method === 'thread/list' && unavailable)
|
|
2125
|
+
throw new Error('RPC_DOWN');
|
|
2126
|
+
if (method === 'thread/list')
|
|
2127
|
+
return {
|
|
2128
|
+
data: [
|
|
2129
|
+
{
|
|
2130
|
+
id: 'preserved-executor',
|
|
2131
|
+
status: { type: 'notLoaded' },
|
|
2132
|
+
source: { subAgent: { thread_spawn: { agent_path: '/root/l1' } } },
|
|
2133
|
+
},
|
|
2134
|
+
],
|
|
2135
|
+
};
|
|
2136
|
+
if (method === 'thread/backgroundTerminals/list')
|
|
2137
|
+
throw new CodexJsonRpcError(-32600, 'thread not found: preserved-executor');
|
|
2138
|
+
return undefined;
|
|
2139
|
+
};
|
|
2140
|
+
return server;
|
|
2141
|
+
},
|
|
2142
|
+
});
|
|
2143
|
+
onTestFinished(() => fixture.app.close());
|
|
2144
|
+
await vi.waitFor(async () => {
|
|
2145
|
+
expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json()).toMatchObject({ autopilot: { enabled: true, reason: 'reconcileFailed' } });
|
|
2146
|
+
});
|
|
2147
|
+
unavailable = false;
|
|
2148
|
+
await fixture.app.inject({
|
|
2149
|
+
method: 'POST',
|
|
2150
|
+
url: `/api/sessions/${fixture.sessionId}/activity/refresh`,
|
|
2151
|
+
});
|
|
2152
|
+
const starts = () => handles
|
|
2153
|
+
.flatMap((handle) => handle.requests)
|
|
2154
|
+
.filter((request) => request.method === 'turn/start');
|
|
2155
|
+
await vi.waitFor(async () => {
|
|
2156
|
+
expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json()).toMatchObject({
|
|
2157
|
+
agentActivity: {
|
|
2158
|
+
confidence: 'fresh',
|
|
2159
|
+
subagents: [
|
|
2160
|
+
{
|
|
2161
|
+
id: 'preserved-executor',
|
|
2162
|
+
canonicalPosition: 'L1',
|
|
2163
|
+
},
|
|
2164
|
+
],
|
|
2165
|
+
},
|
|
2166
|
+
autopilot: { enabled: true },
|
|
2167
|
+
});
|
|
2168
|
+
expect(timers.some((timer) => !timer.cancelled && !timer.fired)).toBe(true);
|
|
2169
|
+
});
|
|
2170
|
+
for (let attempt = 0; attempt < 8 && starts().length === 0; attempt += 1) {
|
|
2171
|
+
const timer = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2172
|
+
expect(timer).toBeDefined();
|
|
2173
|
+
timer.fired = true;
|
|
2174
|
+
timer.callback();
|
|
2175
|
+
await vi.waitFor(() => expect(starts().length > 0 ||
|
|
2176
|
+
timers.some((candidate) => !candidate.cancelled && !candidate.fired)).toBe(true));
|
|
2177
|
+
}
|
|
2178
|
+
expect(starts()).toHaveLength(1);
|
|
2179
|
+
expect(starts()[0].params).toMatchObject({ threadId: 'preserved-executor' });
|
|
2180
|
+
for (const timer of timers.filter((candidate) => candidate.fired))
|
|
2181
|
+
timer.callback();
|
|
2182
|
+
await Promise.resolve();
|
|
2183
|
+
expect(starts()).toHaveLength(1);
|
|
2184
|
+
});
|
|
2107
2185
|
it('production incompatible reconcile remains supervised and schedules reinspection', async () => {
|
|
2108
2186
|
let reconciliations = 0;
|
|
2109
2187
|
const timers = [];
|
|
@@ -3971,7 +4049,7 @@ describe('production composition', () => {
|
|
|
3971
4049
|
// Model and skill catalogs run for bootstrap and session start; the active child closes with the relay.
|
|
3972
4050
|
await vi.waitFor(() => expect(closed).toBe(5));
|
|
3973
4051
|
});
|
|
3974
|
-
it('reconciles
|
|
4052
|
+
it('reconciles cleared interactions and unloaded child rosters through later activity', async () => {
|
|
3975
4053
|
const root = await mkdtemp(join(tmpdir(), 'gestalt-mobile-root-'));
|
|
3976
4054
|
const dataDir = await mkdtemp(join(tmpdir(), 'gestalt-mobile-state-'));
|
|
3977
4055
|
ownTemporaryPaths(root, dataDir);
|
|
@@ -3979,6 +4057,7 @@ describe('production composition', () => {
|
|
|
3979
4057
|
const handles = [];
|
|
3980
4058
|
const activityCallbacks = [];
|
|
3981
4059
|
const activityDiagnostic = vi.fn();
|
|
4060
|
+
let includeUnloadedChild = false;
|
|
3982
4061
|
const app = await composeAuthorizedApp({
|
|
3983
4062
|
root,
|
|
3984
4063
|
dataDir,
|
|
@@ -4008,6 +4087,20 @@ describe('production composition', () => {
|
|
|
4008
4087
|
throw new Error('READ_DOWN');
|
|
4009
4088
|
return { thread: { id: 'thread-1', status: { type: 'idle' }, turns: [] } };
|
|
4010
4089
|
}
|
|
4090
|
+
if (method === 'thread/list')
|
|
4091
|
+
return {
|
|
4092
|
+
data: includeUnloadedChild
|
|
4093
|
+
? [
|
|
4094
|
+
{
|
|
4095
|
+
id: 'l4',
|
|
4096
|
+
status: { type: 'notLoaded' },
|
|
4097
|
+
source: { subAgent: { thread_spawn: { agent_path: '/root/l4' } } },
|
|
4098
|
+
},
|
|
4099
|
+
]
|
|
4100
|
+
: [],
|
|
4101
|
+
};
|
|
4102
|
+
if (method === 'thread/backgroundTerminals/list')
|
|
4103
|
+
throw new CodexJsonRpcError(-32600, 'thread not found: l4');
|
|
4011
4104
|
if (method === 'model/list')
|
|
4012
4105
|
return { data: [{ id: 'gpt-5.6-terra' }] };
|
|
4013
4106
|
if (method === 'skills/list')
|
|
@@ -4049,6 +4142,19 @@ describe('production composition', () => {
|
|
|
4049
4142
|
state: 'ready',
|
|
4050
4143
|
agentActivity: { confidence: 'fresh' },
|
|
4051
4144
|
});
|
|
4145
|
+
// A durable child may be absent from the writer's process registry.
|
|
4146
|
+
// Its process RPC must not prevent roster publication or future refreshes.
|
|
4147
|
+
includeUnloadedChild = true;
|
|
4148
|
+
await app.inject({ method: 'POST', url: `/api/sessions/${sessionId}/activity/refresh` });
|
|
4149
|
+
await vi.waitFor(async () => {
|
|
4150
|
+
expect((await app.inject(`/api/sessions/${sessionId}`)).json()).toMatchObject({
|
|
4151
|
+
agentActivity: {
|
|
4152
|
+
confidence: 'fresh',
|
|
4153
|
+
subagents: [{ id: 'l4', canonicalPosition: 'L4', state: 'disconnected' }],
|
|
4154
|
+
},
|
|
4155
|
+
});
|
|
4156
|
+
});
|
|
4157
|
+
expect(activityDiagnostic).not.toHaveBeenCalled();
|
|
4052
4158
|
const reconciliationCalls = handle.calls.filter((method) => method === 'thread/read' || method === 'thread/list');
|
|
4053
4159
|
const ordinarySave = await app.inject({
|
|
4054
4160
|
method: 'POST',
|
|
@@ -4121,7 +4227,10 @@ describe('production composition', () => {
|
|
|
4121
4227
|
params: { thread: { id: 'thread-1', status: { type: 'active' } } },
|
|
4122
4228
|
});
|
|
4123
4229
|
expect((await app.inject(`/api/sessions/${sessionId}`)).json()).toMatchObject({
|
|
4124
|
-
agentActivity: {
|
|
4230
|
+
agentActivity: {
|
|
4231
|
+
root: { state: 'working' },
|
|
4232
|
+
subagents: [{ id: 'l4', canonicalPosition: 'L4', state: 'disconnected' }],
|
|
4233
|
+
},
|
|
4125
4234
|
});
|
|
4126
4235
|
const pending = handle.request({
|
|
4127
4236
|
id: 7,
|
|
@@ -69,8 +69,14 @@ function classifySupervisedActivity(activity, plan) {
|
|
|
69
69
|
(process.state === 'running' || process.state === 'detached-active'));
|
|
70
70
|
return !historical || supervisedProcess;
|
|
71
71
|
});
|
|
72
|
+
// A fresh authoritative roster can retain the current executor while its
|
|
73
|
+
// runtime is unloaded. Re-reading that same status cannot load it: allow the
|
|
74
|
+
// coordinator's fenced continuation to resume the existing physical thread.
|
|
75
|
+
const resumable = (child) => child.canonicalPosition === `L${position}` &&
|
|
76
|
+
Boolean(child.taskPath && child.canonicalTaskName) &&
|
|
77
|
+
child.state === 'disconnected';
|
|
72
78
|
// An aggregate-only observation cannot prove which child is historical.
|
|
73
|
-
if (retained.length === activity.subagents.length)
|
|
79
|
+
if (retained.length === activity.subagents.length && !retained.some(resumable))
|
|
74
80
|
return classifyAgentActivity(activity);
|
|
75
81
|
if (activity.root.state === 'awaitingHuman' ||
|
|
76
82
|
retained.some((child) => child.state === 'awaitingHuman'))
|
|
@@ -82,12 +88,12 @@ function classifySupervisedActivity(activity, plan) {
|
|
|
82
88
|
(process.state === 'running' || process.state === 'detached-active'))))
|
|
83
89
|
return 'active';
|
|
84
90
|
if (activity.root.state === 'disconnected' ||
|
|
85
|
-
retained.some((child) => child.state === 'disconnected'))
|
|
91
|
+
retained.some((child) => child.state === 'disconnected' && !resumable(child)))
|
|
86
92
|
return 'reconcile';
|
|
87
93
|
const rootSettled = activity.root.state === 'idle' ||
|
|
88
94
|
activity.root.state === 'blocked' ||
|
|
89
95
|
activity.root.state === 'awaitingAgent';
|
|
90
|
-
const childrenSettled = retained.every((child) => child.state === 'idle' || child.state === 'blocked');
|
|
96
|
+
const childrenSettled = retained.every((child) => child.state === 'idle' || child.state === 'blocked' || resumable(child));
|
|
91
97
|
return rootSettled && childrenSettled ? 'settled' : 'observe';
|
|
92
98
|
}
|
|
93
99
|
/** A deliberately pure, exhaustive safety gate. Adapters may only enact this result. */
|
|
@@ -16,7 +16,7 @@ import { gestaltAgentCapacityRecoveryDynamicTool } from '../../../shared/contrac
|
|
|
16
16
|
import { countDiffLines } from '../../../shared/contracts/file-change.js';
|
|
17
17
|
import { threadPlanName } from './thread-plan-name.js';
|
|
18
18
|
import { WriterAcquisitionError, } from '../../features/sessions/application/writer-acquisition.js';
|
|
19
|
-
import { isCodexThreadWriterBusy, isMissingCodexThreadRollout } from './json-rpc-client.js';
|
|
19
|
+
import { CodexJsonRpcError, isCodexThreadWriterBusy, isMissingCodexThreadRollout, } from './json-rpc-client.js';
|
|
20
20
|
import { resolvedServerRequestId } from './server-request.js';
|
|
21
21
|
/** Sticky thread config keeps skill paths out of the app-server process argv. */
|
|
22
22
|
export function threadSkillConfig(skillsConfig, modelConfig = {}) {
|
|
@@ -525,7 +525,24 @@ export class CodexSessionRuntime {
|
|
|
525
525
|
const owned = this.sessions.get(session.id);
|
|
526
526
|
if (!owned)
|
|
527
527
|
return [];
|
|
528
|
-
|
|
528
|
+
let active;
|
|
529
|
+
try {
|
|
530
|
+
active = await this.listChildBackgroundTerminals(owned, child);
|
|
531
|
+
}
|
|
532
|
+
catch (error) {
|
|
533
|
+
// Durable topology includes children absent from this app-server's live
|
|
534
|
+
// registry. Its process RPC then reports "thread not found"; that does
|
|
535
|
+
// not invalidate the roster or prove that previously observed work exited.
|
|
536
|
+
if (child.status !== 'notLoaded' ||
|
|
537
|
+
child.qualified === false ||
|
|
538
|
+
!(error instanceof CodexJsonRpcError) ||
|
|
539
|
+
error.code !== -32600 ||
|
|
540
|
+
error.message !== `thread not found: ${child.id}`)
|
|
541
|
+
throw error;
|
|
542
|
+
return [...owned.ownedChildProcesses.values()].filter((process) => process.ownerThreadId === child.id &&
|
|
543
|
+
process.state !== 'result-consumed' &&
|
|
544
|
+
process.state !== 'terminated-for-budget');
|
|
545
|
+
}
|
|
529
546
|
const activeIds = new Set(active.map((process) => process.processId));
|
|
530
547
|
for (const process of active)
|
|
531
548
|
owned.ownedChildProcesses.set(childProcessKey(child.id, process.processId), process);
|