gestalt-mobile 0.55.4 → 0.55.5

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
@@ -119,7 +119,14 @@ provide that capability. Manual Off is independently respected. Legacy plans
119
119
  without model policy keep their existing behavior.
120
120
 
121
121
  `gestalt_org_plan_health` reports `executionAdmission.allowed`, configured
122
- assurance and `runtimeEnforcement:false`. Its `modelPolicy` evidence separately
122
+ assurance and `executorLaunch`, which checks the requested L1 model/effort using
123
+ the owning runtime's `model/list` before any executor exists. `CATALOG_MATCH`
124
+ includes a normalized-content fingerprint and observation time, never a fabricated
125
+ server revision. Child `modelPolicy.catalogRevision:null` does not mean the
126
+ prelaunch catalog is unavailable. `CHILD_NOT_LAUNCHED` is expected before dispatch.
127
+ Actual missing/incompatible catalogs retain explicit failure codes.
128
+
129
+ Health retains `runtimeEnforcement:false`. Its `modelPolicy` evidence separately
123
130
  reports `admissionScope: runtime-attestation`, `admitted:false`, `attested:false`,
124
131
  requested values and observed configured thread settings. Unknown values remain
125
132
  null, never copied from requests. A configured match is not runtime attestation.
@@ -129,7 +136,8 @@ Native collaboration spawn/followup calls remain cooperatively root-supervised;
129
136
  Mobile does not intercept them or guarantee universal pre-spawn enforcement.
130
137
  One writer per L1, independent review, evidence gates, checkpoint continuation
131
138
  and terminal whole-branch review remain required. See
132
- [update and rollback guidance](docs/org-plan-policy-compatibility.md).
139
+ [update and rollback guidance](docs/org-plan-policy-compatibility.md) and
140
+ [prelaunch catalog recovery](docs/org-plan-prelaunch-catalog.md).
133
141
 
134
142
  ## Skill profiles
135
143
 
@@ -434,6 +434,41 @@ describe('production composition', () => {
434
434
  });
435
435
  expect(JSON.stringify(start.params)).not.toContain('reasoning_effort high');
436
436
  const session = (await app.inject(`/api/sessions/${sessionId}`)).json();
437
+ const requestsBeforeHealth = handle.requests.length;
438
+ const healthResponse = (await handle.request({
439
+ id: 9900,
440
+ method: 'item/tool/call',
441
+ params: {
442
+ threadId: session.threadId,
443
+ turnId: session.activeTurnId,
444
+ tool: 'gestalt_org_plan_health',
445
+ arguments: {},
446
+ },
447
+ }));
448
+ expect(healthResponse.success).toBe(true);
449
+ expect(JSON.parse(healthResponse.contentItems[0].text)).toMatchObject({
450
+ executionAdmission: { allowed: true, assurance: 'configured' },
451
+ executorLaunch: {
452
+ scope: 'prelaunch-catalog',
453
+ validated: true,
454
+ code: 'CATALOG_MATCH',
455
+ requested: { model: 'gpt-6.1-sol', reasoningEffort: 'medium' },
456
+ catalog: {
457
+ source: 'runtime-model-list',
458
+ fingerprint: expect.stringMatching(/^[a-f0-9]{64}$/),
459
+ revisionSource: 'normalized-content-digest',
460
+ },
461
+ },
462
+ modelPolicy: {
463
+ code: 'CHILD_NOT_LAUNCHED',
464
+ catalogRevision: null,
465
+ effective: { model: null, reasoningEffort: null },
466
+ attested: false,
467
+ },
468
+ });
469
+ expect(handle.requests.slice(requestsBeforeHealth).map((call) => call.method)).toEqual([
470
+ 'model/list',
471
+ ]);
437
472
  // Synthetic executor report: real composition validates the authoritative plan boundary.
438
473
  await writeFile(join(workspacePath, 'autopilot.org'), versionedText('DONE'));
439
474
  const result = await handle.request({
@@ -469,6 +504,73 @@ describe('production composition', () => {
469
504
  });
470
505
  expect(handles.flatMap((handle) => handle.requests).filter((call) => call.method === 'turn/start')).toHaveLength(1);
471
506
  });
