pgc-compiler 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- compiler/VERSION +1 -0
- compiler/__init__.py +1 -0
- compiler/atoms/__init__.py +54 -0
- compiler/atoms/error_codes.py +160 -0
- compiler/atoms/errors.py +125 -0
- compiler/atoms/fqdn.py +204 -0
- compiler/atoms/invariants.py +106 -0
- compiler/atoms/phase.py +99 -0
- compiler/atoms/pipeline.py +51 -0
- compiler/atoms/snapshot_gate.py +51 -0
- compiler/atoms/sorting.py +125 -0
- compiler/cli.py +637 -0
- compiler/diagnostics/__init__.py +6 -0
- compiler/diagnostics/determination.py +148 -0
- compiler/diagnostics/machine_block_health.py +199 -0
- compiler/governance/__init__.py +6 -0
- compiler/governance_engine/__init__.py +0 -0
- compiler/governance_engine/artifact_kinds.py +221 -0
- compiler/governance_engine/assertions/__init__.py +0 -0
- compiler/governance_engine/assertions/handlers/__init__.py +200 -0
- compiler/governance_engine/assertions/handlers/assert_ac_declaration_well_formed_v0.py +70 -0
- compiler/governance_engine/assertions/handlers/assert_actor_authority_separation_v0.py +17 -0
- compiler/governance_engine/assertions/handlers/assert_artifact_content_hash_declared_v0.py +60 -0
- compiler/governance_engine/assertions/handlers/assert_assert_not_runtime_referenced_v0.py +49 -0
- compiler/governance_engine/assertions/handlers/assert_assert_parity_v0.py +169 -0
- compiler/governance_engine/assertions/handlers/assert_atom_output_purity_v0.py +186 -0
- compiler/governance_engine/assertions/handlers/assert_authority_constituted_v0.py +56 -0
- compiler/governance_engine/assertions/handlers/assert_authority_required_for_execution_v0.py +16 -0
- compiler/governance_engine/assertions/handlers/assert_authority_state_well_formed_v0.py +17 -0
- compiler/governance_engine/assertions/handlers/assert_binding_integrity_v0.py +64 -0
- compiler/governance_engine/assertions/handlers/assert_binding_surface_closed_v0.py +92 -0
- compiler/governance_engine/assertions/handlers/assert_cc_capability_binding_valid_v0.py +85 -0
- compiler/governance_engine/assertions/handlers/assert_cc_inputs_satisfied_v0.py +89 -0
- compiler/governance_engine/assertions/handlers/assert_cc_no_implicit_chaining_v0.py +89 -0
- compiler/governance_engine/assertions/handlers/assert_cc_no_missing_dependencies_v0.py +89 -0
- compiler/governance_engine/assertions/handlers/assert_cc_no_unused_outputs_v0.py +81 -0
- compiler/governance_engine/assertions/handlers/assert_cc_storage_op_conformance_v0.py +74 -0
- compiler/governance_engine/assertions/handlers/assert_compiler_governance_declared_v0.py +65 -0
- compiler/governance_engine/assertions/handlers/assert_compiler_no_execution_v0.py +86 -0
- compiler/governance_engine/assertions/handlers/assert_concern_not_authority_v0.py +51 -0
- compiler/governance_engine/assertions/handlers/assert_conformance_assertion_mode_valid_v0.py +35 -0
- compiler/governance_engine/assertions/handlers/assert_cryptographic_trust_declared_v0.py +51 -0
- compiler/governance_engine/assertions/handlers/assert_cs_isolated_execution_v0.py +35 -0
- compiler/governance_engine/assertions/handlers/assert_cs_surface_closed_v0.py +241 -0
- compiler/governance_engine/assertions/handlers/assert_cs_traceable_v0.py +35 -0
- compiler/governance_engine/assertions/handlers/assert_ct_output_contract_match_v0.py +167 -0
- compiler/governance_engine/assertions/handlers/assert_ct_surface_closed_v0.py +173 -0
- compiler/governance_engine/assertions/handlers/assert_ct_surface_derived_closed_v0.py +108 -0
- compiler/governance_engine/assertions/handlers/assert_ct_test_data_outcome_declared_v0.py +112 -0
- compiler/governance_engine/assertions/handlers/assert_ev_append_only_v0.py +70 -0
- compiler/governance_engine/assertions/handlers/assert_ev_schema_required_v0.py +59 -0
- compiler/governance_engine/assertions/handlers/assert_execution_placement_declared_v0.py +51 -0
- compiler/governance_engine/assertions/handlers/assert_execution_scheduling_declared_v0.py +51 -0
- compiler/governance_engine/assertions/handlers/assert_fqdn_namespace_authorized_v0.py +38 -0
- compiler/governance_engine/assertions/handlers/assert_fqdn_only_references_v0.py +89 -0
- compiler/governance_engine/assertions/handlers/assert_governance_declaration_resolves_v0.py +126 -0
- compiler/governance_engine/assertions/handlers/assert_handler_registry_closed_v0.py +75 -0
- compiler/governance_engine/assertions/handlers/assert_identity_authority_separation_v0.py +19 -0
- compiler/governance_engine/assertions/handlers/assert_identity_fqdn_consistency.py +75 -0
- compiler/governance_engine/assertions/handlers/assert_implementation_admissible_v0.py +66 -0
- compiler/governance_engine/assertions/handlers/assert_in_no_execution_logic_v0.py +82 -0
- compiler/governance_engine/assertions/handlers/assert_in_schema_required_v0.py +74 -0
- compiler/governance_engine/assertions/handlers/assert_in_workflow_binding_v0.py +101 -0
- compiler/governance_engine/assertions/handlers/assert_inspection_capability_read_only_v0.py +114 -0
- compiler/governance_engine/assertions/handlers/assert_no_ambient_authority_v0.py +17 -0
- compiler/governance_engine/assertions/handlers/assert_no_runtime_authorization_v0.py +18 -0
- compiler/governance_engine/assertions/handlers/assert_no_runtime_topology_synthesis_v0.py +18 -0
- compiler/governance_engine/assertions/handlers/assert_no_smart_execution_v0.py +102 -0
- compiler/governance_engine/assertions/handlers/assert_no_undeclared_behavior_surface_v0.py +52 -0
- compiler/governance_engine/assertions/handlers/assert_no_workflow_authorization_logic_v0.py +18 -0
- compiler/governance_engine/assertions/handlers/assert_protocol_surface_closed_v0.py +119 -0
- compiler/governance_engine/assertions/handlers/assert_rb_binding_policy_conformance_v0.py +124 -0
- compiler/governance_engine/assertions/handlers/assert_rb_cs_only_v0.py +68 -0
- compiler/governance_engine/assertions/handlers/assert_rb_no_logic_v0.py +81 -0
- compiler/governance_engine/assertions/handlers/assert_rb_parameters_declared_v0.py +117 -0
- compiler/governance_engine/assertions/handlers/assert_rb_storage_subdomain_owned_v0.py +118 -0
- compiler/governance_engine/assertions/handlers/assert_runtime_invariant_wired_v0.py +163 -0
- compiler/governance_engine/assertions/handlers/assert_schema_conformance_v0.py +64 -0
- compiler/governance_engine/assertions/handlers/assert_schema_description_well_formed_v0.py +97 -0
- compiler/governance_engine/assertions/handlers/assert_security_domain_declared_v0.py +51 -0
- compiler/governance_engine/assertions/handlers/assert_structure_paths_well_formed_v0.py +118 -0
- compiler/governance_engine/assertions/handlers/assert_superseded_not_referenced_v0.py +134 -0
- compiler/governance_engine/assertions/handlers/assert_test_data_match_ct_output_v0.py +134 -0
- compiler/governance_engine/assertions/handlers/assert_topology_acyclic_v0.py +53 -0
- compiler/governance_engine/assertions/handlers/assert_topology_authority_orthogonal_v0.py +110 -0
- compiler/governance_engine/assertions/handlers/assert_topology_capability_reference_unique_v0.py +63 -0
- compiler/governance_engine/assertions/handlers/assert_topology_contract_closed_v0.py +113 -0
- compiler/governance_engine/assertions/handlers/assert_topology_immutable_after_compilation_v0.py +17 -0
- compiler/governance_engine/assertions/handlers/assert_topology_input_reference_declared_v0.py +112 -0
- compiler/governance_engine/assertions/handlers/assert_topology_routing_complete_v0.py +82 -0
- compiler/governance_engine/assertions/handlers/assert_topology_step_declared_v0.py +77 -0
- compiler/governance_engine/assertions/handlers/assert_topology_step_id_unique_v0.py +60 -0
- compiler/governance_engine/assertions/handlers/assert_topology_surface_canonical_v0.py +180 -0
- compiler/governance_engine/assertions/handlers/assert_topology_transport_orthogonal_v0.py +113 -0
- compiler/governance_engine/assertions/handlers/assert_trace_authority_binding_required_v0.py +18 -0
- compiler/governance_engine/assertions/handlers/assert_transport_canonical_normalization_v0.py +83 -0
- compiler/governance_engine/assertions/handlers/assert_transport_no_dynamic_routing_v0.py +93 -0
- compiler/governance_engine/assertions/handlers/assert_transport_no_workflow_semantics_v0.py +106 -0
- compiler/governance_engine/assertions/handlers/assert_transport_operation_identity_independence_v0.py +56 -0
- compiler/governance_engine/assertions/handlers/assert_transport_response_projection_external_v0.py +38 -0
- compiler/governance_engine/assertions/handlers/assert_transport_result_class_protocol_independence_v0.py +48 -0
- compiler/governance_engine/assertions/handlers/assert_transport_target_exists_v0.py +132 -0
- compiler/governance_engine/assertions/handlers/assert_unique_artifact_id_v0.py +58 -0
- compiler/governance_engine/assertions/handlers/assert_vocabulary_symbols_well_formed_v0.py +163 -0
- compiler/governance_engine/assertions/handlers/assert_wf_announcement_distinct_v0.py +85 -0
- compiler/governance_engine/assertions/handlers/assert_wf_cc_only_nodes_v0.py +60 -0
- compiler/governance_engine/assertions/handlers/assert_wf_entry_intent_v0.py +68 -0
- compiler/governance_engine/assertions/handlers/assert_wf_execution_path_valid_v0.py +89 -0
- compiler/governance_engine/assertions/handlers/assert_wf_node_key_binding_unique_v0.py +107 -0
- compiler/governance_engine/platform_root.py +102 -0
- compiler/governance_engine/structure/__init__.py +56 -0
- compiler/governance_engine/structure/discovery/__init__.py +28 -0
- compiler/governance_engine/structure/discovery/artifact_locator.py +210 -0
- compiler/governance_engine/structure/exceptions.py +113 -0
- compiler/governance_engine/structure/loading/__init__.py +88 -0
- compiler/governance_engine/structure/loading/fs_reader.py +225 -0
- compiler/governance_engine/structure/loading/markdown_parser.py +148 -0
- compiler/governance_engine/structure/loading/protocol_loader.py +587 -0
- compiler/governance_engine/structure/loading/test_case_provider.py +125 -0
- compiler/governance_engine/structure/loading/trace_reader.py +98 -0
- compiler/governance_engine/structure/loading/vocabulary_loader.py +174 -0
- compiler/governance_engine/structure/loading/yaml_parser.py +209 -0
- compiler/governance_engine/structure/resolution/__init__.py +22 -0
- compiler/governance_engine/structure/resolution/domain_resolver.py +124 -0
- compiler/governance_engine/structure/resolution/layer_resolver.py +572 -0
- compiler/governance_engine/structure/resolution/path_registry.py +1054 -0
- compiler/graph/__init__.py +38 -0
- compiler/graph/addressing.py +153 -0
- compiler/graph/edge.py +100 -0
- compiler/graph/evidence.py +637 -0
- compiler/graph/graph.py +269 -0
- compiler/graph/hashing.py +89 -0
- compiler/graph/node.py +134 -0
- compiler/graph/query.py +215 -0
- compiler/graph/state.py +237 -0
- compiler/graph/trace.py +97 -0
- compiler/graph/types.py +71 -0
- compiler/projections/__init__.py +207 -0
- compiler/projections/artifact_index.py +225 -0
- compiler/projections/canonical.py +173 -0
- compiler/projections/dispatch.py +532 -0
- compiler/projections/evidence.py +170 -0
- compiler/projections/handlers.py +224 -0
- compiler/projections/ipm.py +388 -0
- compiler/projections/reverse.py +165 -0
- compiler/projections/tokenized.py +135 -0
- compiler/projections/vocabulary.py +108 -0
- compiler/stages/__init__.py +28 -0
- compiler/stages/s1_extract.py +867 -0
- compiler/stages/s2_canonicalize.py +516 -0
- compiler/stages/s3_semantic_addressing.py +66 -0
- compiler/stages/s4_govern.py +754 -0
- compiler/stages/s5_construct.py +537 -0
- compiler/stages/s6_project.py +94 -0
- compiler/stages/s7_materialize.py +1170 -0
- compiler/stages/s8_verify.py +643 -0
- compiler/stages/s9_attest.py +184 -0
- compiler/structure_loader.py +132 -0
- compiler/visualization/__init__.py +12 -0
- compiler/visualization/consumers/__init__.py +28 -0
- compiler/visualization/consumers/evidence_projection.py +162 -0
- compiler/visualization/consumers/evidence_query.py +296 -0
- compiler/visualization/consumers/evidence_reader.py +127 -0
- compiler/visualization/views/__init__.py +70 -0
- compiler/visualization/views/_png_writer.py +45 -0
- compiler/visualization/views/artifact_lineage.py +180 -0
- compiler/visualization/views/family_view.py +164 -0
- compiler/visualization/views/materialization_view.py +150 -0
- compiler/visualization/views/structural_dag.py +158 -0
- compiler/visualization/wf_graph_generator.py +534 -0
- pgc_compiler-2.0.0.dist-info/METADATA +203 -0
- pgc_compiler-2.0.0.dist-info/RECORD +177 -0
- pgc_compiler-2.0.0.dist-info/WHEEL +5 -0
- pgc_compiler-2.0.0.dist-info/entry_points.txt +2 -0
- pgc_compiler-2.0.0.dist-info/licenses/LICENSE +67 -0
- pgc_compiler-2.0.0.dist-info/licenses/NOTICE +11 -0
- pgc_compiler-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ASSERT Handler Registry - Static, Explicit, Compile-Time Validated
|
|
3
|
+
|
|
4
|
+
ARCHITECTURAL INVARIANT:
|
|
5
|
+
- ALL handlers MUST be explicitly imported
|
|
6
|
+
- NO dynamic discovery via importlib
|
|
7
|
+
- NO runtime module resolution
|
|
8
|
+
- Handler existence validated at compile time
|
|
9
|
+
|
|
10
|
+
This registry is the single source of truth for ASSERT handler resolution.
|
|
11
|
+
Any handler not in this registry MUST cause compile failure.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
# Explicit static imports (no dynamic discovery)
|
|
15
|
+
from compiler.governance_engine.assertions.handlers.assert_assert_parity_v0 import execute as assert_assert_parity_v0
|
|
16
|
+
from compiler.governance_engine.assertions.handlers.assert_atom_output_purity_v0 import execute as assert_atom_output_purity_v0
|
|
17
|
+
from compiler.governance_engine.assertions.handlers.assert_cc_capability_binding_valid_v0 import execute as assert_cc_capability_binding_valid_v0
|
|
18
|
+
from compiler.governance_engine.assertions.handlers.assert_cc_inputs_satisfied_v0 import execute as assert_cc_inputs_satisfied_v0
|
|
19
|
+
from compiler.governance_engine.assertions.handlers.assert_cc_no_implicit_chaining_v0 import execute as assert_cc_no_implicit_chaining_v0
|
|
20
|
+
from compiler.governance_engine.assertions.handlers.assert_cc_no_missing_dependencies_v0 import execute as assert_cc_no_missing_dependencies_v0
|
|
21
|
+
from compiler.governance_engine.assertions.handlers.assert_cc_no_unused_outputs_v0 import execute as assert_cc_no_unused_outputs_v0
|
|
22
|
+
from compiler.governance_engine.assertions.handlers.assert_cs_surface_closed_v0 import execute as assert_cs_surface_closed_v0
|
|
23
|
+
from compiler.governance_engine.assertions.handlers.assert_ct_output_contract_match_v0 import execute as assert_ct_output_contract_match_v0
|
|
24
|
+
from compiler.governance_engine.assertions.handlers.assert_ct_surface_closed_v0 import execute as assert_ct_surface_closed_v0
|
|
25
|
+
from compiler.governance_engine.assertions.handlers.assert_ct_surface_derived_closed_v0 import execute as assert_ct_surface_derived_closed_v0
|
|
26
|
+
from compiler.governance_engine.assertions.handlers.assert_fqdn_only_references_v0 import execute as assert_fqdn_only_references_v0
|
|
27
|
+
from compiler.governance_engine.assertions.handlers.assert_fqdn_namespace_authorized_v0 import execute as assert_fqdn_namespace_authorized_v0
|
|
28
|
+
from compiler.governance_engine.assertions.handlers.assert_concern_not_authority_v0 import execute as assert_concern_not_authority_v0
|
|
29
|
+
from compiler.governance_engine.assertions.handlers.assert_authority_constituted_v0 import execute as assert_authority_constituted_v0
|
|
30
|
+
from compiler.governance_engine.assertions.handlers.assert_structure_paths_well_formed_v0 import execute as assert_structure_paths_well_formed_v0
|
|
31
|
+
from compiler.governance_engine.assertions.handlers.assert_schema_description_well_formed_v0 import execute as assert_schema_description_well_formed_v0
|
|
32
|
+
from compiler.governance_engine.assertions.handlers.assert_ac_declaration_well_formed_v0 import execute as assert_ac_declaration_well_formed_v0
|
|
33
|
+
from compiler.governance_engine.assertions.handlers.assert_vocabulary_symbols_well_formed_v0 import execute as assert_vocabulary_symbols_well_formed_v0
|
|
34
|
+
from compiler.governance_engine.assertions.handlers.assert_assert_not_runtime_referenced_v0 import execute as assert_assert_not_runtime_referenced_v0
|
|
35
|
+
from compiler.governance_engine.assertions.handlers.assert_governance_declaration_resolves_v0 import execute as assert_governance_declaration_resolves_v0
|
|
36
|
+
from compiler.governance_engine.assertions.handlers.assert_identity_fqdn_consistency import execute as assert_identity_fqdn_consistency
|
|
37
|
+
from compiler.governance_engine.assertions.handlers.assert_no_smart_execution_v0 import execute as assert_no_smart_execution_v0
|
|
38
|
+
from compiler.governance_engine.assertions.handlers.assert_no_undeclared_behavior_surface_v0 import execute as assert_no_undeclared_behavior_surface_v0
|
|
39
|
+
from compiler.governance_engine.assertions.handlers.assert_protocol_surface_closed_v0 import execute as assert_protocol_surface_closed_v0
|
|
40
|
+
from compiler.governance_engine.assertions.handlers.assert_test_data_match_ct_output_v0 import execute as assert_test_data_match_ct_output_v0
|
|
41
|
+
from compiler.governance_engine.assertions.handlers.assert_unique_artifact_id_v0 import execute as assert_unique_artifact_id_v0
|
|
42
|
+
from compiler.governance_engine.assertions.handlers.assert_wf_execution_path_valid_v0 import execute as assert_wf_execution_path_valid_v0
|
|
43
|
+
from compiler.governance_engine.assertions.handlers.assert_binding_surface_closed_v0 import execute as assert_binding_surface_closed_v0
|
|
44
|
+
from compiler.governance_engine.assertions.handlers.assert_wf_announcement_distinct_v0 import execute as assert_wf_announcement_distinct_v0
|
|
45
|
+
from compiler.governance_engine.assertions.handlers.assert_wf_cc_only_nodes_v0 import execute as assert_wf_cc_only_nodes_v0
|
|
46
|
+
from compiler.governance_engine.assertions.handlers.assert_wf_entry_intent_v0 import execute as assert_wf_entry_intent_v0
|
|
47
|
+
from compiler.governance_engine.assertions.handlers.assert_in_schema_required_v0 import execute as assert_in_schema_required_v0
|
|
48
|
+
from compiler.governance_engine.assertions.handlers.assert_in_workflow_binding_v0 import execute as assert_in_workflow_binding_v0
|
|
49
|
+
from compiler.governance_engine.assertions.handlers.assert_superseded_not_referenced_v0 import execute as assert_superseded_not_referenced_v0
|
|
50
|
+
from compiler.governance_engine.assertions.handlers.assert_rb_no_logic_v0 import execute as assert_rb_no_logic_v0
|
|
51
|
+
from compiler.governance_engine.assertions.handlers.assert_transport_target_exists_v0 import execute as assert_transport_target_exists_v0
|
|
52
|
+
from compiler.governance_engine.assertions.handlers.assert_transport_no_dynamic_routing_v0 import execute as assert_transport_no_dynamic_routing_v0
|
|
53
|
+
from compiler.governance_engine.assertions.handlers.assert_transport_no_workflow_semantics_v0 import execute as assert_transport_no_workflow_semantics_v0
|
|
54
|
+
from compiler.governance_engine.assertions.handlers.assert_transport_canonical_normalization_v0 import execute as assert_transport_canonical_normalization_v0
|
|
55
|
+
from compiler.governance_engine.assertions.handlers.assert_transport_operation_identity_independence_v0 import execute as assert_transport_operation_identity_independence_v0
|
|
56
|
+
from compiler.governance_engine.assertions.handlers.assert_transport_result_class_protocol_independence_v0 import execute as assert_transport_result_class_protocol_independence_v0
|
|
57
|
+
from compiler.governance_engine.assertions.handlers.assert_transport_response_projection_external_v0 import execute as assert_transport_response_projection_external_v0
|
|
58
|
+
from compiler.governance_engine.assertions.handlers.assert_conformance_assertion_mode_valid_v0 import execute as assert_conformance_assertion_mode_valid_v0
|
|
59
|
+
from compiler.governance_engine.assertions.handlers.assert_ev_schema_required_v0 import execute as assert_ev_schema_required_v0
|
|
60
|
+
from compiler.governance_engine.assertions.handlers.assert_ev_append_only_v0 import execute as assert_ev_append_only_v0
|
|
61
|
+
from compiler.governance_engine.assertions.handlers.assert_rb_cs_only_v0 import execute as assert_rb_cs_only_v0
|
|
62
|
+
from compiler.governance_engine.assertions.handlers.assert_rb_storage_subdomain_owned_v0 import execute as assert_rb_storage_subdomain_owned_v0
|
|
63
|
+
from compiler.governance_engine.assertions.handlers.assert_cs_traceable_v0 import execute as assert_cs_traceable_v0
|
|
64
|
+
from compiler.governance_engine.assertions.handlers.assert_cs_isolated_execution_v0 import execute as assert_cs_isolated_execution_v0
|
|
65
|
+
from compiler.governance_engine.assertions.handlers.assert_in_no_execution_logic_v0 import execute as assert_in_no_execution_logic_v0
|
|
66
|
+
from compiler.governance_engine.assertions.handlers.assert_authority_required_for_execution_v0 import execute as assert_authority_required_for_execution_v0
|
|
67
|
+
from compiler.governance_engine.assertions.handlers.assert_no_workflow_authorization_logic_v0 import execute as assert_no_workflow_authorization_logic_v0
|
|
68
|
+
from compiler.governance_engine.assertions.handlers.assert_authority_state_well_formed_v0 import execute as assert_authority_state_well_formed_v0
|
|
69
|
+
from compiler.governance_engine.assertions.handlers.assert_no_ambient_authority_v0 import execute as assert_no_ambient_authority_v0
|
|
70
|
+
from compiler.governance_engine.assertions.handlers.assert_actor_authority_separation_v0 import execute as assert_actor_authority_separation_v0
|
|
71
|
+
from compiler.governance_engine.assertions.handlers.assert_no_runtime_authorization_v0 import execute as assert_no_runtime_authorization_v0
|
|
72
|
+
from compiler.governance_engine.assertions.handlers.assert_trace_authority_binding_required_v0 import execute as assert_trace_authority_binding_required_v0
|
|
73
|
+
from compiler.governance_engine.assertions.handlers.assert_identity_authority_separation_v0 import execute as assert_identity_authority_separation_v0
|
|
74
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_step_declared_v0 import execute as assert_topology_step_declared_v0
|
|
75
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_capability_reference_unique_v0 import execute as assert_topology_capability_reference_unique_v0
|
|
76
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_input_reference_declared_v0 import execute as assert_topology_input_reference_declared_v0
|
|
77
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_routing_complete_v0 import execute as assert_topology_routing_complete_v0
|
|
78
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_immutable_after_compilation_v0 import execute as assert_topology_immutable_after_compilation_v0
|
|
79
|
+
from compiler.governance_engine.assertions.handlers.assert_no_runtime_topology_synthesis_v0 import execute as assert_no_runtime_topology_synthesis_v0
|
|
80
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_step_id_unique_v0 import execute as assert_topology_step_id_unique_v0
|
|
81
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_authority_orthogonal_v0 import execute as assert_topology_authority_orthogonal_v0
|
|
82
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_transport_orthogonal_v0 import execute as assert_topology_transport_orthogonal_v0
|
|
83
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_contract_closed_v0 import execute as assert_topology_contract_closed_v0
|
|
84
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_surface_canonical_v0 import execute as assert_topology_surface_canonical_v0
|
|
85
|
+
from compiler.governance_engine.assertions.handlers.assert_execution_placement_declared_v0 import execute as assert_execution_placement_declared_v0
|
|
86
|
+
from compiler.governance_engine.assertions.handlers.assert_execution_scheduling_declared_v0 import execute as assert_execution_scheduling_declared_v0
|
|
87
|
+
from compiler.governance_engine.assertions.handlers.assert_security_domain_declared_v0 import execute as assert_security_domain_declared_v0
|
|
88
|
+
from compiler.governance_engine.assertions.handlers.assert_cryptographic_trust_declared_v0 import execute as assert_cryptographic_trust_declared_v0
|
|
89
|
+
from compiler.governance_engine.assertions.handlers.assert_handler_registry_closed_v0 import execute as assert_handler_registry_closed_v0
|
|
90
|
+
from compiler.governance_engine.assertions.handlers.assert_compiler_governance_declared_v0 import execute as assert_compiler_governance_declared_v0
|
|
91
|
+
from compiler.governance_engine.assertions.handlers.assert_compiler_no_execution_v0 import execute as assert_compiler_no_execution_v0
|
|
92
|
+
from compiler.governance_engine.assertions.handlers.assert_artifact_content_hash_declared_v0 import execute as assert_artifact_content_hash_declared_v0
|
|
93
|
+
from compiler.governance_engine.assertions.handlers.assert_topology_acyclic_v0 import execute as assert_topology_acyclic_v0
|
|
94
|
+
from compiler.governance_engine.assertions.handlers.assert_binding_integrity_v0 import execute as assert_binding_integrity_v0
|
|
95
|
+
from compiler.governance_engine.assertions.handlers.assert_implementation_admissible_v0 import execute as assert_implementation_admissible_v0
|
|
96
|
+
from compiler.governance_engine.assertions.handlers.assert_schema_conformance_v0 import execute as assert_schema_conformance_v0
|
|
97
|
+
from compiler.governance_engine.assertions.handlers.assert_rb_binding_policy_conformance_v0 import execute as assert_rb_binding_policy_conformance_v0
|
|
98
|
+
from compiler.governance_engine.assertions.handlers.assert_rb_parameters_declared_v0 import execute as assert_rb_parameters_declared_v0
|
|
99
|
+
from compiler.governance_engine.assertions.handlers.assert_inspection_capability_read_only_v0 import execute as assert_inspection_capability_read_only_v0
|
|
100
|
+
from compiler.governance_engine.assertions.handlers.assert_cc_storage_op_conformance_v0 import execute as assert_cc_storage_op_conformance_v0
|
|
101
|
+
from compiler.governance_engine.assertions.handlers.assert_wf_node_key_binding_unique_v0 import execute as assert_wf_node_key_binding_unique_v0
|
|
102
|
+
from compiler.governance_engine.assertions.handlers.assert_ct_test_data_outcome_declared_v0 import execute as assert_ct_test_data_outcome_declared_v0
|
|
103
|
+
from compiler.governance_engine.assertions.handlers.assert_runtime_invariant_wired_v0 import execute as assert_runtime_invariant_wired_v0
|
|
104
|
+
|
|
105
|
+
# Static handler registry (FQDN → callable)
|
|
106
|
+
# This is the ONLY allowed way to resolve handlers
|
|
107
|
+
# Any handler not in this dict MUST cause compile failure
|
|
108
|
+
HANDLER_REGISTRY = {
|
|
109
|
+
"pgs_governance.registry.handlers.assert_assert_parity_v0": assert_assert_parity_v0,
|
|
110
|
+
"pgs_governance.registry.handlers.assert_atom_output_purity_v0": assert_atom_output_purity_v0,
|
|
111
|
+
"pgs_governance.registry.handlers.assert_cc_capability_binding_valid_v0": assert_cc_capability_binding_valid_v0,
|
|
112
|
+
"pgs_governance.registry.handlers.assert_cc_inputs_satisfied_v0": assert_cc_inputs_satisfied_v0,
|
|
113
|
+
"pgs_governance.registry.handlers.assert_cc_no_implicit_chaining_v0": assert_cc_no_implicit_chaining_v0,
|
|
114
|
+
"pgs_governance.registry.handlers.assert_cc_no_missing_dependencies_v0": assert_cc_no_missing_dependencies_v0,
|
|
115
|
+
"pgs_governance.registry.handlers.assert_cc_no_unused_outputs_v0": assert_cc_no_unused_outputs_v0,
|
|
116
|
+
"pgs_governance.registry.handlers.assert_cs_surface_closed_v0": assert_cs_surface_closed_v0,
|
|
117
|
+
"pgs_governance.registry.handlers.assert_ct_output_contract_match_v0": assert_ct_output_contract_match_v0,
|
|
118
|
+
"pgs_governance.registry.handlers.assert_ct_surface_closed_v0": assert_ct_surface_closed_v0,
|
|
119
|
+
"pgs_governance.registry.handlers.assert_ct_surface_derived_closed_v0": assert_ct_surface_derived_closed_v0,
|
|
120
|
+
"pgs_governance.registry.handlers.assert_fqdn_only_references_v0": assert_fqdn_only_references_v0,
|
|
121
|
+
"pgs_governance.registry.handlers.assert_identity_fqdn_consistency": assert_identity_fqdn_consistency,
|
|
122
|
+
"pgs_governance.registry.handlers.assert_no_smart_execution_v0": assert_no_smart_execution_v0,
|
|
123
|
+
"pgs_governance.registry.handlers.assert_no_undeclared_behavior_surface_v0": assert_no_undeclared_behavior_surface_v0,
|
|
124
|
+
"pgs_governance.registry.handlers.assert_protocol_surface_closed_v0": assert_protocol_surface_closed_v0,
|
|
125
|
+
"pgs_governance.registry.handlers.assert_test_data_match_ct_output_v0": assert_test_data_match_ct_output_v0,
|
|
126
|
+
"pgs_governance.registry.handlers.assert_unique_artifact_id_v0": assert_unique_artifact_id_v0,
|
|
127
|
+
"pgs_governance.registry.handlers.assert_wf_execution_path_valid_v0": assert_wf_execution_path_valid_v0,
|
|
128
|
+
"pgs_governance.registry.handlers.assert_binding_surface_closed_v0": assert_binding_surface_closed_v0,
|
|
129
|
+
"pgs_governance.registry.handlers.assert_wf_announcement_distinct_v0": assert_wf_announcement_distinct_v0,
|
|
130
|
+
"pgs_governance.registry.handlers.assert_wf_cc_only_nodes_v0": assert_wf_cc_only_nodes_v0,
|
|
131
|
+
"pgs_governance.registry.handlers.assert_wf_entry_intent_v0": assert_wf_entry_intent_v0,
|
|
132
|
+
"pgs_governance.registry.handlers.assert_in_schema_required_v0": assert_in_schema_required_v0,
|
|
133
|
+
"pgs_governance.registry.handlers.assert_in_workflow_binding_v0": assert_in_workflow_binding_v0,
|
|
134
|
+
"pgs_governance.registry.handlers.assert_superseded_not_referenced_v0": assert_superseded_not_referenced_v0,
|
|
135
|
+
"pgs_governance.registry.handlers.assert_rb_no_logic_v0": assert_rb_no_logic_v0,
|
|
136
|
+
"pgs_governance.registry.handlers.assert_transport_target_exists_v0": assert_transport_target_exists_v0,
|
|
137
|
+
"pgs_governance.registry.handlers.assert_transport_no_dynamic_routing_v0": assert_transport_no_dynamic_routing_v0,
|
|
138
|
+
"pgs_governance.registry.handlers.assert_transport_no_workflow_semantics_v0": assert_transport_no_workflow_semantics_v0,
|
|
139
|
+
"pgs_governance.registry.handlers.assert_transport_canonical_normalization_v0": assert_transport_canonical_normalization_v0,
|
|
140
|
+
"pgs_governance.registry.handlers.assert_transport_operation_identity_independence_v0": assert_transport_operation_identity_independence_v0,
|
|
141
|
+
"pgs_governance.registry.handlers.assert_transport_result_class_protocol_independence_v0": assert_transport_result_class_protocol_independence_v0,
|
|
142
|
+
"pgs_governance.registry.handlers.assert_transport_response_projection_external_v0": assert_transport_response_projection_external_v0,
|
|
143
|
+
"pgs_governance.registry.handlers.assert_conformance_assertion_mode_valid_v0": assert_conformance_assertion_mode_valid_v0,
|
|
144
|
+
"pgs_governance.registry.handlers.assert_ev_schema_required_v0": assert_ev_schema_required_v0,
|
|
145
|
+
"pgs_governance.registry.handlers.assert_ev_append_only_v0": assert_ev_append_only_v0,
|
|
146
|
+
"pgs_governance.registry.handlers.assert_rb_cs_only_v0": assert_rb_cs_only_v0,
|
|
147
|
+
"pgs_governance.registry.handlers.assert_rb_storage_subdomain_owned_v0": assert_rb_storage_subdomain_owned_v0,
|
|
148
|
+
"pgs_governance.registry.handlers.assert_cs_traceable_v0": assert_cs_traceable_v0,
|
|
149
|
+
"pgs_governance.registry.handlers.assert_cs_isolated_execution_v0": assert_cs_isolated_execution_v0,
|
|
150
|
+
"pgs_governance.registry.handlers.assert_in_no_execution_logic_v0": assert_in_no_execution_logic_v0,
|
|
151
|
+
"pgs_governance.registry.handlers.assert_authority_required_for_execution_v0": assert_authority_required_for_execution_v0,
|
|
152
|
+
"pgs_governance.registry.handlers.assert_no_workflow_authorization_logic_v0": assert_no_workflow_authorization_logic_v0,
|
|
153
|
+
"pgs_governance.registry.handlers.assert_authority_state_well_formed_v0": assert_authority_state_well_formed_v0,
|
|
154
|
+
"pgs_governance.registry.handlers.assert_no_ambient_authority_v0": assert_no_ambient_authority_v0,
|
|
155
|
+
"pgs_governance.registry.handlers.assert_actor_authority_separation_v0": assert_actor_authority_separation_v0,
|
|
156
|
+
"pgs_governance.registry.handlers.assert_no_runtime_authorization_v0": assert_no_runtime_authorization_v0,
|
|
157
|
+
"pgs_governance.registry.handlers.assert_trace_authority_binding_required_v0": assert_trace_authority_binding_required_v0,
|
|
158
|
+
"pgs_governance.registry.handlers.assert_identity_authority_separation_v0": assert_identity_authority_separation_v0,
|
|
159
|
+
"pgs_governance.registry.handlers.assert_topology_step_declared_v0": assert_topology_step_declared_v0,
|
|
160
|
+
"pgs_governance.registry.handlers.assert_topology_capability_reference_unique_v0": assert_topology_capability_reference_unique_v0,
|
|
161
|
+
"pgs_governance.registry.handlers.assert_topology_input_reference_declared_v0": assert_topology_input_reference_declared_v0,
|
|
162
|
+
"pgs_governance.registry.handlers.assert_topology_routing_complete_v0": assert_topology_routing_complete_v0,
|
|
163
|
+
"pgs_governance.registry.handlers.assert_topology_immutable_after_compilation_v0": assert_topology_immutable_after_compilation_v0,
|
|
164
|
+
"pgs_governance.registry.handlers.assert_no_runtime_topology_synthesis_v0": assert_no_runtime_topology_synthesis_v0,
|
|
165
|
+
"pgs_governance.registry.handlers.assert_topology_step_id_unique_v0": assert_topology_step_id_unique_v0,
|
|
166
|
+
"pgs_governance.registry.handlers.assert_topology_authority_orthogonal_v0": assert_topology_authority_orthogonal_v0,
|
|
167
|
+
"pgs_governance.registry.handlers.assert_topology_transport_orthogonal_v0": assert_topology_transport_orthogonal_v0,
|
|
168
|
+
"pgs_governance.registry.handlers.assert_topology_contract_closed_v0": assert_topology_contract_closed_v0,
|
|
169
|
+
"pgs_governance.registry.handlers.assert_topology_surface_canonical_v0": assert_topology_surface_canonical_v0,
|
|
170
|
+
"pgs_governance.registry.handlers.assert_execution_placement_declared_v0": assert_execution_placement_declared_v0,
|
|
171
|
+
"pgs_governance.registry.handlers.assert_execution_scheduling_declared_v0": assert_execution_scheduling_declared_v0,
|
|
172
|
+
"pgs_governance.registry.handlers.assert_security_domain_declared_v0": assert_security_domain_declared_v0,
|
|
173
|
+
"pgs_governance.registry.handlers.assert_cryptographic_trust_declared_v0": assert_cryptographic_trust_declared_v0,
|
|
174
|
+
"pgs_governance.registry.handlers.assert_handler_registry_closed_v0": assert_handler_registry_closed_v0,
|
|
175
|
+
"pgs_governance.registry.handlers.assert_fqdn_namespace_authorized_v0": assert_fqdn_namespace_authorized_v0,
|
|
176
|
+
"pgs_governance.registry.handlers.assert_concern_not_authority_v0": assert_concern_not_authority_v0,
|
|
177
|
+
"pgs_governance.registry.handlers.assert_authority_constituted_v0": assert_authority_constituted_v0,
|
|
178
|
+
"pgs_governance.registry.handlers.assert_structure_paths_well_formed_v0": assert_structure_paths_well_formed_v0,
|
|
179
|
+
"pgs_governance.registry.handlers.assert_schema_description_well_formed_v0": assert_schema_description_well_formed_v0,
|
|
180
|
+
"pgs_governance.registry.handlers.assert_ac_declaration_well_formed_v0": assert_ac_declaration_well_formed_v0,
|
|
181
|
+
"pgs_governance.registry.handlers.assert_vocabulary_symbols_well_formed_v0": assert_vocabulary_symbols_well_formed_v0,
|
|
182
|
+
"pgs_governance.registry.handlers.assert_assert_not_runtime_referenced_v0": assert_assert_not_runtime_referenced_v0,
|
|
183
|
+
"pgs_governance.registry.handlers.assert_governance_declaration_resolves_v0": assert_governance_declaration_resolves_v0,
|
|
184
|
+
"pgs_governance.registry.handlers.assert_compiler_governance_declared_v0": assert_compiler_governance_declared_v0,
|
|
185
|
+
"pgs_governance.registry.handlers.assert_compiler_no_execution_v0": assert_compiler_no_execution_v0,
|
|
186
|
+
"pgs_governance.registry.handlers.assert_artifact_content_hash_declared_v0": assert_artifact_content_hash_declared_v0,
|
|
187
|
+
"pgs_governance.registry.handlers.assert_topology_acyclic_v0": assert_topology_acyclic_v0,
|
|
188
|
+
"pgs_governance.registry.handlers.assert_binding_integrity_v0": assert_binding_integrity_v0,
|
|
189
|
+
"pgs_governance.registry.handlers.assert_implementation_admissible_v0": assert_implementation_admissible_v0,
|
|
190
|
+
"pgs_governance.registry.handlers.assert_schema_conformance_v0": assert_schema_conformance_v0,
|
|
191
|
+
"pgs_governance.registry.handlers.assert_rb_binding_policy_conformance_v0": assert_rb_binding_policy_conformance_v0,
|
|
192
|
+
"pgs_governance.registry.handlers.assert_rb_parameters_declared_v0": assert_rb_parameters_declared_v0,
|
|
193
|
+
"pgs_governance.registry.handlers.assert_inspection_capability_read_only_v0": assert_inspection_capability_read_only_v0,
|
|
194
|
+
"pgs_governance.registry.handlers.assert_cc_storage_op_conformance_v0": assert_cc_storage_op_conformance_v0,
|
|
195
|
+
"pgs_governance.registry.handlers.assert_wf_node_key_binding_unique_v0": assert_wf_node_key_binding_unique_v0,
|
|
196
|
+
"pgs_governance.registry.handlers.assert_ct_test_data_outcome_declared_v0": assert_ct_test_data_outcome_declared_v0,
|
|
197
|
+
"pgs_governance.registry.handlers.assert_runtime_invariant_wired_v0": assert_runtime_invariant_wired_v0,
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
__all__ = ["HANDLER_REGISTRY"]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ASSERT_AC_DECLARATION_WELL_FORMED_V0 Handler
|
|
3
|
+
|
|
4
|
+
An actor declares identity and nothing else. Checks, over AC artifacts:
|
|
5
|
+
|
|
6
|
+
1. core.type is declared and non-empty
|
|
7
|
+
2. every core.attributes entry declares an explicit type
|
|
8
|
+
3. no execution / routing / side-effect key appears at any depth
|
|
9
|
+
4. attribute values are literals, not runtime path expressions
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
RULE = "actor::INVARIANT_AC_DECLARATION_WELL_FORMED_V0"
|
|
15
|
+
|
|
16
|
+
FORBIDDEN_KEYS = frozenset({
|
|
17
|
+
"implementation", "pipeline", "steps", "operations",
|
|
18
|
+
"side_effects", "transforms", "bindings", "next", "on_result",
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _forbidden_paths(data: Any, prefix: str = "") -> list[str]:
|
|
23
|
+
found: list[str] = []
|
|
24
|
+
if isinstance(data, dict):
|
|
25
|
+
for k, v in data.items():
|
|
26
|
+
path = f"{prefix}.{k}" if prefix else str(k)
|
|
27
|
+
if k in FORBIDDEN_KEYS:
|
|
28
|
+
found.append(path)
|
|
29
|
+
found.extend(_forbidden_paths(v, path))
|
|
30
|
+
elif isinstance(data, list):
|
|
31
|
+
for i, item in enumerate(data):
|
|
32
|
+
found.extend(_forbidden_paths(item, f"{prefix}[{i}]"))
|
|
33
|
+
return found
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def execute(artifacts: list[dict], compilation_context: dict) -> dict:
|
|
37
|
+
violations: list[dict] = []
|
|
38
|
+
actors = [a for a in artifacts if a.get("artifact_type") == "AC"]
|
|
39
|
+
|
|
40
|
+
for ac in actors:
|
|
41
|
+
fqdn = ac.get("fqdn_id", "unknown")
|
|
42
|
+
fm = ac.get("frontmatter", {}) or {}
|
|
43
|
+
core = fm.get("core", {}) or {}
|
|
44
|
+
|
|
45
|
+
def flag(message: str, fix: str) -> None:
|
|
46
|
+
violations.append({"fqdn": fqdn, "rule": RULE, "message": message, "fix": fix})
|
|
47
|
+
|
|
48
|
+
if not str(core.get("type") or "").strip():
|
|
49
|
+
flag("actor declares no core.type",
|
|
50
|
+
"Declare core.type from the governed actor type vocabulary")
|
|
51
|
+
|
|
52
|
+
attributes = core.get("attributes")
|
|
53
|
+
if isinstance(attributes, dict):
|
|
54
|
+
for name, spec in attributes.items():
|
|
55
|
+
if not isinstance(spec, dict) or not str(spec.get("type") or "").strip():
|
|
56
|
+
flag(f"attribute '{name}' declares no type",
|
|
57
|
+
f"Give core.attributes.{name} an explicit type")
|
|
58
|
+
elif isinstance(spec.get("value"), str) and spec["value"].startswith("$."):
|
|
59
|
+
flag(f"attribute '{name}' resolves from runtime state: {spec['value']}",
|
|
60
|
+
"Declare a literal value; identity is a compile-time governed fact")
|
|
61
|
+
|
|
62
|
+
for path in _forbidden_paths(fm):
|
|
63
|
+
flag(f"actor declares execution surface at '{path}'",
|
|
64
|
+
"An actor declares identity and attributes only; move behaviour to a CC/CT/CS")
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
"assert_count": len(actors),
|
|
68
|
+
"violations": violations,
|
|
69
|
+
"status": "FAILED" if violations else "PASSED",
|
|
70
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ASSERT_ACTOR_AUTHORITY_SEPARATION_V0
|
|
3
|
+
|
|
4
|
+
Phase 1 stub — governance-layer artifact only.
|
|
5
|
+
Full enforcement (detect authority semantics inside AC_ artifacts: permissions, roles,
|
|
6
|
+
allowed_workflows, admissibility rules, execution rights) is implemented in Phase 4.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def execute(artifacts: list[dict], compilation_context: dict) -> dict:
|
|
11
|
+
# Phase 1: stub — authority governance artifacts are governance-layer only.
|
|
12
|
+
# Detection of authority semantics inside identity artifacts implemented in Phase 4.
|
|
13
|
+
return {
|
|
14
|
+
"assert_count": 0,
|
|
15
|
+
"violations": [],
|
|
16
|
+
"status": "PASSED",
|
|
17
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ASSERT_ARTIFACT_CONTENT_HASH_DECLARED_V0 Handler
|
|
3
|
+
|
|
4
|
+
Verifies every compiled artifact in the snapshot carries a non-empty content_hash —
|
|
5
|
+
confirming full materialization of the compiled set.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def execute(artifacts: list[dict], compilation_context: dict) -> dict:
|
|
12
|
+
"""
|
|
13
|
+
Verify every compiled artifact has a non-empty content_hash.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
artifacts: All compiled artifacts
|
|
17
|
+
compilation_context: Not used
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
{
|
|
21
|
+
"assert_count": int,
|
|
22
|
+
"violations": list[dict],
|
|
23
|
+
"status": str
|
|
24
|
+
}
|
|
25
|
+
"""
|
|
26
|
+
violations = []
|
|
27
|
+
|
|
28
|
+
for artifact in artifacts:
|
|
29
|
+
fqdn_id = artifact.get("fqdn_id", "<unknown>")
|
|
30
|
+
artifact_code = artifact.get("artifact_code", "<unknown>")
|
|
31
|
+
content_hash = artifact.get("content_hash")
|
|
32
|
+
|
|
33
|
+
if not content_hash:
|
|
34
|
+
violations.append({
|
|
35
|
+
"fqdn": fqdn_id,
|
|
36
|
+
"artifact_code": artifact_code,
|
|
37
|
+
"content_hash": content_hash,
|
|
38
|
+
"rule": "compiler::INVARIANT_ARTIFACT_CONTENT_HASH_DECLARED_V0",
|
|
39
|
+
"message": (
|
|
40
|
+
f"Artifact is not fully materialized: content_hash is "
|
|
41
|
+
f"{'missing' if content_hash is None else 'empty'}"
|
|
42
|
+
),
|
|
43
|
+
"fix": (
|
|
44
|
+
"Ensure the MATERIALIZE phase computes and assigns content_hash "
|
|
45
|
+
"for every compiled artifact before emitting the snapshot."
|
|
46
|
+
),
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
if violations:
|
|
50
|
+
return {
|
|
51
|
+
"assert_count": len(artifacts),
|
|
52
|
+
"violations": violations,
|
|
53
|
+
"status": "FAILED",
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
"assert_count": len(artifacts),
|
|
58
|
+
"violations": [],
|
|
59
|
+
"status": "PASSED",
|
|
60
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ASSERT_ASSERT_NOT_RUNTIME_REFERENCED_V0 Handler
|
|
3
|
+
|
|
4
|
+
The compile/execute boundary is one-way. ASSERTs read the compiled graph; nothing in
|
|
5
|
+
the compiled graph may reference an ASSERT. Scans executable artifacts (WF, CC, CS, CT,
|
|
6
|
+
RB) for any ASSERT_ code at any depth of the machine block.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
RULE = "conformance::INVARIANT_ASSERT_NOT_RUNTIME_REFERENCED_V0"
|
|
13
|
+
|
|
14
|
+
EXECUTABLE = frozenset({"WF", "CC", "CS", "CT", "RB"})
|
|
15
|
+
ASSERT_CODE = re.compile(r"\bASSERT_[A-Z0-9_]+_V[0-9]+\b")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _assert_refs(data: Any, prefix: str = "") -> list[tuple[str, str]]:
|
|
19
|
+
found: list[tuple[str, str]] = []
|
|
20
|
+
if isinstance(data, dict):
|
|
21
|
+
for k, v in data.items():
|
|
22
|
+
found.extend(_assert_refs(v, f"{prefix}.{k}" if prefix else str(k)))
|
|
23
|
+
elif isinstance(data, list):
|
|
24
|
+
for i, item in enumerate(data):
|
|
25
|
+
found.extend(_assert_refs(item, f"{prefix}[{i}]"))
|
|
26
|
+
elif isinstance(data, str):
|
|
27
|
+
for m in ASSERT_CODE.findall(data):
|
|
28
|
+
found.append((prefix, m))
|
|
29
|
+
return found
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def execute(artifacts: list[dict], compilation_context: dict) -> dict:
|
|
33
|
+
violations: list[dict] = []
|
|
34
|
+
subjects = [a for a in artifacts if a.get("artifact_type") in EXECUTABLE]
|
|
35
|
+
|
|
36
|
+
for art in subjects:
|
|
37
|
+
for path, code in _assert_refs(art.get("frontmatter", {}) or {}):
|
|
38
|
+
violations.append({
|
|
39
|
+
"fqdn": art.get("fqdn_id", "unknown"),
|
|
40
|
+
"rule": RULE,
|
|
41
|
+
"message": f"executable artifact references {code} at '{path}'",
|
|
42
|
+
"fix": "Remove the ASSERT reference; governance is not reachable from execution",
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
"assert_count": len(subjects),
|
|
47
|
+
"violations": violations,
|
|
48
|
+
"status": "FAILED" if violations else "PASSED",
|
|
49
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ASSERT_ASSERT_PARITY_V0 Handler
|
|
3
|
+
|
|
4
|
+
Meta-registry validation: Ensures every INVARIANT has matching ASSERT (and vice versa).
|
|
5
|
+
|
|
6
|
+
Validation Rules:
|
|
7
|
+
1. Every INVARIANT_X_V0 must have matching ASSERT_X_V0
|
|
8
|
+
2. Every ASSERT_X_V0 must have matching INVARIANT_X_V0
|
|
9
|
+
3. Names must match exactly (excluding prefix)
|
|
10
|
+
|
|
11
|
+
Enforcement Levels:
|
|
12
|
+
- WARNING: Allows dev iteration (violations don't block build)
|
|
13
|
+
- ERROR: Strict enforcement (violations block build) - used in CI
|
|
14
|
+
|
|
15
|
+
This is meta-validation - registry validating itself.
|
|
16
|
+
Must run BEFORE artifact validation.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from typing import Any
|
|
20
|
+
import os
|
|
21
|
+
import re
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def execute(artifacts: list[dict], compilation_context: dict) -> dict:
|
|
25
|
+
"""
|
|
26
|
+
Validate registry parity: INVARIANT ↔ ASSERT symmetry.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
artifacts: All validated artifacts
|
|
30
|
+
compilation_context: Compilation metadata
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
{
|
|
34
|
+
"assert_count": int,
|
|
35
|
+
"violations": list[dict],
|
|
36
|
+
"status": "PASSED/FAILED"
|
|
37
|
+
}
|
|
38
|
+
"""
|
|
39
|
+
invariants = {}
|
|
40
|
+
asserts = {}
|
|
41
|
+
|
|
42
|
+
# Collect INVARIANT and ASSERT artifacts
|
|
43
|
+
# Use artifact_code prefix (not artifact_type) because INVARIANT nodes
|
|
44
|
+
# are mapped to NodeKind.GOVERNANCE in the compiler graph and their
|
|
45
|
+
# projected artifact_type is "GOVERNANCE", not "INVARIANT".
|
|
46
|
+
for artifact in artifacts:
|
|
47
|
+
artifact_code = artifact.get("artifact_code", "")
|
|
48
|
+
fqdn = artifact.get("fqdn_id", "")
|
|
49
|
+
|
|
50
|
+
if artifact_code.startswith("INVARIANT_"):
|
|
51
|
+
# An invariant enforced by a NON-COMPILER mechanism has no same-named ASSERT, and is
|
|
52
|
+
# exempt from INVARIANT<->ASSERT parity:
|
|
53
|
+
# runtime_outcome — bound to a CC violation outcome and WF routing; verified
|
|
54
|
+
# by ASSERT_RUNTIME_INVARIANT_WIRED_V0
|
|
55
|
+
# composition_conformance — evaluated by the assembler over the ASSEMBLED snapshot;
|
|
56
|
+
# admitted by its own `composition_check` declaration
|
|
57
|
+
# A compile-time handler for a composition-scoped rule could only ever see one domain
|
|
58
|
+
# build, which is the opposite of the scope such a rule is about — the platform build
|
|
59
|
+
# legitimately contains none of the artifacts the composition must carry.
|
|
60
|
+
core = artifact.get("frontmatter", {}).get("core", {})
|
|
61
|
+
stages = core.get("enforcement_stage", []) or []
|
|
62
|
+
if {"runtime_outcome", "composition_conformance"} & set(stages):
|
|
63
|
+
continue
|
|
64
|
+
invariants[artifact_code] = fqdn
|
|
65
|
+
elif artifact_code.startswith("ASSERT_"):
|
|
66
|
+
asserts[artifact_code] = fqdn
|
|
67
|
+
|
|
68
|
+
# Extract base names (remove INVARIANT_/ASSERT_ prefix)
|
|
69
|
+
invariant_names = {}
|
|
70
|
+
for code in invariants.keys():
|
|
71
|
+
# Pattern: INVARIANT_{NAME}_V{N}
|
|
72
|
+
match = re.match(r"INVARIANT_(.+)_(V\d+)$", code)
|
|
73
|
+
if match:
|
|
74
|
+
base_name = f"{match.group(1)}_{match.group(2)}"
|
|
75
|
+
invariant_names[base_name] = code
|
|
76
|
+
|
|
77
|
+
assert_names = {}
|
|
78
|
+
for code in asserts.keys():
|
|
79
|
+
# Pattern: ASSERT_{NAME}_V{N}
|
|
80
|
+
match = re.match(r"ASSERT_(.+)_(V\d+)$", code)
|
|
81
|
+
if match:
|
|
82
|
+
base_name = f"{match.group(1)}_{match.group(2)}"
|
|
83
|
+
assert_names[base_name] = code
|
|
84
|
+
|
|
85
|
+
violations = []
|
|
86
|
+
|
|
87
|
+
# Check for orphaned invariants (missing asserts)
|
|
88
|
+
orphaned_invariants = set(invariant_names.keys()) - set(assert_names.keys())
|
|
89
|
+
for base_name in sorted(orphaned_invariants):
|
|
90
|
+
invariant_code = invariant_names[base_name]
|
|
91
|
+
violations.append({
|
|
92
|
+
"fqdn": invariants[invariant_code],
|
|
93
|
+
"rule": "conformance::INVARIANT_ASSERT_PARITY_V0",
|
|
94
|
+
"message": f"Orphaned INVARIANT (no matching ASSERT): {invariant_code}",
|
|
95
|
+
"fix": f"Create matching ASSERT_{base_name}.md file with handler implementation"
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
# Check for orphaned asserts (missing invariants)
|
|
99
|
+
orphaned_asserts = set(assert_names.keys()) - set(invariant_names.keys())
|
|
100
|
+
for base_name in sorted(orphaned_asserts):
|
|
101
|
+
assert_code = assert_names[base_name]
|
|
102
|
+
violations.append({
|
|
103
|
+
"fqdn": asserts[assert_code],
|
|
104
|
+
"rule": "conformance::INVARIANT_ASSERT_PARITY_V0",
|
|
105
|
+
"message": f"Orphaned ASSERT (no matching INVARIANT): {assert_code}",
|
|
106
|
+
"fix": f"Create matching INVARIANT_{base_name}.md file or delete orphaned ASSERT"
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
# Determine enforcement level
|
|
110
|
+
# Check for CI environment (CI=true or CI=1)
|
|
111
|
+
is_ci = os.getenv("CI", "").lower() in ("true", "1")
|
|
112
|
+
|
|
113
|
+
# Get assertion artifact to read enforcement level
|
|
114
|
+
assert_artifact = compilation_context.get("current_assert_artifact")
|
|
115
|
+
default_level = "WARNING" # Default to dev-friendly mode
|
|
116
|
+
|
|
117
|
+
if assert_artifact:
|
|
118
|
+
enforcement = assert_artifact.get("frontmatter", {}).get("enforcement", {})
|
|
119
|
+
ci_override = assert_artifact.get("frontmatter", {}).get("ci_override", {})
|
|
120
|
+
|
|
121
|
+
if is_ci and "level" in ci_override:
|
|
122
|
+
level = ci_override["level"] # CI override takes precedence
|
|
123
|
+
else:
|
|
124
|
+
level = enforcement.get("level", default_level)
|
|
125
|
+
else:
|
|
126
|
+
level = default_level
|
|
127
|
+
|
|
128
|
+
# Return result
|
|
129
|
+
total_pairs = len(invariant_names) + len(assert_names)
|
|
130
|
+
|
|
131
|
+
if violations:
|
|
132
|
+
if level == "WARNING":
|
|
133
|
+
# Dev mode: Warn but don't fail build
|
|
134
|
+
return {
|
|
135
|
+
"assert_count": total_pairs,
|
|
136
|
+
"warnings": violations,
|
|
137
|
+
"violations": [],
|
|
138
|
+
"status": "PASSED_WITH_WARNINGS",
|
|
139
|
+
"summary": {
|
|
140
|
+
"invariants": len(invariants),
|
|
141
|
+
"asserts": len(asserts),
|
|
142
|
+
"orphaned_invariants": len(orphaned_invariants),
|
|
143
|
+
"orphaned_asserts": len(orphaned_asserts)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else:
|
|
147
|
+
# CI/production mode: Hard fail
|
|
148
|
+
return {
|
|
149
|
+
"assert_count": total_pairs,
|
|
150
|
+
"violations": violations,
|
|
151
|
+
"status": "FAILED",
|
|
152
|
+
"summary": {
|
|
153
|
+
"invariants": len(invariants),
|
|
154
|
+
"asserts": len(asserts),
|
|
155
|
+
"orphaned_invariants": len(orphaned_invariants),
|
|
156
|
+
"orphaned_asserts": len(orphaned_asserts)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
"assert_count": total_pairs,
|
|
162
|
+
"violations": [],
|
|
163
|
+
"status": "PASSED",
|
|
164
|
+
"summary": {
|
|
165
|
+
"invariants": len(invariants),
|
|
166
|
+
"asserts": len(asserts),
|
|
167
|
+
"matched_pairs": len(invariant_names)
|
|
168
|
+
}
|
|
169
|
+
}
|