Skip to content

stockflow.verification

Verification engine -- runs domain checks with optional GDS structural checks.

Run verification checks on a StockFlowModel.

  1. SF-001..SF-005 on the model (pre-compilation)
  2. If include_gds_checks: compile to SystemIR and run G-001..G-006

Parameters:

Name Type Description Default
model StockFlowModel

The stock-flow model to verify.

required
domain_checks list[Callable[[StockFlowModel], list[Finding]]] | None

Optional subset of SF checks. Defaults to all.

None
include_gds_checks bool

Whether to compile and run GDS generic checks.

True
Source code in packages/gds-stockflow/stockflow/verification/engine.py
def verify(
    model: StockFlowModel,
    domain_checks: list[Callable[[StockFlowModel], list[Finding]]] | None = None,
    include_gds_checks: bool = True,
) -> VerificationReport:
    """Run verification checks on a StockFlowModel.

    1. SF-001..SF-005 on the model (pre-compilation)
    2. If include_gds_checks: compile to SystemIR and run G-001..G-006

    Args:
        model: The stock-flow model to verify.
        domain_checks: Optional subset of SF checks. Defaults to all.
        include_gds_checks: Whether to compile and run GDS generic checks.
    """
    checks = domain_checks or ALL_SF_CHECKS
    findings: list[Finding] = []

    # Phase 1: SF checks on model
    for check_fn in checks:
        findings.extend(check_fn(model))

    # Phase 2: GDS generic checks on compiled SystemIR
    if include_gds_checks:
        from gds.verification.engine import ALL_CHECKS as GDS_ALL_CHECKS

        system_ir = model.compile_system()
        for gds_check in GDS_ALL_CHECKS:
            findings.extend(gds_check(system_ir))

    return VerificationReport(system_name=model.name, findings=findings)