1717 * datasource's driver is called: the recording driver below sees no write;
1818 * - an outbound node is not executed: the run stops there with the node
1919 * named, and the local server below receives no request;
20+ * - a stop the run goes on past (a try region's catch, a parallel branch)
21+ * does not hide a later real failure: that node is the first failure;
22+ * - a stop inside a child flow is named at the child's node, not reported
23+ * as the calling `subflow` node's failure;
2024 * - a schedule the deployment's scheduled-work switch keeps unarmed is not a
2125 * defect: it is reported as not armed and still run with no caller;
2226 * - an API-triggered flow gets its body as `record` as well as `params`, and
@@ -252,6 +256,97 @@ const outbound: Flow = {
252256 ] ,
253257} as Flow ;
254258
259+ /** A Ledger write with no name: the required field refuses it at run time. */
260+ const failingWrite = ( id : string ) => ( { id, type : 'create_record' , label : id , config : { objectName : LEDGER , fields : { } } } ) ;
261+ const httpCall = ( id : string ) => ( { id, type : 'http' , label : id , config : { url : OUTBOUND_URL , method : 'GET' } } ) ;
262+
263+ /** start → a try region around an `http` call, caught → a write that really fails → end. */
264+ const CAUGHT = 'fr_caught' ;
265+ const caught : Flow = {
266+ name : CAUGHT ,
267+ label : CAUGHT ,
268+ type : 'autolaunched' ,
269+ status : 'active' ,
270+ runAs : 'system' ,
271+ nodes : [
272+ { id : 'start' , type : 'start' , label : 'Start' } ,
273+ {
274+ id : 'guard' ,
275+ type : 'try_catch' ,
276+ label : 'Guard' ,
277+ config : {
278+ try : { nodes : [ httpCall ( 'caught_call' ) ] } ,
279+ catch : { nodes : [ { id : 'call_failed' , type : 'assignment' , label : 'Call failed' } ] } ,
280+ } ,
281+ } ,
282+ failingWrite ( 'boom' ) ,
283+ { id : 'end' , type : 'end' , label : 'End' } ,
284+ ] ,
285+ edges : [
286+ { id : 'e1' , source : 'start' , target : 'guard' } ,
287+ { id : 'e2' , source : 'guard' , target : 'boom' } ,
288+ { id : 'e3' , source : 'boom' , target : 'end' } ,
289+ ] ,
290+ } as Flow ;
291+
292+ /** start → one branch calls out, the other branch's write really fails → end. */
293+ const FORKED = 'fr_forked' ;
294+ const forked : Flow = {
295+ name : FORKED ,
296+ label : FORKED ,
297+ type : 'autolaunched' ,
298+ status : 'active' ,
299+ runAs : 'system' ,
300+ nodes : [
301+ { id : 'start' , type : 'start' , label : 'Start' } ,
302+ {
303+ id : 'fan' ,
304+ type : 'parallel' ,
305+ label : 'Fan out' ,
306+ config : { branches : [ { name : 'call' , nodes : [ httpCall ( 'fork_call' ) ] } , { name : 'write' , nodes : [ failingWrite ( 'fork_boom' ) ] } ] } ,
307+ } ,
308+ { id : 'end' , type : 'end' , label : 'End' } ,
309+ ] ,
310+ edges : [
311+ { id : 'e1' , source : 'start' , target : 'fan' } ,
312+ { id : 'e2' , source : 'fan' , target : 'end' } ,
313+ ] ,
314+ } as Flow ;
315+
316+ /** A child flow that calls out, and a parent that calls it and then writes. */
317+ const CHILD = 'fr_child' ;
318+ const child : Flow = {
319+ name : CHILD ,
320+ label : CHILD ,
321+ type : 'autolaunched' ,
322+ status : 'active' ,
323+ runAs : 'system' ,
324+ nodes : [ { id : 'start' , type : 'start' , label : 'Start' } , httpCall ( 'child_call' ) , { id : 'end' , type : 'end' , label : 'End' } ] ,
325+ edges : [
326+ { id : 'e1' , source : 'start' , target : 'child_call' } ,
327+ { id : 'e2' , source : 'child_call' , target : 'end' } ,
328+ ] ,
329+ } as Flow ;
330+ const PARENT = 'fr_parent' ;
331+ const parent : Flow = {
332+ name : PARENT ,
333+ label : PARENT ,
334+ type : 'autolaunched' ,
335+ status : 'active' ,
336+ runAs : 'system' ,
337+ nodes : [
338+ { id : 'start' , type : 'start' , label : 'Start' } ,
339+ { id : 'call_child' , type : 'subflow' , label : 'Call child' , config : { flowName : CHILD } } ,
340+ ledgerNode ( 'after_child' , "'after the child'" ) ,
341+ { id : 'end' , type : 'end' , label : 'End' } ,
342+ ] ,
343+ edges : [
344+ { id : 'e1' , source : 'start' , target : 'call_child' } ,
345+ { id : 'e2' , source : 'call_child' , target : 'after_child' } ,
346+ { id : 'e3' , source : 'after_child' , target : 'end' } ,
347+ ] ,
348+ } as Flow ;
349+
255350/** A nightly schedule that writes one Ledger row. */
256351const NIGHTLY = 'fr_nightly' ;
257352const nightly : Flow = {
@@ -370,6 +465,10 @@ const fixtureStack = defineStack({
370465 noExecutor ,
371466 confined ,
372467 outbound ,
468+ caught ,
469+ forked ,
470+ child ,
471+ parent ,
373472 nightly ,
374473 hook ,
375474 renewal ,
@@ -464,6 +563,7 @@ describe('runFlowProof — the local flow run', () => {
464563 expect ( report . confinement . outbound ) . toContain ( 'http' ) ;
465564 expect ( report . verdict , formatFlowRunReport ( report ) ) . toBe ( 'stopped' ) ;
466565 expect ( report . firstFailure ) . toMatchObject ( { kind : 'outbound_not_run' , nodeId : 'call' , nodeType : 'http' } ) ;
566+ expect ( report . outboundStops ) . toEqual ( [ { nodeId : 'call' , nodeType : 'http' } ] ) ;
467567 // The run log is the engine's own: the start ran, the call is the failing step, nothing after it ran.
468568 expect ( report . steps . map ( ( s ) => [ s . nodeId , s . status ] ) ) . toEqual ( [
469569 [ 'start' , 'success' ] ,
@@ -474,6 +574,39 @@ describe('runFlowProof — the local flow run', () => {
474574 expect ( report . summary . hardFailures ) . toBe ( 0 ) ;
475575 } ) ;
476576
577+ it ( 'a stop a try region catches does not hide the later node that really fails' , async ( ) => {
578+ const mark = outboundHits . length ;
579+ const report = await runFlowProof ( stack , fixtureStack , { flow : CAUGHT } ) ;
580+ expect ( outboundHits . slice ( mark ) ) . toEqual ( [ ] ) ;
581+ expect ( report . verdict , formatFlowRunReport ( report ) ) . toBe ( 'failed' ) ;
582+ expect ( report . firstFailure ) . toMatchObject ( { kind : 'node_failed' , nodeId : 'boom' , nodeType : 'create_record' } ) ;
583+ expect ( report . outboundStops ) . toEqual ( [ { nodeId : 'caught_call' , nodeType : 'http' } ] ) ;
584+ expect ( report . notes . some ( ( n ) => n . includes ( "'caught_call' (http)" ) && n . includes ( 'went on past' ) ) ) . toBe ( true ) ;
585+ expect ( report . summary . hardFailures ) . toBe ( 1 ) ;
586+ } ) ;
587+
588+ it ( 'a stopped parallel branch does not hide the other branch that really fails' , async ( ) => {
589+ const mark = outboundHits . length ;
590+ const report = await runFlowProof ( stack , fixtureStack , { flow : FORKED } ) ;
591+ expect ( outboundHits . slice ( mark ) ) . toEqual ( [ ] ) ;
592+ expect ( report . verdict , formatFlowRunReport ( report ) ) . toBe ( 'failed' ) ;
593+ expect ( report . firstFailure ) . toMatchObject ( { kind : 'node_failed' , nodeId : 'fork_boom' } ) ;
594+ expect ( report . outboundStops ) . toEqual ( [ { nodeId : 'fork_call' , nodeType : 'http' } ] ) ;
595+ expect ( report . summary . hardFailures ) . toBe ( 1 ) ;
596+ } ) ;
597+
598+ it ( "a stop inside a child flow is named at the child's node, not as the subflow node's failure" , async ( ) => {
599+ const mark = outboundHits . length ;
600+ const report = await runFlowProof ( stack , fixtureStack , { flow : PARENT } ) ;
601+ expect ( outboundHits . slice ( mark ) ) . toEqual ( [ ] ) ;
602+ expect ( report . verdict , formatFlowRunReport ( report ) ) . toBe ( 'stopped' ) ;
603+ expect ( report . firstFailure ) . toMatchObject ( { kind : 'outbound_not_run' , nodeId : 'child_call' , nodeType : 'http' } ) ;
604+ expect ( report . steps . find ( ( s ) => s . nodeId === 'call_child' ) ?. status ) . toBe ( 'failure' ) ;
605+ expect ( report . outboundStops ) . toEqual ( [ { nodeId : 'child_call' , nodeType : 'http' } ] ) ;
606+ expect ( await stack . rows ( LEDGER , { name : 'after the child' } ) ) . toEqual ( [ ] ) ;
607+ expect ( report . summary . hardFailures ) . toBe ( 0 ) ;
608+ } ) ;
609+
477610 it ( 'a schedule the scheduled-work switch keeps unarmed is reported as not armed, and still run with no caller' , async ( ) => {
478611 const report = await runFlowProof ( stack , fixtureStack , { flow : NIGHTLY } ) ;
479612 expect ( report . trigger ) . toMatchObject ( { type : 'schedule' , bound : false , cause : 'deployment_policy' } ) ;
0 commit comments