@@ -1187,6 +1187,83 @@ describe('validateStackExpressions (ADR-0032 build-time)', () => {
11871187 ] ) ;
11881188 } ) ;
11891189
1190+ // [#30025] A screen's resume lands its collected values under their plain
1191+ // names (`applyResumeSignal`), over the flattened field: a bare `title`
1192+ // downstream reads the NUMBER the screen collected, and `title > 5` runs.
1193+ // Where a node can bind a name no reader sees (`script` here, a screen with
1194+ // no input contract), a bare name is not proven to be the field: the verdict
1195+ // is the run-may-fail warning. `record.title` is the field either way.
1196+ describe ( 'a bare name a screen or an open binder can hold (#30025)' , ( ) => {
1197+ const rtFlow = ( name : string , mid : Record < string , unknown > ) : Record < string , unknown > => ( {
1198+ name,
1199+ nodes : [
1200+ { id : 'start' , type : 'start' , config : { objectName : 'crm_opportunity' , triggerType : 'record-after-update' } } ,
1201+ mid ,
1202+ { id : 'route' , type : 'decision' , config : { conditions : [ { label : 'Big' , expression : 'title > 5' } , { label : 'Long' , expression : 'record.title > 5' } ] } } ,
1203+ { id : 'end' , type : 'end' } ,
1204+ ] ,
1205+ edges : [
1206+ { id : 'e1' , source : 'start' , target : 'mid' } ,
1207+ { id : 'e2' , source : 'mid' , target : 'route' , condition : 'title > 5' } ,
1208+ { id : 'e3' , source : 'route' , target : 'end' , label : 'Big' } ,
1209+ { id : 'e4' , source : 'route' , target : 'end' , label : 'Long' } ,
1210+ ] ,
1211+ } ) ;
1212+ const objects = [ { name : 'crm_opportunity' , fields : { title : { type : 'text' , required : true } } } ] ;
1213+ const longBranch = ( flow : string ) : string =>
1214+ `flow '${ flow } ' · node 'route' (decision) decision branch expression at config.conditions[1].expression` ;
1215+
1216+ it ( 'does not type a bare name a screen field holds as the field it shadows' , ( ) => {
1217+ const issues = validateStackExpressions ( {
1218+ objects,
1219+ flows : [ rtFlow ( 'rt_screen' , { id : 'mid' , type : 'screen' , config : { fields : [ { name : 'title' , type : 'number' , label : 'Title' } ] } } ) ] ,
1220+ } ) ;
1221+ const found = typeMismatches ( issues ) ;
1222+ expect ( found . map ( i => [ i . where , i . severity ] ) ) . toEqual ( [ [ longBranch ( 'rt_screen' ) , 'error' ] ] ) ;
1223+ expect ( found [ 0 ] ! . message ) . toContain ( '`record.title` holds text' ) ;
1224+ } ) ;
1225+
1226+ it ( 'warns, does not refuse, a bare-name mismatch after a node that can bind any name' , ( ) => {
1227+ for ( const [ flow , mid ] of [
1228+ [ 'rt_script' , { id : 'mid' , type : 'script' , config : { functionName : 'calc' } } ] ,
1229+ [ 'rt_formscreen' , { id : 'mid' , type : 'screen' , config : { kind : 'object-form' , objectName : 'crm_opportunity' } } ] ,
1230+ ] as const ) {
1231+ const issues = validateStackExpressions ( { objects, flows : [ rtFlow ( flow , mid ) ] } ) ;
1232+ const found = typeMismatches ( issues ) ;
1233+ expect ( found . map ( i => [ i . where , i . severity ] ) , flow ) . toEqual ( [
1234+ [ `flow '${ flow } ' · node 'route' (decision) decision branch expression at config.conditions[0].expression` , 'warning' ] ,
1235+ [ longBranch ( flow ) , 'error' ] ,
1236+ [ `flow '${ flow } ' · edge 'e2' (mid→route) condition` , 'warning' ] ,
1237+ ] ) ;
1238+ for ( const i of found . filter ( f => f . severity === 'warning' ) ) {
1239+ expect ( i . message , `${ flow } ${ i . where } ` ) . toContain ( 'which this check cannot prove here, so this is a warning, not a refusal' ) ;
1240+ }
1241+ }
1242+ } ) ;
1243+
1244+ it ( 'leaves the null-guard twin silent on a bare name a screen field holds' , ( ) => {
1245+ const flow = ( name : string , fields : unknown [ ] ) => ( {
1246+ name,
1247+ nodes : [
1248+ { id : 'start' , type : 'start' , config : { objectName : 'crm_opportunity' , triggerType : 'record-after-update' } } ,
1249+ { id : 'mid' , type : 'screen' , config : { fields } } ,
1250+ { id : 'end' , type : 'end' } ,
1251+ ] ,
1252+ edges : [ { id : 'e1' , source : 'start' , target : 'mid' } , { id : 'e2' , source : 'mid' , target : 'end' , condition : 'budget > 100' } ] ,
1253+ } ) ;
1254+ const nullable = ( issues : ReturnType < typeof validateStackExpressions > ) =>
1255+ issues . filter ( i => / d e c l a r e s a s n u l l a b l e / . test ( i . message ) ) . map ( i => [ i . where , i . severity ] ) ;
1256+ const budgetObjects = [ { name : 'crm_opportunity' , fields : { budget : { type : 'number' } } } ] ;
1257+ expect ( nullable ( validateStackExpressions ( {
1258+ objects : budgetObjects , flows : [ flow ( 'ng_screen' , [ { name : 'budget' , type : 'number' , label : 'Budget' } ] ) ] ,
1259+ } ) ) ) . toEqual ( [ ] ) ;
1260+ // Control: a screen collecting another name leaves `budget` the field, refused.
1261+ expect ( nullable ( validateStackExpressions ( {
1262+ objects : budgetObjects , flows : [ flow ( 'ng_other' , [ { name : 'note' , type : 'text' , label : 'Note' } ] ) ] ,
1263+ } ) ) ) . toEqual ( [ [ "flow 'ng_other' · edge 'e2' (mid→end) condition" , 'error' ] ] ) ;
1264+ } ) ;
1265+ } ) ;
1266+
11901267 it ( 'keeps the warning on an inert node condition of a record-triggered flow (#29926)' , ( ) => {
11911268 const issues = validateStackExpressions ( {
11921269 objects : [ { name : 'crm_opportunity' , fields : { title : { type : 'text' , required : true } } } ] ,
@@ -4128,10 +4205,14 @@ describe('validateStackExpressions — reads only keys the spec declares (meta-t
41284205 // tabled receivers (`rule.severity`) — never read off metadata itself.
41294206 'site' ,
41304207 // [#29959] A `decision` branch's flow-condition hint (`objectName`,
4131- // `faultOutcome`, `flowVariables `), built at the call site from the
4208+ // `faultOutcome`, `flowBare `), built at the call site from the
41324209 // walk's own `objectName`, the ledger's answer and the flow's bound
41334210 // names — never read off metadata itself.
41344211 'flowCondition' ,
4212+ // [#30025] One flow's bare-name facts (`variables`, `unproven`), built
4213+ // from the flow's collected names and the root judge's `provable`, and
4214+ // its screen-field name set (Set methods) — never read off metadata.
4215+ 'flowBare' , 'screenFields' ,
41354216 ] ) ;
41364217 expect ( receivers . filter ( ( r ) => ! tabled . has ( r ) && ! PLUMBING . has ( r ) ) ) . toEqual ( [ ] ) ;
41374218 } ) ;
0 commit comments