@sequenceholdings/studio-cli 0.1.27 → 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.
- package/README.md +255 -72
- package/dist/app/adapters.d.ts +9 -0
- package/dist/app/adapters.js +176 -0
- package/dist/app/commands.d.ts +2 -2
- package/dist/app/commands.js +98 -22
- package/dist/app/deploy.d.ts +9 -10
- package/dist/app/deploy.js +83 -141
- package/dist/app/graph.d.ts +15 -0
- package/dist/app/graph.js +36 -0
- package/dist/app/manifest-validation.d.ts +16 -0
- package/dist/app/manifest-validation.js +99 -0
- package/dist/app/manifest.d.ts +27 -9
- package/dist/app/manifest.js +23 -107
- package/dist/app/paths.d.ts +14 -0
- package/dist/app/paths.js +77 -0
- package/dist/app/primitive-scaffold.d.ts +18 -0
- package/dist/app/primitive-scaffold.js +136 -0
- package/dist/app/readme.d.ts +4 -18
- package/dist/app/readme.js +105 -233
- package/dist/app/run-deployment.d.ts +8 -0
- package/dist/app/run-deployment.js +50 -0
- package/dist/app/scaffold-files.d.ts +13 -0
- package/dist/app/scaffold-files.js +68 -0
- package/dist/app/scaffold.d.ts +11 -3
- package/dist/app/scaffold.js +77 -245
- package/dist/app/workspace-compile.d.ts +18 -0
- package/dist/app/workspace-compile.js +143 -0
- package/dist/app/workspace-model.d.ts +70 -0
- package/dist/app/workspace-model.js +159 -0
- package/dist/app/workspace-scaffold.d.ts +27 -0
- package/dist/app/workspace-scaffold.js +126 -0
- package/dist/app/workspace.d.ts +14 -0
- package/dist/app/workspace.js +147 -0
- package/dist/atlas-client.js +28 -6
- package/dist/auth-cmds/commands.d.ts +1 -1
- package/dist/auth-cmds/commands.js +5 -2
- package/dist/functions/commands.js +7 -1
- package/dist/functions/manifest.d.ts +18 -0
- package/dist/functions/manifest.js +29 -4
- package/dist/main.js +8 -3
- package/dist/pat-hints.js +1 -0
- package/dist/pipeline/commands.js +27 -9
- package/dist/pipeline/lifecycle.d.ts +2 -0
- package/dist/pipeline/lifecycle.js +91 -11
- package/dist/process/build.js +59 -43
- package/dist/process/codegen.d.ts +3 -2
- package/dist/process/codegen.js +143 -27
- package/dist/process/commands.d.ts +2 -0
- package/dist/process/commands.js +63 -18
- package/dist/process/discover.d.ts +6 -3
- package/dist/process/discover.js +11 -3
- package/dist/process/lint.d.ts +14 -0
- package/dist/process/lint.js +143 -5
- package/dist/process/plan-diff.d.ts +8 -0
- package/dist/process/plan-diff.js +61 -4
- package/dist/process/safety-baseline.d.ts +154 -0
- package/dist/process/safety-baseline.js +387 -0
- package/dist/process/simulate.js +64 -22
- package/dist/repos/commands.d.ts +1 -1
- package/dist/repos/commands.js +29 -3
- package/package.json +6 -5
package/dist/process/lint.js
CHANGED
|
@@ -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 {
|
|
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: [
|
|
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: [
|
|
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
|
-
|
|
234
|
-
|
|
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)
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lattice safety-profile baseline (LAT-140): scan every committed first-party
|
|
3
|
+
* process definition and derive the observed corpus maxima for each statically
|
|
4
|
+
* measurable safety-profile dimension. `seq-studio process safety-baseline`
|
|
5
|
+
* prints the report (`--write` refreshes the committed copy at
|
|
6
|
+
* atlas/lattice/SAFETY_PROFILE_BASELINE.md); safety-baseline.test.ts asserts
|
|
7
|
+
* the committed DEFAULT_LATTICE_SAFETY_PROFILE fits the whole corpus, which is
|
|
8
|
+
* the backwards-compatibility gate for the profile's defaults.
|
|
9
|
+
*
|
|
10
|
+
* Scanned corpus: every committed first-party apply root, discovered by
|
|
11
|
+
* RECURSIVELY finding each `process.ts` under both bases (`atlas/processes`
|
|
12
|
+
* and repo-root `processes/`, skipping node_modules/hidden dirs) and taking
|
|
13
|
+
* `dirname(dirname(file))` as its apply root — so arbitrarily nested layouts
|
|
14
|
+
* (`banksouth-mortgage/loan-handoff/loan-handoff/process.ts`) are covered.
|
|
15
|
+
* Repo-root packages' `@sequenceholdings/lattice` import resolves through the
|
|
16
|
+
* repo-root node_modules (the workspace SDK is a root devDependency), so they
|
|
17
|
+
* load through the same tsx lane.
|
|
18
|
+
*
|
|
19
|
+
* Every static-graph observation is taken from the CANONICAL BUILT BUNDLE per
|
|
20
|
+
* apply root (`buildBundleFromProcesses` with fixed provenance and normalized
|
|
21
|
+
* metadata) using the SDK's shared measurer (`measureBundleStaticGraph`,
|
|
22
|
+
* LAT-148) — the same walker registration enforces with — so the baseline
|
|
23
|
+
* measures exactly what the server will check. Raw TS source bytes are
|
|
24
|
+
* reported for information only.
|
|
25
|
+
*
|
|
26
|
+
* Determinism: roots and processes are iterated in sorted order, provenance
|
|
27
|
+
* and metadata are pinned to fixed values, and every observation is a pure
|
|
28
|
+
* function of the committed sources, so two derivations over the same tree
|
|
29
|
+
* are deep-equal (asserted by the test) and the committed report is
|
|
30
|
+
* byte-identical across machines.
|
|
31
|
+
*/
|
|
32
|
+
import type { LatticeSafetyProfile } from '@sequenceholdings/lattice';
|
|
33
|
+
/** Repo-relative path of the committed, generated baseline report. */
|
|
34
|
+
export declare const SAFETY_PROFILE_BASELINE_RELATIVE_PATH = "atlas/lattice/SAFETY_PROFILE_BASELINE.md";
|
|
35
|
+
/** Statically measurable observations for one committed process definition. */
|
|
36
|
+
export interface ProcessSafetyObservation {
|
|
37
|
+
/** Repo-relative apply root the process was discovered under. */
|
|
38
|
+
readonly root: string;
|
|
39
|
+
readonly processId: string;
|
|
40
|
+
/** Repo-relative path of the process.ts file. */
|
|
41
|
+
readonly file: string;
|
|
42
|
+
/** Node definitions, including nested parallel sub-nodes. */
|
|
43
|
+
readonly nodeCount: number;
|
|
44
|
+
/** Total outgoing edges across all nodes and sub-nodes. */
|
|
45
|
+
readonly edgeCount: number;
|
|
46
|
+
/** Deepest parallel-in-parallel nesting (0 = no parallel blocks). */
|
|
47
|
+
readonly parallelNestingDepth: number;
|
|
48
|
+
/** Unique subprocess target process ids (sorted). */
|
|
49
|
+
readonly subprocessTargets: readonly string[];
|
|
50
|
+
/**
|
|
51
|
+
* Longest known subprocess chain STARTING at this process, resolved across
|
|
52
|
+
* the full committed graph (co-located and cross-root ids): 0 = no
|
|
53
|
+
* subprocess nodes, chain A→B→C gives A depth 2, and an unknown external
|
|
54
|
+
* child contributes exactly one edge. Same unit as
|
|
55
|
+
* MAX_SUBPROCESS_NESTING_DEPTH ("a top-level subprocess is depth 1").
|
|
56
|
+
*/
|
|
57
|
+
readonly subprocessChainDepth: number;
|
|
58
|
+
/**
|
|
59
|
+
* Unique linked protected resources — (kind, ref) pairs across agents (or
|
|
60
|
+
* their backing workflows when `workflowId` is set, matching the
|
|
61
|
+
* linked-resource authz target semantics), managed functions, and
|
|
62
|
+
* subprocess children, nested parallel branches included.
|
|
63
|
+
*/
|
|
64
|
+
readonly linkedResourceRefs: number;
|
|
65
|
+
/** Max multiplicative fan-out width along any parallel nesting path. */
|
|
66
|
+
readonly fanoutProduct: number;
|
|
67
|
+
/** Declared per-run caps (undefined = orchestrator default). */
|
|
68
|
+
readonly maxIterations: number | undefined;
|
|
69
|
+
readonly maxRevisits: number | undefined;
|
|
70
|
+
readonly maxConcurrentRuns: number | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Largest explicit retry attempts / delay across node `withRetry`
|
|
73
|
+
* middleware and every supervisor_retry lane (process orchestrator,
|
|
74
|
+
* parallel runner, subprocess runner).
|
|
75
|
+
*/
|
|
76
|
+
readonly maxRetryAttempts: number;
|
|
77
|
+
readonly maxRetryDelayMs: number;
|
|
78
|
+
/** Byte size of the raw process.ts source file (informational only). */
|
|
79
|
+
readonly sourceBytes: number;
|
|
80
|
+
/**
|
|
81
|
+
* Total bytes of SERIALIZED inline source across this process's bundle form:
|
|
82
|
+
* every `*_source` (Function.toString) and `*_expr` (JSONata) mapper slot,
|
|
83
|
+
* nested parallel branches included. Measured from the built bundle, not the
|
|
84
|
+
* TS file.
|
|
85
|
+
*/
|
|
86
|
+
readonly inlineSourceBytes: number;
|
|
87
|
+
}
|
|
88
|
+
/** Corpus maxima keyed by the safety-profile fields they gate. */
|
|
89
|
+
export interface ObservedCorpusMaxima {
|
|
90
|
+
readonly staticGraph: {
|
|
91
|
+
readonly maxProcessesPerBundle: number;
|
|
92
|
+
readonly maxNodesPerProcess: number;
|
|
93
|
+
readonly maxEdgesPerProcess: number;
|
|
94
|
+
readonly maxLinkedResourceRefs: number;
|
|
95
|
+
readonly maxParallelNestingDepth: number;
|
|
96
|
+
readonly maxSubprocessNestingDepth: number;
|
|
97
|
+
/** Largest per-process serialized inline source, bytes. */
|
|
98
|
+
readonly maxInlineSourceBytes: number;
|
|
99
|
+
/** Largest canonical built bundle across apply roots, bytes. */
|
|
100
|
+
readonly maxBundleBytes: number;
|
|
101
|
+
};
|
|
102
|
+
readonly runtime: {
|
|
103
|
+
readonly maxIterationsPerRun: number;
|
|
104
|
+
readonly maxRevisitsPerNode: number;
|
|
105
|
+
readonly maxFanoutProductPerRun: number;
|
|
106
|
+
readonly maxRetryAttempts: number;
|
|
107
|
+
readonly maxRetryDelayMs: number;
|
|
108
|
+
readonly maxConcurrentRunsPerProcess: number;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export interface LatticeSafetyBaseline {
|
|
112
|
+
readonly roots: ReadonlyArray<{
|
|
113
|
+
readonly root: string;
|
|
114
|
+
readonly processCount: number;
|
|
115
|
+
/** Canonical built-bundle size for this apply root, bytes. */
|
|
116
|
+
readonly bundleBytes: number;
|
|
117
|
+
}>;
|
|
118
|
+
readonly processes: readonly ProcessSafetyObservation[];
|
|
119
|
+
/**
|
|
120
|
+
* Subprocess reference cycles detected across the committed graph, as
|
|
121
|
+
* canonical `a -> b -> a` strings (sorted). Always empty for a healthy
|
|
122
|
+
* corpus; a cycle makes chain depth unbounded and fails the fit assertion.
|
|
123
|
+
*/
|
|
124
|
+
readonly subprocessCycles: readonly string[];
|
|
125
|
+
readonly observed: ObservedCorpusMaxima;
|
|
126
|
+
}
|
|
127
|
+
/** Derive the observed baseline for the committed first-party process corpus. */
|
|
128
|
+
export declare function deriveLatticeSafetyBaseline({ repoRoot, }: {
|
|
129
|
+
repoRoot: string;
|
|
130
|
+
}): Promise<LatticeSafetyBaseline>;
|
|
131
|
+
/**
|
|
132
|
+
* Assert every committed process fits the profile. Throws with the full
|
|
133
|
+
* violation list — the test gate that keeps the committed defaults ≥ what the
|
|
134
|
+
* committed corpus needs (LAT-140's backwards-compatibility requirement).
|
|
135
|
+
* A subprocess reference cycle also fails: chain depth is unbounded there.
|
|
136
|
+
*/
|
|
137
|
+
export declare function assertBaselineFitsProfile({ baseline, profile, }: {
|
|
138
|
+
baseline: LatticeSafetyBaseline;
|
|
139
|
+
profile: LatticeSafetyProfile;
|
|
140
|
+
}): void;
|
|
141
|
+
/** Render the human-readable baseline report (markdown, deterministic). */
|
|
142
|
+
export declare function formatSafetyBaselineReport({ baseline, profile, }: {
|
|
143
|
+
baseline: LatticeSafetyBaseline;
|
|
144
|
+
profile: LatticeSafetyProfile;
|
|
145
|
+
}): string;
|
|
146
|
+
/**
|
|
147
|
+
* `seq-studio process safety-baseline [--repo-root <dir>] [--write]` — derive
|
|
148
|
+
* the baseline from the committed corpus, assert it fits the committed default
|
|
149
|
+
* profile, and print the markdown report. `--write` also refreshes the
|
|
150
|
+
* committed copy at {@link SAFETY_PROFILE_BASELINE_RELATIVE_PATH}.
|
|
151
|
+
*/
|
|
152
|
+
export declare function safetyBaselineCommand({ flags, }: {
|
|
153
|
+
flags: Record<string, string | true>;
|
|
154
|
+
}): Promise<number>;
|