gestalt-mobile 0.44.1 → 0.44.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.
package/README.md CHANGED
@@ -434,16 +434,32 @@ Run `npm run check`, `npm test`, `npm run lint`, and `npm run build`.
434
434
 
435
435
  ### Test lanes
436
436
 
437
- The aggregate commands remain the default required checks: `npm test` runs every
438
- Vitest test and `npm run test:e2e` runs every browser test except the isolated
439
- real-auth journey. The additive lanes make ownership inspectable without changing
440
- those defaults:
437
+ Pull requests and pushes to `main` run Quality, the full Vitest suite, and Package
438
+ smoke. Package smoke includes a production build, so CI does not build it again
439
+ in a separate job. New commits cancel superseded PR runs; main release runs are
440
+ not cancelled.
441
+
442
+ Playwright functional shards, real authentication, visual evidence, and
443
+ authorization stress run weekly (Monday 03:23 UTC) or through **Actions → CI → Run
444
+ workflow**. They do not gate ordinary PRs or releases. Browser regressions can
445
+ therefore be detected later; run the relevant browser suite locally when changing
446
+ browser behavior.
447
+
448
+ These choices follow successful CI run `37347775035`: browser jobs consumed
449
+ 483 of 652 total pre-release runner seconds. Removing them from ordinary runs
450
+ and removing the redundant 18-second Build job leaves a 153-second baseline
451
+ across three jobs instead of nine. These are measured runner durations, not a
452
+ guarantee about elapsed time or GitHub's runner allocation queue. The full Vitest
453
+ job took 77 seconds and remains in the default gate.
454
+
455
+ Local aggregate commands remain unchanged: `npm test` runs every Vitest test and
456
+ `npm run test:e2e` runs every browser test except the isolated real-auth journey.
441
457
 
442
458
  - `npm run test:vitest` — all Vitest tests.
443
459
  - `npm run test:coverage` — all Vitest tests with a V8 JSON summary at
444
460
  `coverage/vitest/coverage-summary.json` (the generated directory is ignored).
445
- - `npm run test:e2e:functional` — browser-functional specs excluding the exhaustive
446
- visual-evidence files and real-auth journey.
461
+ - `npm run test:e2e:functional` — browser-functional specs, including checks in
462
+ visual-evidence files, excluding the real-auth journey.
447
463
  - `npm run test:e2e:evidence` — the exhaustive visual/responsive evidence files.
448
464
  - `npm run test:auth:stress` — the existing multi-process authorization contention
449
465
  repetitions.
