fix(config): post-checkout resolves pql --vault to the worktree, not main

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 <noreply@anthropic.com>
This commit is contained in:
2026-07-11 15:03:32 +02:00
co-authored by Claude Fable 5
parent 2bc590c1ba
commit 0fe6458254
+13 -2
View File
@@ -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