Files
Metamorph/backend
Knacky b8fd99a5f4 feat(m5): test_template + scenario_template CRUD with MITRE tags and ordered tests
- Service `app/services/test_templates.py`: CRUD with MITRE tag resolution
  (kind, external_id) → polymorphic join, filters by tactic/technique/
  subtechnique/opsec/tag, `_UNSET` sentinel for partial-update semantics.
- Service `app/services/scenario_templates.py`: ordered test list, reorder
  via full-replace (atomic w.r.t. UNIQUE(position) constraint), soft-delete.
- REST endpoints on /api/v1/test-templates and /scenario-templates with
  pydantic schemas + perm gating (test_template.* and scenario_template.*).
- /diag/reset truncates the 4 new tables before MITRE (FK ordering).
- 19 pytest covering CRUD, MITRE tag merge, soft-delete chaining, perm
  enforcement, and reorder atomicity.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 19:57:33 +02:00
..

Metamorph backend

Flask 3 API. See repo root README.md for the big picture.

Layout

app/
├── api/        # HTTP layer (blueprints), versioned under /api/v1
├── core/       # config (env-driven), structured logging
├── db/         # SQLAlchemy session + Alembic (M1+)
├── models/     # ORM models (M1+)
├── services/   # domain logic (M2+)
└── i18n/       # message catalogs (M13)
tests/          # pytest

Local dev

Requires uv and a reachable Postgres (M1+; not needed yet for /health).

uv sync                                            # install deps from pyproject.toml
uv run flask --app app.main run --debug --port 8000
curl http://localhost:8000/api/v1/health

Tests

uv run pytest

Lint

uv run ruff check .
uv run ruff format .