Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .abacus.donotdelete

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/python-validator-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:

- name: Run validator unit tests (PowerShell)
shell: pwsh
run: powershell -NoProfile -ExecutionPolicy Bypass -File "tests/run_python_tests.ps1"
run: powershell -NoProfile -ExecutionPolicy Bypass -File "backend/migration/tests/run_python_tests.ps1"
10 changes: 5 additions & 5 deletions .github/workflows/quality-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: make health

- name: Evals — Tier P (offline validator scenarios)
run: python3 evals/runner.py --tiers p --verbose
run: python3 backend/migration/evals/runner.py --tiers p --verbose

# Full integration surface: Tier I deploys env_dev.sql twice (idempotency),
# Tier S runs the 85-assertion SQL suite, then the PG-gated pytest tiers run.
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:

- name: Write CI database config
run: |
cat > build/config.local.env <<'EOF'
cat > backend/migration/build/config.local.env <<'EOF'
DB_ENGINE="postgresql"
PG_HOST="localhost"
PG_PORT="5432"
Expand All @@ -100,10 +100,10 @@ jobs:
done

- name: Evals — Tiers P, I, S
run: python3 evals/runner.py --tiers p,i,s --verbose
run: python3 backend/migration/evals/runner.py --tiers p,i,s --verbose

- name: Deploy test environment (for cross-env parity)
run: psql -v ON_ERROR_STOP=1 -f build/environments/env_test.sql
run: psql -v ON_ERROR_STOP=1 -f backend/migration/build/environments/env_test.sql

