From 0fe645825459c61e330b1e84d0d93b5cac60e85a Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sat, 11 Jul 2026 15:03:32 +0200 Subject: [PATCH] fix(config): post-checkout resolves pql --vault to the worktree, not main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pql finds the vault by walking up for a .git *directory*; a linked worktree's .git is a *file*, so a bare `pql plan rebuild` from a fresh worktree resolved to the MAIN checkout and left the worktree's own pql.db empty — breaking ticket/decision reads inside worktrees (hit during the Layer-5 batch; agents had to rebuild by hand). Pass --vault "$(git rev-parse --show-toplevel)": the worktree root in a worktree, the repo root on main (no-op there). Upstream pql bug filed as FR-4. Co-Authored-By: Claude Fable 5 --- .config/hooks/post-checkout | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.config/hooks/post-checkout b/.config/hooks/post-checkout index a637ad9c6..660157cd2 100755 --- a/.config/hooks/post-checkout +++ b/.config/hooks/post-checkout @@ -16,6 +16,17 @@ # rows mid-checkout — those could otherwise leak onto the wrong branch when a later # switch rebuilds by replaying the working-tree changelog. if [ "${3:-0}" = "1" ] && [ "$1" != "$2" ] && command -v pql >/dev/null 2>&1; then - pql plan rebuild >/dev/null 2>&1 || true - pql decisions sync >/dev/null 2>&1 || true + # Resolve the vault to THIS checkout explicitly. pql otherwise finds the vault + # by walking up for a `.git` *directory* — but a linked worktree's `.git` is a + # *file*, so a bare `pql` invoked from a worktree resolves to the MAIN checkout + # and rebuilds main's pql.db, leaving the worktree's own empty (the symptom that + # broke ticket/decision reads inside worktrees). `git rev-parse --show-toplevel` + # returns this worktree's root; on the main checkout it is the repo root, so + # this is a no-op there and a correctness fix in worktrees. (Upstream pql bug — + # ~/Projects/pql/feature-request.md FR-4; drop the --vault once it lands.) + vault="$(git rev-parse --show-toplevel 2>/dev/null)" + if [ -n "$vault" ]; then + pql --vault "$vault" plan rebuild >/dev/null 2>&1 || true + pql --vault "$vault" decisions sync >/dev/null 2>&1 || true + fi fi