feat: reversible route matching

Routes now default to bidirectional matching — packets traversing the
configured path in reverse (C->B->A instead of A->B->C) also count
towards health.  A 'reversible' toggle lets users constrain a route
to one direction when needed.

- Route model: new 'reversible' column (default true, server_default 1)
- Migration: a1b2c3d4e5f6 (additive ALTER TABLE)
- Matching engine: _match_hops + _fetch_candidate_paths_maybe_bidirectional
  helpers shared across evaluate_route, recent_matches, and preview_route
- API schemas: reversible on RouteCreate/Update/Read/Detail/PreviewRequest
- SPA: toggle in modal; card path chips show <-> for reversible, -> otherwise
- Seed loader + example YAML: reads 'reversible' key
- 4 new collector tests (reverse match, non-reversible, both-directions, API)
This commit is contained in:
Louis King committed 2026-07-12 22:39:15 +01:00
1 parent 14fbc45387
commit 0e202b3999
12 files changed
+216 -16

No files matched your search

@@ -0,0 +1,37 @@
"""add reversible column to routes
Revision ID: a1b2c3d4e5f6
Revises: 8f2a3c4d5e6f
Create Date: 2026-07-13 01:00:00.000000+00:00
Adds a ``reversible`` boolean to the ``routes`` table (default true).
When true, the matching engine also checks the reverse-ordered path,
so A->B->C matches packets observed as C->B->A.
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "a1b2c3d4e5f6"
down_revision: Union[str, None] = "8f2a3c4d5e6f"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.add_column(
"routes",
sa.Column(
"reversible",
sa.Boolean(),
nullable=False,
server_default=sa.text("1"),
),
)
def downgrade() -> None:
op.drop_column("routes", "reversible")