@uipath/maestro-builder-sdk 6.87.2 → 6.87.4

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.
@@ -650,10 +650,15 @@ export interface StartOpts {
650
650
  * reports that as `ERROR_START_OUTSIDE_EVENT_SUBPROCESS` rather than leaving it to
651
651
  * be discovered at run time, because `uip maestro bpmn validate` accepts it.
652
652
  *
653
- * Interrupting is the only form emitted: `isInterrupting` is left unset, which is
654
- * BPMN's default and what the platform's own templates produce. A
655
- * non-interrupting error start is not a thing — the throw has already ended its
656
- * scope by the time the handler sees it.
653
+ * Interrupting is the form to author: `isInterrupting` is left unset, which is
654
+ * BPMN's default and what the platform's own templates produce. On a
655
+ * NON-interrupting error start the engine never starts the event sub-process: both
656
+ * the platform (`EventSubProcessPredicates.IsInterruptingErrorEventSubProcess`) and
657
+ * the local engine require an interrupting error start, so the handler does not run
658
+ * and the error faults the scope. Deployed processes still carry
659
+ * `isInterrupting="false"` on one and `uip maestro bpmn validate` accepts it, so
660
+ * `interrupting: false` is kept as written and `check` warns
661
+ * (BPMN_ERROR_START_NOT_INTERRUPTING). Drop it to make the handler run.
657
662
  */
658
663
  error?: ErrorLike;
659
664
  /** Start on a timer — an ISO-8601 duration string, or a full {@link TimerSpec}. */
@@ -712,9 +717,11 @@ export interface StartOpts {
712
717
  * `false` makes a message or timer start NON-interrupting: the event sub-process it
713
718
  * starts runs beside the container instead of cancelling it (`isInterrupting="false"`).
714
719
  *
715
- * Only meaningful on the start event of an event sub-process, and never for an
716
- * `error` start, which BPMN defines as interrupting — the throw has already ended its
717
- * scope. Defaults to `true`, the BPMN default, which writes no attribute.
720
+ * Only meaningful on the start event of an event sub-process. Never set it on an
721
+ * `error` start: the engine never starts the event sub-process, so the handler does
722
+ * not run and the error faults the scope. It is still written as given there
723
+ * (deployed processes carry it), and `check` warns (BPMN_ERROR_START_NOT_INTERRUPTING).
724
+ * Defaults to `true`, the BPMN default, which writes no attribute.
718
725
  * {@link ScopeBuilder.eventSubProcess} sets this from its own `interrupting` option.
719
726
  */
720
727
  interrupting?: boolean;
@@ -1980,7 +1987,9 @@ export interface EventSubProcessOpts {
1980
1987
  /**
1981
1988
  * For a `message` or `timer` start: `false` lets the container keep running while
1982
1989
  * the sub-process handles the event (`isInterrupting="false"`). Defaults to `true`.
1983
- * Refused with `error`, which BPMN defines as interrupting.
1990
+ * Do not set it with `error`: the engine never starts the event sub-process, so the
1991
+ * handler does not run and the error faults the scope. It is written as given
1992
+ * (deployed processes carry it) and `check` warns (BPMN_ERROR_START_NOT_INTERRUPTING).
1984
1993
  */
1985
1994
  interrupting?: boolean;
1986
1995
  /**
@@ -3130,8 +3139,8 @@ declare abstract class ScopeBuilder {
3130
3139
  * @param opts - What starts it — exactly one of `error` / `message` / `timer` — and the rest of {@link EventSubProcessOpts}.
3131
3140
  * @param fn - Receives the body builder; elements chain in the order they are written.
3132
3141
  * @returns This builder, so calls chain.
3133
- * @throws If none or several of `error` / `message` / `timer` are given, if an error start
3134
- * is asked to be non-interrupting, or if a path in the body is left open.
3142
+ * @throws If none or several of `error` / `message` / `timer` are given, or if a path in the
3143
+ * body is left open.
3135
3144
  */
3136
3145
  eventSubProcess(id: string, opts: EventSubProcessOpts, fn: (sp: SubProcessBuilder) => void): this;
3137
3146
  /**
@@ -716,9 +716,6 @@ class ScopeBuilder {
716
716
  if (opts.trigger !== undefined && opts.payload !== undefined) {
717
717
  throw new CompileRefusal('BPMN_START_TRIGGER_AND_PAYLOAD', `startEvent "${id}": \`trigger\` and \`payload\` both write the event's extension element; pass one.`);
718
718
  }
719
- if (opts.interrupting === false && opts.error !== undefined) {
720
- throw new CompileRefusal('BPMN_ERROR_START_NOT_INTERRUPTING', `startEvent "${id}": an error start is always interrupting — the throw has already ended the scope it came from.`);
721
- }
722
719
  return this.push({
723
720
  kind: 'startEvent',
724
721
  id,
@@ -2073,17 +2070,14 @@ class ScopeBuilder {
2073
2070
  * @param opts - What starts it — exactly one of `error` / `message` / `timer` — and the rest of {@link EventSubProcessOpts}.
2074
2071
  * @param fn - Receives the body builder; elements chain in the order they are written.
2075
2072
  * @returns This builder, so calls chain.
2076
- * @throws If none or several of `error` / `message` / `timer` are given, if an error start
2077
- * is asked to be non-interrupting, or if a path in the body is left open.
2073
+ * @throws If none or several of `error` / `message` / `timer` are given, or if a path in the
2074
+ * body is left open.
2078
2075
  */
2079
2076
  eventSubProcess(id, opts, fn) {
2080
2077
  const given = [opts.error !== undefined, opts.message !== undefined, opts.timer !== undefined].filter(Boolean).length;
2081
2078
  if (given !== 1) {
2082
2079
  throw new CompileRefusal('BPMN_EVENT_SUBPROCESS_START_COUNT', `eventSubProcess "${id}" needs exactly one of { error, message, timer } — that is what starts it.`);
2083
2080
  }
2084
- if (opts.error !== undefined && opts.interrupting === false) {
2085
- throw new CompileRefusal('BPMN_ERROR_START_NOT_INTERRUPTING', `eventSubProcess "${id}": an error start is always interrupting — the throw has already ended the scope it came from.`);
2086
- }
2087
2081
  if (opts.errorVar !== undefined && opts.errorVar !== false && opts.error === undefined) {
2088
2082
  throw new CompileRefusal('BPMN_ERROR_VAR_WITHOUT_ERROR', `eventSubProcess "${id}": \`errorVar\` captures an error, so it needs \`error\`.`);
2089
2083
  }
@@ -1451,6 +1451,16 @@ inEventSubProcess = false) {
1451
1451
  where: n.id,
1452
1452
  });
1453
1453
  }
1454
+ // Dead handler: both engines start an error ESP only when its start is interrupting.
1455
+ if (n.kind === 'startEvent' && n.event?.type === 'error' && n.interrupting === false) {
1456
+ diags.push({
1457
+ level: 'warning',
1458
+ code: 'BPMN_ERROR_START_NOT_INTERRUPTING',
1459
+ message: `Error start event "${n.id}" is marked non-interrupting, so the engine never starts this event ` +
1460
+ 'sub-process and the error faults the scope. Drop `interrupting: false`.',
1461
+ where: n.id,
1462
+ });
1463
+ }
1454
1464
  if (n.kind !== 'subProcess' && 'event' in n && n.event?.type === 'timer') {
1455
1465
  const t = n.event.timer;
1456
1466
  const blank = [t.duration, t.date, t.cycle].find(isBlankTimerValue) !== undefined;
@@ -1741,8 +1741,6 @@ function renderEventSubProcess(plan, sp, depth, indent) {
1741
1741
  const def = singleDefinition(start);
1742
1742
  if (!def)
1743
1743
  return reject('its start carries no single error, timer or message definition');
1744
- if (def === 'error' && start.isInterrupting === false)
1745
- return reject('a non-interrupting error start is not a thing');
1746
1744
  const outs = g.outs.get(start.id) ?? [];
1747
1745
  if (outs.length !== 1)
1748
1746
  return reject(`its start has ${outs.length} outgoing flows`);
@@ -1803,7 +1801,9 @@ function renderEventSubProcess(plan, sp, depth, indent) {
1803
1801
  const optsText = opts([
1804
1802
  ['name', sp.name !== undefined ? tsText(sp.name) : undefined],
1805
1803
  [def, defExpr],
1806
- ['interrupting', def !== 'error' && start.isInterrupting === false ? 'false' : undefined],
1804
+ // Written for an error start too: a deployed one can carry `isInterrupting="false"`
1805
+ // (which makes it a dead handler; check warns), and dropping it would change the file.
1806
+ ['interrupting', start.isInterrupting === false ? 'false' : undefined],
1807
1807
  // `` `${id}_Error` `` is compile's default and `false` its opt-out, so neither is
1808
1808
  // left implicit the wrong way round: an error start with no capture row recompiles
1809
1809
  // without one, and a capture the designer named something else is spelled out.
@@ -1,6 +1,7 @@
1
1
  /**
2
- * case-expr-check — the CASE adapter over the shared `core/expr-check`, run by
3
- * `CaseBuilder.build()` before it hands back the model to be serialized.
2
+ * case-expr-check — the CASE adapter over the shared `core/expr-check`. Its
3
+ * `lint` findings go to `check` (`caseExprLints`); the rest stop
4
+ * `CaseBuilder.build()` before it hands back the model (`caseExprRefusals`).
4
5
  *
5
6
  * A case `=js:` gate reads a declared variable as `=js:vars.<name>` — the `vars.`
6
7
  * namespace, NOT `case.` (a `case.` reference resolves to nothing; the platform's
@@ -8,7 +9,9 @@
8
9
  * `vars.` is a CLOSED namespace: a reference to a name no variable declares is a
9
10
  * definite mistake, and `validate` says so (`vars.<name> does not exist`). So this
10
11
  * flags every undeclared `vars.<root>`, exactly as the flow check flags `$vars`,
11
- * and `build()` is the fast pre-`validate` gate.
12
+ * and `check` is the fast pre-`validate` gate. It is `lint`, not a refusal:
13
+ * the serializer writes the read as authored, so a plan that has one still
14
+ * compiles (decided on builder-sdk#1712).
12
15
  *
13
16
  * The surfaces that carry a `=js:` gate: every rule's `expression`, a task's
14
17
  * `skipWhen`, and each SLA's `when`. Stage/task STRUCTURAL references
@@ -23,42 +26,46 @@ export interface CaseLocatedDiagnostic extends ExprDiagnostic {
23
26
  where: string;
24
27
  }
25
28
  /**
26
- * The undeclared `vars.<root>` names `expr` reads, as `build()` reports them
27
- * (`EXPR_UNDECLARED_REF`). A task-output reference stands in as a declared root.
28
- * For decompile, which refuses such a gate by name rather than writing source
29
- * compile refuses.
29
+ * An EXPR_UNDECLARED_REF finding with the read it is about: the expression as
30
+ * authored and the undeclared root. `check` uses it to drop plan-check's
31
+ * CASE_MGMT_REFERENCE_UNBOUND on the same read (one mistake, one finding).
30
32
  */
31
- export declare function undeclaredVarReads(expr: string, roots: ReadonlySet<string>): string[];
33
+ export interface CaseExprFinding extends CaseLocatedDiagnostic {
34
+ read?: {
35
+ expr: string;
36
+ root: string;
37
+ };
38
+ }
32
39
  /**
33
40
  * The platform variable that says whether the stage labelled `label` has run
34
41
  * (case-schema `baseLocalStageHasRunVariableInfoForStage`): `Stage 1` ->
35
42
  * `stageHasRun_Stage_1`. Exported for the Case fuzzer's stage renames.
36
43
  */
37
44
  export declare function stageHasRunVariable(label: string): string;
38
- /**
39
- * Variables the platform declares for every case, which a plan's gates may read
40
- * though no row of the plan declares them. `uip maestro case validate` adds the
41
- * same set to the variables it checks against (case-schema
42
- * `validateCaseManagementVariables`), and the BPMN converter writes each one:
43
- *
44
- * - `stageHasRun_<stage label>` per stage (`getCaseStateVariables`), set in the
45
- * initial variables setup and updated when the stage exits or completes. The
46
- * platform's own V11->V12 migration writes gates on it:
47
- * `=js:(vars.stageHasRun_Review != true)` for "first time this stage runs";
48
- * - the hidden event-subprocess rows `tasksEventSubprocessResponse`,
49
- * `mainEventSubprocessResponse`, `connectorResponse` and `eventMetadata`.
50
- *
51
- * Not here: the per-SLA `stageSla_<stage>_<sla id>` rows, whose ids compile
52
- * mints after this check runs.
53
- */
54
- export declare function platformVariables(stageLabels: readonly string[]): string[];
55
45
  /** Every first-level expression problem in a built case, each stamped with its location. */
56
46
  export declare function checkCaseExpressions(built: BuiltCase): CaseLocatedDiagnostic[];
47
+ /**
48
+ * The expression findings `CaseBuilder.build()` refuses: every error whose code
49
+ * is not `lint`. Today that is TASK_OUTPUT_REF_UNRESOLVED, a task-output
50
+ * reference naming no stage, task or output, which the serializer has no id to
51
+ * lower to.
52
+ */
53
+ export declare function caseExprRefusals(built: BuiltCase): CaseLocatedDiagnostic[];
54
+ /**
55
+ * The expression findings only `check` reports: every `lint` code, such as
56
+ * EXPR_UNDECLARED_REF (`=js:vars.missing` where no variable is named
57
+ * `missing`). The serializer writes such a read exactly as authored, so it
58
+ * never stops `build()` or `compile` (decided on builder-sdk#1712): a
59
+ * brownfield plan that already carries one still loads, compiles and merges.
60
+ */
61
+ export declare function caseExprLints(built: BuiltCase): CaseExprFinding[];
57
62
  /**
58
63
  * Thrown by `CaseBuilder.build()` when the first-level expression check finds a
59
- * likely-typo'd case-variable reference. Same shape/rationale as the flow's
60
- * `FlowBuildError`: `message` lists every problem; `diagnostics` carries them
61
- * structured.
64
+ * reference the serializer cannot lower: a task-output reference that names no
65
+ * stage, task or output (TASK_OUTPUT_REF_UNRESOLVED). An undeclared
66
+ * `vars.<name>` read (EXPR_UNDECLARED_REF) no longer throws it; `check`
67
+ * reports that one. Same shape as the flow's `FlowBuildError`: `message` lists
68
+ * every problem; `diagnostics` carries them structured.
62
69
  */
63
70
  export declare class CaseBuildError extends CompileRefusal {
64
71
  readonly diagnostics: CaseLocatedDiagnostic[];
@@ -1,6 +1,7 @@
1
1
  /**
2
- * case-expr-check — the CASE adapter over the shared `core/expr-check`, run by
3
- * `CaseBuilder.build()` before it hands back the model to be serialized.
2
+ * case-expr-check — the CASE adapter over the shared `core/expr-check`. Its
3
+ * `lint` findings go to `check` (`caseExprLints`); the rest stop
4
+ * `CaseBuilder.build()` before it hands back the model (`caseExprRefusals`).
4
5
  *
5
6
  * A case `=js:` gate reads a declared variable as `=js:vars.<name>` — the `vars.`
6
7
  * namespace, NOT `case.` (a `case.` reference resolves to nothing; the platform's
@@ -8,7 +9,9 @@
8
9
  * `vars.` is a CLOSED namespace: a reference to a name no variable declares is a
9
10
  * definite mistake, and `validate` says so (`vars.<name> does not exist`). So this
10
11
  * flags every undeclared `vars.<root>`, exactly as the flow check flags `$vars`,
11
- * and `build()` is the fast pre-`validate` gate.
12
+ * and `check` is the fast pre-`validate` gate. It is `lint`, not a refusal:
13
+ * the serializer writes the read as authored, so a plan that has one still
14
+ * compiles (decided on builder-sdk#1712).
12
15
  *
13
16
  * The surfaces that carry a `=js:` gate: every rule's `expression`, a task's
14
17
  * `skipWhen`, and each SLA's `when`. Stage/task STRUCTURAL references
@@ -17,6 +20,7 @@
17
20
  */
18
21
  import { checkExpression, extractRefs } from '../core/expr-check.js';
19
22
  import { CompileRefusal } from '../core/compile-refusal.js';
23
+ import { refusalClass } from '../core/refusals.js';
20
24
  import { readEventFilter } from '../core/event-filters.js';
21
25
  import { defaultActionOutputVar } from './action-output-var.js';
22
26
  import { lowerTaskOutputRefs, pickByName, pickOutputRow, taskOutputRefs, unresolvedTaskOutputRef } from './task-output-ref.js';
@@ -77,25 +81,18 @@ function checkTaskOutputRefs(built, value, where, out) {
77
81
  out.push({ level: 'error', code: 'TASK_OUTPUT_REF_UNRESOLVED', message: unresolvedTaskOutputRef(ref, why), where });
78
82
  }
79
83
  }
80
- /**
81
- * The undeclared `vars.<root>` names `expr` reads, as `build()` reports them
82
- * (`EXPR_UNDECLARED_REF`). A task-output reference stands in as a declared root.
83
- * For decompile, which refuses such a gate by name rather than writing source
84
- * compile refuses.
85
- */
86
- export function undeclaredVarReads(expr, roots) {
87
- const lowered = lowerTaskOutputRefs(expr, () => TASK_OUTPUT_ROOT);
88
- const scope = new Set([...roots, TASK_OUTPUT_ROOT]);
89
- return [...new Set(extractRefs(lowered, NAMESPACE).map((ref) => ref.root).filter((root) => !scope.has(root)))];
90
- }
91
84
  function checkExpr(built, expr, where, roots, out) {
92
85
  if (!expr)
93
86
  return;
94
87
  checkTaskOutputRefs(built, expr, where, out);
95
88
  const lowered = lowerTaskOutputRefs(expr, () => TASK_OUTPUT_ROOT);
96
89
  const scope = lowered === expr ? roots : new Set([...roots, TASK_OUTPUT_ROOT]);
90
+ // The undeclared roots, in the order checkExpression reports them (one each).
91
+ const undeclared = [...new Set(extractRefs(lowered, NAMESPACE).map((r) => r.root).filter((r) => !scope.has(r)))];
92
+ let next = 0;
97
93
  for (const d of checkExpression(lowered, { roots: scope, noun: NOUN, namespace: NAMESPACE })) {
98
- out.push({ ...d, where });
94
+ const root = d.code === 'EXPR_UNDECLARED_REF' ? undeclared[next++] : undefined;
95
+ out.push({ ...d, where, ...(root !== undefined ? { read: { expr, root } } : {}) });
99
96
  }
100
97
  }
101
98
  /**
@@ -158,7 +155,7 @@ export function stageHasRunVariable(label) {
158
155
  * Not here: the per-SLA `stageSla_<stage>_<sla id>` rows, whose ids compile
159
156
  * mints after this check runs.
160
157
  */
161
- export function platformVariables(stageLabels) {
158
+ function platformVariables(stageLabels) {
162
159
  return [
163
160
  ...stageLabels.map((label) => stageHasRunVariable(label)),
164
161
  'tasksEventSubprocessResponse',
@@ -226,11 +223,32 @@ export function checkCaseExpressions(built) {
226
223
  }
227
224
  return out;
228
225
  }
226
+ /**
227
+ * The expression findings `CaseBuilder.build()` refuses: every error whose code
228
+ * is not `lint`. Today that is TASK_OUTPUT_REF_UNRESOLVED, a task-output
229
+ * reference naming no stage, task or output, which the serializer has no id to
230
+ * lower to.
231
+ */
232
+ export function caseExprRefusals(built) {
233
+ return checkCaseExpressions(built).filter((d) => d.level === 'error' && refusalClass(d.code) !== 'lint');
234
+ }
235
+ /**
236
+ * The expression findings only `check` reports: every `lint` code, such as
237
+ * EXPR_UNDECLARED_REF (`=js:vars.missing` where no variable is named
238
+ * `missing`). The serializer writes such a read exactly as authored, so it
239
+ * never stops `build()` or `compile` (decided on builder-sdk#1712): a
240
+ * brownfield plan that already carries one still loads, compiles and merges.
241
+ */
242
+ export function caseExprLints(built) {
243
+ return checkCaseExpressions(built).filter((d) => refusalClass(d.code) === 'lint');
244
+ }
229
245
  /**
230
246
  * Thrown by `CaseBuilder.build()` when the first-level expression check finds a
231
- * likely-typo'd case-variable reference. Same shape/rationale as the flow's
232
- * `FlowBuildError`: `message` lists every problem; `diagnostics` carries them
233
- * structured.
247
+ * reference the serializer cannot lower: a task-output reference that names no
248
+ * stage, task or output (TASK_OUTPUT_REF_UNRESOLVED). An undeclared
249
+ * `vars.<name>` read (EXPR_UNDECLARED_REF) no longer throws it; `check`
250
+ * reports that one. Same shape as the flow's `FlowBuildError`: `message` lists
251
+ * every problem; `diagnostics` carries them structured.
234
252
  */
235
253
  export class CaseBuildError extends CompileRefusal {
236
254
  diagnostics;
@@ -238,7 +256,7 @@ export class CaseBuildError extends CompileRefusal {
238
256
  const label = built.name || built.id || 'case';
239
257
  const lines = diagnostics.map((d) => ` ✗ [${d.code}] in ${d.where}: ${d.message}${d.suggestion ? ` (did you mean "${d.suggestion}"?)` : ''}`);
240
258
  // The first problem's code; `diagnostics` carries every one.
241
- super(diagnostics[0]?.code ?? 'EXPR_UNDECLARED_REF', `Cannot build case "${label}" — ${diagnostics.length} expression problem(s):\n${lines.join('\n')}`);
259
+ super(diagnostics[0]?.code ?? 'TASK_OUTPUT_REF_UNRESOLVED', `Cannot build case "${label}" — ${diagnostics.length} expression problem(s):\n${lines.join('\n')}`);
242
260
  this.name = 'CaseBuildError';
243
261
  this.diagnostics = diagnostics;
244
262
  }
@@ -22,7 +22,7 @@ import { CASE_SCRIPT_RUNTIME } from './script.js';
22
22
  import { ACTION_PASSTHROUGH_SETTINGS } from './action-settings.js';
23
23
  import { connector as makeConnector, subscriptionFrom, } from '../core/actions.js';
24
24
  import { isTriggerDescriptor } from '../core/connectors.js';
25
- import { checkCaseExpressions, CaseBuildError } from './case-expr-check.js';
25
+ import { caseExprRefusals, CaseBuildError } from './case-expr-check.js';
26
26
  import { taskOutputMarker } from './task-output-ref.js';
27
27
  import { CASE_FORMAT_PROFILE, CASE_SCHEMA_VERSIONS, recordAuthoredCaseVersion } from './format-profile.js';
28
28
  import { schemaVersionRefusal } from '../schema-version.js';
@@ -1445,10 +1445,13 @@ class CaseBuilder {
1445
1445
  };
1446
1446
  if (this._authoredVersion !== undefined)
1447
1447
  recordAuthoredCaseVersion(built, this._authoredVersion);
1448
- // First-level validation, intrinsic to running the SDK: catch a reference to
1449
- // an undeclared `vars.<name>` HERE, before the caseplan is serialized, rather
1450
- // than three steps later at `uip maestro case validate`. See case-expr-check.
1451
- const errors = checkCaseExpressions(built).filter((d) => d.level === 'error');
1448
+ // A task-output reference that names no stage, task or output is refused
1449
+ // here (TASK_OUTPUT_REF_UNRESOLVED, `lowering`). A `lint` finding (a read of
1450
+ // a `vars.<name>` nothing declares, EXPR_UNDECLARED_REF) is not: the
1451
+ // serializer writes that read as authored, so `check` reports it and a
1452
+ // brownfield plan that already has one still builds, compiles and merges
1453
+ // (decided on builder-sdk#1712). See case-expr-check.
1454
+ const errors = caseExprRefusals(built);
1452
1455
  if (errors.length)
1453
1456
  throw new CaseBuildError(built, errors);
1454
1457
  return built;
@@ -10,6 +10,7 @@ import { httpRequestLint } from './http-request.js';
10
10
  import { checkRuleSemantics } from './check-rule-semantics.js';
11
11
  import { serialize } from './serialize.js';
12
12
  import { lintPlanFindings, planReport } from './plan-check/index.js';
13
+ import { caseExprLints } from './case-expr-check.js';
13
14
  const TYPE_NAMES = new Set(Object.values(types));
14
15
  // audit-case-coverage: rule-slot table start
15
16
  // This runtime table must equal the committed matrix's rejected cells. The audit
@@ -183,23 +184,25 @@ export function check(built, opts = {}) {
183
184
  };
184
185
  // An In-arg with no `{ from }` and no primary trigger to bind to is the
185
186
  // serializer's CASE_IN_ARG_UNBOUND (in-arg-binding.ts), reported per arg.
186
- // ── `=js:vars.<name>` resolvability — REMOVED, superseded by #257 ───────────
187
- // This file briefly carried a VAR_NOT_REFERENCEABLE error asserting that only a
188
- // trigger-bound In-arg (`.input(shape, { from })`) could be read as `=js:vars.x`,
189
- // and that a bare `.var()` always failed `uip maestro case validate` with
190
- // "Variable 'vars.x' does not exist". That was empirically true when written and
191
- // is now FALSE: #257 fixed the serializer to emit the `inputOutputs` companion
192
- // with `id: <name>` / `elementId: "root"`, which is what the platform resolves
193
- // `vars.<name>` against — so a declared `.var()` is readable.
194
- //
195
- // Both halves of the old rule are superseded:
196
- // - "declared vars are unreadable" -> no longer true (#257 serializer fix).
197
- // - "undeclared vars.x slips through" -> #257 also added a strict namespace
198
- // check to CaseBuilder.build(), which throws CaseBuildError with a
199
- // near-miss suggestion before check() ever runs.
200
- // Re-adding any variable-reachability rule here would reintroduce a false
201
- // positive that blocks emit (this gate runs before serialization), so it must be
202
- // re-derived from the serializer rather than from remembered probe results.
187
+ // ── `=js:vars.<name>` resolvability ─────────────────────────────────────────
188
+ // A read of a `vars.<name>` no variable declares (EXPR_UNDECLARED_REF) is
189
+ // `lint`: the serializer writes it as authored, so it is reported here, on
190
+ // the gate it is in, and never stops `build()` or `compile` (decided on
191
+ // builder-sdk#1712; it was a CaseBuildError from build() since #257). The
192
+ // declared set is the serializer's (`inputOutputs` companions: `.var()`s, task
193
+ // and action outputs, trigger extractions), so a declared `.var()` is not
194
+ // flagged. The refusing findings stay in build() (`caseExprRefusals`).
195
+ // The location and the near-miss hint go into the message too: `case check`
196
+ // prints `[code] message`, and its JSON carries no `where`.
197
+ const exprLints = caseExprLints(built);
198
+ for (const d of exprLints)
199
+ diags.push({
200
+ level: d.level, code: d.code,
201
+ message: `in ${d.where}: ${d.message}${d.suggestion ? ` (did you mean "${d.suggestion}"?)` : ''}`,
202
+ where: d.where,
203
+ ...(d.suggestion ? { suggestion: d.suggestion } : {}),
204
+ });
205
+ const reportedReads = exprLints.flatMap((d) => (d.read ? [d.read] : []));
203
206
  for (const stage of built.stages) {
204
207
  checkStage(stage, diags, refStage, refPlacement);
205
208
  stage.slaRules.forEach((s, i) => checkSla(s, `stage "${stage.label}" SLA #${i + 1}`, diags));
@@ -240,7 +243,7 @@ export function check(built, opts = {}) {
240
243
  diags.push({ level: 'error', code: f.code, message: f.message, ...(f.suggestion ? { suggestion: f.suggestion } : {}), where: t.name });
241
244
  checkRuleSemantics(built, diags);
242
245
  checkLibraryConnectors(built, opts, diags);
243
- diags.push(...serializerRefusals(built, opts, diags));
246
+ diags.push(...serializerRefusals(built, opts, diags, reportedReads));
244
247
  return diags;
245
248
  }
246
249
  /**
@@ -256,7 +259,7 @@ export function check(built, opts = {}) {
256
259
  * `internal SDK error:` is passed on, unless `check` or the serializer already
257
260
  * found an error, which the author has to fix first.
258
261
  */
259
- function serializerRefusals(built, opts, found) {
262
+ function serializerRefusals(built, opts, found, reportedReads = []) {
260
263
  const collected = [];
261
264
  const warned = [];
262
265
  let plan;
@@ -299,6 +302,8 @@ function serializerRefusals(built, opts, found) {
299
302
  // one place they are heard.
300
303
  if (plan)
301
304
  for (const f of lintPlanFindings(plan)) {
305
+ if (sameReadAsExprLint(plan, f, reportedReads))
306
+ continue;
302
307
  const r = planReport(f);
303
308
  out.push({
304
309
  level: f.level, code: r.code, message: r.message,
@@ -317,6 +322,64 @@ function serializerRefusals(built, opts, found) {
317
322
  }
318
323
  return out;
319
324
  }
325
+ /** The value at a plan-check path (`nodes[1].data.tasks[0][0].skipCondition`). */
326
+ function valueAtPlanPath(plan, path) {
327
+ let at = plan;
328
+ for (const m of path.matchAll(/([^.[\]]+)|\[(\d+)\]/g)) {
329
+ if (at === null || typeof at !== 'object')
330
+ return undefined;
331
+ at = at[m[2] ?? m[1]];
332
+ }
333
+ return at;
334
+ }
335
+ /** An expression without its `=js:` / `=` prefix, outer parentheses and spacing, so an authored gate and the text the plan carries compare. */
336
+ function exprBody(text) {
337
+ let body = text.trim().replace(/^=(?:js:)?/, '').trim();
338
+ while (/^\(.*\)$/s.test(body))
339
+ body = body.slice(1, -1).trim();
340
+ return body;
341
+ }
342
+ /**
343
+ * The plan fields the expression check reads, where plan-check's
344
+ * REFERENCE_UNBOUND can be about the same read: a rule's
345
+ * `conditionExpression`, a task's `skipCondition` and an SLA's `expression`
346
+ * hold the gate as authored, so the read must equal it.
347
+ */
348
+ const GATE_PATH = /(?:\.conditionExpression|\.skipCondition|slaRules\[\d+\]\.expression)$/;
349
+ /**
350
+ * A wait filter's expression sits inside a larger encoded value, so the read
351
+ * is found by containment: the filter body
352
+ * (`…inputs[0].body.filters.variables.var_0`) and the encoded configuration
353
+ * (`…context[8].body.activityPropertyConfiguration.configuration`).
354
+ */
355
+ const WAIT_FILTER_PATH = /\.body\.(?:filters\b|activityPropertyConfiguration\.configuration$)/;
356
+ /**
357
+ * True when `f` is plan-check's CASE_MGMT_REFERENCE_UNBOUND on a read the
358
+ * expression check already reported as EXPR_UNDECLARED_REF: the same root, in
359
+ * plan text written from that expression (the gate verbatim, or a wait
360
+ * filter's expression inside its encoded configuration). One mistake, one
361
+ * finding. A REFERENCE_UNBOUND anywhere else, such as a task input
362
+ * `=vars.x` or a connector body field, which the expression check does not
363
+ * read, is still reported, even when its text equals the gate's.
364
+ */
365
+ function sameReadAsExprLint(plan, f, reads) {
366
+ if (f.code !== 'CASE_MGMT_REFERENCE_UNBOUND' || !reads.length)
367
+ return false;
368
+ const gate = GATE_PATH.test(f.path);
369
+ const contained = !gate && WAIT_FILTER_PATH.test(f.path);
370
+ if (!gate && !contained)
371
+ return false;
372
+ const value = valueAtPlanPath(plan, f.path);
373
+ if (typeof value !== 'string')
374
+ return false;
375
+ const body = exprBody(value);
376
+ return reads.some((r) => {
377
+ if (!f.message.startsWith(`"vars.${r.root}"`))
378
+ return false;
379
+ const read = exprBody(r.expr);
380
+ return gate ? read === body : value.includes(read);
381
+ });
382
+ }
320
383
  /**
321
384
  * The connector-library warnings only `check` gives (#1014): a connector task's
322
385
  * schema-readiness warnings, because the `connectors-local` overlay `registry
@@ -7,9 +7,11 @@
7
7
  *
8
8
  * Only serializes, to a V32 caseplan.json (docs/CHECK_COMPILE_CONTRACT_DESIGN.md
9
9
  * D1, phase 8). It does not run `check()`'s lint rules: run `case check` first
10
- * for those. It stops only when it cannot write a correct plan, a refusal the
11
- * serializer throws, printed in `check`'s `✗ [CODE]` shape (and `case check`
12
- * reports the same refusal, from the same code). The authoritative deploy gate
10
+ * for those. One exception, as a warning that does not stop the write: a gate
11
+ * reading an undeclared case variable (EXPR_UNDECLARED_REF). It stops only
12
+ * when it cannot write a correct plan, a refusal the serializer throws,
13
+ * printed in `check`'s `✗ [CODE]` shape (and `case check` reports the same
14
+ * refusal, from the same code). The authoritative deploy gate
13
15
  * is `uip maestro case validate`.
14
16
  * Output defaults to the plan file the project in the working directory ships
15
17
  * (`caseplan.case` for a project `uip maestro case init` scaffolded), else
@@ -34,6 +36,7 @@ import { ensureTypeScriptRuntime } from '../node-runtime.js';
34
36
  import { CASE_FORMAT_PROFILE } from './format-profile.js';
35
37
  import { deriveCaseBindingsV2 } from './bindings-v2.js';
36
38
  import { orphanWarnings } from './orphaned-resources.js';
39
+ import { caseExprLints } from './case-expr-check.js';
37
40
  import { BINDINGS_V2_DOCUMENT_VERSION } from '../core/bindings-v2-resource.js';
38
41
  import { sha256Uuid } from '../core/stable-id.js';
39
42
  export async function run(argv) {
@@ -91,6 +94,15 @@ export async function run(argv) {
91
94
  }
92
95
  // Solution declarations no project binds once this derivation lands.
93
96
  warnings.push(...orphanWarnings(caseplan, out));
97
+ // A gate that reads a case variable nothing declares (`=js:vars.missing`):
98
+ // `lint`, so compile writes it as authored (#1712), but it is a definite
99
+ // mistake the gate will evaluate as `undefined`, so compile says so for an
100
+ // agent that skipped `case check`, which reports it as an error.
101
+ for (const d of caseExprLints(built))
102
+ warnings.push({
103
+ level: 'warning', code: d.code, message: `in ${d.where}: ${d.message}`, where: d.where,
104
+ ...(d.suggestion ? { suggestion: d.suggestion } : {}),
105
+ });
94
106
  for (const w of warnings)
95
107
  console.error(` ${diagnosticLine(w)}`);
96
108
  // Reported before the first write, so a write that throws still carries it.
@@ -191,7 +191,7 @@ export interface DecompileOptions {
191
191
  bestEffort?: boolean;
192
192
  }
193
193
  export interface CaseDecompileDiagnostic {
194
- code: 'UNSUPPORTED_TASK_KIND' | 'UNKNOWN_STAGE_REFERENCE' | 'UNKNOWN_TASK_REFERENCE' | 'UNKNOWN_EXIT_TARGET' | 'UNDECLARED_VARIABLE_REFERENCE';
194
+ code: 'UNSUPPORTED_TASK_KIND' | 'UNKNOWN_STAGE_REFERENCE' | 'UNKNOWN_TASK_REFERENCE' | 'UNKNOWN_EXIT_TARGET';
195
195
  message: string;
196
196
  location: string;
197
197
  }