- name: Integration / e2e / parity tests
run: pytest -m "e2e or integration or parity" tests/ -v
run: pytest -m "e2e or integration or parity" backend/migration/tests/ -v
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ pg_dump_*
test_output/
*.out
*.log
# Migration engine runtime artifacts (relocated under backend/migration/)
csv/logs/
evals/reports/
backend/migration/build/csv/logs/
backend/migration/evals/reports/
*_report_*.txt
*_skipped_*.csv
*_valid_*.csv
Expand Down Expand Up @@ -48,7 +51,34 @@ terraform-github-repos/*.tfstate.*
terraform-github-repos/crash.log
.abacusai/

# --- MEP v2 (Migration Evaluation Platform) ---
# Node / React frontend
node_modules/
frontend/node_modules/
frontend/build/
frontend/dist/
frontend/.next/
npm-debug.log*
yarn-error.log*
# Python bytecode / virtualenvs
__pycache__/
*.py[cod]
.env
.env.*
# CSV upload staging (keep the directory, ignore its contents)
uploads/*
!uploads/.gitkeep
reports/
*.db
test_*.db

# Terraform plan artifacts (binary, environment-specific, never commit)
*.tfplan
tfplan
.terraform.lock.hcl
docs/Phase0-Setup-Manual.docx
docs/Phase0-Setup-Manual.pdf
*.docx
*.pdf
# .github/workflows/ci.yml — parked at docs/ci/ci.yml.pending (GitHub App lacks workflows permission)
backend/uploads/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
88 changes: 36 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,96 +1,80 @@
.PHONY: test-free test-gate test-evals test-e2e test-all \
lint lint-diff health \
eval-list eval-compare eval-summary select-tests \
csv-load csv-list csv-demo
csv-load csv-list csv-demo \
test-mep

# ── Test tiers ────────────────────────────────────────────────────────────────
# Path prefix for the relocated original engine
ENGINE := backend/migration

# ── Test tiers (original engine) ──────────────────────────────────────────────

# Free: unit + regression + security + snapshot — no database, no network.
# Mirrors: bun test (free tier in gstack)
test-free:
pytest -m "unit or regression or security or snapshot" tests/ -v
pytest -m "unit or regression or security or snapshot" $(ENGINE)/tests/ -v

# Gate: everything in test-free + coverage report. CI default, blocks merge.
# Mirrors: bun run test:gate
test-gate:
pytest -m "unit or regression or security or snapshot" tests/ \
--cov=build/csv --cov=evals --cov-report=term-missing
pytest -m "unit or regression or security or snapshot" $(ENGINE)/tests/ \
--cov=$(ENGINE)/build/csv --cov=$(ENGINE)/evals --cov-report=term-missing

# Evals: Tier P (offline) + Tier I/S (skip cleanly if no PostgreSQL).
# Mirrors: bun run test:evals
test-evals:
python3 evals/runner.py --tiers p,i,s --verbose
python3 $(ENGINE)/evals/runner.py --tiers p,i,s --verbose

# E2E: full pipeline tests that require a running PostgreSQL instance.
# Mirrors: bun run test:e2e
test-e2e:
pytest -m "e2e or integration or parity" tests/ -v
pytest -m "e2e or integration or parity" $(ENGINE)/tests/ -v

# All: every test tier including evals.
# Mirrors: bun run test:evals:all
test-all:
pytest tests/ --cov=build/csv --cov=evals --cov-report=term-missing
python3 evals/runner.py --tiers p,i,s --verbose
pytest $(ENGINE)/tests/ --cov=$(ENGINE)/build/csv --cov=$(ENGINE)/evals --cov-report=term-missing
python3 $(ENGINE)/evals/runner.py --tiers p,i,s --verbose

# ── MEP backend tests ────────────────────────────────────────────────────────

test-mep:
pytest backend/tests/ -v

# ── Code quality ──────────────────────────────────────────────────────────────

# Full flake8 + bandit scan over all Python source.
# Mirrors: bun run slop
lint:
bash scripts/lint.sh
bash scripts/lint.sh

# Lint only Python files changed on this branch vs origin/main.
# Mirrors: bun run slop:diff
lint-diff:
bash scripts/lint_diff.sh
bash scripts/lint_diff.sh

# ── Health & eval tooling ─────────────────────────────────────────────────────

# Component health dashboard — walks every expected file and reports PASS/FAIL.
# Mirrors: bun run skill:check
health:
python3 scripts/health_check.py
python3 scripts/health_check.py

# List all past eval runs.
# Mirrors: bun run eval:list
eval-list:
python3 scripts/eval_list.py
python3 scripts/eval_list.py

# Compare two eval runs side-by-side (auto-picks the two most recent).
# Mirrors: bun run eval:compare
eval-compare:
python3 scripts/eval_compare.py
python3 scripts/eval_compare.py

# Aggregate pass/fail/skip stats across all stored eval runs.
# Mirrors: bun run eval:summary
eval-summary:
python3 scripts/eval_summary.py
python3 scripts/eval_summary.py

# Show which pytest tests would run given the current git diff.
# Mirrors: bun run eval:select
select-tests:
python3 scripts/select_tests.py
python3 scripts/select_tests.py

# ── CSV loader / utiliser ─────────────────────────────────────────────────────

# Load any CSV file into the target environment's database.
# Usage: make csv-load FILE=path/to.csv [ENV=dev] [ENGINE=postgresql]
csv-load:
@if [ -z "$(FILE)" ]; then \
echo "Usage: make csv-load FILE=path/to.csv [ENV=dev] [ENGINE=postgresql]"; \
exit 1; \
fi
bash build/csv_loader.sh "$(FILE)" --env $(or $(ENV),dev) $(if $(ENGINE),--engine $(ENGINE),)

# List CSV-loaded tables in the target environment.
# Usage: make csv-list [ENV=dev]
@if [ -z "$(FILE)" ]; then \
echo "Usage: make csv-load FILE=path/to.csv [ENV=dev] [ENGINE=postgresql]"; \
exit 1; \
fi
bash $(ENGINE)/build/csv_loader.sh "$(FILE)" --env $(or $(ENV),dev) $(if $(ENGINE_ARG),--engine $(ENGINE_ARG),)

csv-list:
bash build/csv_utilise.sh list --env $(or $(ENV),dev)
bash $(ENGINE)/build/csv_utilise.sh list --env $(or $(ENV),dev)

# One-shot proof: load the three sample CSVs into dev, then list them.
# Usage: make csv-demo [ENV=dev]
csv-demo:
bash build/csv_loader.sh build/csv/samples/customers.csv --env $(or $(ENV),dev)
bash build/csv_loader.sh build/csv/samples/orders.csv --env $(or $(ENV),dev)
bash build/csv_loader.sh build/csv/samples/inventory.csv --env $(or $(ENV),dev)
bash build/csv_utilise.sh list --env $(or $(ENV),dev)
bash $(ENGINE)/build/csv_loader.sh $(ENGINE)/build/csv/samples/customers.csv --env $(or $(ENV),dev)
bash $(ENGINE)/build/csv_loader.sh $(ENGINE)/build/csv/samples/orders.csv --env $(or $(ENV),dev)
bash $(ENGINE)/build/csv_loader.sh $(ENGINE)/build/csv/samples/inventory.csv --env $(or $(ENV),dev)
bash $(ENGINE)/build/csv_utilise.sh list --env $(or $(ENV),dev)
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
# T&E Database Framework
# Migration Evaluation Platform (MEP) v2

> **MEP** is a web application that wraps the existing CSV → PostgreSQL migration engine
> with a **React frontend** and a **FastAPI backend**, turning a powerful CLI/script-based
> tool into an interactive platform for **uploading CSV files, running migrations, and
> evaluating migration quality** (completeness, integrity, business-rule conformance, and
> reconciliation reporting).

[![Status](https://img.shields.io/badge/MEP-v2%20(in%20development)-blueviolet)](#)
[![Backend](https://img.shields.io/badge/Backend-FastAPI-009688?logo=fastapi&logoColor=white)](#)
[![Frontend](https://img.shields.io/badge/Frontend-React-61DAFB?logo=react&logoColor=white)](#)
[![Engine](https://img.shields.io/badge/Engine-CSV%20%E2%86%92%20PostgreSQL-336791?logo=postgresql&logoColor=white)](backend/migration/)

## What MEP Is

The **Migration Evaluation Platform** does not replace the proven migration engine — it
**wraps** it. The original, battle-tested SQL-first framework and CSV → PostgreSQL
loader/validator pipeline now lives, unchanged, at **[`backend/migration/`](backend/migration/)**.
The FastAPI backend shells out to / orchestrates that engine rather than reimplementing it,
and a React frontend provides a UI for the full migrate-and-evaluate workflow.

### Repository layout (MEP v2)

```
PostgreDataMigrationApp/
├── backend/
│ ├── api/ FastAPI routes (HTTP layer)
│ ├── services/ Business logic
│ ├── migration/ ← ORIGINAL migration engine (build/ evals/ infra/ tests/), preserved
│ ├── evaluation/ Migration-quality evaluation logic
│ ├── reports/ Reconciliation / evaluation report generation
│ └── database/ MEP metadata models (MigrationRun, UploadedFile, ...)
├── frontend/ React app
├── docker/ Dockerfiles / compose
├── docs/ Documentation
├── uploads/ CSV upload staging
└── .github/ CI workflows
```

> **Original engine:** everything that shipped before MEP — the multi-engine database
> framework, the CSV pipeline, the 23 eval scenarios, the 85 SQL assertions, and the Azure
> IaC — is preserved verbatim under **[`backend/migration/`](backend/migration/README.md)**.
> The documentation below describes that original engine.

---

# T&E Database Framework (original engine — now under `backend/migration/`)

> A fully parameterised, idempotent **PostgreSQL database framework** for **Test & Evaluation (T&E)** programme management — covering TEMP documents, VCRM traceability, test execution, defect reporting, and multi-environment deployment, with a built-in SQL test suite.

Expand Down
Loading
Loading