507
+ it.each(['missing', 'model', 'effort', 'manual-off'])('exposes prechild catalog evidence without changing admission or Manual Off: %s', async (scenario) => {
508
+ const f = await createProductionAutopilotFixture({ autopilotSchedule: () => () => { } }, versionedText());
509
+ onTestFinished(() => f.app.close());
510
+ const session = (await f.app.inject(`/api/sessions/${f.sessionId}`)).json();
511
+ const handle = f.handles.find((candidate) => candidate.request);
512
+ for (const candidate of f.handles)
513
+ candidate.respond = (method) => method !== 'model/list'
514
+ ? undefined
515
+ : scenario === 'missing'
516
+ ? {}
517
+ : scenario === 'model'
518
+ ? {
519
+ data: [
520
+ {
521
+ id: 'gpt-6-sol',
522
+ supportedReasoningEfforts: [{ reasoningEffort: 'medium' }],
523
+ },
524
+ ],
525
+ }
526
+ : scenario === 'effort'
527
+ ? {
528
+ data: [
529
+ {
530
+ id: 'gpt-6.1-sol',
531
+ supportedReasoningEfforts: [{ reasoningEffort: 'low' }],
532
+ },
533
+ ],
534
+ }
535
+ : policyCatalog;
536
+ if (scenario === 'manual-off')
537
+ await f.app.inject({
538
+ method: 'PUT',
539
+ url: `/api/sessions/${f.sessionId}/autopilot`,
540
+ payload: { enabled: false },
541
+ });
542
+ const beforeHealth = f.handles
543
+ .flatMap((candidate) => candidate.requests)
544
+ .filter((call) => ['turn/start', 'thread/read', 'thread/resume'].includes(call.method));
545
+ const response = (await handle.request({
546
+ id: 9902,
547
+ method: 'item/tool/call',
548
+ params: {
549
+ threadId: session.threadId,
550
+ tool: 'gestalt_org_plan_health',
551
+ arguments: {},
552
+ },
553
+ }));
554
+ const health = JSON.parse(response.contentItems[0].text);
555
+ expect(health).toMatchObject({
556
+ executionAdmission: { allowed: true },
557
+ executorLaunch: {
558
+ validated: scenario === 'manual-off',
559
+ code: scenario === 'missing'
560
+ ? 'CATALOG_UNAVAILABLE'
561
+ : scenario === 'model'
562
+ ? 'MODEL_UNAVAILABLE'
563
+ : scenario === 'effort'
564
+ ? 'EFFORT_UNSUPPORTED'
565
+ : 'CATALOG_MATCH',
566
+ },
567
+ });
568
+ if (scenario === 'manual-off')
569
+ expect(health).toMatchObject({ enabled: false, reason: 'manualDisabled' });
570
+ expect(f.handles
571
+ .flatMap((candidate) => candidate.requests)
572
+ .filter((call) => ['turn/start', 'thread/read', 'thread/resume'].includes(call.method))).toEqual(beforeHealth);
573
+ });
472
574
  it('keeps explicit strict v1 blocked at production activation without scheduling', async () => {
473
575
  const timers = [];
474
576
  const f = await createProductionAutopilotFixture({
@@ -87,6 +87,7 @@ import { autopilotWaitLeaseToolResponse, } from '../shared/contracts/autopilot-w
87
87
  import { agentCapacityRecoveryToolResponse } from '../shared/contracts/agent-capacity-recovery.js';
88
88
  import { isOrgPlanHealthCall } from '../shared/contracts/org-plan-health.js';
89
89
  import { ExecutorModelEvidenceReader } from './features/plans/application/executor-model-evidence.js';
90
+ import { ExecutorLaunchValidationReader } from './features/plans/application/executor-launch-validation.js';
90
91
  import { requireModelPolicyAdmission } from './features/plans/domain/model-policy-admission.js';
91
92
  import { currentExecutableL1Index } from './features/plans/domain/supervised-plan.js';
92
93
  import { pwaIconUrl } from './features/pwa/register-routes.js';
@@ -712,7 +713,7 @@ export async function composeRelayApp(options) {
712
713
  let closing = false;
713
714
  let runtime = null;
714
715
  let kimiRuntime = null;
715
- const executorModelEvidence = new ExecutorModelEvidenceReader((sessionId) => {
716
+ const executorPolicyContext = (sessionId) => {
716
717
  const session = sessions.find(sessionId);
717
718
  const plan = supervisedPlans.find(sessionId);
718
719
  if (!session || session.provider !== 'codex' || plan?.modelPolicyVersion !== 1)
@@ -722,13 +723,19 @@ export async function composeRelayApp(options) {
722
723
  provider: session.provider,
723
724
  rootThreadId: session.threadId ?? null,
724
725
  planIdentity: supervisedPlans.identity(sessionId),
726
+ modelPolicyStatus: supervisedPlans.modelPolicyStatus(sessionId),
725
727
  plan,
726
728
  executor: autopilotStore.find(sessionId)?.executor ?? null,
727
729
  };
728
- }, {
730
+ };
731
+ const executorModelEvidence = new ExecutorModelEvidenceReader(executorPolicyContext, {
729
732
  read: (input) => runtime?.readExecutorConfiguration(input) ??
730
733
  Promise.resolve({ kind: 'unavailable', code: 'RUNTIME_UNAVAILABLE' }),
731
734
  });
735
+ const executorLaunchValidation = new ExecutorLaunchValidationReader(executorPolicyContext, {
736
+ read: (input) => runtime?.readExecutorPolicyCatalog(input) ??
737
+ Promise.resolve({ kind: 'unavailable', code: 'RUNTIME_UNAVAILABLE' }),
738
+ });
732
739
  /**
733
740
  * Shared acceptance path for a provider-neutral pending interaction: it
734
741
  * enters the durable store, requests human attention, and notifies autopilot.
@@ -909,8 +916,9 @@ export async function composeRelayApp(options) {
909
916
  if (!session)
910
917
  return false;
911
918
  if (isOrgPlanHealthCall(request)) {
912
- const snapshot = autopilot.snapshot(sessionId);
913
919
  const modelPolicy = await executorModelEvidence.read(sessionId);
920
+ const executorLaunch = await executorLaunchValidation.read(sessionId);
921
+ const snapshot = autopilot.snapshot(sessionId);
914
922
  return (runtime?.resolveServerRequest(sessionId, String(request.id), {
915
923
  success: true,
916
924
  contentItems: [
@@ -925,6 +933,7 @@ export async function composeRelayApp(options) {
925
933
  ? { executionAdmission: snapshot.executionAdmission }
926
934
  : {}),
927
935
  ...(modelPolicy ? { modelPolicy } : {}),
936
+ ...(executorLaunch ? { executorLaunch } : {}),
928
937
  }),
929
938
  },
930
939
  ],
@@ -0,0 +1,91 @@
1
+ /*
2
+ * Copyright (C) 2026 Dyne.org foundation
3
+ * Designed by Denis Roio <jaromil@dyne.org>
4
+ * SPDX-License-Identifier: AGPL-3.0-or-later
5
+ */
6
+ import { assessModelPolicyAdmission, } from '../domain/model-policy-admission.js';
7
+ import { currentExecutableL1Index } from '../domain/supervised-plan.js';
8
+ import { executionPolicyDigest, } from './executor-model-evidence.js';
9
+ /** Read-only selection evidence, never an enduring dispatch authorization or receipt. */
10
+ export class ExecutorLaunchValidationReader {
11
+ context;
12
+ runtime;
13
+ constructor(context, runtime) {
14
+ this.context = context;
15
+ this.runtime = runtime;
16
+ }
17
+ async read(sessionId) {
18
+ const context = this.context(sessionId);
19
+ if (!context ||
20
+ context.sessionId !== sessionId ||
21
+ context.provider !== 'codex' ||
22
+ context.plan?.modelPolicyVersion !== 1)
23
+ return null;
24
+ const index = currentExecutableL1Index(context.plan);
25
+ const step = context.plan.steps[index];
26
+ const policy = step?.modelPolicy;
27
+ if (!policy)
28
+ return null;
29
+ const admission = assessModelPolicyAdmission(context.plan, context.modelPolicyStatus);
30
+ const l1Id = Buffer.byteLength(JSON.stringify(step.id), 'utf8') <= 96 ? step.id : null;
31
+ const report = {
32
+ scope: 'prelaunch-catalog',
33
+ assurance: context.plan.modelPolicyAssurance ?? 'configured',
34
+ l1: { id: l1Id, position: index + 1 },
35
+ policyDigest: executionPolicyDigest(policy),
36
+ requested: { model: policy.model, reasoningEffort: policy.reasoningEffort },
37
+ validated: false,
38
+ code: 'CATALOG_UNAVAILABLE',
39
+ catalog: null,
40
+ runtimeEnforcement: false,
41
+ action: 'Read the active runtime catalog through health; child catalogRevision is not a prelaunch prerequisite.',
42
+ };
43
+ const finish = (code, action) => ({ ...report, code, action });
44
+ if (!admission.allowed)
45
+ return finish(admission.reason, admission.action);
46
+ if (!context.rootThreadId || !context.planIdentity || !l1Id)
47
+ return finish('ROOT_BINDING_MISMATCH', 'Restore the owning root/session binding before validating launch settings.');
48
+ const before = launchFence(context);
49
+ let result;
50
+ try {
51
+ result = await this.runtime.read({ sessionId, rootThreadId: context.rootThreadId });
52
+ }
53
+ catch {
54
+ return finish('CATALOG_UNAVAILABLE', 'The active runtime model/list read failed; inspect its capability without inventing catalog evidence.');
55
+ }
56
+ if (launchFence(this.context(sessionId)) !== before)
57
+ return finish('CONTEXT_CHANGED', 'Plan, policy or root ownership changed during the read; refresh health once before launch.');
58
+ if (result.kind !== 'observed')
59
+ return finish(result.code, 'The owning runtime catalog is unavailable; inspect the returned capability/binding code. No child receipt is required.');
60
+ report.catalog = {
61
+ source: result.source,
62
+ fingerprint: result.catalog.revision,
63
+ revisionSource: 'normalized-content-digest',
64
+ observedAt: result.observedAt,
65
+ };
66
+ const available = result.catalog.models.find((model) => model.id === policy.model);
67
+ if (!available)
68
+ return finish('MODEL_UNAVAILABLE', 'The runtime catalog does not support the requested exact model. Do not substitute a fallback silently.');
69
+ if (!available.reasoningEfforts.includes(policy.reasoningEffort))
70
+ return finish('EFFORT_UNSUPPORTED', 'The runtime catalog does not support the requested effort. Do not change effort silently.');
71
+ report.validated = true;
72
+ return finish('CATALOG_MATCH', 'Requested model/effort are supported by the owning runtime catalog. Proceed with the validated launch recipe within current controller authority; child settings remain unknown until observed.');
73
+ }
74
+ }
75
+ function launchFence(context) {
76
+ const index = context?.plan ? currentExecutableL1Index(context.plan) : -1;
77
+ const step = context?.plan?.steps[index];
78
+ return JSON.stringify([
79
+ context?.sessionId,
80
+ context?.provider,
81
+ context?.rootThreadId,
82
+ context?.planIdentity,
83
+ context?.plan?.modelPolicyVersion,
84
+ context?.modelPolicyStatus,
85
+ context?.plan?.modelPolicyAssurance ?? 'configured',
86
+ index,
87
+ step?.id,
88
+ step?.state,
89
+ step?.modelPolicy ? executionPolicyDigest(step.modelPolicy) : null,
90
+ ]);
91
+ }
@@ -79,6 +79,7 @@ export class ExecutorModelEvidenceReader {
79
79
  runtimeEnforcement: false,
80
80
  assurance: context.plan.modelPolicyAssurance ?? 'configured',
81
81
  code: 'CHILD_BINDING_UNKNOWN',
82
+ action: 'Child-only evidence. Use executorLaunch for prelaunch catalog validation; this report is not launch admission.',
82
83
  unknown: [],
83
84
  };
84
85
  const finish = (code) => {
@@ -94,8 +95,9 @@ export class ExecutorModelEvidenceReader {
94
95
  ];
95
96
  return report;
96
97
  };
97
- if (!executor ||
98
- !identity ||
98
+ if (!executor)
99
+ return finish('CHILD_NOT_LAUNCHED');
100
+ if (!identity ||
99
101
  !context.rootThreadId ||
100
102
  !context.planIdentity ||
101
103
  !child.threadId ||
@@ -321,11 +321,13 @@ export class CodexSessionRuntime {
321
321
  resource.turnThreads.set(result, childThreadId);
322
322
  return result;
323
323
  }
324
- /** Uses the active writer's catalog; never upgrades requested settings to observations. */
325
- async validateExecutorPolicy(sessionId, policy) {
326
- const resource = this.sessions.get(sessionId);
327
- if (!resource)
328
- throw new Error('EXECUTOR_CATALOG_UNAVAILABLE');
324
+ /** The same session-owned catalog source for health and pre-dispatch validation. */
325
+ async readExecutorPolicyCatalog(input) {
326
+ const resource = this.sessions.get(input.sessionId);
327
+ if (!resource?.active)
328
+ return { kind: 'unavailable', code: 'RUNTIME_UNAVAILABLE' };
329
+ if (!input.rootThreadId || resource.threadId !== input.rootThreadId)
330
+ return { kind: 'unavailable', code: 'ROOT_BINDING_MISMATCH' };
329
331
  let timer;
330
332
  let catalog;
331
333
  try {
@@ -336,12 +338,36 @@ export class CodexSessionRuntime {
336
338
  }),
337
339
  ]));
338
340
  }
341
+ catch {
342
+ return { kind: 'unavailable', code: 'CATALOG_UNAVAILABLE' };
343
+ }
339
344
  finally {
340
345
  if (timer)
341
346
  clearTimeout(timer);
342
347
  }
343
- if (!catalog || this.sessions.get(sessionId) !== resource || !resource.active)
348
+ if (this.sessions.get(input.sessionId) !== resource ||
349
+ !resource.active ||
350
+ resource.threadId !== input.rootThreadId)
351
+ return { kind: 'unavailable', code: 'CONTEXT_CHANGED' };
352
+ if (!catalog)
353
+ return { kind: 'unavailable', code: 'CATALOG_UNAVAILABLE' };
354
+ return {
355
+ kind: 'observed',
356
+ source: 'runtime-model-list',
357
+ observedAt: new Date().toISOString(),
358
+ catalog,
359
+ };
360
+ }
361
+ /** Uses the active writer's catalog; never upgrades requested settings to observations. */
362
+ async validateExecutorPolicy(sessionId, policy) {
363
+ const resource = this.sessions.get(sessionId);
364
+ const result = await this.readExecutorPolicyCatalog({
365
+ sessionId,
366
+ rootThreadId: resource?.threadId ?? '',
367
+ });
368
+ if (result.kind !== 'observed')
344
369
  throw new Error('EXECUTOR_CATALOG_UNAVAILABLE');
370
+ const catalog = result.catalog;
345
371
  const model = catalog.models.find((entry) => entry.id === policy.model);
346
372
  if (!model)
347
373
  throw new Error('EXECUTOR_MODEL_UNAVAILABLE');
@@ -6,7 +6,7 @@
6
6
  export const gestaltOrgPlanHealthDynamicTool = {
7
7
  type: 'function',
8
8
  name: 'gestalt_org_plan_health',
9
- description: 'Read the current session’s authoritative Org execution health, using the same controller state as Mobile. Read-only; does not enable, resume, checkpoint, or change the Org Plan.',
9
+ description: 'Read current Org execution health. executorLaunch validates requested model/effort against the owning runtime catalog before a child exists; modelPolicy describes child-only settings and may remain unknown. Read-only; does not enable, resume, checkpoint, or change the Org Plan.',
10
10
  inputSchema: { type: 'object', additionalProperties: false, properties: {} },
11
11
  };
12
12
  export function isOrgPlanHealthCall(input) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.55.4",
3
+ "version": "0.55.5",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",