@@ -372,6 +372,60 @@ private predicate summaryModel(
372372 )
373373}
374374
375+ private predicate relevantPackage ( string package ) {
376+ sourceModel ( package , _, _, _, _, _, _, _) or
377+ sinkModel ( package , _, _, _, _, _, _, _) or
378+ summaryModel ( package , _, _, _, _, _, _, _, _)
379+ }
380+
381+ private predicate packageLink ( string shortpkg , string longpkg ) {
382+ relevantPackage ( shortpkg ) and
383+ relevantPackage ( longpkg ) and
384+ longpkg .prefix ( longpkg .indexOf ( "." ) ) = shortpkg
385+ }
386+
387+ private predicate canonicalPackage ( string package ) {
388+ relevantPackage ( package ) and not packageLink ( _, package )
389+ }
390+
391+ private predicate canonicalPkgLink ( string package , string subpkg ) {
392+ canonicalPackage ( package ) and
393+ ( subpkg = package or packageLink ( package , subpkg ) )
394+ }
395+
396+ /**
397+ * Holds if CSV framework coverage of `package` is `n` api endpoints of the
398+ * kind `(kind, part)`.
399+ */
400+ predicate modelCoverage ( string package , int pkgs , string kind , string part , int n ) {
401+ pkgs = strictcount ( string subpkg | canonicalPkgLink ( package , subpkg ) ) and
402+ (
403+ part = "source" and
404+ n =
405+ strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
406+ string ext , string output |
407+ canonicalPkgLink ( package , subpkg ) and
408+ sourceModel ( subpkg , type , subtypes , name , signature , ext , output , kind )
409+ )
410+ or
411+ part = "sink" and
412+ n =
413+ strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
414+ string ext , string input |
415+ canonicalPkgLink ( package , subpkg ) and
416+ sinkModel ( subpkg , type , subtypes , name , signature , ext , input , kind )
417+ )
418+ or
419+ part = "summary" and
420+ n =
421+ strictcount ( string subpkg , string type , boolean subtypes , string name , string signature ,
422+ string ext , string input , string output |
423+ canonicalPkgLink ( package , subpkg ) and
424+ summaryModel ( subpkg , type , subtypes , name , signature , ext , input , output , kind )
425+ )
426+ )
427+ }
428+
375429/** Provides a query predicate to check the CSV data for validation errors. */
376430module CsvValidation {
377431 /** Holds if some row in a CSV-based flow model appears to contain typos. */
0 commit comments