gds.verification¶
Engine¶
Run verification checks against a SystemIR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemIR
|
The system to verify. |
required |
checks
|
list[Callable[[SystemIR], list[Finding]]] | None
|
Optional subset of checks. Defaults to all generic checks. |
None
|
Source code in packages/gds-framework/gds/verification/engine.py
Findings¶
Bases: BaseModel
A single verification check result — pass or fail with context.
Source code in packages/gds-framework/gds/verification/findings.py
Bases: BaseModel
Aggregated verification results for a system.
Source code in packages/gds-framework/gds/verification/findings.py
Generic Checks¶
Generic verification checks G-001 through G-006.
These checks operate on the domain-neutral SystemIR. They verify type consistency, structural completeness, and graph topology without referencing any domain-specific block types or semantics.
check_g001_domain_codomain_matching(system)
¶
G-001: Domain/Codomain Matching.
For every covariant block-to-block wiring, verify the label is consistent with source forward_out or target forward_in. Contravariant wirings are skipped (handled by G-003).
Property: For every wiring w where w.direction = COVARIANT and both endpoints are blocks: tokens(w.label) is a subset of tokens(source.forward_out) OR tokens(target.forward_in).
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/generic_checks.py
check_g002_signature_completeness(system)
¶
G-002: Signature Completeness.
Every block must have at least one non-empty input slot and at least one non-empty output slot. BoundaryAction blocks (block_type == "boundary") are exempt from the input requirement -- they have no inputs by design, since they model exogenous signals entering the system from outside.
Property: For every block b: has_output(b) is True, and (if b is not a BoundaryAction) has_input(b) is True, where has_input/has_output check that at least one of the forward/backward slots is non-empty.
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/generic_checks.py
check_g003_direction_consistency(system)
¶
G-003: Direction Consistency.
Validate direction flag consistency and contravariant port-slot matching.
Two validations:
A) Flag consistency -- direction, is_feedback, is_temporal must
not contradict:
- COVARIANT + is_feedback -> ERROR (feedback implies contravariant)
- CONTRAVARIANT + is_temporal -> ERROR (temporal implies covariant)
B) Contravariant port-slot matching -- for CONTRAVARIANT wirings, the label must be a token-subset of the source's backward_out (signature[3]) or the target's backward_in (signature[2]). G-001 already covers the covariant side.
Property: (A) NOT (COVARIANT AND is_feedback) and NOT (CONTRAVARIANT AND is_temporal). (B) For contravariant wirings: tokens(label) is a subset of tokens(source.backward_out) OR tokens(target.backward_in).
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/generic_checks.py
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 | |
check_g004_dangling_wirings(system)
¶
G-004: Dangling Wirings.
Flag wirings whose source or target is not in the system's block or input set. A dangling reference indicates a typo or missing block.
Property: For every wiring w: w.source in N and w.target in N, where N = {b.name for b in blocks} union {i.name for i in inputs}.
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/generic_checks.py
check_g005_sequential_type_compatibility(system)
¶
G-005: Sequential Type Compatibility.
In stack (sequential) composition, the wiring label must be a token-subset of BOTH the source's forward_out AND the target's forward_in. This is stricter than G-001, which only requires matching one side.
Property: For every covariant, non-temporal wiring w between blocks: tokens(w.label) is a subset of tokens(source.forward_out) AND tokens(w.label) is a subset of tokens(target.forward_in).
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/generic_checks.py
check_g006_covariant_acyclicity(system)
¶
G-006: Covariant Acyclicity.
The covariant (forward) flow graph must be a directed acyclic graph (DAG). Temporal wirings and contravariant wirings are excluded because they do not create within-evaluation algebraic dependencies.
Property: Let G_cov = (V, E_cov) where V = {b.name for b in blocks} and E_cov = {(w.source, w.target) for w in wirings if w.direction = COVARIANT and not w.is_temporal}. G_cov is acyclic.
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/generic_checks.py
Spec Checks¶
SC-001: Completeness.
Every entity variable is updated by at least one mechanism. Detects orphan state variables that can never change -- a likely specification error.
Property: Let U = {(e, v) for m in Mechanisms for (e, v) in m.updates}. For every entity e and variable v in e.variables: (e.name, v) in U. The mechanism update map is surjective onto the state variable set.
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/spec_checks.py
SC-002: Determinism.
Within each wiring, no two mechanisms update the same variable. Detects write conflicts where multiple mechanisms try to modify the same state variable within the same composition.
Property: For every wiring w and every (entity, variable) pair (e, v): |{m in w.block_names : m is Mechanism, (e, v) in m.updates}| <= 1. The state transition f must be a function, not a multi-valued relation.
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/spec_checks.py
SC-003: Reachability.
Can signals reach from one block to another through the wiring graph? Maps to the GDS attainability correspondence.
Property: There exists a directed path in the wire graph from from_block to to_block, where edges are (wire.source, wire.target) across all SpecWiring instances. Unlike other semantic checks, requires explicit from_block and to_block arguments.
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/spec_checks.py
SC-004: Type Safety.
Wire spaces match source and target block expectations. Verifies that space references on wires correspond to registered spaces.
Property: For every wire in every SpecWiring: if wire.space is non-empty, then wire.space is in spec.spaces. Referential integrity of space declarations on wiring channels.
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/spec_checks.py
SC-005: Parameter References.
All parameter references in blocks resolve to registered parameters.
Validates that every params_used entry on blocks corresponds to a
parameter definition in the spec's parameter_schema.
Property: For every block b implementing HasParams: {p for p in b.params_used} is a subset of spec.parameter_schema.names().
See: docs/framework/design/check-specifications.md
Source code in packages/gds-framework/gds/verification/spec_checks.py
SC-006/SC-007: Canonical Wellformedness.
Canonical projection structural validity. Two sub-checks:
- SC-006: At least one mechanism exists (f is non-empty). Property: |project_canonical(spec).mechanism_blocks| >= 1.
- SC-007: State space X is non-empty (entities with variables exist). Property: |project_canonical(spec).state_variables| >= 1.
Together these ensure the canonical form h = f . g is non-degenerate.
See: docs/framework/design/check-specifications.md