feat: Replace PostgreSQL with embedded SQLite database #318
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.55) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.55 · 566 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.379
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #318"
general
weight: 0.35
amito
Description
Replace the external PostgreSQL dependency with Python's built-in
sqlite3module. The backend no longer requires a separate database server — benchmark data is stored in a local SQLite file(
PLANNER_DB_PATH, defaultdata/planner.db). This eliminates operational complexity and enables releasing the backend as a self-contained Python wheel.### What changed
New
db.pyconnection factory:-
create_connection(db_path)— creates a connection with WAL mode, busy timeout, and auto schema initialization- Per-instance pattern:
BenchmarkRepositoryowns its connection (no global singleton)-
find_project_root()resolves the default DB path relative to the project root, not cwdBenchmarkRepositoryAPI improvements (inspired by amito/llm-d-planner#3):-
from_files(json_paths)classmethod — construct a ready-to-use repository from JSON files-
replace_benchmarks(source, benchmarks)— delete-by-source + insert (used by Model Catalog sync)-
load_benchmarks(benchmarks, source, confidence_level)— append mode insert-
get_stats()/reset()— database management via public APISQL dialect migration:
-
%s→?,%(name)s→:name,ANY(%s)→IN (?, ?, ...)-
TRUNCATE CASCADE→DELETE FROM,execute_batch→executemany-
COUNT(DISTINCT (col1, col2))→ subquery- Window functions and
ON CONFLICT DO NOTHING— same syntax, supported by SQLiteModel Catalog sync:
-
sync_model_catalog()takes aBenchmarkRepositoryinstead of a raw connection- Uses
repo.replace_benchmarks("model_catalog", rows)instead of raw DELETE + executemany- Duplicate
_INSERT_COLUMNS/_INSERT_QUERYremoved (~60 lines)-
confidence_levelexplicitly set to"benchmarked"for catalog dataInfrastructure:
-
make db-resetusesDELETE FROM(safe while backend is running — no file replacement)-
make db-stop,make db-convert-pgdump,make test-dbremoved-
PLANNER_BENCHMARK_SOURCEdefault renamed"postgresql"→"database"- Docker Compose:
postgresservice removed- Kubernetes:
postgres.yamlanddb-init-job.yamldeleted, PVC added at/app/dbfor the database file (avoids shadowing the image'sdata/directory)-
postgresql-clientremoved from Dockerfile-
psycopg2-binaryremoved frompyproject.tomlTests:
-
@pytest.mark.databasemerged into unit tests (no external DB needed)-
conftest.pyusesBenchmarkRepository.from_files()with a temp SQLite file- Mock targets updated for per-instance pattern (no singleton management)
-
test_postgresql_integration.pyrenamed totest_benchmark_repository.pyKnown limitation: Single-instance only. If multi-replica with shared state is needed later, an external DB backend can be added — the DB surface area is contained in
knowledge_base/.### Key behavioral change
make db-resetnow clears data in-place (DELETE FROM) instead of deleting and recreating the file. This meansmake db-reset && make db-load-guidellmworks while the backend is running —the backend's connection remains valid because the file isn't replaced.
## How Has This Been Tested?
- 538 unit tests passing (
make test-unit)- 3 integration scenario tests passing (
test_recommendation_workflow.py— end-to-end recommendation generation with BLIS and GuideLLM benchmark data)-
make format/make lint/make typecheckall clean- Database workflow verified:
make db-reset && make db-load-blis && make db-query-traffic && make db-query-models- Zero remaining references:
grep -rn 'psycopg2\|DATABASE_URL' src/ scripts/ tests/ --include='.py'returns no hits- Manual testing: backend + UI started locally, recommendation requests submitted and verified
- OpenShift deployment tested: deployed to ephemeral namespace, verified Configuration tab, Define Use Case tab, and recommendation generation all work
- Model Catalog sync path verified:
PLANNER_BENCHMARK_SOURCE=model_catalogwith live cluster sync## Merge criteria:
- [x] The commits are squashed in a cohesive manner and have meaningful messages.
- [x] Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
- [x] The developer has manually tested the changes and verified that the changes work