orchestrata_ultimate.verification.requirements.constraint_definitions
Reference › orchestrata_ultimate › verification › requirements › constraint_definitions
A library of predefined Constraint templates with stable ids. The lists FUNCTIONAL_CONSTRAINTS (file exists, code compiles, dependencies defined), QUALITY_CONSTRAINTS (for example test coverage of at least 80 percent, linting passes, documentation), PERFORMANCE_CONSTRAINTS (response time 200 ms, throughput 100, memory 512 MB) and SECURITY_CONSTRAINTS (no SQL injection, no secrets in code) are concatenated into ALL_PREDEFINED. get_constraints_by_type filters that collection by ConstraintType and get_constraint_by_id finds one by id, returning None when absent. The predicates match those recognised by the requirements parser and used by the checkpoint definitions. No module imports it inside the package.
At a glance
| Source | src/orchestrata_ultimate/verification/requirements/constraint_definitions.py |
| Lines of code | 133 |
| Classes | 0 |
| Functions | 2 |
| Imports (internal) | orchestrata_ultimate.core.base.traces, orchestrata_ultimate.verification.types |
| Imported by | none |
| Tests that import it | tests/verification/requirements/test_constraint_definitions.py, tests/verification/test_constraint_definitions.py, tests/verification/test_requirements.py, tests/verification/test_small_modules.py |
Class diagram
No classes; see Functions.
Dependency diagram
API
Functions
| Function | Signature | Summary |
|---|---|---|
get_constraints_by_type traces |
get_constraints_by_type(constraint_type: ConstraintType) -> list[Constraint] |
Get predefined constraints by type. |
get_constraint_by_id traces |
get_constraint_by_id(constraint_id: str) -> Constraint | None |
Get a predefined constraint by ID. |
Source
"""Predefined constraint specifications and templates."""
from orchestrata_ultimate.core.base.traces import traces
from orchestrata_ultimate.verification.types import Constraint, ConstraintType
# Predefined functional constraints
FUNCTIONAL_CONSTRAINTS = [
Constraint(
id="func-file-exists",
type=ConstraintType.FUNCTIONAL,
predicate="file_exists",
expected=True,
description="Required files exist",
),
Constraint(
id="func-code-compiles",
type=ConstraintType.FUNCTIONAL,
predicate="code_compiles",
expected=True,
description="Code compiles without errors",
),
Constraint(
id="func-deps-defined",
type=ConstraintType.FUNCTIONAL,
predicate="dependencies_defined",
expected=True,
description="All dependencies are defined",
),
]
# Predefined quality constraints
QUALITY_CONSTRAINTS = [
Constraint(
id="qual-coverage-80",
type=ConstraintType.QUALITY,
predicate="test_coverage_percentage",
expected=80,
description="Test coverage >= 80%",
),
Constraint(
id="qual-linting",
type=ConstraintType.QUALITY,
predicate="linting_passes",
expected=True,
description="Linting passes",
),
Constraint(
id="qual-docs",
type=ConstraintType.QUALITY,
predicate="documentation_complete",
expected=True,
description="Documentation complete",
),
]
# Predefined performance constraints
PERFORMANCE_CONSTRAINTS = [
Constraint(
id="perf-response-200ms",
type=ConstraintType.PERFORMANCE,
predicate="response_time_max_ms",
expected=200,
description="Response time <= 200ms",
),
Constraint(
id="perf-throughput-100",
type=ConstraintType.PERFORMANCE,
predicate="throughput_min",
expected=100,
description="Throughput >= 100 req/s",
),
Constraint(
id="perf-memory-512mb",
type=ConstraintType.PERFORMANCE,
predicate="memory_usage_max_mb",
expected=512,
description="Memory usage <= 512MB",
),
]
# Predefined security constraints
SECURITY_CONSTRAINTS = [
Constraint(
id="sec-no-sqli",
type=ConstraintType.SECURITY,
predicate="no_sql_injection_vulnerabilities",
expected=True,
description="No SQL injection",
),
Constraint(
id="sec-no-secrets",
type=ConstraintType.SECURITY,
predicate="secrets_not_in_code",
expected=True,
description="No secrets in code",
),
]
ALL_PREDEFINED = (
FUNCTIONAL_CONSTRAINTS
+ QUALITY_CONSTRAINTS
+ PERFORMANCE_CONSTRAINTS
+ SECURITY_CONSTRAINTS
)
@traces(
spec="035",
story="US-002",
reqs=[
"REQ-035-US-010-004",
"REQ-035-US-010-005",
"REQ-035-US-010-008",
"REQ-035-US-010-010",
"REQ-035-US-011-010",
"REQ-035-US-002-001",
"REQ-035-US-002-002",
"REQ-035-US-002-003",
"REQ-035-US-002-004",
],
)
def get_constraints_by_type(constraint_type: ConstraintType) -> list[Constraint]:
"""Get predefined constraints by type."""
return [c for c in ALL_PREDEFINED if c.type == constraint_type]
@traces(spec="035", story="US-010", reqs=["REQ-035-US-010-017", "REQ-035-US-010-021"])
def get_constraint_by_id(constraint_id: str) -> Constraint | None:
"""Get a predefined constraint by ID."""
for c in ALL_PREDEFINED:
if c.id == constraint_id:
return c
return None