fix(meta): address PR #155 review — DEVOPS layout + common.py cleanup
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) <noreply@anthropic.com>
This commit is contained in:
+3
-2
@@ -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).
|
||||
|
||||
+7
-37
@@ -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 <worktree-parent>/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::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user