@sequenceholdings/studio-cli 0.1.26 → 0.1.28

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.
Files changed (62) hide show
  1. package/README.md +265 -81
  2. package/dist/app/adapters.d.ts +9 -0
  3. package/dist/app/adapters.js +176 -0
  4. package/dist/app/commands.d.ts +2 -2
  5. package/dist/app/commands.js +98 -22
  6. package/dist/app/deploy.d.ts +9 -10
  7. package/dist/app/deploy.js +83 -141
  8. package/dist/app/graph.d.ts +15 -0
  9. package/dist/app/graph.js +36 -0
  10. package/dist/app/manifest-validation.d.ts +16 -0
  11. package/dist/app/manifest-validation.js +99 -0
  12. package/dist/app/manifest.d.ts +27 -9
  13. package/dist/app/manifest.js +23 -107
  14. package/dist/app/paths.d.ts +14 -0
  15. package/dist/app/paths.js +77 -0
  16. package/dist/app/primitive-scaffold.d.ts +18 -0
  17. package/dist/app/primitive-scaffold.js +136 -0
  18. package/dist/app/readme.d.ts +4 -18
  19. package/dist/app/readme.js +107 -229
  20. package/dist/app/run-deployment.d.ts +8 -0
  21. package/dist/app/run-deployment.js +50 -0
  22. package/dist/app/scaffold-files.d.ts +13 -0
  23. package/dist/app/scaffold-files.js +68 -0
  24. package/dist/app/scaffold.d.ts +11 -3
  25. package/dist/app/scaffold.js +77 -245
  26. package/dist/app/workspace-compile.d.ts +18 -0
  27. package/dist/app/workspace-compile.js +143 -0
  28. package/dist/app/workspace-model.d.ts +70 -0
  29. package/dist/app/workspace-model.js +159 -0
  30. package/dist/app/workspace-scaffold.d.ts +27 -0
  31. package/dist/app/workspace-scaffold.js +126 -0
  32. package/dist/app/workspace.d.ts +14 -0
  33. package/dist/app/workspace.js +147 -0
  34. package/dist/atlas-client.js +28 -6
  35. package/dist/auth-cmds/commands.d.ts +1 -1
  36. package/dist/auth-cmds/commands.js +5 -2
  37. package/dist/functions/commands.js +7 -1
  38. package/dist/functions/manifest.d.ts +18 -0
  39. package/dist/functions/manifest.js +29 -4
  40. package/dist/main.js +9 -4
  41. package/dist/orm/delegate.js +30 -23
  42. package/dist/pat-hints.js +1 -0
  43. package/dist/pipeline/commands.js +27 -9
  44. package/dist/pipeline/lifecycle.d.ts +2 -0
  45. package/dist/pipeline/lifecycle.js +91 -11
  46. package/dist/process/build.js +59 -43
  47. package/dist/process/codegen.d.ts +3 -2
  48. package/dist/process/codegen.js +143 -27
  49. package/dist/process/commands.d.ts +2 -0
  50. package/dist/process/commands.js +63 -18
  51. package/dist/process/discover.d.ts +6 -3
  52. package/dist/process/discover.js +11 -3
  53. package/dist/process/lint.d.ts +14 -0
  54. package/dist/process/lint.js +143 -5
  55. package/dist/process/plan-diff.d.ts +8 -0
  56. package/dist/process/plan-diff.js +61 -4
  57. package/dist/process/safety-baseline.d.ts +154 -0
  58. package/dist/process/safety-baseline.js +387 -0
  59. package/dist/process/simulate.js +64 -22
  60. package/dist/repos/commands.d.ts +1 -1
  61. package/dist/repos/commands.js +29 -3
  62. package/package.json +8 -7
@@ -17,7 +17,7 @@ import { finalizeCompiledBundle, summarizeBundle } from './build.js';
17
17
  import { buildResolveProcessPinFromEnv } from './resolve-process-pin.js';
18
18
  import { loadBundleForPublish } from './local-bundle.js';
19
19
  import { findProcessRoot } from './discover.js';
20
- import { formatLintResult, lintSerializedAgentContracts, } from './lint.js';
20
+ import { formatLintResult, lintBundleStaticGraphLimits, lintSerializedAgentContracts, } from './lint.js';
21
21
  import { diffBundleAgainstActive, formatPlanDiff, } from './plan-diff.js';
22
22
  import { formatSimulateResult } from './simulate.js';
23
23
  import { buildAgentSchemaLoader } from './agent-loader.js';
