gestalt-mobile 0.46.1 → 0.46.2
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.
|
@@ -2070,7 +2070,97 @@ describe('production composition', () => {
|
|
|
2070
2070
|
expect(fixture.handles.flatMap((candidate) => candidate.requests.filter((call) => call.method === 'turn/start'))[0]?.params).toMatchObject({ threadId: 'child-1' });
|
|
2071
2071
|
await fixture.app.close();
|
|
2072
2072
|
});
|
|
2073
|
-
it('production
|
|
2073
|
+
it('production resumes an unloaded executor without leaving its command issued or replacing it', async () => {
|
|
2074
|
+
const timers = [];
|
|
2075
|
+
const fixture = await createProductionAutopilotFixture({
|
|
2076
|
+
autopilotActivity: (sessionId) => {
|
|
2077
|
+
const observedAt = new Date().toISOString();
|
|
2078
|
+
return {
|
|
2079
|
+
sessionId,
|
|
2080
|
+
rootThreadId: 'thread-1',
|
|
2081
|
+
root: {
|
|
2082
|
+
state: 'idle',
|
|
2083
|
+
reason: 'turnCompleted',
|
|
2084
|
+
observedAt,
|
|
2085
|
+
lastActivityAt: observedAt,
|
|
2086
|
+
},
|
|
2087
|
+
subagents: [
|
|
2088
|
+
{
|
|
2089
|
+
id: 'child-1',
|
|
2090
|
+
threadId: 'child-1',
|
|
2091
|
+
taskPath: '/root/l1',
|
|
2092
|
+
canonicalTaskName: 'l1',
|
|
2093
|
+
canonicalPosition: 'L1',
|
|
2094
|
+
continuationGeneration: 1,
|
|
2095
|
+
outcome: 'partial',
|
|
2096
|
+
ownedProcesses: [],
|
|
2097
|
+
state: 'idle',
|
|
2098
|
+
reason: 'turnCompleted',
|
|
2099
|
+
observedAt,
|
|
2100
|
+
lastActivityAt: observedAt,
|
|
2101
|
+
},
|
|
2102
|
+
],
|
|
2103
|
+
aggregateSubagents: 'idle',
|
|
2104
|
+
confidence: 'fresh',
|
|
2105
|
+
};
|
|
2106
|
+
},
|
|
2107
|
+
autopilotSchedule: (callback) => {
|
|
2108
|
+
const timer = { callback, cancelled: false };
|
|
2109
|
+
timers.push(timer);
|
|
2110
|
+
return () => {
|
|
2111
|
+
timer.cancelled = true;
|
|
2112
|
+
};
|
|
2113
|
+
},
|
|
2114
|
+
});
|
|
2115
|
+
onTestFinished(() => fixture.app.close());
|
|
2116
|
+
for (const handle of fixture.handles) {
|
|
2117
|
+
let loaded = false;
|
|
2118
|
+
handle.respond = (method, params) => {
|
|
2119
|
+
if (params.threadId !== 'child-1')
|
|
2120
|
+
return undefined;
|
|
2121
|
+
if (method === 'thread/resume') {
|
|
2122
|
+
loaded = true;
|
|
2123
|
+
return { thread: { id: 'child-1' } };
|
|
2124
|
+
}
|
|
2125
|
+
if (method === 'turn/start') {
|
|
2126
|
+
if (!loaded)
|
|
2127
|
+
throw new CodexJsonRpcError(-32600, 'thread not found: child-1');
|
|
2128
|
+
return { turn: { id: 'child-turn' } };
|
|
2129
|
+
}
|
|
2130
|
+
return undefined;
|
|
2131
|
+
};
|
|
2132
|
+
}
|
|
2133
|
+
expect((await fixture.app.inject({
|
|
2134
|
+
method: 'PUT',
|
|
2135
|
+
url: `/api/sessions/${fixture.sessionId}/autopilot`,
|
|
2136
|
+
payload: { enabled: true },
|
|
2137
|
+
})).statusCode).toBe(200);
|
|
2138
|
+
await vi.waitFor(() => expect(timers.some((timer) => !timer.cancelled)).toBe(true));
|
|
2139
|
+
timers.find((timer) => !timer.cancelled).callback();
|
|
2140
|
+
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
2141
|
+
onTestFinished(() => database.close());
|
|
2142
|
+
await vi.waitFor(() => {
|
|
2143
|
+
const row = database
|
|
2144
|
+
.prepare('SELECT lifecycle_json FROM autopilot_sessions WHERE session_id = ?')
|
|
2145
|
+
.get(fixture.sessionId);
|
|
2146
|
+
expect(JSON.parse(row.lifecycle_json)).toMatchObject({
|
|
2147
|
+
executor: {
|
|
2148
|
+
continuationCount: 1,
|
|
2149
|
+
commands: [expect.objectContaining({ status: 'accepted', threadId: 'child-1' })],
|
|
2150
|
+
},
|
|
2151
|
+
});
|
|
2152
|
+
});
|
|
2153
|
+
const calls = fixture.handles
|
|
2154
|
+
.flatMap((handle) => handle.requests)
|
|
2155
|
+
.filter((call) => call.params.threadId === 'child-1');
|
|
2156
|
+
expect(calls.filter((call) => call.method === 'turn/start')).toHaveLength(2);
|
|
2157
|
+
expect(calls.filter((call) => call.method === 'thread/resume')).toHaveLength(1);
|
|
2158
|
+
const failures = database
|
|
2159
|
+
.prepare("SELECT count(*) AS count FROM session_events WHERE session_id = ? AND type IN ('autopilot.operation-failed', 'autopilot.executor-replacement-scheduled')")
|
|
2160
|
+
.get(fixture.sessionId);
|
|
2161
|
+
expect(failures.count).toBe(0);
|
|
2162
|
+
});
|
|
2163
|
+
it.each(['missing rollout', 'unloaded child without rollout'])('production treats %s as an executor rejection and starts one fenced replacement', async (scenario) => {
|
|
2074
2164
|
const timers = [];
|
|
2075
2165
|
const fixture = await createProductionAutopilotFixture({
|
|
2076
2166
|
autopilotActivity: (sessionId) => {
|
|
@@ -2116,7 +2206,11 @@ describe('production composition', () => {
|
|
|
2116
2206
|
// every live writer that can own the executor continuation.
|
|
2117
2207
|
for (const handle of fixture.handles)
|
|
2118
2208
|
handle.respond = (method, params) => {
|
|
2119
|
-
if (
|
|
2209
|
+
if (params.threadId !== 'child-1')
|
|
2210
|
+
return undefined;
|
|
2211
|
+
if (method === 'turn/start' && scenario === 'unloaded child without rollout')
|
|
2212
|
+
throw new CodexJsonRpcError(-32600, 'thread not found: child-1');
|
|
2213
|
+
if (method === 'turn/start' || method === 'thread/resume')
|
|
2120
2214
|
throw new CodexJsonRpcError(-32600, 'no rollout found for thread id child-1');
|
|
2121
2215
|
return undefined;
|
|
2122
2216
|
};
|
|
@@ -2191,7 +2285,10 @@ describe('production composition', () => {
|
|
|
2191
2285
|
expect(replacements.count).toBe(1);
|
|
2192
2286
|
await fixture.app.close();
|
|
2193
2287
|
});
|
|
2194
|
-
it(
|
|
2288
|
+
it.each([
|
|
2289
|
+
['transport-lost', new Error('CODEX_CONNECTION_LOST')],
|
|
2290
|
+
['ambiguous RPC failure', new CodexJsonRpcError(-32603, 'internal error')],
|
|
2291
|
+
])('production leaves a %s executor command issued and never replays it as a replacement', async (_scenario, failure) => {
|
|
2195
2292
|
const timers = [];
|
|
2196
2293
|
const fixture = await createProductionAutopilotFixture({
|
|
2197
2294
|
autopilotActivity: (sessionId) => {
|
|
@@ -2236,7 +2333,7 @@ describe('production composition', () => {
|
|
|
2236
2333
|
for (const handle of fixture.handles)
|
|
2237
2334
|
handle.respond = (method, params) => {
|
|
2238
2335
|
if (method === 'turn/start' && params.threadId === 'child-1')
|
|
2239
|
-
throw
|
|
2336
|
+
throw failure;
|
|
2240
2337
|
return undefined;
|
|
2241
2338
|
};
|
|
2242
2339
|
expect((await fixture.app.inject({
|
|
@@ -246,7 +246,7 @@ export class CodexSessionRuntime {
|
|
|
246
246
|
const resource = this.sessions.get(session.id);
|
|
247
247
|
if (!resource)
|
|
248
248
|
throw new Error('CODEX_SESSION_NOT_RUNNING');
|
|
249
|
-
const
|
|
249
|
+
const params = {
|
|
250
250
|
threadId: childThreadId,
|
|
251
251
|
input: [{ type: 'text', text, text_elements: [] }],
|
|
252
252
|
clientUserMessageId,
|
|
@@ -256,7 +256,24 @@ export class CodexSessionRuntime {
|
|
|
256
256
|
...(session.modelSettings?.executorReasoningEffort
|
|
257
257
|
? { effort: session.modelSettings.executorReasoningEffort }
|
|
258
258
|
: {}),
|
|
259
|
-
}
|
|
259
|
+
};
|
|
260
|
+
let response;
|
|
261
|
+
try {
|
|
262
|
+
response = await resource.process.rpc.request('turn/start', params);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
// Codex 0.160 rejects a durable child absent from this writer's live
|
|
266
|
+
// registry. Load that same thread without overriding its role/config.
|
|
267
|
+
// Only this exact rejection permits one retry; transport loss may hide
|
|
268
|
+
// accepted work and must retain the durable issued fence.
|
|
269
|
+
if (!(error instanceof CodexJsonRpcError) ||
|
|
270
|
+
error.code !== -32600 ||
|
|
271
|
+
error.message !== `thread not found: ${childThreadId}`)
|
|
272
|
+
throw error;
|
|
273
|
+
await resource.process.rpc.request('thread/resume', { threadId: childThreadId });
|
|
274
|
+
response = await resource.process.rpc.request('turn/start', params);
|
|
275
|
+
}
|
|
276
|
+
const result = decodeTurnStart(response);
|
|
260
277
|
if (resource.turnThreads.has(result) || resource.turnThreads.size < 256)
|
|
261
278
|
resource.turnThreads.set(result, childThreadId);
|
|
262
279
|
return result;
|