|
2 | 2 | This script performs whatever validations are possible on the metadata in |
3 | 3 | the manifest.json files. Prominent checks include: |
4 | 4 | * .tla files containing pluscal or proofs are marked as such |
5 | | - * .tla files importing community modules have those modules listed |
6 | | - * Human-written fields are not empty |
| 5 | + * Model state counts are applicable to the model type |
| 6 | + * Human-written fields such as authorship are not empty |
7 | 7 | """ |
8 | 8 |
|
9 | 9 | from argparse import ArgumentParser |
@@ -75,81 +75,6 @@ def get_module_features(examples_root, path, parser, queries): |
75 | 75 | tree, _, _ = tla_utils.parse_module(examples_root, parser, path) |
76 | 76 | return get_tree_features(tree, queries) |
77 | 77 |
|
78 | | -# All the standard modules available when using TLC |
79 | | -tlc_modules = { |
80 | | - 'Bags', |
81 | | - 'FiniteSets', |
82 | | - 'Integers', |
83 | | - 'Json', |
84 | | - 'Naturals', |
85 | | - 'Randomization', |
86 | | - 'RealTime', |
87 | | - 'Reals', |
88 | | - 'Sequences', |
89 | | - 'TLC', |
90 | | - 'TLCExt', |
91 | | - 'Toolbox', |
92 | | - 'Apalache' |
93 | | -} |
94 | | - |
95 | | -# All the standard modules available when using TLAPS |
96 | | -tlaps_modules = { |
97 | | - 'BagsTheorems', |
98 | | - 'FiniteSetTheorems', |
99 | | - 'FunctionForkTheorems', |
100 | | - 'FunctionsFork', |
101 | | - 'NaturalsInduction', |
102 | | - 'SequencesExtForkTheorems', |
103 | | - 'SequenceTheorems', |
104 | | - 'TLAPS', |
105 | | - 'WellFoundedInduction' |
106 | | -} |
107 | | - |
108 | | -# Modules overloaded by TLAPS; some of these are ordinarily imported as |
109 | | -# community modules. |
110 | | -tlaps_module_overloads = { |
111 | | - 'Bags', |
112 | | - 'FiniteSets', |
113 | | - 'Functions', |
114 | | - 'RealTime', |
115 | | - 'SequencesExt' |
116 | | -} |
117 | | - |
118 | | -def get_community_imports(examples_root, tree, text, dir, has_proof, queries): |
119 | | - """ |
120 | | - Gets all modules imported by a given .tla file that are not standard |
121 | | - modules or modules in the same file or directory. Community module |
122 | | - imports are what's left. |
123 | | - """ |
124 | | - imports = set( |
125 | | - [ |
126 | | - tla_utils.node_to_string(text, node) |
127 | | - for node in tla_utils.all_nodes_of(queries.imports.captures(tree.root_node)) |
128 | | - ] |
129 | | - ) |
130 | | - modules_in_file = set( |
131 | | - [ |
132 | | - tla_utils.node_to_string(text, node) |
133 | | - for node in tla_utils.all_nodes_of(queries.module_names.captures(tree.root_node)) |
134 | | - ] |
135 | | - ) |
136 | | - imports = ( |
137 | | - imports |
138 | | - - modules_in_file |
139 | | - - tlc_modules |
140 | | - - tlaps_modules |
141 | | - - get_module_names_in_dir(examples_root, dir) |
142 | | - ) |
143 | | - return imports - tlaps_module_overloads if has_proof else imports |
144 | | - |
145 | | -def get_community_module_imports(examples_root, parser, path, queries): |
146 | | - """ |
147 | | - Gets all community modules imported by the .tla file at the given path. |
148 | | - """ |
149 | | - tree, text, _ = tla_utils.parse_module(examples_root, parser, path) |
150 | | - has_proof = 'proof' in get_tree_features(tree, queries) |
151 | | - return get_community_imports(examples_root, tree, text, dirname(path), has_proof, queries) |
152 | | - |
153 | 78 | def check_features(parser, queries, manifest, examples_root): |
154 | 79 | """ |
155 | 80 | Validates every field of the manifest that can be validated. |
@@ -177,14 +102,6 @@ def check_features(parser, queries, manifest, examples_root): |
177 | 102 | if 'proof' in module_features and 'proof' not in module: |
178 | 103 | success = False |
179 | 104 | logging.error(f'Module {module["path"]} contains proof but no proof runtime details in manifest') |
180 | | - expected_imports = get_community_imports(examples_root, tree, text, dirname(module_path), 'proof' in module_features, queries) |
181 | | - actual_imports = set(module['communityDependencies']) |
182 | | - if expected_imports != actual_imports: |
183 | | - success = False |
184 | | - logging.error( |
185 | | - f'Module {module["path"]} has incorrect community dependencies in manifest; ' |
186 | | - + f'expected {list(expected_imports)}, actual {list(actual_imports)}' |
187 | | - ) |
188 | 105 | for model in module['models']: |
189 | 106 | if tla_utils.has_state_count(model) and not tla_utils.is_state_count_valid(model): |
190 | 107 | success = False |
|
0 commit comments