@@ -27,6 +27,15 @@ import { compileProcessSourceIsolated, simulateProcessIsolated, } from './compil
27
27
  export function parseArgs(rest) {
28
28
  const positional = [];
29
29
  const flags = {};
30
+ const repeatedFlags = {};
31
+ const setFlag = (key, value) => {
32
+ flags[key] = value;
33
+ if (typeof value === 'string') {
34
+ const values = repeatedFlags[key] ?? [];
35
+ values.push(value);
36
+ repeatedFlags[key] = values;
37
+ }
38
+ };
30
39
  for (let i = 0; i < rest.length; i++) {
31
40
  const arg = rest[i];
32
41
  if (arg === '--') {
@@ -41,7 +50,7 @@ export function parseArgs(rest) {
41
50
  // wrong target.
42
51
  const eqIdx = body.indexOf('=');
43
52
  if (eqIdx >= 0) {
44
- flags[body.slice(0, eqIdx)] = body.slice(eqIdx + 1);
53
+ setFlag(body.slice(0, eqIdx), body.slice(eqIdx + 1));
45
54
  continue;
46
55
  }
47
56
  const key = body;
@@ -51,11 +60,11 @@ export function parseArgs(rest) {
51
60
  // would consume `-e` as the value of `--out` and silently swallow
52
61
  // the `-e` flag.
53
62
  if (next && !next.startsWith('-')) {
54
- flags[key] = next;
63
+ setFlag(key, next);
55
64
  i += 1;
56
65
  }
57
66
  else {
58
- flags[key] = true;
67
+ setFlag(key, true);
59
68
  }
60
69
  }
61
70
  else if (arg.startsWith('-') && arg.length >= 2 && !arg.startsWith('--')) {
@@ -71,23 +80,27 @@ export function parseArgs(rest) {
71
80
  continue;
72
81
  }
73
82
  if (eqIdx >= 0) {
74
- flags[longName] = arg.slice(eqIdx + 1);
83
+ setFlag(longName, arg.slice(eqIdx + 1));
75
84
  continue;
76
85
  }
77
86
  const next = rest[i + 1];
78
87
  if (next && !next.startsWith('-')) {
79
- flags[longName] = next;
88
+ setFlag(longName, next);
80
89
  i += 1;
81
90
  }
82
91
  else {
83
- flags[longName] = true;
92
+ setFlag(longName, true);
84
93
  }
85
94
  }
86
95
  else {
87
96
  positional.push(arg);
88
97
  }
89
98
  }
90
- return { positional, flags };
99
+ return {
100
+ positional,
101
+ flags,
102
+ ...(Object.keys(repeatedFlags).length > 0 ? { repeatedFlags } : {}),
103
+ };
91
104
  }
92
105
  const SHORT_FLAG_ALIASES = {
93
106
  '-e': 'env',
@@ -132,6 +145,10 @@ export function parseProcessSourceSpec(flags) {
132
145
  throw new Error('--repo requires a value: --repo processes/<name>');
133
146
  if (flags.ref === true)
134
147
  throw new Error('--ref requires a value.');
148
+ if (flags.dir === true)
149
+ throw new Error('--dir requires a directory.');
150
+ if (repo && flags.dir !== undefined)
151
+ throw new Error('--dir cannot be combined with --repo.');
135
152
  if (ref && !repo)
136
153
  throw new Error('--ref only applies together with --repo.');
137
154
  if (ref && ref.startsWith('-'))
@@ -213,7 +230,15 @@ function slugify(value) {
213
230
  // lint
214
231
  // ---------------------------------------------------------------------------
215
232
  export async function lintCommand(args) {
216
- const compiled = await compileLocalProcessSource();
233
+ const compiled = await compileLocalProcessSource(args);
234
+ const selection = resolveOnlyIds({
235
+ only: args.flags.only,
236
+ knownIds: new Set(compiled.bundle.processes.map((definition) => definition.id)),
237
+ });
238
+ if (selection.error) {
239
+ console.error(selection.error);
240
+ return 1;
241
+ }
217
242
  const result = await lintCompiledProcessSource({
218
243
  compiled,
219
244
  loadAgentSchemaEdgeIdEnum: await tryBuildAgentLoader(args),
@@ -228,8 +253,13 @@ export async function lintCommand(args) {
228
253
  console.log(`\nlint ok — ${compiled.bundle.processes.length} process(es) checked, ${result.warnings.length} warning(s)`);
229
254
  return 0;
230
255
  }
231
- async function compileLocalProcessSource() {
232
- const rootDir = await findProcessRoot();
256
+ function localProcessDirectory(args) {
257
+ if (args.flags.dir === true)
258
+ throw new Error('--dir requires a directory.');
259
+ return args.flags.dir;
260
+ }
261
+ async function compileLocalProcessSource(args) {
262
+ const rootDir = await findProcessRoot({ directory: localProcessDirectory(args) });
233
263
  return compileProcessSourceIsolated({
234
264
  rootDir,
235
265
  provenance: localGitMetadata(rootDir),
@@ -243,12 +273,18 @@ async function lintCompiledProcessSource({ compiled, loadAgentSchemaEdgeIdEnum,
243
273
  // parent only adds registry-dependent validation (or the offline warning).
244
274
  includeStaticValidation: false,
245
275
  });
276
+ // Static graph limits (LAT-148): ceilings are errors, published defaults
277
+ // are warnings — the target deployment's profile is what registration
278
+ // actually enforces.
279
+ const limitLint = lintBundleStaticGraphLimits({ bundle: compiled.bundle });
246
280
  return {
247
- errors: [...compiled.lint.errors, ...agentLint.errors],
248
- warnings: [...compiled.lint.warnings, ...agentLint.warnings],
281
+ errors: [...compiled.lint.errors, ...agentLint.errors, ...limitLint.errors],
282
+ warnings: [...compiled.lint.warnings, ...agentLint.warnings, ...limitLint.warnings],
249
283
  };
250
284
  }
251
285
  async function tryBuildAgentLoader(args) {
286
+ if (args.flags.offline === true || args.flags.offline === 'true')
287
+ return undefined;
252
288
  // Agent loader is only meaningful when we have a target env + token.
253
289
  // If either fails to resolve, skip the check; lint will emit a warning
254
290
  // for multi-edge agent nodes instead of failing.
@@ -286,8 +322,17 @@ async function buildBundleForPublish(args, compiled) {
286
322
  }
287
323
  }
288
324
  export async function planCommand(args) {
289
- const compiled = await compileLocalProcessSource();
325
+ const compiled = await compileLocalProcessSource(args);
290
326
  const bundle = await buildBundleForPublish(args, compiled);
327
+ // Static graph limits (LAT-148): run limits lint so `process plan` matches registration.
328
+ const limitLint = lintBundleStaticGraphLimits({ bundle });
329
+ const formattedLint = formatLintResult(limitLint);
330
+ if (formattedLint.text)
331
+ console.log(formattedLint.text);
332
+ if (formattedLint.hasErrors) {
333
+ console.error(`\nplan FAILED — ${limitLint.errors.length} static graph limit error(s), ${limitLint.warnings.length} warning(s)`);
334
+ return 1;
335
+ }
291
336
  const summary = summarizeBundle(bundle);
292
337
  console.log(JSON.stringify(summary, null, 2));
293
338
  const loadActiveProcess = await tryBuildActiveProcessLoader(args);
@@ -339,7 +384,7 @@ async function tryBuildActiveProcessLoader(args) {
339
384
  // test (CI wrapper)
340
385
  // ---------------------------------------------------------------------------
341
386
  export async function testCommand(args) {
342
- const compiled = await compileLocalProcessSource();
387
+ const compiled = await compileLocalProcessSource(args);
343
388
  const lintResult = await lintCompiledProcessSource({
344
389
  compiled,
345
390
  loadAgentSchemaEdgeIdEnum: await tryBuildAgentLoader(args),
@@ -415,7 +460,7 @@ export async function applyCommand(args) {
415
460
  return applyLocal(args);
416
461
  }
417
462
  async function applyLocal(args) {
418
- const compiled = await compileLocalProcessSource();
463
+ const compiled = await compileLocalProcessSource(args);
419
464
  const { env, token } = await getEnvAndToken(args);
420
465
  return registerAndPromote({ args, env, token, compiled });
421
466
  }
@@ -613,7 +658,7 @@ export async function bundleCommand(args) {
613
658
  const sub = args.positional[0];
614
659
  switch (sub) {
615
660
  case 'build': {
616
- const compiled = await compileLocalProcessSource();
661
+ const compiled = await compileLocalProcessSource(args);
617
662
  const bundle = await buildBundleForPublish(args, compiled);
618
663
  const out = typeof args.flags.out === 'string' ? resolve(args.flags.out) : null;
619
664
  if (out) {
@@ -750,7 +795,7 @@ export async function simulateCommand(args) {
750
795
  return 1;
751
796
  }
752
797
  const simulation = await simulateProcessIsolated({
753
- rootDir: await findProcessRoot(),
798
+ rootDir: await findProcessRoot({ directory: localProcessDirectory(args) }),
754
799
  processId,
755
800
  });
756
801
  if (simulation.kind === 'not-found') {
@@ -20,10 +20,13 @@ export interface LoadedProcess {
20
20
  * Resolve the root directory to scan for `<id>/process.ts` folders.
21
21
  *
22
22
  * Precedence:
23
- * 1. `LATTICE_PROCESSES_ROOT` env var (absolute or relative to cwd)
24
- * 2. The current working directory (the typical case in an external repo)
23
+ * 1. Explicit `--dir` (absolute or relative to cwd)
24
+ * 2. `LATTICE_PROCESSES_ROOT` env var (absolute or relative to cwd)
25
+ * 3. The current working directory (the typical case in an external repo)
25
26
  */
26
- export declare function findProcessRoot(): Promise<string>;
27
+ export declare function findProcessRoot({ directory }?: {
28
+ directory?: string;
29
+ }): Promise<string>;
27
30
  /**
28
31
  * Load every `<dir>/process.ts` under the configured root. Each module
29
32
  * must `export default defineProcess(...)`. Process ids must be unique
@@ -37,10 +37,18 @@ async function fileExists(path) {
37
37
  * Resolve the root directory to scan for `<id>/process.ts` folders.
38
38
  *
39
39
  * Precedence:
40
- * 1. `LATTICE_PROCESSES_ROOT` env var (absolute or relative to cwd)
41
- * 2. The current working directory (the typical case in an external repo)
40
+ * 1. Explicit `--dir` (absolute or relative to cwd)
41
+ * 2. `LATTICE_PROCESSES_ROOT` env var (absolute or relative to cwd)
42
+ * 3. The current working directory (the typical case in an external repo)
42
43
  */
43
- export async function findProcessRoot() {
44
+ export async function findProcessRoot({ directory } = {}) {
45
+ if (directory !== undefined) {
46
+ const resolved = resolve(directory);
47
+ if (!directory.trim() || !(await isDir(resolved))) {
48
+ throw new Error(`--dir is not a directory: ${resolved}`);
49
+ }
50
+ return resolved;
51
+ }
44
52
  const envRoot = process.env['LATTICE_PROCESSES_ROOT']?.trim();
45
53
  if (envRoot) {
46
54
  const resolved = resolve(envRoot);
@@ -36,6 +36,20 @@ export interface LintInput {
36
36
  suppressUnavailableAgentWarnings?: boolean;
37
37
  }
38
38
  export declare function lintProcesses(input: LintInput): Promise<LintResult>;
39
+ /**
40
+ * Static graph-shape limits (LAT-148), measured by the SDK's shared walker —
41
+ * exactly what registration measures. Two tiers, because the CLI does not
42
+ * know the target deployment's profile:
43
+ *
44
+ * - over a platform HARD CEILING → error: no deployment can be configured
45
+ * to accept it, so `apply` would fail everywhere.
46
+ * - over the PUBLISHED DEFAULT (but under the ceiling) → warning: the
47
+ * default deployment rejects it, a deployment with a raised
48
+ * `LATTICE_SAFETY_PROFILE` may accept it. The server is authoritative.
49
+ */
50
+ export declare function lintBundleStaticGraphLimits({ bundle }: {
51
+ bundle: LatticeBundle;
52
+ }): LintResult;
39
53
  export declare function lintSerializedAgentContracts({ bundle, loadAgentSchemaEdgeIdEnum, includeStaticValidation, }: {
40
54
  bundle: LatticeBundle;
41
55
  loadAgentSchemaEdgeIdEnum?: LintInput['loadAgentSchemaEdgeIdEnum'];
@@ -10,8 +10,10 @@
10
10
  * but on_timeout_edge_id is unset, warn
11
11
  */
12
12
  import { readFileSync } from 'node:fs';
13
- import { forEachSerializedNode, } from '@sequenceholdings/lattice/bundle';
14
- import { parallelSubNodes, validateEmailReminders } from '@sequenceholdings/lattice/define';
13
+ import { checkBundleStaticGraphLimits, forEachSerializedNode, measureBundleStaticGraph, } from '@sequenceholdings/lattice/bundle';
14
+ import { DEFAULT_LATTICE_SAFETY_PROFILE, LATTICE_SAFETY_CEILINGS, } from '@sequenceholdings/lattice';
15
+ import { isJsonataExpr, parallelSubNodes, validateEmailReminders } from '@sequenceholdings/lattice/define';
16
+ import { assertJsonataExpr } from '@sequenceholdings/lattice/jsonata-runtime';
15
17
  export async function lintProcesses(input) {
16
18
  const errors = [];
17
19
  const warnings = [];
@@ -67,7 +69,14 @@ export async function lintProcesses(input) {
67
69
  });
68
70
  }
69
71
  }
72
+ lintJsonataExpression({
73
+ processId: p.id,
74
+ field: 'supervisor_retry.retryIf',
75
+ value: p.supervisor_retry?.retryIf,
76
+ errors,
77
+ });
70
78
  for (const node of p.nodes) {
79
+ lintJsonataExpressions(p.id, node, errors);
71
80
  await lintNodeContract(p.id, node, errors, warnings, input.loadAgentSchemaEdgeIdEnum, input.suppressUnavailableAgentWarnings ?? false);
72
81
  }
73
82
  // Closure-scope check: mappers / fn / join / fan_out / output are
@@ -86,6 +95,88 @@ export async function lintProcesses(input) {
86
95
  }
87
96
  return { errors, warnings };
88
97
  }
98
+ function lintJsonataExpressions(processId, node, errors) {
99
+ const expressions = [];
100
+ const add = (field, value) => {
101
+ if (isJsonataExpr(value))
102
+ expressions.push({ field, value });
103
+ };
104
+ add('input', 'input' in node ? node.input : undefined);
105
+ switch (node.kind) {
106
+ case 'human': {
107
+ const human = node;
108
+ add('artifact_refs', human.artifact_refs);
109
+ add('advance_allowed', human.advance_allowed);
110
+ add('dueDate', human.dueDate);
111
+ const email = human.emailNotification;
112
+ if (isJsonataExpr(email)) {
113
+ add('emailNotification.template', email);
114
+ }
115
+ else if (email && typeof email === 'object') {
116
+ add('emailNotification.template', email.template);
117
+ email.reminders?.forEach((reminder, index) => {
118
+ add(`emailNotification.reminders[${index}].template`, reminder.template);
119
+ });
120
+ }
121
+ break;
122
+ }
123
+ case 'parallel': {
124
+ const parallel = node;
125
+ add('join', parallel.join);
126
+ if ('fan_out' in parallel)
127
+ add('fan_out', parallel.fan_out);
128
+ add('supervisor_retry.retryIf', parallel.supervisor_retry?.retryIf);
129
+ for (const { node: sub } of parallelSubNodes(parallel)) {
130
+ lintJsonataExpressions(processId, sub, errors);
131
+ }
132
+ break;
133
+ }
134
+ case 'subprocess': {
135
+ const subprocess = node;
136
+ add('output', subprocess.output);
137
+ add('supervisor_retry.retryIf', subprocess.supervisor_retry?.retryIf);
138
+ break;
139
+ }
140
+ }
141
+ const middleware = 'middleware' in node ? node.middleware : undefined;
142
+ if (Array.isArray(middleware)) {
143
+ middleware.forEach((ref) => {
144
+ const expr = ref.config?.retryIfExpr;
145
+ if (typeof expr === 'string') {
146
+ expressions.push({
147
+ field: 'middleware.retryIf',
148
+ value: { $mapper: 'jsonata', expr },
149
+ });
150
+ }
151
+ });
152
+ }
153
+ for (const { field, value } of expressions) {
154
+ lintJsonataExpression({
155
+ processId,
156
+ nodeId: node.id,
157
+ field,
158
+ value,
159
+ errors,
160
+ });
161
+ }
162
+ }
163
+ function lintJsonataExpression({ processId, nodeId, field, value, errors, }) {
164
+ if (!isJsonataExpr(value))
165
+ return;
166
+ try {
167
+ assertJsonataExpr({
168
+ label: `process "${processId}"${nodeId ? ` node "${nodeId}"` : ''} ${field}`,
169
+ expr: value.expr,
170
+ });
171
+ }
172
+ catch (error) {
173
+ errors.push({
174
+ process_id: processId,
175
+ ...(nodeId ? { node_id: nodeId } : {}),
176
+ message: error instanceof Error ? error.message : String(error),
177
+ });
178
+ }
179
+ }
89
180
  /**
90
181
  * Module-scope binding names introduced by `import` statements in the process
91
182
  * file. These are exactly the names a serialized (vm-executed) function must
@@ -336,6 +427,40 @@ function lintSubprocessOutput(processId, node, errors, warnings) {
336
427
  }
337
428
  }
338
429
  const EDGE_ID_LITERAL_RE = /\bedge_id\s*:\s*['"`]([^'"`]+)['"`]/g;
430
+ /**
431
+ * Static graph-shape limits (LAT-148), measured by the SDK's shared walker —
432
+ * exactly what registration measures. Two tiers, because the CLI does not
433
+ * know the target deployment's profile:
434
+ *
435
+ * - over a platform HARD CEILING → error: no deployment can be configured
436
+ * to accept it, so `apply` would fail everywhere.
437
+ * - over the PUBLISHED DEFAULT (but under the ceiling) → warning: the
438
+ * default deployment rejects it, a deployment with a raised
439
+ * `LATTICE_SAFETY_PROFILE` may accept it. The server is authoritative.
440
+ */
441
+ export function lintBundleStaticGraphLimits({ bundle }) {
442
+ const measurement = measureBundleStaticGraph({ bundle });
443
+ const overCeiling = checkBundleStaticGraphLimits({
444
+ measurement,
445
+ limits: LATTICE_SAFETY_CEILINGS.staticGraph,
446
+ limitsLabel: 'the platform ceiling',
447
+ });
448
+ const ceilingKeys = new Set(overCeiling.map((v) => `${v.code}\u0000${v.processId ?? ''}`));
449
+ const overDefault = checkBundleStaticGraphLimits({
450
+ measurement,
451
+ limits: DEFAULT_LATTICE_SAFETY_PROFILE.staticGraph,
452
+ limitsLabel: 'the published default',
453
+ }).filter((v) => !ceilingKeys.has(`${v.code}\u0000${v.processId ?? ''}`));
454
+ const issue = (v, tail) => ({
455
+ process_id: v.processId ?? '(bundle)',
456
+ ...(v.nodePath !== null ? { node_id: v.nodePath } : {}),
457
+ message: `${v.message} (${v.field}; ${tail})`,
458
+ });
459
+ return {
460
+ errors: overCeiling.map((v) => issue(v, 'platform hard ceiling — no deployment accepts this')),
461
+ warnings: overDefault.map((v) => issue(v, 'published default — registration fails unless the target deployment raised its LATTICE_SAFETY_PROFILE')),
462
+ };
463
+ }
339
464
  export async function lintSerializedAgentContracts({ bundle, loadAgentSchemaEdgeIdEnum, includeStaticValidation = true, }) {
340
465
  const errors = [];
341
466
  const warnings = [];
@@ -364,11 +489,13 @@ function serializedAgentContract(node) {
364
489
  if (node.kind !== 'agent' || !isUnknownRecord(node.metadata))
365
490
  return null;
366
491
  const agentId = node.metadata.agent_id;
492
+ const agentVersion = node.metadata.agent_version;
367
493
  if (typeof agentId !== 'string')
368
494
  return null;
369
495
  const onResetEdgeId = node.metadata.on_reset_edge_id;
370
496
  return {
371
497
  agentId,
498
+ ...(typeof agentVersion === 'number' ? { agentVersion } : {}),
372
499
  allEdgeIds: node.outgoing_edges.map((edge) => edge.id),
373
500
  ...(typeof onResetEdgeId === 'string' ? { onResetEdgeId } : {}),
374
501
  };
@@ -381,6 +508,7 @@ async function lintAgent(processId, node, errors, warnings, loadAgentSchemaEdgeI
381
508
  processId,
382
509
  nodeId: node.id,
383
510
  agentId: node.agent.id,
511
+ agentVersion: node.agent.version,
384
512
  allEdgeIds: node.outgoing_edges.map((edge) => edge.id),
385
513
  onResetEdgeId: node.on_reset_edge_id,
386
514
  errors,
@@ -390,7 +518,7 @@ async function lintAgent(processId, node, errors, warnings, loadAgentSchemaEdgeI
390
518
  includeStaticValidation: true,
391
519
  });
392
520
  }
393
- async function lintAgentContract({ processId, nodeId, agentId, allEdgeIds, onResetEdgeId, errors, warnings, loadAgentSchemaEdgeIdEnum, suppressUnavailableAgentWarnings, includeStaticValidation, }) {
521
+ async function lintAgentContract({ processId, nodeId, agentId, agentVersion, allEdgeIds, onResetEdgeId, errors, warnings, loadAgentSchemaEdgeIdEnum, suppressUnavailableAgentWarnings, includeStaticValidation, }) {
394
522
  if (includeStaticValidation && onResetEdgeId && !allEdgeIds.includes(onResetEdgeId)) {
395
523
  errors.push({
396
524
  process_id: processId,
@@ -399,6 +527,16 @@ async function lintAgentContract({ processId, nodeId, agentId, allEdgeIds, onRes
399
527
  });
400
528
  }
401
529
  const outgoingIds = allEdgeIds.filter((id) => id !== onResetEdgeId);
530
+ if (agentVersion !== undefined) {
531
+ if (outgoingIds.length > 1) {
532
+ warnings.push({
533
+ process_id: processId,
534
+ node_id: nodeId,
535
+ message: `agent "${agentId}" version ${agentVersion} uses an immutable snapshot; lint cannot load its exact edge_id enum, so registration validates snapshot compatibility and runtime validates edge_id rather than checking the live agent`,
536
+ });
537
+ }
538
+ return;
539
+ }
402
540
  if (!loadAgentSchemaEdgeIdEnum) {
403
541
  if (outgoingIds.length > 1 && !suppressUnavailableAgentWarnings) {
404
542
  warnings.push({
@@ -536,8 +674,8 @@ function lintHuman(processId, node, errors, warnings) {
536
674
  // after it times out / past the cap) are author bugs the runner silently
537
675
  // skips — catch them here. Only the object form carries reminders.
538
676
  const email = node.emailNotification;
539
- if (email && typeof email === 'object') {
540
- const hasDueDate = typeof node.dueDate === 'function';
677
+ if (email && typeof email === 'object' && !isJsonataExpr(email)) {
678
+ const hasDueDate = typeof node.dueDate === 'function' || isJsonataExpr(node.dueDate);
541
679
  for (const issue of validateEmailReminders(email, node.timeout, hasDueDate)) {
542
680
  errors.push({
543
681
  process_id: processId,
@@ -22,6 +22,14 @@ export interface ProcessDiff {
22
22
  from: string;
23
23
  to: string;
24
24
  };
25
+ /**
26
+ * Process-level behavioral fields (orchestrator supervisor_retry, run
27
+ * caps, run_as identity, entity_spec) that changed between active and
28
+ * next. Without this a bundle whose only change is e.g. the orchestrator
29
+ * retry predicate would diff as "unchanged" and `process test` would stay
30
+ * green even though new runs adopt the new policy.
31
+ */
32
+ process_fields_changed?: readonly string[];
25
33
  added_nodes: readonly string[];
26
34
  removed_nodes: readonly string[];
27
35
  changed_nodes: readonly NodeChange[];
@@ -28,6 +28,9 @@ export async function diffBundleAgainstActive(input) {
28
28
  process_id: newProc.id,
29
29
  status: diff.unchanged ? 'unchanged' : 'updated',
30
30
  ...(diff.startNodeChanged ? { start_node_changed: diff.startNodeChanged } : {}),
31
+ ...(diff.processFieldsChanged.length > 0
32
+ ? { process_fields_changed: diff.processFieldsChanged }
33
+ : {}),
31
34
  added_nodes: diff.addedNodes,
32
35
  removed_nodes: diff.removedNodes,
33
36
  changed_nodes: diff.changedNodes,
@@ -48,6 +51,7 @@ function diffProcesses(active, next) {
48
51
  const startNodeChanged = active.start_node_id !== next.start_node_id
49
52
  ? { from: active.start_node_id, to: next.start_node_id }
50
53
  : undefined;
54
+ const processFieldsChanged = PROCESS_BEHAVIORAL_FIELDS.filter((field) => !stableEqual(active[field], next[field]));
51
55
  const activeNodeIds = new Set(active.nodes.map((n) => n.id));
52
56
  const nextNodeIds = new Set(next.nodes.map((n) => n.id));
53
57
  const removedNodes = [...activeNodeIds].filter((id) => !nextNodeIds.has(id));
@@ -104,6 +108,7 @@ function diffProcesses(active, next) {
104
108
  retargetedEdges.length > 0 ||
105
109
  changedNodes.some((c) => c.kind_changed != null || c.agent_ref_changed != null);
106
110
  const unchanged = startNodeChanged == null &&
111
+ processFieldsChanged.length === 0 &&
107
112
  removedNodes.length === 0 &&
108
113
  addedNodes.length === 0 &&
109
114
  changedNodes.length === 0 &&
@@ -113,6 +118,7 @@ function diffProcesses(active, next) {
113
118
  return {
114
119
  unchanged,
115
120
  ...(startNodeChanged ? { startNodeChanged } : {}),
121
+ processFieldsChanged,
116
122
  addedNodes,
117
123
  removedNodes,
118
124
  changedNodes,
@@ -122,6 +128,23 @@ function diffProcesses(active, next) {
122
128
  isBreaking,
123
129
  };
124
130
  }
131
+ /**
132
+ * Process-level fields that alter behavior for new runs: the orchestrator's
133
+ * supervisor retry policy (JS or JSONata predicate included), run caps,
134
+ * dispatch concurrency, the run_as identity, and the entity binding spec.
135
+ * `name`/`description`/`tags`/`recommendations` are cosmetic and stay out —
136
+ * same narrowness rationale as {@link BEHAVIORAL_METADATA_FIELDS}.
137
+ * `start_node_id` and `nodes` are diffed structurally above.
138
+ */
139
+ const PROCESS_BEHAVIORAL_FIELDS = [
140
+ 'entity_spec',
141
+ 'input_schema',
142
+ 'max_iterations',
143
+ 'max_revisits',
144
+ 'max_concurrent_runs',
145
+ 'supervisor_retry',
146
+ 'run_as',
147
+ ];
125
148
  /**
126
149
  * Per-kind set of metadata fields that, when changed, alter behavior
127
150
  * for new runs. Kept narrow on purpose: cosmetic/non-behavioral fields
@@ -140,6 +163,7 @@ const BEHAVIORAL_METADATA_FIELDS = {
140
163
  'function_version',
141
164
  'function_id',
142
165
  'input_mapper_source',
166
+ 'input_mapper_expr',
143
167
  'registered_function_id',
144
168
  // Native automation nodes: static config (e.g. a target resource id) and
145
169
  // limits alter which function runs and with what budget.
@@ -147,15 +171,32 @@ const BEHAVIORAL_METADATA_FIELDS = {
147
171
  'limits',
148
172
  'middleware',
149
173
  ],
150
- agent: ['input_mapper_source', 'timeout', 'workflow_id', 'middleware', 'on_reset_edge_id'],
174
+ agent: [
175
+ 'agent_version',
176
+ 'input_mapper_source',
177
+ 'input_mapper_expr',
178
+ 'timeout',
179
+ 'workflow_id',
180
+ 'middleware',
181
+ 'on_reset_edge_id',
182
+ ],
151
183
  // managed_function: the target ref, version pin, output/timeout budget,
152
184
  // input mapper, and middleware (e.g. retry) all alter what runs for new runs.
153
- managed_function: ['function_id', 'version', 'limits', 'input_mapper_source', 'middleware'],
185
+ managed_function: [
186
+ 'function_id',
187
+ 'version',
188
+ 'limits',
189
+ 'input_mapper_source',
190
+ 'input_mapper_expr',
191
+ 'middleware',
192
+ ],
154
193
  human: [
155
194
  'artifact_refs',
156
195
  'artifact_refs_mapper_source',
196
+ 'artifact_refs_mapper_expr',
157
197
  'comments',
158
198
  'input_mapper_source',
199
+ 'input_mapper_expr',
159
200
  'timeout',
160
201
  'on_timeout_edge_id',
161
202
  'metadata',
@@ -165,10 +206,19 @@ const BEHAVIORAL_METADATA_FIELDS = {
165
206
  // behavioral (otherwise `process test` stays green on an auth change).
166
207
  'advance_allowed',
167
208
  'advance_allowed_mapper_source',
209
+ 'advance_allowed_mapper_expr',
168
210
  // dueDate fn computes the task's due instant at parking — a change alters
169
211
  // run behavior (inbox due pill/sort), so it must diff as behavioral.
170
212
  'due_date_source',
213
+ 'due_date_expr',
214
+ 'email_notification',
215
+ 'email_notification_template_source',
216
+ 'email_notification_template_expr',
217
+ 'email_notification_timezone',
218
+ 'email_notification_reminders',
219
+ 'email_notification_enabled_environments',
171
220
  ],
221
+ parallel: ['input_mapper_source', 'input_mapper_expr', 'parallel'],
172
222
  };
173
223
  /** Nested `metadata.subprocess` fields that change behavior for new parent runs. */
174
224
  const SUBPROCESS_BEHAVIORAL_FIELDS = [
@@ -177,6 +227,8 @@ const SUBPROCESS_BEHAVIORAL_FIELDS = [
177
227
  'bundle_hash',
178
228
  'on_child_error',
179
229
  'output_mapper_source',
230
+ 'output_mapper_expr',
231
+ 'supervisor_retry',
180
232
  ];
181
233
  function diffNode(a, b) {
182
234
  const change = { node_id: a.id };
@@ -230,8 +282,10 @@ function diffNode(a, b) {
230
282
  subprocessChanged.push(`subprocess.${f}`);
231
283
  }
232
284
  }
233
- if (!stableEqual(metaA.input_mapper_source, metaB.input_mapper_source)) {
234
- subprocessChanged.push('input_mapper_source');
285
+ for (const field of ['input_mapper_source', 'input_mapper_expr']) {
286
+ if (!stableEqual(metaA[field], metaB[field])) {
287
+ subprocessChanged.push(field);
288
+ }
235
289
  }
236
290
  if (subprocessChanged.length > 0) {
237
291
  change.metadata_fields_changed = [
@@ -300,6 +354,9 @@ export function formatPlanDiff(diff) {
300
354
  if (p.start_node_changed) {
301
355
  lines.push(` ! start_node_id: ${p.start_node_changed.from} → ${p.start_node_changed.to} (BREAKING)`);
302
356
  }
357
+ if (p.process_fields_changed && p.process_fields_changed.length > 0) {
358
+ lines.push(` ~ process fields: ${p.process_fields_changed.join(', ')}`);
359
+ }
303
360
  if (p.added_nodes.length > 0)
304
361
  lines.push(` + nodes: ${p.added_nodes.join(', ')}`);
305
362
  if (p.removed_nodes.length > 0)