Skip to content

Commit 7abeaf4

Browse files
committed
wip(spec): the expression ledger roots a path in connectorConfig
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzGExkj8nxREmV7FjX
1 parent 2e955dd commit 7abeaf4

7 files changed

Lines changed: 207 additions & 45 deletions

File tree

‎packages/lint/src/validate-expressions.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,8 +2769,11 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
27692769
severity: 'error',
27702770
});
27712771
}
2772-
for (const found of resolveFlowNodeExpressions(nodeType, cfg)) {
2773-
const slotWhere = `${at} · node '${node.id}' (${nodeType}) ${found.entry.label} at config.${found.path}`;
2772+
// [#27968] Handed the node, the ledger reaches a slot rooted in a
2773+
// sibling block too — a `connector_action` node's
2774+
// `connectorConfig.input` — and names the block it is in.
2775+
for (const found of resolveFlowNodeExpressions(nodeType, cfg, node)) {
2776+
const slotWhere = `${at} · node '${node.id}' (${nodeType}) ${found.entry.label} at ${found.block}.${found.path}`;
27742777
// [#15137] `value` slots are checkable too, by their own rule — see
27752778
// `checkDeclaredValue`. Not shadowing-checked: the shadow diagnostic is
27762779
// about a bare identifier resolving to a variable instead of a field,
@@ -2828,9 +2831,9 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
28282831
// (`flowNodeValueTemplateRefusals`), walking the ledger's `value` slots
28292832
// and the two legacy `assignment` shapes, so build and registration
28302833
// give one verdict, and each refusal names the token's CEL spelling.
2831-
for (const templateRefusal of flowNodeValueTemplateRefusals(nodeType, cfg)) {
2834+
for (const templateRefusal of flowNodeValueTemplateRefusals(nodeType, cfg, node)) {
28322835
issues.push({
2833-
where: `${at} · node '${node.id}' (${nodeType}) ${templateRefusal.label} at config.${templateRefusal.path}`,
2836+
where: `${at} · node '${node.id}' (${nodeType}) ${templateRefusal.label} at ${templateRefusal.block}.${templateRefusal.path}`,
28342837
message: templateRefusal.message,
28352838
source: templateRefusal.source,
28362839
severity: 'error',

‎packages/services/service-automation/src/engine.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9000,12 +9000,10 @@ export class AutomationEngine implements IAutomationService {
90009000
* `assignments`
90019001
* through `builtin/value-slot-map.ts`, the one per-slot resolver
90029002
* (`resolveValueSlotMap`, `resolveValueSlot`, `resolveCollectionSlot`).
9003-
* One slot reaches it undeclared: a `connector_action`'s
9004-
* `connectorConfig.input` map (#27327), evaluated through the same
9005-
* resolver. The ledger addresses only `node.config`, and `connectorConfig`
9006-
* is a sibling block, so registration does not judge an envelope there
9007-
* yet — a malformed one registers and faults at run time — until #27968
9008-
* declares it.
9003+
* So does a `connector_action`'s `connectorConfig.input` map (#27327),
9004+
* evaluated through the same resolver — the one entry the ledger roots in
9005+
* a sibling block rather than `config` (#27968), so registration judges an
9006+
* envelope there like every other.
90099007
* The two legacy
90109008
* `assignment` shapes the executor still normalizes (the
90119009
* `assignments: [{ variable, value }]` array and the bare

‎packages/services/service-automation/src/flow-registration-checks.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,14 @@ export function validateFlowExpressions(
591591
// `FlowValueSlotSchema` on the CRUD nodes, the same call on the
592592
// `assignment` node — so a flow that registers is never refused
593593
// there, and vice versa.
594-
for (const refusal of flowNodeValueTemplateRefusals(node.type, node.config)) {
594+
//
595+
// [#27968] The node is handed for its sibling blocks: a
596+
// `connector_action` node's `connectorConfig.input` is a value slot
597+
// the ledger roots in that block, located as `connectorConfig.…`.
598+
for (const refusal of flowNodeValueTemplateRefusals(node.type, node.config, node)) {
595599
refuse(
596-
`${nodePath}.config.${refusal.path}`,
597-
`${at}node '${node.id}' (${node.type}) ${refusal.label} at config.${refusal.path}`,
600+
`${nodePath}.${refusal.block}.${refusal.path}`,
601+
`${at}node '${node.id}' (${node.type}) ${refusal.label} at ${refusal.block}.${refusal.path}`,
598602
refusal.message,
599603
refusal.source,
600604
);
@@ -630,10 +634,14 @@ export function validateFlowExpressions(
630634
// envelope as a CEL value (#15137) — the two roles the ledger has
631635
// since #19939 retired the single-brace one with the `loop` / `map`
632636
// `collection` it recorded.
633-
for (const found of resolveFlowNodeExpressions(node.type, node.config)) {
634-
const slotPath = `${nodePath}.config.${found.path}`;
637+
//
638+
// [#27968] Handed the node, the ledger reaches a slot rooted in a
639+
// sibling block too — a `connector_action` node's
640+
// `connectorConfig.input` — and names the block it is in.
641+
for (const found of resolveFlowNodeExpressions(node.type, node.config, node)) {
642+
const slotPath = `${nodePath}.${found.block}.${found.path}`;
635643
const slotWhere =
636-
`${at}node '${node.id}' (${node.type}) ${found.entry.label} at config.${found.path}`;
644+
`${at}node '${node.id}' (${node.type}) ${found.entry.label} at ${found.block}.${found.path}`;
637645
// [#15137] `value` slots — the ruled `assignment.assignments.*`
638646
// and, since #19938, `create_record` / `update_record`
639647
// `fields.*`. The resolver emits ONLY envelope-shaped objects

‎packages/spec/src/automation/flow-node-config-refusals.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ function insideRegion(nodeType: string, path: ReadonlyArray<PropertyKey>): boole
247247
*/
248248
function insideValueSlot(nodeType: string, path: ReadonlyArray<PropertyKey>): boolean {
249249
return FLOW_NODE_EXPRESSION_PATHS.some((entry) => {
250-
if (entry.nodeType !== nodeType || entry.role !== 'value') return false;
250+
// [#27968] A path here is inside `config`: an entry rooted in a sibling
251+
// block (`connectorConfig`) names no position in it.
252+
if (entry.nodeType !== nodeType || entry.role !== 'value' || entry.block !== undefined) return false;
251253
const segments = ledgerSlotSegments(entry.path);
252254
return path.length > segments.length && startsWithLedgerSlot(segments, path);
253255
});
@@ -341,7 +343,8 @@ function atOrInsideJudgedLedgerSlot(
341343
path: ReadonlyArray<PropertyKey>,
342344
): boolean {
343345
return FLOW_NODE_EXPRESSION_PATHS.some((entry) => {
344-
if (entry.nodeType !== nodeType || !LEDGER_JUDGED_ROLES.has(entry.role)) return false;
346+
// [#27968] `config`-rooted entries only, as in `insideValueSlot`.
347+
if (entry.nodeType !== nodeType || !LEDGER_JUDGED_ROLES.has(entry.role) || entry.block !== undefined) return false;
345348
const segments = ledgerSlotSegments(entry.path);
346349
if (!startsWithLedgerSlot(segments, path)) return false;
347350
if (entry.role !== 'value') return true;

‎packages/spec/src/automation/flow-node-expression-paths.ts‎

Lines changed: 118 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,56 @@ export type FlowNodeExpressionRole =
172172
*/
173173
| 'value';
174174

175+
/**
176+
* [#27968] The SIBLING blocks of a node's `config` a ledger path can be rooted
177+
* in, each with the one node type whose executor reads it.
178+
*
179+
* Two node types keep their contract in a declared block of `FlowNodeSchema`
180+
* beside `config` rather than in `config` (`flow-sibling-block-loose-keys.ts`):
181+
* `wait` (`waitEventConfig`) and `connector_action` (`connectorConfig`). Only
182+
* the second holds a value slot — `connectorConfig.input`, evaluated by the
183+
* `connector_action` executor through the same per-key resolver as every other
184+
* value map — so it is the one listed. `waitEventConfig` holds literals only.
185+
*
186+
* The marker that declares a slot here rides `FlowNodeSchema` itself (the
187+
* block's own Zod, `.meta({ xExpression })`), and the reconciliation ratchet
188+
* (`config-expression-ledger.test.ts` in `service-automation`) reads it from
189+
* there, mapping each block to its node type through this table — so a marker
190+
* on a block this table does not name fails it, and so does an entry rooted in
191+
* a block no marker declares.
192+
*/
193+
export const FLOW_NODE_SIBLING_EXPRESSION_BLOCKS = {
194+
connectorConfig: 'connector_action',
195+
} as const satisfies Readonly<Record<string, string>>;
196+
197+
/** A sibling block of `config` a ledger path can be rooted in ({@link FLOW_NODE_SIBLING_EXPRESSION_BLOCKS}). */
198+
export type FlowNodeSiblingExpressionBlock = keyof typeof FLOW_NODE_SIBLING_EXPRESSION_BLOCKS;
199+
200+
/** The node block a ledger path is rooted in: `config`, or a declared sibling block. */
201+
export type FlowNodeExpressionBlock = 'config' | FlowNodeSiblingExpressionBlock;
202+
203+
/**
204+
* [#27968] The sibling blocks of one node, as the resolvers read them — the
205+
* node itself satisfies it. A caller that hands none is answered for the
206+
* `config`-rooted entries only.
207+
*/
208+
export type FlowNodeSiblingBlocks = { readonly [Block in FlowNodeSiblingExpressionBlock]?: unknown };
209+
175210
/** One expression-bearing config slot on a builtin flow node type. */
176211
export interface FlowNodeExpressionPath {
177212
/** Registry node type the path belongs to (`node.type`). */
178213
readonly nodeType: string;
179214
/**
180-
* Dot path into `node.config`, using `[]` for "every element of this array"
181-
* and a `*` segment for "every key of this object" (#14149).
215+
* [#27968] The node block the path is rooted in, when it is not `config`: a
216+
* declared sibling block ({@link FLOW_NODE_SIBLING_EXPRESSION_BLOCKS}) —
217+
* today `connectorConfig`, for a `connector_action` node's `input` map.
218+
* Absent means `config`, which every entry before #27968 is.
219+
*/
220+
readonly block?: FlowNodeSiblingExpressionBlock;
221+
/**
222+
* Dot path into the node's {@link FlowNodeExpressionPath.block} — `config`
223+
* unless the entry names another — using `[]` for "every element of this
224+
* array" and a `*` segment for "every key of this object" (#14149).
182225
* `'fields[].visibleWhen'` reads `config.fields[i].visibleWhen` for each `i`;
183226
* `'assignments.*'` reads `config.assignments[k]` for each authored key `k`
184227
* — the spelling for a map whose keys are the author's own names (variable
@@ -337,6 +380,13 @@ export interface FlowNodeExpressionPath {
337380
* open map with no marker). The entry carries
338381
* {@link FlowNodeExpressionPath.filterOperands}: the walks emit each operand
339382
* at its own path, never the filter itself.
383+
*
384+
* So is, since #27968, a `connector_action` node's `input` map — the one entry
385+
* rooted outside `config` ({@link FlowNodeExpressionPath.block}): the node's
386+
* contract is its `connectorConfig` sibling block, and the executor hands each
387+
* value of `connectorConfig.input` to the action through the per-key resolver
388+
* the callee maps use. Declared on `FlowNodeSchema.connectorConfig`'s `input`
389+
* map value (`.meta({ xExpression: 'value' })`).
340390
*/
341391
export const FLOW_NODE_EXPRESSION_PATHS: readonly FlowNodeExpressionPath[] = [
342392
{
@@ -590,8 +640,37 @@ export const FLOW_NODE_EXPRESSION_PATHS: readonly FlowNodeExpressionPath[] = [
590640
label: 'delete_record filter operand',
591641
filterOperands: true,
592642
},
643+
{
644+
// [#27968] The input map a `connector_action` node hands to the action —
645+
// `{ <action input>: <value> }`, keys named by the connector's action —
646+
// evaluated in the run's scope before dispatch, through the one per-key
647+
// resolver the callee maps above use (`resolveValueSlotMap`). Rooted in the
648+
// node's `connectorConfig` sibling block, not `config`: that block is the
649+
// node's whole contract, and the executor reads nothing else. Declared
650+
// through the block's own Zod (`FlowNodeSchema.connectorConfig`'s `input`
651+
// map value carries `.meta({ xExpression: 'value' })`).
652+
nodeType: 'connector_action',
653+
block: 'connectorConfig',
654+
path: 'input.*',
655+
role: 'value',
656+
label: 'connector_action input value',
657+
},
593658
];
594659

660+
/** The block `entry`'s path is rooted in. */
661+
export function flowNodeExpressionBlock(entry: FlowNodeExpressionPath): FlowNodeExpressionBlock {
662+
return entry.block ?? 'config';
663+
}
664+
665+
/**
666+
* The value `entry`'s path is walked from on one node: its `config`, or — for
667+
* an entry rooted in a sibling block — that block, read off `siblings`
668+
* (`undefined` when the caller handed none).
669+
*/
670+
function entryRoot(entry: FlowNodeExpressionPath, config: unknown, siblings: FlowNodeSiblingBlocks | undefined): unknown {
671+
return entry.block === undefined ? config : siblings?.[entry.block];
672+
}
673+
595674
/** One operand of a flow node's query filter ({@link flowFilterOperands}). */
596675
export interface FlowFilterOperand {
597676
/**
@@ -703,7 +782,14 @@ function operandPath(prefix: string, path: readonly (string | number)[]): string
703782
export interface ResolvedFlowNodeExpression {
704783
/** The ledger entry that matched. */
705784
readonly entry: FlowNodeExpressionPath;
706-
/** Concrete location, with array indices filled in (`fields[1].visibleWhen`). */
785+
/**
786+
* [#27968] The node block {@link ResolvedFlowNodeExpression.path} is inside
787+
* — `config`, or the entry's sibling block — so a consumer locates the value
788+
* as `<block>.<path>` (`config.fields[1].visibleWhen`,
789+
* `connectorConfig.input.ticket`).
790+
*/
791+
readonly block: FlowNodeExpressionBlock;
792+
/** Concrete location inside {@link ResolvedFlowNodeExpression.block}, with array indices filled in (`fields[1].visibleWhen`). */
707793
readonly path: string;
708794
/** The authored value sitting at that location. */
709795
readonly value: unknown;
@@ -786,28 +872,38 @@ export function isExpressionEnvelopeShaped(value: unknown): value is { dialect:
786872
* each element of an array as a value of its own, at its index (#19939). An
787873
* entry with {@link FlowNodeExpressionPath.filterOperands} reads each operand
788874
* of the filter as a value of its own, at its path (#19939).
875+
*
876+
* [#27968] An entry rooted in a sibling block ({@link FlowNodeExpressionPath.block})
877+
* is walked from that block, read off `siblings` — pass the node itself — and
878+
* each result names the block it is in ({@link ResolvedFlowNodeExpression.block}).
879+
* A caller that hands no `siblings` is answered for the `config`-rooted entries
880+
* only: every door that judges a whole node (`FlowSchema.parse`,
881+
* `AutomationEngine.registerFlow`, `objectstack validate`) hands the node.
789882
*/
790883
export function resolveFlowNodeExpressions(
791884
nodeType: string,
792885
config: unknown,
886+
siblings?: FlowNodeSiblingBlocks,
793887
): ResolvedFlowNodeExpression[] {
794-
if (config == null || typeof config !== 'object') return [];
795888
const out: ResolvedFlowNodeExpression[] = [];
796889
for (const entry of FLOW_NODE_EXPRESSION_PATHS) {
797-
if (entry.nodeType !== nodeType || !readOn(entry, config)) continue;
798-
walk(config as Record<string, unknown>, entry.path.split('.'), '', slotEmitter(entry, (path, value) => {
890+
if (entry.nodeType !== nodeType) continue;
891+
const root = entryRoot(entry, config, siblings);
892+
if (root == null || typeof root !== 'object' || !readOn(entry, root)) continue;
893+
const block = flowNodeExpressionBlock(entry);
894+
walk(root, entry.path.split('.'), '', slotEmitter(entry, (path, value) => {
799895
if (entry.role === 'value') {
800-
if (isExpressionEnvelopeShaped(value)) out.push({ entry, path, value });
896+
if (isExpressionEnvelopeShaped(value)) out.push({ entry, block, path, value });
801897
} else if (typeof value === 'string') {
802898
// #17493 — every string in a `predicate` slot is emitted, a BLANK one
803899
// included, for the consumer to refuse (see `predicateSlotRefusal`).
804-
out.push({ entry, path, value });
900+
out.push({ entry, block, path, value });
805901
} else if (value != null || entry.required) {
806902
// #15572 — a non-string in a predicate slot. Emitted so a consumer can
807903
// REFUSE it (see `predicateSlotRefusal`), never so it can be parsed.
808904
// #19961 — on a REQUIRED slot, absent and `null` are emitted too: the
809905
// walk hands over `undefined` for a key an existing element lacks.
810-
out.push({ entry, path, value });
906+
out.push({ entry, block, path, value });
811907
}
812908
}));
813909
}
@@ -832,15 +928,22 @@ export function resolveFlowNodeExpressions(
832928
* filter at its own path.
833929
*
834930
* Pure path resolution, like its sibling — no judgement about what a value
835-
* says.
931+
* says. Reads a sibling-block entry off `siblings` exactly as its sibling does
932+
* (#27968).
836933
*/
837-
export function resolveFlowNodeValueSlots(nodeType: string, config: unknown): ResolvedFlowNodeExpression[] {
838-
if (config == null || typeof config !== 'object') return [];
934+
export function resolveFlowNodeValueSlots(
935+
nodeType: string,
936+
config: unknown,
937+
siblings?: FlowNodeSiblingBlocks,
938+
): ResolvedFlowNodeExpression[] {
839939
const out: ResolvedFlowNodeExpression[] = [];
840940
for (const entry of FLOW_NODE_EXPRESSION_PATHS) {
841-
if (entry.nodeType !== nodeType || entry.role !== 'value' || !readOn(entry, config)) continue;
842-
walk(config as Record<string, unknown>, entry.path.split('.'), '', slotEmitter(entry, (path, value) => {
843-
if (value !== undefined) out.push({ entry, path, value });
941+
if (entry.nodeType !== nodeType || entry.role !== 'value') continue;
942+
const root = entryRoot(entry, config, siblings);
943+
if (root == null || typeof root !== 'object' || !readOn(entry, root)) continue;
944+
const block = flowNodeExpressionBlock(entry);
945+
walk(root, entry.path.split('.'), '', slotEmitter(entry, (path, value) => {
946+
if (value !== undefined) out.push({ entry, block, path, value });
844947
}));
845948
}
846949
return out;

0 commit comments

Comments
 (0)