orchestrata_ultimate.verification.edge_cases.database

Reference › orchestrata_ultimate › verification › edge_cases › database

EdgeCaseDatabase is a small in-memory store of EdgeCase records from types (Spec 035 US-006). It keeps a dictionary keyed by case id and offers add (returns the id), get, get_by_constraint, list_all, remove (returns whether anything was removed), clear and a count property. Nothing is persisted. Note that detector defines its own, larger EdgeCaseDatabase with occurrence and coverage tracking; this module is the simple store.

At a glance

Source src/orchestrata_ultimate/verification/edge_cases/database.py
Lines of code 74
Classes 1
Functions 0
Imports (internal) orchestrata_ultimate.core.base.traces, orchestrata_ultimate.verification.types
Imported by none
Tests that import it tests/generated_recovery/test_verification_edge_cases_database.py, tests/verification/edge_cases/test_database.py, tests/verification/test_edge_case_database.py, tests/verification/test_edge_cases.py, tests/verification/test_edge_cases_database.py

Class diagram

Class diagram orchestrata_ultimate.verification.edge_cases.database

Dependency diagram

Dependency diagram orchestrata_ultimate.verification.edge_cases.database

API

Classes

EdgeCaseDatabase

Decorators: traces(spec='035', story='US-006', reqs=['REQ-035-US-010-009', 'REQ-035-US-006-006', 'REQ-035-US-006-007', 'REQ-035-US-… · Line 28

Stores and retrieves detected edge cases.

Method Signature Summary
__init__ __init__() -> None
add add(edge_case: EdgeCase) -> str Add an edge case.
get get(case_id: str) -> EdgeCase | None Get an edge case by ID.
get_by_constraint get_by_constraint(constraint_id: str) -> list[EdgeCase] Get all edge cases for a constraint.
list_all list_all() -> list[EdgeCase] List all edge cases.
remove remove(case_id: str) -> bool Remove an edge case.
count property count() -> int
clear clear() -> None Clear all edge cases.

Source

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

"""Edge case storage and retrieval."""

# Spec: 035 - Verification Agent

import logging

from orchestrata_ultimate.core.base.traces import traces
from orchestrata_ultimate.verification.types import EdgeCase

logger = logging.getLogger(__name__)


@traces(
    spec="035",
    story="US-006",
    reqs=[
        "REQ-035-US-010-009",
        "REQ-035-US-006-006",
        "REQ-035-US-006-007",
        "REQ-035-US-006-008",
        "REQ-035-US-006-009",
        "REQ-035-US-006-012",
        "REQ-035-US-006-014",
        "REQ-035-US-006-016",
        "REQ-035-US-006-018",
    ],
)
class EdgeCaseDatabase:
    """Stores and retrieves detected edge cases."""

    def __init__(self) -> None:
        self._cases: dict[str, EdgeCase] = {}

    @traces(
        spec="035", story="US-006", reqs=["REQ-035-US-010-009", "REQ-035-US-006-008"]
    )
    def add(self, edge_case: EdgeCase) -> str:
        """Add an edge case. Returns its ID."""
        self._cases[edge_case.id] = edge_case
        return edge_case.id

    def get(self, case_id: str) -> EdgeCase | None:
        """Get an edge case by ID."""
        return self._cases.get(case_id)

    @traces(spec="035", story="US-006", reqs=["REQ-035-US-006-007"])
    def get_by_constraint(self, constraint_id: str) -> list[EdgeCase]:
        """Get all edge cases for a constraint."""
        return [ec for ec in self._cases.values() if ec.constraint_id == constraint_id]

    @traces(spec="035", story="US-006", reqs=["REQ-035-US-006-014"])
    def list_all(self) -> list[EdgeCase]:
        """List all edge cases."""
        return list(self._cases.values())

    def remove(self, case_id: str) -> bool:
        """Remove an edge case."""
        if case_id in self._cases:
            del self._cases[case_id]
            return True
        return False

    @property
    @traces(
        spec="035",
        story="US-006",
        reqs=["REQ-035-US-006-006", "REQ-035-US-006-012"],
    )
    def count(self) -> int:
        return len(self._cases)

    def clear(self) -> None:
        """Clear all edge cases."""
        self._cases.clear()