@@ -61,7 +61,13 @@ function liveAppServer(handles) {
61
61
  if (method === 'turn/start')
62
62
  return { turn: { id: `turn-${handle.calls.length}` } };
63
63
  if (method === 'thread/read')
64
- return { thread: { turns: [] } };
64
+ return {
65
+ thread: {
66
+ id: params.threadId,
67
+ status: { type: 'idle' },
68
+ turns: [],
69
+ },
70
+ };
65
71
  if (method === 'model/list')
66
72
  return { data: [{ id: 'gpt-5.6-terra' }] };
67
73
  if (method === 'skills/list')
@@ -373,6 +379,68 @@ async function createUnauthorizedProductionApp(root, dataDir) {
373
379
  }
374
380
  describe('production composition', () => {
375
381
  describeCompositionConcern('autopilot', () => {
382
+ it('health reads match UI authority, reject session selection, and expose recoverable corrupt state', async () => {
383
+ const fixture = await createProductionAutopilotFixture();
384
+ const { app, sessionId, handles, dataDir } = fixture;
385
+ const database = new DatabaseSync(join(dataDir, 'relay.sqlite'));
386
+ try {
387
+ const handle = handles.filter((value) => value.request).at(-1);
388
+ const read = () => handle.request({
389
+ id: 901,
390
+ method: 'item/tool/call',
391
+ params: {
392
+ tool: 'gestalt_org_plan_health',
393
+ arguments: {},
394
+ },
395
+ });
396
+ const before = (await app.inject(`/api/sessions/${sessionId}`)).json();
397
+ const response = await read();
398
+ expect(response.success).toBe(true);
399
+ const health = JSON.parse(response.contentItems[0].text);
400
+ expect(health).toMatchObject({
401
+ state: before.autopilot.state,
402
+ enabled: before.autopilot.enabled,
403
+ });
404
+ expect(health.health).toMatchObject({
405
+ phase: before.autopilot.health.phase,
406
+ healthy: before.autopilot.health.healthy,
407
+ });
408
+ await expect(handle.request({
409
+ id: 902,
410
+ method: 'item/tool/call',
411
+ params: {
412
+ tool: 'gestalt_org_plan_health',
413
+ arguments: { sessionId: 'another' },
414
+ },
415
+ })).rejects.toThrow();
416
+ await app.inject({
417
+ method: 'PUT',
418
+ url: `/api/sessions/${sessionId}/autopilot`,
419
+ payload: { enabled: false },
420
+ });
421
+ database
422
+ .prepare('UPDATE autopilot_sessions SET lifecycle_json = ? WHERE session_id = ?')
423
+ .run('{broken', sessionId);
424
+ expect(JSON.parse((await read()).contentItems[0].text)).toMatchObject({
425
+ health: { phase: 'degraded', degradationReason: 'controllerUnavailable' },
426
+ });
427
+ expect(database.prepare('SELECT * FROM autopilot_state_quarantine').all()).toHaveLength(0);
428
+ const recovered = await app.inject({
429
+ method: 'PUT',
430
+ url: `/api/sessions/${sessionId}/autopilot`,
431
+ payload: { enabled: false },
432
+ });
433
+ expect(recovered.statusCode).toBe(200);
434
+ expect(recovered.json()).toMatchObject({
435
+ autopilot: { enabled: false, health: { phase: 'off' } },
436
+ });
437
+ expect(database.prepare('SELECT * FROM autopilot_state_quarantine').all()).toHaveLength(1);
438
+ }
439
+ finally {
440
+ database.close();
441
+ await app.close();
442
+ }
443
+ });
376
444
  it('autopilot production composition keeps disabled sessions free of timers, reads, polls, and leaks', async () => {
377
445
  const root = await mkdtemp(join(tmpdir(), 'gestalt-mobile-root-'));
378
446
  const dataDir = await mkdtemp(join(tmpdir(), 'gestalt-mobile-state-'));
@@ -1020,6 +1088,13 @@ describe('production composition', () => {
1020
1088
  const startsBefore = fixture.handles
1021
1089
  .flatMap((candidate) => candidate.requests)
1022
1090
  .filter((request) => request.method === 'turn/start').length;
1091
+ const unresolvedCall = handle.request({
1092
+ ...checkpointCall(815),
1093
+ params: { ...checkpointCall(815).params, arguments: { kind: 'l2Completed' } },
1094
+ });
1095
+ await vi.waitFor(() => expect(handle.pendingResponses.has(815)).toBe(true));
1096
+ handle.responseSettled({ id: 815, outcome: 'resultWritten' });
1097
+ await expect(unresolvedCall).resolves.toEqual(toOrgPlanCheckpointToolResponse('failed', { reasonCode: 'checkpointBoundaryAmbiguous' }));
1023
1098
  const first = handle.request(checkpointCall(813));
1024
1099
  await vi.waitFor(() => expect(handle.pendingResponses.has(813)).toBe(true));
1025
1100
  handle.responseSettled({ id: 813, outcome: 'resultWritten' });
@@ -3823,7 +3898,7 @@ describe('production composition', () => {
3823
3898
  if (method === 'thread/read') {
3824
3899
  if (handle.failReads)
3825
3900
  throw new Error('READ_DOWN');
3826
- return { thread: { turns: [] } };
3901
+ return { thread: { id: 'thread-1', status: { type: 'idle' }, turns: [] } };
3827
3902
  }
3828
3903
  if (method === 'model/list')
3829
3904
  return { data: [{ id: 'gpt-5.6-terra' }] };
@@ -3902,7 +3977,9 @@ describe('production composition', () => {
3902
3977
  await Promise.resolve();
3903
3978
  }
3904
3979
  await vi.waitFor(() => expect(activityDiagnostic).toHaveBeenCalledTimes(1));
3905
- expect(activityDiagnostic).toHaveBeenCalledWith(sessionId, 'reconcileExhausted');
3980
+ expect(activityDiagnostic).toHaveBeenCalledWith(sessionId, 'reconcileExhausted', {
3981
+ attempt: 4,
3982
+ });
3906
3983
  handle.failReads = false;
3907
3984
  const initialActivityEvents = activityEvents.filter((message) => message.event.type === 'agent.activity.updated').length;
3908
3985
  handle.notify({
@@ -72,6 +72,7 @@ import { createRelyingPartyConfig } from './config.js';
72
72
  import { parseOrgPlanAttention, parseOrgPlanAttentionToolResponse, toOrgPlanAttentionAcknowledgement, } from '../shared/contracts/org-plan-attention.js';
73
73
  import { autopilotWaitLeaseToolResponse, } from '../shared/contracts/autopilot-wait-lease.js';
74
74
  import { agentCapacityRecoveryToolResponse } from '../shared/contracts/agent-capacity-recovery.js';
75
+ import { isOrgPlanHealthCall } from '../shared/contracts/org-plan-health.js';
75
76
  import { pwaIconUrl } from './features/pwa/register-routes.js';
76
77
  const generatedProtocolVersion = 'codex-cli 0.144.3';
77
78
  const checkpointDiagnostic = debuglog('gestalt-mobile:checkpoint');
@@ -159,7 +160,7 @@ export async function composeRelayApp(options) {
159
160
  }),
160
161
  now: () => new Date().toISOString(),
161
162
  diagnostic: options.activityDiagnostic ??
162
- ((sessionId, code) => console.warn(`agent activity ${code} session=${sessionId}`)),
163
+ ((sessionId, code, detail) => console.warn(`agent activity ${code} session=${sessionId} attempt=${detail?.attempt ?? 0} rpcCode=${detail?.rpcCode ?? 'none'}`)),
163
164
  reconcile: async (sessionId) => {
164
165
  const session = sessions.find(sessionId);
165
166
  if (!session)
@@ -187,7 +188,7 @@ export async function composeRelayApp(options) {
187
188
  }
188
189
  if (!runtime)
189
190
  return false;
190
- const history = await runtime.readHistory(session);
191
+ const rootActivity = await runtime.readActivity(session);
191
192
  const children = await runtime.listDirectChildren(session);
192
193
  const childProcesses = new Map();
193
194
  await mapWithConcurrency([...children], 4, async (child) => {
@@ -203,9 +204,8 @@ export async function composeRelayApp(options) {
203
204
  activity.observe({
204
205
  sessionId,
205
206
  occurredAt,
206
- kind: history.activeTurnId ? 'turnStarted' : 'turnCompleted',
207
+ kind: rootActivity.active ? 'turnStarted' : 'turnCompleted',
207
208
  ...(session.threadId ? { threadId: session.threadId } : {}),
208
- ...(history.activeTurnId ? { turnId: history.activeTurnId } : {}),
209
209
  });
210
210
  activity.childrenReconciled(sessionId, occurredAt, children.map((child) => ({
211
211
  ...child,
@@ -739,7 +739,7 @@ export async function composeRelayApp(options) {
739
739
  if (session && turnId && session.activeTurnId === turnId) {
740
740
  completedSession = RelaySession.rehydrate(session).completeTurn(turnId, occurredAt).snapshot;
741
741
  sessions.save(completedSession);
742
- autopilot.turnCompleted(sessionId);
742
+ autopilot.turnCompleted(sessionId, turnId);
743
743
  }
744
744
  planMeasurementRefresh?.refreshNow(sessionId);
745
745
  }
@@ -769,12 +769,32 @@ export async function composeRelayApp(options) {
769
769
  const session = withPendingInteractions(sessions.find(sessionId));
770
770
  if (!session)
771
771
  return false;
772
+ if (isOrgPlanHealthCall(request)) {
773
+ const snapshot = autopilot.snapshot(sessionId);
774
+ return (runtime?.resolveServerRequest(sessionId, String(request.id), {
775
+ success: true,
776
+ contentItems: [
777
+ {
778
+ type: 'inputText',
779
+ text: JSON.stringify({
780
+ state: snapshot.state,
781
+ enabled: snapshot.enabled,
782
+ health: snapshot.health,
783
+ reason: snapshot.reason,
784
+ }),
785
+ },
786
+ ],
787
+ }) === true);
788
+ }
772
789
  const compactCheckpointKind = compactOrgPlanCheckpointKind(request);
773
790
  if (!rawInteraction && compactCheckpointKind) {
774
791
  const retained = supervisedPlans.find(sessionId);
775
792
  const identity = supervisedPlans.identity(sessionId);
776
793
  const checkpoint = retained && identity
777
- ? resolveOrgPlanCheckpointSignal(compactCheckpointKind, retained, identity, supervisedPlans.publicationReason(sessionId))
794
+ ? resolveOrgPlanCheckpointSignal(compactCheckpointKind, retained, identity, supervisedPlans.publicationReason(sessionId), autopilotStore
795
+ .find(sessionId)
796
+ ?.checkpoints?.completionEpochs?.filter((epoch) => epoch.completed && !epoch.reopened)
797
+ .map((epoch) => epoch.target), autopilotStore.find(sessionId)?.checkpoints?.pendingTarget)
778
798
  : null;
779
799
  if (checkpoint)
780
800
  rawInteraction = {
@@ -782,6 +802,10 @@ export async function composeRelayApp(options) {
782
802
  kind: 'orgPlanCheckpoint',
783
803
  payload: checkpoint,
784
804
  };
805
+ else
806
+ return (runtime?.resolveServerRequest(sessionId, String(request.id), toOrgPlanCheckpointToolResponse('failed', {
807
+ reasonCode: 'checkpointBoundaryAmbiguous',
808
+ })) === true);
785
809
  }
786
810
  if (!rawInteraction && isAgentCapacityRecoveryCall(request)) {
787
811
  const rootOwned = origin.kind === 'root' && origin.physicalTurnId === session.activeTurnId;
@@ -167,13 +167,23 @@ export class AgentActivityRegistry {
167
167
  if (this.#generation.get(sessionId) === generation)
168
168
  this.reconciled(sessionId, this.options.now?.() ?? now);
169
169
  }
170
- catch {
170
+ catch (error) {
171
171
  if (this.#generation.get(sessionId) !== generation)
172
172
  return;
173
173
  const delays = this.options.retryDelaysMs ?? [1_000, 5_000, 15_000];
174
174
  if (attempt >=
175
175
  Math.min(this.options.maxReconcileAttempts ?? delays.length + 1, delays.length + 1)) {
176
- this.options.diagnostic?.(sessionId, 'reconcileExhausted');
176
+ const rpcCode = error &&
177
+ typeof error === 'object' &&
178
+ 'code' in error &&
179
+ typeof error.code === 'number' &&
180
+ Number.isSafeInteger(error.code)
181
+ ? error.code
182
+ : undefined;
183
+ this.options.diagnostic?.(sessionId, 'reconcileExhausted', {
184
+ attempt,
185
+ ...(rpcCode !== undefined ? { rpcCode } : {}),
186
+ });
177
187
  this.disconnected(sessionId, this.options.now?.() ?? now);
178
188
  return;
179
189
  }