From f8d9b777b0d21c0d01355f8feee7c1a9dcb12953 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sat, 6 Jun 2026 21:05:31 +0200 Subject: [PATCH] =?UTF-8?q?fix(config):=20address=20PR=20#154=20review=20?= =?UTF-8?q?=E2=80=94=20gitattributes=20glob=20+=20script=20roots?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tyre (architecture review): - .gitattributes: `.pql/changelog/*.sql` matched nothing (files are one level deeper at .pql/changelog//.sql), so the union-merge driver never applied — `git check-attr merge` returned `unspecified`. Fixed to `.pql/changelog/**/*.sql`; now resolves to `merge: union` for monthly + schema files. Restores the changelog's conflict-free merge guarantee. - Migration scripts: the re-runnable ones (seed_tickets.py, add_workshop_provenance.py) now derive the repo root from `git rev-parse --show-toplevel` instead of a hardcoded /main path, so re-running from a worktree/clone targets the right checkout. The three one-shot transforms (restructure_decisions, repath_references, retag_ticket_refs) get a comment noting they're already-applied and unsafe to re-run (git mv on moved sources) — keeping the path honest rather than implying re-runnability. Hoshe approved (all QA checks passed). ruff clean. Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitattributes | 2 +- tooling/pql-migrate/add_workshop_provenance.py | 6 ++++-- tooling/pql-migrate/repath_references.py | 3 +++ tooling/pql-migrate/restructure_decisions.py | 3 +++ tooling/pql-migrate/retag_ticket_refs.py | 2 ++ tooling/pql-migrate/seed_tickets.py | 5 ++++- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index 788efb114..e2f87f6dc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -.pql/changelog/*.sql merge=union +.pql/changelog/**/*.sql merge=union diff --git a/tooling/pql-migrate/add_workshop_provenance.py b/tooling/pql-migrate/add_workshop_provenance.py index 08ace0afa..ed2cec083 100644 --- a/tooling/pql-migrate/add_workshop_provenance.py +++ b/tooling/pql-migrate/add_workshop_provenance.py @@ -16,10 +16,12 @@ import glob import os import re import sqlite3 +import subprocess import sys APPLY = "--apply" in sys.argv -REPO = "/var/mnt/data/projects/settled-reach/main" +# Derive the repo root from git so the script targets the checkout it's run from. +REPO = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip() DB = f"{REPO}/.pql/pql.db" D_IDS = set(r[0] for r in sqlite3.connect(DB).execute( @@ -48,7 +50,7 @@ def main(): text = open(f, encoding="utf-8").read() fm, body = split_frontmatter(text) refs = refs_in(body if fm is not None else text) - rel = f.split("/main/", 1)[-1] + rel = os.path.relpath(f, REPO) wname = os.path.basename(os.path.dirname(f)) refs_yaml = "[" + ", ".join(refs) + "]" diff --git a/tooling/pql-migrate/repath_references.py b/tooling/pql-migrate/repath_references.py index 6c937957f..870efc688 100644 --- a/tooling/pql-migrate/repath_references.py +++ b/tooling/pql-migrate/repath_references.py @@ -35,6 +35,9 @@ REPLACEMENTS = [ (re.compile(r"(? governance/). The +# absolute paths below are the canonical main checkout where it was run; kept +# committed for provenance. TARGETS = sorted(set( glob.glob("/var/mnt/data/projects/settled-reach/main/.claude/agents/*.md") + glob.glob("/var/mnt/data/projects/settled-reach/main/.claude/skills/**/*.md", recursive=True) diff --git a/tooling/pql-migrate/restructure_decisions.py b/tooling/pql-migrate/restructure_decisions.py index d6844b50b..8849a909b 100644 --- a/tooling/pql-migrate/restructure_decisions.py +++ b/tooling/pql-migrate/restructure_decisions.py @@ -17,6 +17,9 @@ import subprocess import sys from pathlib import Path +# One-shot transform, already applied (decisions/ -> governance/). Re-running is +# unsupported: the git mv calls would fail on already-moved sources. The path below +# is the canonical main checkout where it was run; kept committed for provenance. ROOT = Path("/var/mnt/data/projects/settled-reach/main") APPLY = "--apply" in sys.argv diff --git a/tooling/pql-migrate/retag_ticket_refs.py b/tooling/pql-migrate/retag_ticket_refs.py index 3b3a65ef9..5bc18cb28 100644 --- a/tooling/pql-migrate/retag_ticket_refs.py +++ b/tooling/pql-migrate/retag_ticket_refs.py @@ -23,6 +23,8 @@ import sqlite3 import sys APPLY = "--apply" in sys.argv +# One-shot transform, already applied (#N -> T-N). The path below is the canonical +# main checkout where it was run; kept committed for provenance. REPO = "/var/mnt/data/projects/settled-reach/main" SRC = os.environ.get("SR_DB_PATH", "/var/home/jeroenschweitzer/Projects/settled-reach/settledreach.db") diff --git a/tooling/pql-migrate/seed_tickets.py b/tooling/pql-migrate/seed_tickets.py index c41265912..bc2889759 100644 --- a/tooling/pql-migrate/seed_tickets.py +++ b/tooling/pql-migrate/seed_tickets.py @@ -25,10 +25,13 @@ import hashlib import os import re import sqlite3 +import subprocess import sys APPLY = "--apply" in sys.argv -REPO = "/var/mnt/data/projects/settled-reach/main" +# Derive the repo root from git so the script targets the checkout it's run from +# (a worktree, a fresh clone, or main) rather than a hardcoded path. +REPO = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip() SRC = os.environ.get("SR_DB_PATH", "/var/home/jeroenschweitzer/Projects/settled-reach/settledreach.db") DST = f"{REPO}/.pql/pql.db" SEED_TS = "2026-06-06 00:00:00" # well-formed stamp for rows the legacy schema didn't timestamp