-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_component_catalog.py
More file actions
2235 lines (2101 loc) · 95.4 KB
/
Copy pathgenerate_component_catalog.py
File metadata and controls
2235 lines (2101 loc) · 95.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""Generate the Python/C++ component catalog from one versioned declaration.
The checked-in products are intentional: package imports and C++ consumers do not need a
generator at runtime. ``--check`` is the CI non-drift gate.
"""
from __future__ import annotations
import argparse
import copy
import hashlib
import json
from pathlib import Path
import pprint
import re
import sys
from typing import Any
ROOT = Path(__file__).resolve().parents[1]
SOURCE = ROOT / "schemas" / "component_catalog.v2.json"
PY_SCHEMA = ROOT / "python" / "pops" / "model" / "_generated_component_schema.py"
PY_ROUTES = ROOT / "python" / "pops" / "runtime" / "_generated_component_routes.py"
PY_INTERFACES = ROOT / "python" / "pops" / "_generated_component_interfaces.py"
CPP_CATALOG = ROOT / "include" / "pops" / "runtime" / "config" / "generated_component_catalog.hpp"
CPP_ACCESSORS = ROOT / "include" / "pops" / "runtime" / "config" / "generated_route_accessors.inc"
CPP_COMPONENT_ABI = ROOT / "include" / "pops" / "runtime" / "config" / "generated_component_abi.hpp"
CPP_PYBIND_INVOKERS = (ROOT / "python" / "bindings" / "core" / "init" /
"generated_component_invokers.inc")
MANIFEST_SEMANTIC_FIELDS = (
"schema_version", "uri", "component_type", "version", "facets", "signature", "reads",
"writes", "parameters", "interfaces", "requirements", "capabilities", "effects",
"layouts", "clocks", "target", "determinism", "restart", "precision", "conservation",
"entry_points",
)
MANIFEST_TOP_LEVEL_FIELDS = MANIFEST_SEMANTIC_FIELDS + ("extensions", "digests")
TARGET_FIELDS = ("variants",)
DIGEST_FIELDS = ("semantic", "manifest")
class CatalogError(ValueError):
pass
def _exact(value: Any, fields: set[str], where: str) -> dict[str, Any]:
if not isinstance(value, dict):
raise CatalogError(f"{where} must be an object")
unknown = sorted(set(value) - fields)
missing = sorted(fields - set(value))
if unknown or missing:
raise CatalogError(f"{where} field mismatch: missing={missing}, unknown={unknown}")
return value
def _identifier(value: Any, where: str) -> str:
if not isinstance(value, str) or re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", value) is None:
raise CatalogError(f"{where} must be a C++ identifier")
return value
def _strings(value: Any, where: str) -> list[str]:
if not isinstance(value, list) or any(
not isinstance(item, str) or not item or item != item.strip() for item in value
):
raise CatalogError(f"{where} must be a list of canonical non-empty strings")
if len(value) != len(set(value)):
raise CatalogError(f"{where} contains duplicates")
return value
def _catalog_digests(data: dict[str, Any]) -> tuple[str, str]:
canonical = json.dumps(data, ensure_ascii=False, sort_keys=True,
separators=(",", ":")).encode("utf-8")
semantic = copy.deepcopy(data)
for family in semantic["route_families"]:
for route in family["routes"]:
route.pop("limitations", None)
route["metadata"].pop("summary", None)
semantic_canonical = json.dumps(
semantic, ensure_ascii=False, sort_keys=True, separators=(",", ":")
).encode("utf-8")
return hashlib.sha256(canonical).hexdigest(), hashlib.sha256(semantic_canonical).hexdigest()
def _load_catalog() -> tuple[dict[str, Any], str, str]:
data = json.loads(SOURCE.read_text(encoding="utf-8"))
_exact(data, {
"catalog_schema_version", "component_manifest_schema_version",
"route_registry_version", "capability_vocabulary_version", "manifest_schema",
"interface_vocabulary", "native_interface_abi_version", "native_common_abi_version",
"tagging_program_abi",
"native_interface_abis", "boundary_handle_native_routes",
"route_family_native_interfaces", "route_family_interfaces",
"route_component_defaults", "route_families",
}, "component catalog")
if data["catalog_schema_version"] != 2:
raise CatalogError("unsupported component catalog schema_version")
for name in (
"component_manifest_schema_version", "route_registry_version",
"capability_vocabulary_version",
):
if isinstance(data[name], bool) or not isinstance(data[name], int) or data[name] < 1:
raise CatalogError(f"{name} must be an integer >= 1")
if data["component_manifest_schema_version"] != 2:
raise CatalogError("this generator implements ComponentManifest schema version 2")
schema = _exact(data["manifest_schema"], {
"semantic_fields", "top_level_fields", "target_fields", "digest_fields",
"extension_kinds",
}, "manifest_schema")
for field in schema:
_strings(schema[field], f"manifest_schema.{field}")
if tuple(schema["semantic_fields"]) != MANIFEST_SEMANTIC_FIELDS:
raise CatalogError("manifest_schema.semantic_fields does not match implemented schema v2")
if tuple(schema["top_level_fields"]) != MANIFEST_TOP_LEVEL_FIELDS:
raise CatalogError("manifest_schema.top_level_fields does not match implemented schema v2")
if tuple(schema["target_fields"]) != TARGET_FIELDS:
raise CatalogError("manifest_schema.target_fields does not match implemented schema v2")
if tuple(schema["digest_fields"]) != DIGEST_FIELDS:
raise CatalogError("manifest_schema.digest_fields does not match implemented schema v2")
if schema["extension_kinds"] != ["documentary", "semantic"]:
raise CatalogError("extension_kinds must be documentary, semantic")
vocabulary = data["interface_vocabulary"]
if not isinstance(vocabulary, list) or not vocabulary:
raise CatalogError("interface_vocabulary must be a non-empty list")
interface_names: set[str] = set()
for index, interface in enumerate(vocabulary):
interface = _exact(interface, {"name", "method", "required_args"},
f"interface_vocabulary[{index}]")
name = interface["name"]
if not isinstance(name, str) or re.fullmatch(r"[a-z][a-z0-9_]*", name) is None:
raise CatalogError(f"interface_vocabulary[{index}].name is not canonical")
if name in interface_names:
raise CatalogError(f"duplicate component interface {name!r}")
interface_names.add(name)
_identifier(interface["method"], f"interface_vocabulary[{index}].method")
required_args = interface["required_args"]
if isinstance(required_args, bool) or not isinstance(required_args, int) \
or required_args < 0:
raise CatalogError(
f"interface_vocabulary[{index}].required_args must be an integer >= 0")
for name, label in (
("native_interface_abi_version", "interface"),
("native_common_abi_version", "common"),
):
if isinstance(data[name], bool) or not isinstance(data[name], int) or data[name] != 1:
raise CatalogError(
f"unsupported native component {label} ABI version")
tagging = _exact(data["tagging_program_abi"], {
"version", "execution_modes", "collective_scopes", "memory_spaces", "leaf_opcodes", "logical_opcodes",
"candidate_outputs",
"indicator_stencil_routes", "maximum_stencil_terms",
"maximum_instruction_count", "non_finite_policy", "persistent_hysteresis",
}, "tagging_program_abi")
if tagging["version"] != 1 or tagging["persistent_hysteresis"] is not True:
raise CatalogError(
"tagging_program_abi v1 requires checkpointed persistent hysteresis")
if tagging["non_finite_policy"] != "reject":
raise CatalogError(
"tagging_program_abi v1 requires fail-closed non-finite rejection")
execution_modes = tagging["execution_modes"]
if execution_modes != {"native_backend": 1, "host": 2}:
raise CatalogError(
"tagging_program_abi execution_modes must be the canonical v2 executor mapping")
if tagging["collective_scopes"] != {"none": 0}:
raise CatalogError(
"tagging_program_abi collective_scopes must forbid component collectives")
if tagging["memory_spaces"] != ["host", "managed", "device"]:
raise CatalogError(
"tagging_program_abi memory_spaces must be the canonical component ABI spaces")
opcode_ids: set[int] = set()
for family in ("leaf_opcodes", "logical_opcodes"):
values = tagging[family]
if not isinstance(values, dict) or not values:
raise CatalogError(f"tagging_program_abi.{family} must be a non-empty mapping")
for name, opcode in values.items():
_identifier(name, f"tagging_program_abi.{family} opcode")
if isinstance(opcode, bool) or not isinstance(opcode, int) \
or opcode < 1 or opcode > 127 or opcode in opcode_ids:
raise CatalogError(f"tagging_program_abi.{family}.{name} has an invalid id")
opcode_ids.add(opcode)
if tagging["candidate_outputs"] != [
"refine_candidates", "coarsen_candidates",
"refine_equalities", "coarsen_equalities",
]:
raise CatalogError("tagging_program_abi candidate outputs are not canonical")
routes = tagging["indicator_stencil_routes"]
if not isinstance(routes, list) or not routes \
or len(routes) != len(set(routes)) \
or any(not isinstance(route, str) or not route for route in routes):
raise CatalogError(
"tagging_program_abi indicator_stencil_routes must be unique strings")
maximum_terms = tagging["maximum_stencil_terms"]
if isinstance(maximum_terms, bool) or not isinstance(maximum_terms, int) \
or maximum_terms < 1:
raise CatalogError("tagging_program_abi maximum_stencil_terms must be >= 1")
maximum = tagging["maximum_instruction_count"]
if isinstance(maximum, bool) or not isinstance(maximum, int) or maximum < 1:
raise CatalogError("tagging_program_abi maximum_instruction_count must be >= 1")
native_abis = data["native_interface_abis"]
if not isinstance(native_abis, list) or not native_abis:
raise CatalogError("native_interface_abis must be a non-empty list")
native_names: set[str] = set()
native_ids: set[int] = set()
native_uris: set[str] = set()
native_tables: set[str] = set()
for index, native in enumerate(native_abis):
native = _exact(native, {
"id", "name", "uri", "version", "cpp_table", "hot_path", "facets", "operations",
}, f"native_interface_abis[{index}]")
abi_id = native["id"]
if isinstance(abi_id, bool) or not isinstance(abi_id, int) or abi_id < 0:
raise CatalogError(
f"native_interface_abis[{index}].id must be an integer >= 0")
if abi_id in native_ids:
raise CatalogError(f"duplicate native component interface id {abi_id}")
native_ids.add(abi_id)
name = native["name"]
if not isinstance(name, str) or re.fullmatch(r"[a-z][a-z0-9_]*", name) is None:
raise CatalogError(f"native_interface_abis[{index}].name is not canonical")
if name in native_names:
raise CatalogError(f"duplicate native component interface {name!r}")
native_names.add(name)
uri = native["uri"]
if not isinstance(uri, str) or not uri.startswith("pops://interfaces/"):
raise CatalogError(f"native_interface_abis[{index}].uri is not a PoPS interface URI")
if uri in native_uris:
raise CatalogError(f"duplicate native component interface URI {uri!r}")
native_uris.add(uri)
if isinstance(native["version"], bool) or not isinstance(native["version"], int) \
or native["version"] < 1:
raise CatalogError(f"native_interface_abis[{index}].version must be >= 1")
table = _identifier(native["cpp_table"], f"native_interface_abis[{index}].cpp_table")
if name == "field_solver" and (native["version"] != 2 or
table != "PopsFieldSolverApiV2"):
raise CatalogError(
"field_solver must declare the indivisible PopsFieldSolverApiV2 interface")
if name == "field_topology" and (native["version"] != 2 or
table != "PopsFieldTopologyApiV2"):
raise CatalogError(
"field_topology must declare the indivisible PopsFieldTopologyApiV2 interface")
if table in native_tables:
raise CatalogError(f"duplicate native component interface table {table!r}")
native_tables.add(table)
if not isinstance(native["hot_path"], bool):
raise CatalogError(f"native_interface_abis[{index}].hot_path must be boolean")
facets = _strings(native["facets"], f"native_interface_abis[{index}].facets")
unknown_facets = sorted(set(facets) - interface_names)
if unknown_facets:
raise CatalogError(
f"native_interface_abis[{index}].facets are unknown: {unknown_facets}")
operations = _strings(
native["operations"], f"native_interface_abis[{index}].operations")
if not operations or any(re.fullmatch(r"[a-z][a-z0-9_]*", op) is None
for op in operations):
raise CatalogError(
f"native_interface_abis[{index}].operations must be canonical identifiers")
boundary_routes = data["boundary_handle_native_routes"]
if not isinstance(boundary_routes, dict) or not boundary_routes:
raise CatalogError("boundary_handle_native_routes must be a non-empty object")
native_operations = {
row["name"]: frozenset(row["operations"]) for row in native_abis
}
for kind, route in boundary_routes.items():
if not isinstance(kind, str) or re.fullmatch(r"[a-z][a-z0-9_]*", kind) is None:
raise CatalogError(
f"boundary_handle_native_routes key {kind!r} is not canonical")
route = _exact(
route, {"interface", "operation"},
f"boundary_handle_native_routes.{kind}")
interface = route["interface"]
operation = route["operation"]
if interface not in native_operations:
raise CatalogError(
f"boundary_handle_native_routes.{kind} names unknown interface {interface!r}")
if operation not in native_operations[interface]:
raise CatalogError(
f"boundary_handle_native_routes.{kind} operation {operation!r} is not "
f"exported by {interface!r}")
family_native_interfaces = data["route_family_native_interfaces"]
if not isinstance(family_native_interfaces, dict):
raise CatalogError("route_family_native_interfaces must be an object")
for family, name in family_native_interfaces.items():
if name is not None and name not in native_names:
raise CatalogError(
f"route_family_native_interfaces.{family} names unknown interface {name!r}")
family_interfaces = data["route_family_interfaces"]
if not isinstance(family_interfaces, dict):
raise CatalogError("route_family_interfaces must be an object")
for family, declarations in family_interfaces.items():
if not isinstance(family, str) or re.fullmatch(r"[a-z][a-z0-9_]*", family) is None:
raise CatalogError(f"route_family_interfaces key {family!r} is not canonical")
if not isinstance(declarations, list) or not declarations:
raise CatalogError(f"route_family_interfaces.{family} must be a non-empty list")
declared: set[str] = set()
for index, declaration in enumerate(declarations):
declaration = _exact(declaration, {"name", "mode", "binding"},
f"route_family_interfaces.{family}[{index}]")
name = declaration["name"]
if name not in interface_names:
raise CatalogError(
f"route_family_interfaces.{family}[{index}] names unknown interface {name!r}")
if name in declared:
raise CatalogError(
f"route_family_interfaces.{family} declares {name!r} more than once")
declared.add(name)
if declaration["mode"] not in {"method", "value", "entry_point"}:
raise CatalogError(
f"route_family_interfaces.{family}[{index}].mode is invalid")
binding = declaration["binding"]
if not isinstance(binding, str) or re.fullmatch(
r"[A-Za-z_][A-Za-z0-9_]*", binding) is None:
raise CatalogError(
f"route_family_interfaces.{family}[{index}].binding is invalid")
defaults = _exact(data["route_component_defaults"], {
"version", "facets", "signature", "reads", "writes", "parameters", "interfaces",
"effects", "layouts", "clocks", "target", "determinism", "restart", "precision",
"conservation", "extensions",
}, "route_component_defaults")
version = _exact(defaults["version"], {"major", "minor", "patch"},
"route_component_defaults.version")
for name, value in version.items():
if isinstance(value, bool) or not isinstance(value, int) or value < 0:
raise CatalogError(f"route_component_defaults.version.{name} must be an integer >= 0")
for name in (
"facets", "reads", "writes", "parameters", "interfaces", "effects", "layouts",
"clocks", "conservation",
):
if not isinstance(defaults[name], list):
raise CatalogError(f"route_component_defaults.{name} must be a list")
if not isinstance(defaults["signature"], dict):
raise CatalogError("route_component_defaults.signature must be an object")
target = _exact(defaults["target"], set(TARGET_FIELDS), "route_component_defaults.target")
variants = target["variants"]
if not isinstance(variants, list) or not variants:
raise CatalogError("route_component_defaults.target.variants must be a non-empty list")
normalized_variants = []
for index, variant in enumerate(variants):
variant = _exact(variant, {"dimension", "scalar", "device", "features"},
f"route_component_defaults.target.variants[{index}]")
dimension = variant["dimension"]
if isinstance(dimension, bool) or not isinstance(dimension, int) or dimension < 1:
raise CatalogError("route target variant dimension must be an integer >= 1")
for name in ("scalar", "device"):
value = variant[name]
if not isinstance(value, str) or not value or value != value.strip():
raise CatalogError(f"route target variant {name} must be canonical text")
_strings(variant["features"],
f"route_component_defaults.target.variants[{index}].features")
normalized_variants.append(json.dumps(variant, sort_keys=True, separators=(",", ":")))
if len(normalized_variants) != len(set(normalized_variants)):
raise CatalogError("route_component_defaults.target.variants contains duplicates")
determinism = _exact(defaults["determinism"], {"classification", "scope"},
"route_component_defaults.determinism")
if determinism["classification"] not in {
"unspecified", "bitwise", "reproducible", "statistical", "nondeterministic",
}:
raise CatalogError("route_component_defaults.determinism.classification is invalid")
_strings(determinism["scope"], "route_component_defaults.determinism.scope")
restart = _exact(defaults["restart"], {"mode", "schema_uri", "schema_version"},
"route_component_defaults.restart")
if restart != {"mode": "stateless", "schema_uri": "", "schema_version": 0}:
raise CatalogError("builtin route defaults must be stateless")
precision = _exact(defaults["precision"], {"inputs", "accumulation", "outputs"},
"route_component_defaults.precision")
_strings(precision["inputs"], "route_component_defaults.precision.inputs")
_strings(precision["outputs"], "route_component_defaults.precision.outputs")
if not isinstance(precision["accumulation"], str) or not precision["accumulation"]:
raise CatalogError("route_component_defaults.precision.accumulation must be non-empty")
if defaults["extensions"] != {}:
raise CatalogError("builtin route defaults cannot inject undeclared extensions")
families = data["route_families"]
if not isinstance(families, list) or not families:
raise CatalogError("route_families must be a non-empty list")
if len(families) > 255:
raise CatalogError("route_families exceeds the uint8 RouteFamily wire space")
seen_families: set[str] = set()
for family_index, family in enumerate(families):
family = _exact(family, {"name", "cpp_enum", "cpp_table", "routes"},
f"route_families[{family_index}]")
name = family["name"]
if not isinstance(name, str) or re.fullmatch(r"[a-z][a-z0-9_]*", name) is None:
raise CatalogError(f"route_families[{family_index}].name is not canonical")
if name in seen_families:
raise CatalogError(f"duplicate route family {name!r}")
seen_families.add(name)
_identifier(family["cpp_enum"], f"{name}.cpp_enum")
_identifier(family["cpp_table"], f"{name}.cpp_table")
routes = family["routes"]
if not isinstance(routes, list) or not routes:
raise CatalogError(f"{name}.routes must be non-empty")
if len(routes) > 255:
raise CatalogError(f"{name}.routes uses reserved wire id 255")
tokens: set[str] = set()
cpp_ids: set[str] = set()
for index, route in enumerate(routes):
route = _exact(route, {
"token", "wire_id", "cpp_id", "native_entry", "requirements",
"limitations", "aliases", "metadata",
}, f"{name}.routes[{index}]")
token = route["token"]
if not isinstance(token, str) or re.fullmatch(r"[a-z][a-z0-9_]*", token) is None:
raise CatalogError(f"{name}.routes[{index}].token is not canonical")
if token in tokens:
raise CatalogError(f"duplicate route token {name}.{token}")
tokens.add(token)
if isinstance(route["wire_id"], bool) or not isinstance(route["wire_id"], int) \
or route["wire_id"] != index:
raise CatalogError(f"{name}.{token} wire_id must equal its stable position {index}")
cpp_id = _identifier(route["cpp_id"], f"{name}.{token}.cpp_id")
if cpp_id in cpp_ids:
raise CatalogError(f"duplicate C++ route id {family['cpp_enum']}::{cpp_id}")
cpp_ids.add(cpp_id)
if not isinstance(route["native_entry"], str) or not route["native_entry"] \
or route["native_entry"] != route["native_entry"].strip():
raise CatalogError(f"{name}.{token}.native_entry must be canonical and non-empty")
_strings(route["requirements"], f"{name}.{token}.requirements")
_strings(route["limitations"], f"{name}.{token}.limitations")
if _strings(route["aliases"], f"{name}.{token}.aliases"):
raise CatalogError(
f"{name}.{token}.aliases must be empty; final route IDs have one spelling")
if not isinstance(route["metadata"], dict):
raise CatalogError(f"{name}.{token}.metadata must be an object")
metadata_fields = {
"riemann": {"needs_wave_speeds", "needs_hllc_struct", "needs_roe_diss", "polar_ok"},
"limiter": {"n_ghost", "formal_order", "muscl_compatible"},
"transport": {"n_vars_by_dimension", "polar_ok", "parameters", "summary"},
"source": {"min_vars", "parameters", "summary"},
"elliptic": {"parameters", "summary"},
}.get(name, set())
_exact(route["metadata"], metadata_fields, f"{name}.{token}.metadata")
if "parameters" in route["metadata"]:
_strings(route["metadata"]["parameters"], f"{name}.{token}.metadata.parameters")
for key in ("n_ghost", "formal_order", "n_vars", "min_vars"):
if key in route["metadata"] and (
isinstance(route["metadata"][key], bool)
or not isinstance(route["metadata"][key], int)
or route["metadata"][key] < 1
):
raise CatalogError(f"{name}.{token}.metadata.{key} must be an integer >= 1")
if "n_vars_by_dimension" in route["metadata"]:
counts = route["metadata"]["n_vars_by_dimension"]
if (
not isinstance(counts, list)
or len(counts) != 3
or any(
isinstance(count, bool) or not isinstance(count, int) or count < 1
for count in counts
)
):
raise CatalogError(
f"{name}.{token}.metadata.n_vars_by_dimension must contain "
"three positive integer counts for dimensions 1, 2, and 3"
)
for key in (
"polar_ok", "needs_wave_speeds", "needs_hllc_struct", "needs_roe_diss",
"muscl_compatible",
):
if key in route["metadata"] and not isinstance(route["metadata"][key], bool):
raise CatalogError(f"{name}.{token}.metadata.{key} must be boolean")
if "summary" in route["metadata"] and (
not isinstance(route["metadata"]["summary"], str)
or not route["metadata"]["summary"]
):
raise CatalogError(f"{name}.{token}.metadata.summary must be non-empty")
required_specializations = {"riemann", "limiter", "transport", "source", "elliptic"}
missing_specializations = sorted(required_specializations - seen_families)
if missing_specializations:
raise CatalogError(f"component catalog misses generated typed views {missing_specializations}")
if set(family_interfaces) != seen_families:
raise CatalogError(
"route_family_interfaces must cover every route family exactly: missing=%s, unknown=%s"
% (sorted(seen_families - set(family_interfaces)),
sorted(set(family_interfaces) - seen_families)))
if set(family_native_interfaces) != seen_families:
raise CatalogError(
"route_family_native_interfaces must cover every route family exactly: "
"missing=%s, unknown=%s"
% (sorted(seen_families - set(family_native_interfaces)),
sorted(set(family_native_interfaces) - seen_families)))
full_digest, semantic_digest = _catalog_digests(data)
return data, full_digest, semantic_digest
def _py_literal(value: Any) -> str:
return pprint.pformat(value, width=100, sort_dicts=False)
def _render_schema(catalog: dict[str, Any], digest: str, semantic_digest: str | None = None) -> str:
semantic_digest = semantic_digest or digest
schema = catalog["manifest_schema"]
lines = [
'"""Generated by scripts/generate_component_catalog.py; DO NOT EDIT."""',
"from __future__ import annotations",
"",
f"COMPONENT_CATALOG_SCHEMA_VERSION = {catalog['catalog_schema_version']}",
f"COMPONENT_MANIFEST_SCHEMA_VERSION = {catalog['component_manifest_schema_version']}",
f"COMPONENT_CATALOG_SHA256 = {digest!r}",
f"COMPONENT_CATALOG_SEMANTIC_SHA256 = {semantic_digest!r}",
f"COMPONENT_INTERFACE_SPECS = {_py_literal(tuple(catalog['interface_vocabulary']))}",
]
for name, source_name in (
("COMPONENT_MANIFEST_SEMANTIC_FIELDS", "semantic_fields"),
("COMPONENT_MANIFEST_TOP_LEVEL_FIELDS", "top_level_fields"),
("COMPONENT_TARGET_FIELDS", "target_fields"),
("COMPONENT_DIGEST_FIELDS", "digest_fields"),
("COMPONENT_EXTENSION_KINDS", "extension_kinds"),
):
lines.append(f"{name} = {tuple(schema[source_name])!r}")
lines.extend(("", "__all__ = [name for name in globals() if name.startswith('COMPONENT_')]", ""))
return "\n".join(lines)
def _render_routes(catalog: dict[str, Any], digest: str,
semantic_digest: str | None = None) -> str:
semantic_digest = semantic_digest or digest
tables: dict[str, tuple[Any, ...]] = {}
metadata: dict[str, dict[str, dict[str, Any]]] = {}
cpp: dict[str, dict[str, Any]] = {}
brick_rows: list[dict[str, Any]] = []
for family in catalog["route_families"]:
name = family["name"]
tables[name] = tuple((
row["token"], row["native_entry"], tuple(row["requirements"]),
tuple(row["limitations"]),
) for row in family["routes"])
metadata[name] = {row["token"]: row["metadata"] for row in family["routes"]}
cpp[name] = {
"enum": family["cpp_enum"], "table": family["cpp_table"],
"ids": tuple(row["cpp_id"] for row in family["routes"]),
}
if name in {"transport", "source", "elliptic"}:
for row in family["routes"]:
meta = row["metadata"]
brick_rows.append({
"category": name,
"id": row["token"],
"route_index": row["wire_id"],
"native_entry": row["native_entry"],
"parameters": tuple(meta["parameters"]),
"n_vars_by_dimension": tuple(meta["n_vars_by_dimension"])
if "n_vars_by_dimension" in meta else (),
"min_vars": meta.get("min_vars", -1),
"polar_ok": bool(meta.get("polar_ok", False)),
"requirements": tuple(row["requirements"]),
"limitations": tuple(row["limitations"]),
"summary": meta["summary"],
})
signature = f"v{catalog['route_registry_version']}:{semantic_digest}"
values = {
"COMPONENT_CATALOG_SCHEMA_VERSION": catalog["catalog_schema_version"],
"COMPONENT_MANIFEST_SCHEMA_VERSION": catalog["component_manifest_schema_version"],
"ROUTE_REGISTRY_VERSION": catalog["route_registry_version"],
"CAPABILITY_VOCAB_VERSION": catalog["capability_vocabulary_version"],
"COMPONENT_CATALOG_SHA256": digest,
"COMPONENT_CATALOG_SEMANTIC_SHA256": semantic_digest,
"ROUTE_REGISTRY_SIGNATURE": signature,
"ROUTE_TABLES": tables,
"ROUTE_METADATA": metadata,
"ROUTE_CPP_BINDINGS": cpp,
"ROUTE_COMPONENT_DEFAULTS": catalog["route_component_defaults"],
"ROUTE_FAMILY_INTERFACES": catalog["route_family_interfaces"],
"COMPONENT_INTERFACE_SPECS": tuple(catalog["interface_vocabulary"]),
"ROUTE_FAMILY_NATIVE_INTERFACES": catalog["route_family_native_interfaces"],
"BRICK_CATALOG_ROWS": tuple(brick_rows),
}
lines = [
'"""Generated by scripts/generate_component_catalog.py; DO NOT EDIT."""',
"from __future__ import annotations",
"",
]
for name, value in values.items():
lines.append(f"{name} = {_py_literal(value)}")
lines.append("")
lines.append("__all__ = [name for name in globals() if name.startswith(('ROUTE_', 'COMPONENT_', 'CAPABILITY_', 'BRICK_'))]")
lines.append("")
return "\n".join(lines)
def _render_native_interfaces(catalog: dict[str, Any], digest: str,
semantic_digest: str) -> str:
rows = tuple({
"id": row["id"],
"name": row["name"],
"uri": row["uri"],
"version": row["version"],
"cpp_table": row["cpp_table"],
"hot_path": row["hot_path"],
"facets": tuple(row["facets"]),
"operations": tuple(row["operations"]),
} for row in catalog["native_interface_abis"])
boundary_routes = {
kind: (row["interface"], row["operation"])
for kind, row in catalog["boundary_handle_native_routes"].items()
}
return "\n".join((
'\"\"\"Generated by scripts/generate_component_catalog.py; DO NOT EDIT.\"\"\"',
"from __future__ import annotations",
"",
f"NATIVE_COMPONENT_ABI_VERSION = {catalog['native_interface_abi_version']}",
f"NATIVE_COMPONENT_COMMON_ABI_VERSION = {catalog['native_common_abi_version']}",
f"NATIVE_COMPONENT_CATALOG_SHA256 = {digest!r}",
f"NATIVE_COMPONENT_CATALOG_SEMANTIC_SHA256 = {semantic_digest!r}",
f"NATIVE_TAGGING_PROGRAM_ABI = {_py_literal(catalog['tagging_program_abi'])}",
f"NATIVE_COMPONENT_INTERFACES = {_py_literal(rows)}",
"NATIVE_COMPONENT_INTERFACE_BY_NAME = {row['name']: row for row in NATIVE_COMPONENT_INTERFACES}",
"NATIVE_COMPONENT_INTERFACE_BY_URI = {row['uri']: row for row in NATIVE_COMPONENT_INTERFACES}",
f"NATIVE_COMPONENT_BOUNDARY_HANDLE_ROUTES = {_py_literal(boundary_routes)}",
"",
"__all__ = [name for name in globals() if name.startswith('NATIVE_COMPONENT_')]",
"",
))
def _render_component_abi(catalog: dict[str, Any], digest: str) -> str:
"""Render the closed C/POD execution ABI shared by builtin and package conformers."""
enum_rows = "\n".join(
" POPS_NATIVE_INTERFACE_%s_V%d = %d," % (
row["name"].upper(), row["version"], row["id"])
for row in catalog["native_interface_abis"]
)
tagging = catalog["tagging_program_abi"]
tagging_opcode_rows = "\n".join(
" POPS_TAGGING_%s_V1 = %d," % (name.upper(), opcode)
for family in ("leaf_opcodes", "logical_opcodes")
for name, opcode in tagging[family].items()
)
tagging_leaf_cases = " ".join(
"case POPS_TAGGING_%s_V1:" % name.upper()
for name in tagging["leaf_opcodes"]
)
tagging_logical_cases = " ".join(
"case POPS_TAGGING_%s_V1:" % name.upper()
for name in tagging["logical_opcodes"]
)
tagging_execution_mode_rows = "\n".join(
" POPS_TAGGER_EXECUTION_%s_V2 = %d," % (name.upper(), value)
for name, value in tagging["execution_modes"].items()
).rstrip(",")
tagging_collective_scope_rows = "\n".join(
" POPS_TAGGER_COLLECTIVE_%s_V2 = %d," % (name.upper(), value)
for name, value in tagging["collective_scopes"].items()
).rstrip(",")
tagging_stencil_route_rows = "\n".join(
'#define POPS_TAGGING_STENCIL_ROUTE_%s "%s"'
% (route.upper(), route)
for route in tagging["indicator_stencil_routes"]
)
table_size_rows = "\n".join(
" case POPS_NATIVE_INTERFACE_%s_V%d: return sizeof(%s);"
% (row["name"].upper(), row["version"], row["cpp_table"])
for row in catalog["native_interface_abis"]
)
table_name_rows = "\n".join(
" case POPS_NATIVE_INTERFACE_%s_V%d: return \"%s\";"
% (row["name"].upper(), row["version"], row["cpp_table"])
for row in catalog["native_interface_abis"]
)
table_complete_rows = "\n".join(
""" case POPS_NATIVE_INTERFACE_%s_V%d: {
if (table_size < sizeof(%s)) return false;
const auto* api = static_cast<const %s*>(table);
return %s;
}"""
% (
row["name"].upper(),
row["version"],
row["cpp_table"],
row["cpp_table"],
" && ".join("api->%s != nullptr" % operation
for operation in row["operations"]),
)
for row in catalog["native_interface_abis"]
)
return f'''#pragma once
// Generated by scripts/generate_component_catalog.py; DO NOT EDIT.
// clang-format off
// The ABI crosses no C++ standard-library or backend-owned type. Hot interfaces are batch calls;
// discovery and symbol resolution happen once during installation, never inside a scientific loop.
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
#include <pops/runtime/dynamic/abi_key.hpp>
extern "C" {{
#endif
#define POPS_COMPONENT_API_SYMBOL_V1 "pops_component_interface_v1"
#define POPS_COMPONENT_CATALOG_SHA256_V1 "{digest}"
#define POPS_COMPONENT_PROTOCOL_ABI_V1 {catalog['native_interface_abi_version']}u
#define POPS_COMPONENT_COMMON_ABI_V1 {catalog['native_common_abi_version']}u
typedef enum PopsNativeInterfaceIdV1 {{
{enum_rows}
}} PopsNativeInterfaceIdV1;
typedef enum PopsTaggingOpcodeV1 {{
{tagging_opcode_rows}
}} PopsTaggingOpcodeV1;
#define POPS_TAGGING_MAXIMUM_INSTRUCTION_COUNT_V1 {tagging['maximum_instruction_count']}u
#define POPS_TAGGING_MAXIMUM_STENCIL_TERMS_V1 {tagging['maximum_stencil_terms']}u
#define POPS_TAGGING_NO_STENCIL_V1 ((size_t)-1)
#define POPS_TAGGING_NON_FINITE_REJECT_V1 1
{tagging_stencil_route_rows}
static inline int pops_tagging_opcode_is_leaf_v1(int32_t opcode) {{
switch (opcode) {{ {tagging_leaf_cases} return 1; default: return 0; }}
}}
static inline int pops_tagging_opcode_is_logical_v1(int32_t opcode) {{
switch (opcode) {{ {tagging_logical_cases} return 1; default: return 0; }}
}}
typedef enum PopsComponentActionV1 {{
POPS_COMPONENT_CONTINUE_V1 = 0,
POPS_COMPONENT_RETRY_STEP_V1 = 1,
POPS_COMPONENT_REJECT_STEP_V1 = 2,
POPS_COMPONENT_ABORT_RUN_V1 = 3
}} PopsComponentActionV1;
typedef struct PopsComponentStatusV1 {{
uint32_t struct_size;
int32_t code;
// Component-owned output: validate the fixed-width wire value before treating it as an action.
int32_t action;
const char* reason;
}} PopsComponentStatusV1;
typedef enum PopsMemorySpaceV1 {{
POPS_MEMORY_SPACE_HOST_V1 = 1,
POPS_MEMORY_SPACE_DEVICE_V1 = 2,
POPS_MEMORY_SPACE_MANAGED_V1 = 3
}} PopsMemorySpaceV1;
typedef enum PopsScalarTypeV1 {{
POPS_SCALAR_FLOAT32_V1 = 1,
POPS_SCALAR_FLOAT64_V1 = 2
}} PopsScalarTypeV1;
typedef enum PopsFieldCenteringV1 {{
POPS_FIELD_CENTERING_CELL_V1 = 1,
POPS_FIELD_CENTERING_FACE_V1 = 2,
POPS_FIELD_CENTERING_NODE_V1 = 3,
POPS_FIELD_CENTERING_EDGE_V1 = 4
}} PopsFieldCenteringV1;
typedef enum PopsFieldOwnershipV1 {{
POPS_FIELD_OWNERSHIP_RUNTIME_BORROWED_V1 = 1,
POPS_FIELD_OWNERSHIP_COMPONENT_BORROWED_V1 = 2,
POPS_FIELD_OWNERSHIP_COMPONENT_OWNED_V1 = 3
}} PopsFieldOwnershipV1;
typedef struct PopsConstFieldViewV1 {{
uint32_t struct_size;
const void* data;
int32_t dimension;
size_t extents[3];
ptrdiff_t axis_strides[3];
size_t component_count;
ptrdiff_t component_stride;
PopsFieldCenteringV1 centering;
uint32_t centering_axes;
size_t ghost_lower[3];
size_t ghost_upper[3];
PopsScalarTypeV1 scalar_type;
PopsMemorySpaceV1 memory_space;
const char* layout_identity;
const char* patch_identity;
PopsFieldOwnershipV1 ownership;
}} PopsConstFieldViewV1;
typedef struct PopsFieldViewV1 {{
uint32_t struct_size;
void* data;
int32_t dimension;
size_t extents[3];
ptrdiff_t axis_strides[3];
size_t component_count;
ptrdiff_t component_stride;
PopsFieldCenteringV1 centering;
uint32_t centering_axes;
size_t ghost_lower[3];
size_t ghost_upper[3];
PopsScalarTypeV1 scalar_type;
PopsMemorySpaceV1 memory_space;
const char* layout_identity;
const char* patch_identity;
PopsFieldOwnershipV1 ownership;
}} PopsFieldViewV1;
typedef struct PopsConstByteViewV1 {{
uint32_t struct_size;
const uint8_t* data;
size_t size;
}} PopsConstByteViewV1;
typedef struct PopsByteViewV1 {{
uint32_t struct_size;
uint8_t* data;
size_t size;
}} PopsByteViewV1;
typedef struct PopsInt32ViewV1 {{
uint32_t struct_size;
int32_t* data;
size_t size;
}} PopsInt32ViewV1;
typedef struct PopsConstInt32ViewV1 {{
uint32_t struct_size;
const int32_t* data;
size_t size;
}} PopsConstInt32ViewV1;
typedef struct PopsLogicalTimeV1 {{
uint32_t struct_size;
const char* clock_identity;
int64_t tick;
int32_t level;
int32_t substep;
int32_t stage;
int64_t fraction_numerator;
int64_t fraction_denominator;
double dt;
double physical_time;
}} PopsLogicalTimeV1;
typedef enum PopsPrecisionV1 {{
POPS_PRECISION_FLOAT16_V1 = 1,
POPS_PRECISION_BFLOAT16_V1 = 2,
POPS_PRECISION_FLOAT32_V1 = 3,
POPS_PRECISION_FLOAT64_V1 = 4
}} PopsPrecisionV1;
#define POPS_EXECUTION_NONCOLLECTIVE_IDENTITY_V1 "pops::execution::noncollective"
typedef struct PopsExecutionContextV1 {{
uint32_t struct_size;
uint32_t context_version;
const char* execution_identity;
PopsMemorySpaceV1 memory_space;
const char* backend_identity;
const char* device_identity;
PopsScalarTypeV1 scalar_type;
PopsPrecisionV1 storage_precision;
PopsPrecisionV1 compute_precision;
PopsPrecisionV1 accumulation_precision;
PopsPrecisionV1 reduction_precision;
uint64_t stream_handle;
const char* stream_identity;
int64_t communicator_f_handle;
int64_t communicator_datatype_f_handle;
const char* communicator_identity;
const char* communicator_datatype_identity;
}} PopsExecutionContextV1;
typedef struct PopsComponentPrepareRequestV1 {{
uint32_t struct_size;
const char* parameters_json;
const char* target_json;
PopsExecutionContextV1 execution;
}} PopsComponentPrepareRequestV1;
typedef int32_t (*PopsComponentPrepareFnV1)(
const PopsComponentPrepareRequestV1*, void**, PopsComponentStatusV1*);
typedef void (*PopsComponentDestroyFnV1)(void*);
typedef struct PopsComponentTableHeaderV1 {{
uint32_t struct_size;
uint32_t abi_version;
PopsNativeInterfaceIdV1 interface_id;
uint32_t interface_version;
PopsComponentPrepareFnV1 prepare;
PopsComponentDestroyFnV1 destroy;
}} PopsComponentTableHeaderV1;
typedef struct PopsNumericalFluxRequestV1 {{
uint32_t struct_size;
PopsConstFieldViewV1 left;
PopsConstFieldViewV1 right;
PopsConstFieldViewV1 normals;
const double* face_measures;
PopsLogicalTimeV1 logical_time;
PopsExecutionContextV1 execution;
}} PopsNumericalFluxRequestV1;
typedef struct PopsNumericalFluxResultV1 {{
uint32_t struct_size;
PopsFieldViewV1 normal_flux;
double* stability_bounds;
PopsComponentActionV1* actions;
PopsComponentStatusV1 status;
}} PopsNumericalFluxResultV1;
typedef int32_t (*PopsEvaluateFacesFnV1)(
void*, const PopsNumericalFluxRequestV1*, PopsNumericalFluxResultV1*);
typedef struct PopsNumericalFluxApiV1 {{
PopsComponentTableHeaderV1 header;
PopsEvaluateFacesFnV1 evaluate_faces;
}} PopsNumericalFluxApiV1;
typedef enum PopsBoundaryRegionKindV1 {{
POPS_BOUNDARY_FACE_V1 = 1,
POPS_BOUNDARY_EDGE_V1 = 2,
POPS_BOUNDARY_CORNER_V1 = 3
}} PopsBoundaryRegionKindV1;
typedef struct PopsBoundaryRegionV1 {{
uint32_t struct_size;
PopsBoundaryRegionKindV1 kind;
int32_t dimension;
int32_t codimension;
size_t axis_count;
const int32_t* axes;
const int32_t* sides;
const char* region_identity;
}} PopsBoundaryRegionV1;
typedef struct PopsQualifiedConstFieldV1 {{
uint32_t struct_size;
uint32_t present;
const char* qualified_id;
PopsConstFieldViewV1 values;
}} PopsQualifiedConstFieldV1;
typedef struct PopsQualifiedFieldV1 {{
uint32_t struct_size;
const char* qualified_id;
PopsFieldViewV1 values;
}} PopsQualifiedFieldV1;
typedef struct PopsQualifiedScalarV1 {{
uint32_t struct_size;
const char* qualified_id;
double value;
}} PopsQualifiedScalarV1;
typedef struct PopsGhostBoundaryRequestV1 {{
uint32_t struct_size;
const char* producer_identity;
const char* state_identity;
const char* ghost_identity;
PopsConstFieldViewV1 interior;
PopsFieldViewV1 ghosts;
PopsConstFieldViewV1 coordinates;
PopsBoundaryRegionV1 region;
size_t dependency_count;
const PopsQualifiedConstFieldV1* dependencies;
size_t parameter_count;
const PopsQualifiedScalarV1* parameters;
PopsLogicalTimeV1 logical_time;
PopsExecutionContextV1 execution;
}} PopsGhostBoundaryRequestV1;
typedef int32_t (*PopsApplyRegionBatchFnV1)(
void*, const PopsGhostBoundaryRequestV1*, PopsComponentStatusV1*);
typedef struct PopsGhostBoundaryApiV1 {{
PopsComponentTableHeaderV1 header;
PopsApplyRegionBatchFnV1 apply_region_batch;
}} PopsGhostBoundaryApiV1;
typedef struct PopsBoundaryFluxRequestV1 {{
uint32_t struct_size;
const char* provider_identity;
const char* state_identity;
PopsConstFieldViewV1 base_outward_normal_flux;
PopsConstFieldViewV1 coordinates;
PopsConstFieldViewV1 outward_normals;
const double* face_measures;
PopsBoundaryRegionV1 region;
size_t dependency_count;
const PopsQualifiedConstFieldV1* dependencies;
size_t parameter_count;
const PopsQualifiedScalarV1* parameters;
PopsLogicalTimeV1 logical_time;
PopsExecutionContextV1 execution;
}} PopsBoundaryFluxRequestV1;
typedef struct PopsBoundaryFluxResultV1 {{
uint32_t struct_size;
PopsFieldViewV1 outward_normal_flux;
PopsComponentActionV1* actions;
PopsComponentStatusV1 status;
}} PopsBoundaryFluxResultV1;
typedef int32_t (*PopsTransformBoundaryFacesFnV1)(
void*, const PopsBoundaryFluxRequestV1*, PopsBoundaryFluxResultV1*);
typedef struct PopsBoundaryFluxApiV1 {{
PopsComponentTableHeaderV1 header;
PopsTransformBoundaryFacesFnV1 transform_faces;
}} PopsBoundaryFluxApiV1;
typedef struct PopsFieldBoundaryRequestV1 {{
uint32_t struct_size;
const char* closure_identity;
PopsBoundaryRegionV1 region;
PopsConstFieldViewV1 coordinates;
size_t state_count;
const PopsQualifiedConstFieldV1* states;
size_t direction_count;
const PopsQualifiedConstFieldV1* directions;
size_t field_count;
const PopsQualifiedConstFieldV1* fields;
size_t parameter_count;