orchestrata_ultimate.verification.constraints.definitions

Reference › orchestrata_ultimate › verification › constraints › definitions

Small pure helpers over lists of Constraint objects (Spec 035 US-002). is_blocking treats a constraint as blocking when its priority is 3 or higher or its type is security. group_by_type returns a dictionary from ConstraintType to constraints, filter_by_type selects one type, and sort_by_priority orders constraints highest priority first. The functions have no side effects and no importers inside the package; the types are in types.

At a glance

Source src/orchestrata_ultimate/verification/constraints/definitions.py
Lines of code 41
Classes 0
Functions 4
Imports (internal) orchestrata_ultimate.core.base.traces, orchestrata_ultimate.verification.types
Imported by none
Tests that import it tests/test_verification.py, tests/verification/constraints/test_definitions.py, tests/verification/test_constraints.py, tests/verification/test_constraints_definitions.py, tests/verification/test_small_modules.py

Class diagram

No classes; see Functions.

Dependency diagram

Dependency diagram orchestrata_ultimate.verification.constraints.definitions

API

Functions

Function Signature Summary
is_blocking traces is_blocking(constraint: Constraint) -> bool Check if a constraint failure blocks progress.
group_by_type traces group_by_type(constraints: list[Constraint]) -> dict[ConstraintType, list[Constraint]] Group constraints by type.
sort_by_priority traces sort_by_priority(constraints: list[Constraint]) -> list[Constraint] Sort constraints by priority (highest first).
filter_by_type traces filter_by_type(constraints: list[Constraint], constraint_type: ConstraintType) -> list[Constraint] Filter constraints by type.

Source

Permalink: https://gitlab.com/MSamy/orchestrata-ultimate-architecture/-/blob/a4cbc2bdf/src/orchestrata_ultimate/verification/constraints/definitions.py

"""Constraint type definitions and helpers."""

# Spec: 035 - Verification Agent

from orchestrata_ultimate.core.base.traces import traces
from orchestrata_ultimate.verification.types import Constraint, ConstraintType


@traces(spec="035", story="US-002", reqs=["REQ-035-US-002-008", "REQ-035-US-002-014"])
def is_blocking(constraint: Constraint) -> bool:
    """Check if a constraint failure blocks progress."""
    return constraint.priority >= 3 or constraint.type == ConstraintType.SECURITY


@traces(spec="035", story="US-002", reqs=["REQ-035-US-002-007"])
def group_by_type(
    constraints: list[Constraint],
) -> dict[ConstraintType, list[Constraint]]:
    """Group constraints by type."""
    result: dict[ConstraintType, list[Constraint]] = {}
    for c in constraints:
        result.setdefault(c.type, []).append(c)
    return result


@traces(
    spec="035",
    story="US-002",
    reqs=["REQ-035-US-002-005", "REQ-035-US-002-012", "REQ-035-US-002-020"],
)
def sort_by_priority(constraints: list[Constraint]) -> list[Constraint]:
    """Sort constraints by priority (highest first)."""
    return sorted(constraints, key=lambda c: c.priority, reverse=True)


@traces(spec="035", story="US-001", reqs=["REQ-035-US-001-001"])
def filter_by_type(
    constraints: list[Constraint], constraint_type: ConstraintType
) -> list[Constraint]:
    """Filter constraints by type."""
    return [c for c in constraints if c.type == constraint_type]