From ccc194d5f95c3a0b534fdabe6b9169d819699c77 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sat, 6 Jun 2026 23:06:39 +0200 Subject: [PATCH] =?UTF-8?q?fix(meta):=20address=20PR=20#155=20review=20?= =?UTF-8?q?=E2=80=94=20DEVOPS=20layout=20+=20common.py=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hoshe (QA): docs/DEVOPS.md Repository Layout still listed `decisions/` — corrected to `governance/` (the DQR tree) and added a `.pql/` entry for the planning store. Tyre (architecture, non-blocking): tooling/db/common.py docstring named deleted scripts as consumers and `resolve_db_path`/`load_config`/`get_connection` were dead settledreach.db code. Trimmed common.py to just `ensure_venv` (the only symbol any kept connector imports) and rewrote the docstring to name the real consumers. ruff clean; common.py parses; ensure_venv intact. Co-Authored-By: Claude Opus 4.8 (1M context) --- docs/DEVOPS.md | 5 +++-- tooling/db/common.py | 44 +++++++------------------------------------- 2 files changed, 10 insertions(+), 39 deletions(-) diff --git a/docs/DEVOPS.md b/docs/DEVOPS.md index a2566cd5f..7579f3639 100644 --- a/docs/DEVOPS.md +++ b/docs/DEVOPS.md @@ -16,11 +16,12 @@ client/ Godot 4 client (GDScript, scenes, assets) server/ Rust/bevy_ecs simulation server tooling/ Build tools, scripts, asset pipelines tests/ Integration and end-to-end tests (cross-boundary) -decisions/ Decision domain files (source of truth for all D/Q/R entries) +governance/ Decision records — decisions/ questions/ rejected/ per domain (pql DQR tree) +.pql/ pql planning store — git-tracked changelog/ + config.yaml (pql.db is rebuildable) .config/ Configuration files (linters, formatters, CI) .cache/ Local caches for testing/linting (gitignored) docs/ Design, architecture, briefings, workshops -db/ SQLite schema + seed data (connectors at tooling/db/) +db/ Schema + seed data (asset connectors at tooling/db/) ``` Unit tests live inside their respective projects (`server/` uses `#[cfg(test)]` inline + `tests/` directory per D-030). The top-level `tests/` directory is for integration tests that cross the client-server boundary (IPC round-trip, serialization fixtures, divergence tests). diff --git a/tooling/db/common.py b/tooling/db/common.py index 707c10494..98bc308f4 100644 --- a/tooling/db/common.py +++ b/tooling/db/common.py @@ -1,13 +1,14 @@ #!/usr/bin/env python3 -"""Shared utilities for Settled Reach DB tooling scripts. +"""Shared utilities for Settled Reach asset/connector scripts. -Provides the standard DB path resolution, config loading, and connection -helpers used across ticket, sprint, sqlite_connector, and decisions_sync. +Provides `ensure_venv`, used by the asset connectors (audio_connector, +audio_batch, image_connector, trellis_connector) to re-exec into the project +.venv before their third-party imports. The former settledreach.db connection +helpers were removed when the ticket/decision tooling was retired (pql migration +Phase 6); planning now lives in pql (`.pql/`). """ -import json import os -import sqlite3 import sys from pathlib import Path @@ -16,7 +17,6 @@ from pathlib import Path # --------------------------------------------------------------------------- SCRIPT_DIR = Path(__file__).resolve().parent -CONFIG_PATH = SCRIPT_DIR / "config.json" WORKTREE_ROOT = (SCRIPT_DIR / ".." / "..").resolve() @@ -25,41 +25,11 @@ WORKTREE_ROOT = (SCRIPT_DIR / ".." / "..").resolve() # --------------------------------------------------------------------------- -def resolve_db_path() -> Path: - """Return the ticket database path. - - Prefers the SR_DB_PATH environment variable (absolute path). - Falls back to /settledreach.db — the shared DB location - used when working directly in the main repo checkout. - """ - if os.environ.get("SR_DB_PATH"): - return Path(os.environ["SR_DB_PATH"]).resolve() - return (WORKTREE_ROOT / ".." / "settledreach.db").resolve() - - -def load_config() -> dict: - """Load tooling/db/config.json and inject the resolved DB path.""" - with open(CONFIG_PATH) as f: - cfg = json.load(f) - cfg["sqlite_db_resolved"] = str(resolve_db_path()) - return cfg - - -def get_connection(cfg: dict) -> sqlite3.Connection: - """Return a WAL-mode SQLite connection with foreign keys enabled.""" - conn = sqlite3.connect(cfg["sqlite_db_resolved"]) - conn.execute("PRAGMA journal_mode=WAL;") - conn.execute("PRAGMA foreign_keys=ON;") - conn.row_factory = sqlite3.Row - return conn - - def ensure_venv() -> None: """Re-exec into the project .venv Python if not already running there. Call this at the top of any script that uses third-party packages, - before those imports. Pure-stdlib scripts (ticket, sprint, - sqlite_connector, decisions_sync) do not need it. + before those imports. Usage::