Skip to content

Commit 5ccbebe

Browse files
committed
test(metadata-protocol): wire the flow fixtures that held a node no edge reaches
Claude-Session: https://claude.ai/code/session_01FEkQ5oEQNYg7j3ueo5t6pV Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1a0e8db commit 5ccbebe

2 files changed

Lines changed: 23 additions & 12 deletions

File tree

‎packages/metadata-protocol/src/protocol.metadata-redaction.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,9 @@ function relocate(served: any, secret?: string) {
766766
config: { triggerType: 'api', hookId: 'intake', ...(secret !== undefined ? { secret } : {}) },
767767
},
768768
],
769-
edges: [{ id: 'e1', source: 'begin_v2', target: 'finish' }],
769+
// `e2` keeps the old start node reached: a node no edge reaches is
770+
// refused at parse, which is not the refusal these tests are about.
771+
edges: [{ id: 'e1', source: 'begin_v2', target: 'finish' }, { id: 'e2', source: 'begin_v2', target: 'begin' }],
770772
};
771773
}
772774

@@ -906,7 +908,8 @@ function storedCalloutFlow() {
906908
},
907909
},
908910
],
909-
edges: [],
911+
// Wired: a top-level node no edge reaches is refused at parse.
912+
edges: [{ id: 's1', source: 'begin', target: 'each' }, { id: 's2', source: 'each', target: 'fan' }],
910913
};
911914
}
912915

@@ -1042,6 +1045,7 @@ function storedMovesFlow() {
10421045
const flow: any = storedCalloutFlow();
10431046
flow.name = 'moves';
10441047
flow.nodes.push({ id: 'call', type: 'http', label: 'Call', config: { url: 'https://c', durable: true, signingSecret: SIGNING } });
1048+
flow.edges.push({ id: 's3', source: 'fan', target: 'call' });
10451049
return flow;
10461050
}
10471051

@@ -1054,6 +1058,7 @@ function movedOutOfLoop(served: any) {
10541058
return {
10551059
...served,
10561060
nodes: [begin, { ...each, config: { ...each.config, body: { nodes: [NOOP('body_noop')], edges: [] } } }, fan, call, perRow],
1061+
edges: [...served.edges, { id: 's4', source: 'call', target: perRow.id }],
10571062
};
10581063
}
10591064

@@ -1178,7 +1183,7 @@ describe('#20590 round 2 — the relocation counts nodes, not every object carry
11781183
const stored = storedMovesFlow();
11791184
const incoming = movedWithEdgeTwin(redactMetadataItem('flow', stored));
11801185
const out: any = carryForwardRedactedValues('flow', incoming, stored);
1181-
expect(out.edges.map((e: any) => e.id)).toEqual(['per_row']);
1186+
expect(out.edges.map((e: any) => e.id)).toEqual(['s1', 's2', 's3', 's4', 'per_row']);
11821187
expect(out.nodes[4].id).toBe('per_row');
11831188
expect(out.nodes[4].config.signingSecret).toBe(SIGNING);
11841189
expect(allStrings(redactMetadataItem('flow', out))).not.toContain(SIGNING);
@@ -1197,7 +1202,7 @@ describe('#20590 round 2 — the relocation counts nodes, not every object carry
11971202
await protocol.saveMetaItem({ type: 'flow', name: 'moves', item: movedWithEdgeTwin(editable) });
11981203

11991204
const at = JSON.parse(Array.from(rows.values()).find((r) => r.name === 'moves' && r.state === 'active')!.metadata);
1200-
expect(at.edges.map((e: any) => e.id)).toEqual(['per_row']);
1205+
expect(at.edges.map((e: any) => e.id)).toEqual(['s1', 's2', 's3', 's4', 'per_row']);
12011206
expect(at.nodes[4].config.signingSecret).toBe(SIGNING);
12021207
expect(allStrings(await protocol.getMetaItem({ type: 'flow', name: 'moves' }))).not.toContain(SIGNING);
12031208
});

‎packages/metadata-protocol/src/runtime-authoring-gate.flow-region.test.ts‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@ const RULE = 'flow-region-shape-invalid';
2121

2222
type Rec = Record<string, unknown>;
2323

24-
/** start → the given nodes (unwired) → end; region cases need no top-level edges. */
25-
const flowOf = (name: string, nodes: Rec[]) => ({
26-
name,
27-
label: name,
28-
type: 'autolaunched',
29-
nodes: [{ id: 'start', type: 'start', label: 'Start' }, ...nodes, { id: 'end', type: 'end', label: 'End' }],
30-
edges: [] as Rec[],
31-
});
24+
/**
25+
* start → the given nodes → end, chained in order: a top-level node no edge
26+
* reaches is refused at parse, and that is not the rule these cases judge.
27+
*/
28+
const flowOf = (name: string, nodes: Rec[]) => {
29+
const ids = ['start', ...nodes.map((n) => String(n.id)), 'end'];
30+
return {
31+
name,
32+
label: name,
33+
type: 'autolaunched',
34+
nodes: [{ id: 'start', type: 'start', label: 'Start' }, ...nodes, { id: 'end', type: 'end', label: 'End' }],
35+
edges: ids.slice(1).map((target, i) => ({ id: `e${i}`, source: ids[i], target })) as Rec[],
36+
};
37+
};
3238

3339
const oneStep = (id: string) => ({ nodes: [{ id, type: 'assignment', label: id }], edges: [] });
3440

0 commit comments

Comments
 (0)