gestalt-mobile 0.50.0 → 0.50.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.
@@ -2664,6 +2664,7 @@ describe('production composition', () => {
2664
2664
  },
2665
2665
  autopilot: { enabled: true },
2666
2666
  });
2667
+ expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json().autopilot.reason).toBeUndefined();
2667
2668
  expect(timers.some((timer) => !timer.cancelled && !timer.fired)).toBe(true);
2668
2669
  });
2669
2670
  for (let attempt = 0; attempt < 8 && starts().length === 0; attempt += 1) {
@@ -2681,7 +2682,11 @@ describe('production composition', () => {
2681
2682
  await Promise.resolve();
2682
2683
  expect(starts()).toHaveLength(1);
2683
2684
  });
2684
- it.each([false, true])('continues past a disconnected auxiliary helper after L2 completion, reported=%s', async (reported) => {
2685
+ it.each([
2686
+ { reported: false, completed: false },
2687
+ { reported: true, completed: false },
2688
+ { reported: true, completed: true },
2689
+ ])('continues past a disconnected auxiliary helper after L2 completion, %j', async ({ reported, completed }) => {
2685
2690
  const handles = [];
2686
2691
  const launch = liveAppServer(handles);
2687
2692
  const timers = [];
@@ -2733,9 +2738,11 @@ describe('production composition', () => {
2733
2738
  payload: { enabled: false },
2734
2739
  });
2735
2740
  await writeFile(join(fixture.workspacePath, 'autopilot.org'), acceptedL1WithNextTodoPlanText()
2736
- .replace('* TODO [#B] Next parent', '* WIP [#B] Next parent')
2741
+ .replace('* TODO [#B] Next parent', `* ${completed ? 'DONE' : 'WIP'} [#B] Next parent`)
2737
2742
  .replace('** TODO [#B] Next child', '** DONE [#B] Next child') +
2738
- `
2743
+ (completed
2744
+ ? ''
2745
+ : `
2739
2746
  ** TODO [#B] Next child two
2740
2747
  :PROPERTIES:
2741
2748
  :ID: next-child-two
@@ -2744,7 +2751,7 @@ describe('production composition', () => {
2744
2751
  - Change :: Resume the canonical executor.
2745
2752
  - Tests :: Verify one fenced continuation.
2746
2753
  - Done when :: The next L2 starts.
2747
- `);
2754
+ `));
2748
2755
  await expect
2749
2756
  .poll(async () => (await fixture.app.inject(`/api/sessions/${fixture.sessionId}/plan`)).json()
2750
2757
  .currentStepId)
@@ -2812,7 +2819,7 @@ describe('production composition', () => {
2812
2819
  const rootThreadId = (await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json()
2813
2820
  .threadId;
2814
2821
  expect(starts()[0].params).toMatchObject({
2815
- threadId: reported ? 'executor' : rootThreadId,
2822
+ threadId: reported && !completed ? 'executor' : rootThreadId,
2816
2823
  });
2817
2824
  // Replayed timers cannot duplicate the root report or the later
2818
2825
  // continuation of the same canonical executor.
@@ -2824,7 +2831,7 @@ describe('production composition', () => {
2824
2831
  try {
2825
2832
  expect(database
2826
2833
  .prepare('SELECT count(*) AS count FROM session_events WHERE session_id = ? AND type = ?')
2827
- .get(fixture.sessionId, reported ? 'autopilot.executor-resumed' : 'autopilot.control-issued')).toMatchObject({ count: 1 });
2834
+ .get(fixture.sessionId, reported && !completed ? 'autopilot.executor-resumed' : 'autopilot.control-issued')).toMatchObject({ count: 1 });
2828
2835
  }
2829
2836
  finally {
2830
2837
  database.close();
@@ -1508,10 +1508,14 @@ export class AutopilotCoordinator {
1508
1508
  const epoch = epochs.get(target);
1509
1509
  return Boolean(epoch?.reopened || epoch?.completed === false);
1510
1510
  };
1511
- return plan.steps.some((l1) => (l1.state !== 'SUSPENDED' &&
1512
- l1.children.some((l2) => l2.state === 'DONE' &&
1513
- (!reportedL2.has(JSON.stringify([l1.id, l2.id])) ||
1514
- epochNeedsReport(checkpointTarget('l2', l1.id, l2.id))))) ||
1511
+ return plan.steps.some((l1) =>
1512
+ // A finished executor cannot review its own milestone. Even after all
1513
+ // L2 reports, the root must run the review before work can advance.
1514
+ (l1.state === 'DONE' && l1.reviewStatus !== 'REVIEWED') ||
1515
+ (l1.state !== 'SUSPENDED' &&
1516
+ l1.children.some((l2) => l2.state === 'DONE' &&
1517
+ (!reportedL2.has(JSON.stringify([l1.id, l2.id])) ||
1518
+ epochNeedsReport(checkpointTarget('l2', l1.id, l2.id))))) ||
1515
1519
  (l1.state === 'DONE' &&
1516
1520
  l1.reviewStatus === 'REVIEWED' &&
1517
1521
  (!reportedL1.has(l1.id) || epochNeedsReport(checkpointTarget('l1', l1.id)))));
@@ -2438,9 +2442,11 @@ export class AutopilotCoordinator {
2438
2442
  });
2439
2443
  }
2440
2444
  semanticSnapshot(next, control) {
2445
+ const snapshot = this.snapshotFor(next, control);
2441
2446
  return JSON.stringify({
2442
- ...this.snapshotFor(next, control),
2447
+ ...snapshot,
2443
2448
  updatedAt: '',
2449
+ health: { ...snapshot.health, observedAt: '', lastTransitionAt: '' },
2444
2450
  });
2445
2451
  }
2446
2452
  snapshotEvents(next, control) {
@@ -2611,6 +2617,8 @@ export class AutopilotCoordinator {
2611
2617
  if (activity?.confidence === 'fresh' &&
2612
2618
  Date.parse(this.deps.now()) - Date.parse(activity.root.observedAt) <=
2613
2619
  this.deps.policy.staleAfterMs) {
2620
+ if (current.stopReason === 'reconcileFailed')
2621
+ this.persist({ ...current, stopReason: null, updatedAt: this.deps.now() });
2614
2622
  this.evaluate(sessionId);
2615
2623
  }
2616
2624
  else {
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { DatabaseSync } from 'node:sqlite';
7
7
  const relevant = /^(?:org-plan\.|autopilot\.|agent\.activity\.|session\.status\.)/;
8
+ const statusTypes = ['autopilot.updated', 'agent.activity.updated', 'session.status.updated'];
8
9
  // Export structural telemetry only. Event types alone do not imply payload safety.
9
10
  const diagnosticFields = new Set([
10
11
  'traceId',
@@ -112,9 +113,20 @@ function diagnose(events) {
112
113
  export function exportControlPlaneTrace(databasePath, sessionId, generatedAt = new Date().toISOString()) {
113
114
  const database = new DatabaseSync(databasePath, { readOnly: true });
114
115
  try {
116
+ database.exec('BEGIN');
117
+ // Reserve the diagnostic budget for causal transitions. Polling status
118
+ // snapshots must not evict the failed handoff from an otherwise retained
119
+ // journal. Keep a recent status tail and disclose every omitted row.
120
+ const statusEventLimit = 100;
121
+ const transitionEventLimit = 4900;
122
+ const relevantWhere = "(type LIKE 'org-plan.%' OR type LIKE 'autopilot.%' OR type LIKE 'agent.activity.%' OR type LIKE 'session.status.%')";
123
+ const statusWhere = `type IN (${statusTypes.map(() => '?').join(',')})`;
124
+ const counts = database
125
+ .prepare(`SELECT SUM(CASE WHEN ${statusWhere} THEN 1 ELSE 0 END) AS statuses, COUNT(*) AS total FROM session_events WHERE session_id = ? AND ${relevantWhere}`)
126
+ .get(...statusTypes, sessionId);
115
127
  const rows = database
116
- .prepare("SELECT sequence,occurred_at,type,payload_json FROM session_events WHERE session_id = ? AND (type LIKE 'org-plan.%' OR type LIKE 'autopilot.%' OR type LIKE 'agent.activity.%' OR type LIKE 'session.status.%') ORDER BY sequence DESC LIMIT 5000")
117
- .all(sessionId);
128
+ .prepare(`SELECT * FROM (SELECT sequence,occurred_at,type,payload_json FROM session_events WHERE session_id = ? AND ${statusWhere} ORDER BY sequence DESC LIMIT ?) UNION ALL SELECT * FROM (SELECT sequence,occurred_at,type,payload_json FROM session_events WHERE session_id = ? AND ${relevantWhere} AND NOT (${statusWhere}) ORDER BY sequence DESC LIMIT ?) ORDER BY sequence DESC`)
129
+ .all(sessionId, ...statusTypes, statusEventLimit, sessionId, ...statusTypes, transitionEventLimit);
118
130
  const events = rows
119
131
  .reverse()
120
132
  .filter((row) => relevant.test(row.type))
@@ -128,7 +140,19 @@ export function exportControlPlaneTrace(databasePath, sessionId, generatedAt = n
128
140
  traceId: correlation(payload),
129
141
  };
130
142
  });
131
- return { schemaVersion: 1, sessionId, generatedAt, events, diagnoses: diagnose(events) };
143
+ return {
144
+ schemaVersion: 1,
145
+ sessionId,
146
+ generatedAt,
147
+ events,
148
+ diagnoses: diagnose(events),
149
+ selection: {
150
+ statusEventLimit,
151
+ transitionEventLimit,
152
+ omittedStatusEvents: Math.max(0, (counts.statuses ?? 0) - statusEventLimit),
153
+ omittedTransitionEvents: Math.max(0, counts.total - (counts.statuses ?? 0) - transitionEventLimit),
154
+ },
155
+ };
132
156
  }
133
157
  finally {
134
158
  database.close();
@@ -138,6 +162,7 @@ export function formatControlPlaneTrace(trace) {
138
162
  const lines = [
139
163
  `Control-plane trace for ${trace.sessionId}`,
140
164
  `Generated: ${trace.generatedAt}`,
165
+ `Omitted by export limits: ${trace.selection.omittedStatusEvents} status snapshots, ${trace.selection.omittedTransitionEvents} transitions.`,
141
166
  '',
142
167
  ];
143
168
  for (const event of trace.events) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.50.0",
3
+ "version": "0.50.1",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",