Skip to content

Commit 5428619

Browse files
committed
wip: validate tests, ADR-0087 D3 entry, changesets
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzGExkj8nxREmV7FjX
1 parent a3e2481 commit 5428619

6 files changed

Lines changed: 210 additions & 3 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/spec': minor
3+
---
4+
5+
feat(spec)!: the flow-node expression ledger roots a path in a node's sibling block, and declares a `connector_action` node's `connectorConfig.input` a value slot
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: narrowed
9+
10+
<!-- adr-0087: registered connector-action-input-value-slot-judged -->
11+
12+
**BREAKING** accept-set narrowing of `connectorConfig.input` on `connector_action` flow nodes, served at `AutomationEngine.registerFlow` and `objectstack validate` (see the `@objectstack/service-automation` and `@objectstack/lint` entries). This package carries the ledger both doors read.
13+
14+
- **The ledger.** `FLOW_NODE_EXPRESSION_PATHS` could address a node's `config` only, so the one value map the executor reads from a sibling block — `connectorConfig.input`, evaluated before dispatch since the executor half landed — was declared nowhere and judged by no door. An entry may now name `block: 'connectorConfig'` (absent means `config`); `FLOW_NODE_SIBLING_EXPRESSION_BLOCKS` lists the blocks a path can be rooted in with the node type that reads each, and `FlowNodeExpressionBlock` / `FlowNodeSiblingExpressionBlock` / `FlowNodeSiblingBlocks` type them. The new entry is `connector_action` · `connectorConfig` · `input.*` · `value`.
15+
- **The resolvers.** `resolveFlowNodeExpressions`, `resolveFlowNodeValueSlots` and `flowNodeValueTemplateRefusals` take an optional third argument, the node's sibling blocks (pass the node itself), and each result names the `block` its `path` is inside. A caller that passes none is answered for `config` only, exactly as before; every `config`-rooted result reads `block: 'config'`.
16+
- **The declaration.** `FlowNodeSchema.connectorConfig.input`'s map value carries `.meta({ xExpression: 'value' })`, and `getFlowNodeSiblingBlockJsonSchemas()` hands the node's blocks other than `config` to the reconciliation ratchet as its third channel. The value stays `z.unknown()`: `FlowSchema.parse` does not judge the map, as it judges no value slot of a node's open `config`.
17+
- **Unchanged.** Every `config`-rooted entry resolves byte-identically. The `FlowSchema` example comment no longer says `connectorConfig.input` is handed to the action as written.
18+
19+
**The remedy.** Write a computed input value as a CEL value envelope, `{ dialect: 'cel', source: 'record.id' }`, and a constant as the literal it is; a string that carried a `{…}` token takes the CEL spelling its refusal names (`'{rec.id}'` → `{ dialect: 'cel', source: 'rec.id' }`).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/service-automation': minor
3+
---
4+
5+
fix(service-automation)!: `registerFlow` refuses a malformed envelope and a `{…}` token in a `connector_action` node's `connectorConfig.input`
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: narrowed
9+
10+
<!-- adr-0087: registered connector-action-input-value-slot-judged -->
11+
12+
**BREAKING** accept-set narrowing at `AutomationEngine.registerFlow`.
13+
14+
- **Before.** The executor evaluates `connectorConfig.input` as a value-slot map, but registration judged value slots through a ledger that could address `config` only. A malformed CEL envelope (`{ dialect: 'cel', source: 'rec.' }`), a template envelope (`{ dialect: 'template', … }`) and a `{…}` token string (`'{rec.id}'`) all registered there, while the same three under a `subflow`'s `config.input` were refused. The malformed envelope failed the step at run time; the token string was handed to the action as its literal text.
15+
- **Now.** The value-envelope and value-slot template checks read the ledger's `connectorConfig` entry, so all three are refused at registration, each located at `connectorConfig.input.<key>` with the same refusal a `subflow` input value draws. A flow row in `sys_metadata` carrying one is skipped at boot with a `warn` naming it, its trigger not armed.
16+
- **Unchanged.** Literals and valid CEL envelopes register and dispatch as before; an envelope nested inside a literal is data; `input` stays optional.
17+
18+
**The remedy.** Write a computed value as `{ dialect: 'cel', source: '…' }` and a constant as a literal; follow the CEL spelling each refusal names.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/lint': minor
3+
---
4+
5+
fix(lint)!: `objectstack validate` judges a `connector_action` node's `connectorConfig.input` as a value slot
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: narrowed
9+
10+
<!-- adr-0087: registered connector-action-input-value-slot-judged -->
11+
12+
**BREAKING** accept-set narrowing at `validateStackExpressions` (`objectstack validate`), and so at the runtime authoring gate that runs the same pass on a flow write.
13+
14+
- **Before.** A malformed CEL envelope, a template envelope and a `{…}` token string in `connectorConfig.input` passed clean; the same three under a `subflow`'s `config.input` were `error`s.
15+
- **Now.** Each is an `error` at `node 'ID' (connector_action) connector_action input value at connectorConfig.input.KEY`, with the message a `subflow` input value draws. A valid envelope is also held to the value slots' other checks, the unbound-root judgment included, as every value slot is.
16+
- **Unchanged.** Literals and valid CEL envelopes pass.
17+
18+
**The remedy.** Write a computed value as `{ dialect: 'cel', source: '…' }` and a constant as a literal; follow the CEL spelling each refusal names.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* **`objectstack validate` judges a `connector_action` node's
5+
* `connectorConfig.input`** (#27968) — the build door's half of the slot
6+
* `registerFlow` now judges too.
7+
*
8+
* The expression pass reads value slots only through the spec's expression
9+
* ledger, whose paths were rooted in `node.config`; `connectorConfig` is a
10+
* sibling block, so a malformed CEL envelope, a template-dialect envelope and a
11+
* `{…}` token string there passed `validateStackExpressions` clean while the
12+
* same three under a `subflow`'s `config.input` were refused. The ledger now
13+
* roots the slot in the block, and this pass judges it like every other value
14+
* slot, located at `connectorConfig.input.<key>`, at `error`. The runtime
15+
* authoring gate runs the same pass, so a flow write is refused there as well.
16+
*/
17+
18+
import { describe, expect, it } from 'vitest';
19+
import { VALUE_ENVELOPE_REFUSAL, VALUE_SLOT_TEMPLATE_REFUSAL } from '@objectstack/spec/automation';
20+
21+
import { runRuntimeAuthoringRules } from './runtime-gate.js';
22+
import { validateStackExpressions, type ExprIssue } from './validate-expressions.js';
23+
24+
type AnyRec = Record<string, unknown>;
25+
26+
/** start → `node` → end, the record an input variable. */
27+
function flowWith(node: AnyRec): AnyRec {
28+
return {
29+
name: 'f',
30+
label: 'F',
31+
type: 'autolaunched',
32+
variables: [{ name: 'rec', type: 'object', isInput: true }],
33+
nodes: [
34+
{ id: 'start', type: 'start', config: {} },
35+
{ id: 'call', label: 'Call', ...node },
36+
{ id: 'done', type: 'end', config: {} },
37+
],
38+
edges: [{ id: 'e1', source: 'start', target: 'call' }, { id: 'e2', source: 'call', target: 'done' }],
39+
};
40+
}
41+
42+
const connectorNode = (input: AnyRec): AnyRec => ({
43+
type: 'connector_action',
44+
connectorConfig: { connectorId: 'vendor', actionId: 'lookup', input },
45+
});
46+
const subflowNode = (input: AnyRec): AnyRec => ({ type: 'subflow', config: { flowName: 'child', input } });
47+
48+
const errorsOf = (flow: AnyRec): ExprIssue[] =>
49+
validateStackExpressions({ flows: [flow] }).filter((i) => (i.severity ?? 'error') === 'error');
50+
51+
/** The three shapes the #27327 thread measured passing the build door under `connectorConfig.input`. */
52+
const SHAPES = [
53+
['a malformed CEL envelope', { dialect: 'cel', source: 'rec.' }, VALUE_ENVELOPE_REFUSAL],
54+
['a template-dialect envelope', { dialect: 'template', source: '{rec.id}' }, VALUE_ENVELOPE_REFUSAL],
55+
['a bare `{…}` token string', '{rec.id}', VALUE_SLOT_TEMPLATE_REFUSAL],
56+
] as const;
57+
58+
describe('objectstack validate refuses the three shapes at `connectorConfig.input.<key>`', () => {
59+
it.each(SHAPES)('%s', (_shape, value, lead) => {
60+
const found = errorsOf(flowWith(connectorNode({ customerId: value, region: 'eu' })));
61+
expect(found.map((i) => i.where)).toEqual([
62+
"flow 'f' · node 'call' (connector_action) connector_action input value at connectorConfig.input.customerId",
63+
]);
64+
expect(found[0]!.message.startsWith(lead)).toBe(true);
65+
// The same shape under a `subflow`'s input map: the same refusal, at its own position.
66+
const control = errorsOf(flowWith(subflowNode({ customerId: value })));
67+
expect(control.map((i) => i.where)).toEqual([
68+
"flow 'f' · node 'call' (subflow) subflow input value at config.input.customerId",
69+
]);
70+
// The connector's refusal is the subflow's, minus the callee sentence a
71+
// child flow's input value adds: the action was handed the text, not nothing.
72+
expect(control[0]!.message.startsWith(found[0]!.message)).toBe(true);
73+
});
74+
75+
it('a valid envelope and literals pass', () => {
76+
expect(errorsOf(flowWith(connectorNode({
77+
customerId: { dialect: 'cel', source: 'rec.id' },
78+
region: 'eu',
79+
body: { filter: { dialect: 'cel', source: 'rec.id' } },
80+
})))).toEqual([]);
81+
expect(errorsOf(flowWith({ type: 'connector_action', connectorConfig: { connectorId: 'vendor', actionId: 'lookup' } }))).toEqual([]);
82+
});
83+
84+
it('the runtime authoring gate refuses a flow write carrying one, through the same pass', () => {
85+
const result = runRuntimeAuthoringRules({ type: 'flow', item: flowWith(connectorNode({ customerId: '{rec.id}' })) });
86+
const refused = result.errors.filter((f) => f.where.includes('connectorConfig.input.customerId'));
87+
expect(refused.map((f) => f.rule)).toEqual(['expression-invalid']);
88+
expect(refused[0]!.message.startsWith(VALUE_SLOT_TEMPLATE_REFUSAL)).toBe(true);
89+
});
90+
});

‎packages/services/service-automation/src/builtin/connector-input-registration.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function registrationError(node: Record<string, unknown>): string {
9090

9191
/** The three shapes the #27327 thread measured registering under `connectorConfig.input`. */
9292
const SHAPES = [
93-
['a malformed CEL envelope', { dialect: 'cel', source: 'rec.' }, ''],
93+
['a malformed CEL envelope', { dialect: 'cel', source: 'rec.' }, VALUE_ENVELOPE_REFUSAL],
9494
['a template-dialect envelope', { dialect: 'template', source: '{rec.id}' }, VALUE_ENVELOPE_REFUSAL],
9595
['a bare `{…}` token string', '{rec.id}', VALUE_SLOT_TEMPLATE_REFUSAL],
9696
] as const;
@@ -105,8 +105,10 @@ describe('1. registerFlow refuses the three shapes at `connectorConfig.input.<ke
105105
// one slot rule, two positions, one reject set.
106106
const control = registrationError(subflowNode({ customerId: value }));
107107
expect(control).toContain(`node 'call' (subflow) subflow input value at config.input.customerId: ${lead}`);
108-
const detail = (m: string) => m.slice(m.indexOf('input.customerId: ') + 'input.customerId: '.length).split('\n')[0];
109-
expect(detail(message)).toBe(detail(control));
108+
// The connector's refusal is the subflow's, minus the callee sentence a
109+
// child flow's input value adds: the action was handed the text, not nothing.
110+
const detail = (m: string) => m.slice(m.indexOf('input.customerId: ') + 'input.customerId: '.length).split('\n')[0]!;
111+
expect(detail(control).startsWith(detail(message))).toBe(true);
110112
});
111113

112114
it('a refused flow is not registered: it cannot be run', async () => {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import type { SemanticMigration } from '../../types.js';
4+
5+
// A connector_action node's connectorConfig.input joins the value slots the
6+
// expression ledger declares, rooted in the node's sibling block, so the two
7+
// build doors judge it as they judge a subflow's input map. Its executor half
8+
// (the map evaluated through the per-key value-slot resolver) landed first.
9+
//
10+
// Form D: no tracker number anywhere in the author-shown text; the decision is
11+
// stated in words.
12+
//
13+
// No backticks in `surface` — build-upgrade-guide.ts renders it inside a code
14+
// span already, and a nested backtick would close it.
15+
export const entry: SemanticMigration = {
16+
id: 'connector-action-input-value-slot-judged',
17+
surface:
18+
'Each value of connectorConfig.input on a type: \'connector_action\' flow node, at any depth of the flow, '
19+
+ 'including an ADR-0031 region body. Two values that registered and passed objectstack validate are now '
20+
+ 'refused there: an expression envelope (an object naming a dialect) that is not a valid CEL value '
21+
+ 'envelope — a CEL source that does not parse, a blank or missing source, a dialect other than cel, a '
22+
+ 'template envelope among them — and a string carrying a single-brace {…} token of the retired flow '
23+
+ 'template dialect, anywhere in the value (a string inside a nested list or object included). Reachable '
24+
+ 'wherever a flow is authored or stored: defineStack({ flows }) sources and objectstack validate, a flow '
25+
+ 'written through the runtime authoring gate (a flow saved from the Studio flow designer), and a flow row '
26+
+ 'already sitting in sys_metadata, judged when the engine registers it at boot',
27+
replacement:
28+
'Write a computed value as a CEL value envelope, `{ dialect: \'cel\', source: \'record.id\' }`, evaluated '
29+
+ 'in the run\'s scope before the action is dispatched; write a constant as the literal it is. For a '
30+
+ 'string that carried a token, the refusal names the token\'s CEL spelling: `\'{rec.id}\'` becomes '
31+
+ '`{ dialect: \'cel\', source: \'rec.id\' }`, and text with a token inside it becomes a CEL string '
32+
+ 'expression (`\'Ticket for \' + rec.name`). For a malformed envelope, correct its source or write the '
33+
+ 'value as a literal',
34+
reason:
35+
'The connector_action executor evaluates every top-level CEL envelope in `connectorConfig.input` before '
36+
+ 'dispatch, through the same per-key value-slot resolver a subflow\'s `input` map uses, and fails the '
37+
+ 'step on a malformed one. The two build doors judge value slots only through the spec\'s expression '
38+
+ 'ledger, whose paths could address a node\'s `config` and no sibling block, so `registerFlow` and '
39+
+ '`objectstack validate` admitted a malformed envelope, a template envelope and a `{…}` token in this '
40+
+ 'map while refusing the same three under a subflow\'s `config.input`: one slot, two reject sets, and '
41+
+ 'the malformed envelope met first by a run. A token string was never read as a template here; the '
42+
+ 'action was handed its text as written. The ledger now roots a path in the node\'s `connectorConfig` '
43+
+ 'block, so both doors judge this map by the value-slot rule every other value map takes. '
44+
+ '⚠️ No D2 conversion: no token has a lossless CEL spelling (the value-slot template retirement measured '
45+
+ 'each), and a malformed envelope carries no source the platform could correct. '
46+
+ '⚠️ Where such a node already sits the whole flow is refused: registered from the metadata registry or '
47+
+ '`sys_metadata` at boot it is skipped with a `warn` naming it, its trigger not armed, while the flows '
48+
+ 'beside it register; a `defineStack({ flows })` source fails `objectstack validate`. The flow parse '
49+
+ '(`FlowSchema.parse`) does not judge the map, as it judges no value slot of a node\'s open `config`. '
50+
+ 'ADR-0087, ADR-0032.',
51+
acceptanceCriteria:
52+
'Run `objectstack validate` over every stack authored in config files, and boot every deployed stack. '
53+
+ 'Each refusal names the node and the key: `objectstack validate` prints `node \'ID\' (connector_action) '
54+
+ 'connector_action input value at connectorConfig.input.KEY`, and `registerFlow` names the same position, '
55+
+ 'its message leading with the value-slot refusal sentence. For each hit, rewrite the value per the '
56+
+ 'replacement. Two proofs. (1) For a stack authored in config files, `objectstack validate` is clean. '
57+
+ '(2) Boot the stack and confirm each flow REGISTERS: no `failed to register flow` warn for it — that warn '
58+
+ 'line is the locator for a row that exists only in `sys_metadata`. A connector node whose input holds '
59+
+ 'literals and valid CEL envelopes registers and dispatches as before, and `input` stays optional.',
60+
};

0 commit comments

Comments
 (0)