You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(locks): locks dir is cwd-relative while the hook reads the git toplevel — acquiring from a subdirectory silently protects nothing #909
the hook keeps reading <toplevel>/.sequant/locks/checkout.lock, sees no lock, and waves every session through
So the acquire silently succeeds while providing no protection at all, and locks list from the root reports nothing held. The same divergence applies to the per-issue locks (status, merge, resume, run-orchestrator all construct LockManager with no explicit dir).
Severity: moderate. Silent no-op rather than a wrong answer, but it defeats the feature exactly when someone works from a subdirectory — and nothing reports it.
Fix sketch
Resolve against the git toplevel, matching the hook:
with the cwd-relative form kept only as the fallback when git fails (not a repo). SEQUANT_LOCKS_DIR and the explicit option keep priority, since the tests depend on them.
Worth deciding at the same time whether a worktree should share the main checkout's locks dir. The checkout lock represents the main tree, so it should resolve to the main checkout even when called from a linked worktree — git rev-parse --path-format=absolute --git-common-dir gives that, where --show-toplevel does not.
Test plan
Acquire from a subdirectory; assert the lock file lands at <toplevel>/.sequant/locks/.
Acquire from a subdirectory, then run the real hook with cwd at the toplevel; assert it blocks (today it does not).
Acquire from a linked worktree; assert the intended target (see the open question above) once decided.
#909 — fix(locks): locks dir is cwd-relative while the hook reads the git toplevel — acquiring from a subdirectory silently protects nothing
Open · bug
────────────────────────────────────────────────────────────────
→ PROCEED — Divergence confirmed on main at 5a68930 — resolveLocksDir uses resolve(".sequant/locks"), pre-tool.sh:563 uses git --show-toplevel
Commands:
sequant run 909 -Q # after 908 lands
spec → exec → qa
Flags:
-Q path resolution changes every LockManager construction site (status, merge, resume, run-orchestrator) plus a worktree semantics decision
Considered:
--testgen bug-only label; testgen skips bug/fix issues even though the body carries a Test plan
--security-review no security/auth label — path resolution, not authz
────────────────────────────────────────────────────────────────
⚠ Body has zero - [ ] checkboxes — spec must derive ACs from the Fix sketch / Test plan; --strict-preflight would hard-stop this issue
⚠ Body carries an unresolved design question — should a linked worktree share the main checkout's locks dir? It proposes git rev-parse --path-format=absolute --git-common-dir. Decide this in spec, before exec; the third test-plan bullet is blocked on the answer
⚠ Order: land after 908 — both edit src/lib/locks/lock-manager.ts, and this resolveLocksDir change is the smaller of the two to rebase
────────────────────────────────────────────────────────────────
AC-1: resolveLocksDir resolves against the shared git checkout root, not process.cwd()
AC-2: A linked worktree resolves to the main checkout's locks directory, not its own
AC-3: Non-git cwd falls back to today's cwd-relative behavior
AC-4: SEQUANT_LOCKS_DIR and the explicit locksDir option keep top priority over git-derived resolution
Implementation Plan
Add a git rev-parse --path-format=absolute --git-common-dir helper in src/lib/locks/lock-manager.ts, resolving to the parent directory (shared checkout root across main + worktrees), with a swallowed-error fallback to today's cwd-relative resolution.
Update resolveLocksDir to use it as the new default (below explicit/SEQUANT_LOCKS_DIR, above plain cwd fallback).
No call-site changes needed — LockManager/CheckoutLock construction is the single choke point.
Add unit tests (subdirectory resolution, non-git fallback) and one integration test (linked worktree resolves to the same path as the main checkout).
Key Decision
Resolves the issue's open question in favor of sharing the locks directory between the main checkout and its linked worktrees (via --git-common-dir), rather than giving each worktree its own. This matches the intent of both lock types: the checkout lock represents "the tree," and the per-issue lock exists specifically to catch collisions across concurrent sessions — including sessions that are each in a different worktree of the same repo.
Workflow
Phases: spec → exec → qa (no /test — backend-only; no /testgen — targeted tests sufficient for a bug-labeled single-function fix)
Build/Lint/Tests: all clean (211 tests passed across affected modules)
QA: All checks passed (type safety, deleted-tests, scope/size, security — all PASS)
Fix mutation-verified: reverting resolveLocksDir to pre-fix behavior makes the new AC-1/AC-2 tests fail exactly as expected
Root cause & fix
resolveLocksDir resolved .sequant/locks against process.cwd(), while pre-tool.sh's checkout guard reads it from the git toplevel — the two only agreed when the CLI ran from the repo root. Fixed via git rev-parse --path-format=absolute --git-common-dir, which also unifies a linked worktree with the main checkout's locks dir (a deliberate improvement over the issue's own --show-toplevel fix sketch, documented in the CHANGELOG entry). No call-site changes needed — every consumer already routes through this one function.
Iterations
Spec: 1 (no iteration needed)
Exec: 1 (no iteration needed)
Test: skipped (no UI labels — backend-only fix)
QA: 1 (no iteration needed, READY_FOR_MERGE on first pass)
Companion follow-up parked hereMoved to #919 — #909 was already in flight in another session, so the #908 steal-restore residual is tracked as its own issue instead. Nothing here is in #909's scope.
Activity
admarble commentedon Aug 7, 2026
#909 — fix(locks): locks dir is cwd-relative while the hook reads the git toplevel — acquiring from a subdirectory silently protects nothing
Open · bug
────────────────────────────────────────────────────────────────
→ PROCEED — Divergence confirmed on main at 5a68930 — resolveLocksDir uses resolve(".sequant/locks"), pre-tool.sh:563 uses git --show-toplevel
Commands:
sequant run 909 -Q # after 908 lands
spec → exec → qa
Flags:
-Q path resolution changes every LockManager construction site (status, merge, resume, run-orchestrator) plus a worktree semantics decision
Considered:
--testgen bug-only label; testgen skips bug/fix issues even though the body carries a Test plan
--security-review no security/auth label — path resolution, not authz
────────────────────────────────────────────────────────────────
⚠ Body has zero
- [ ]checkboxes — spec must derive ACs from the Fix sketch / Test plan; --strict-preflight would hard-stop this issue⚠ Body carries an unresolved design question — should a linked worktree share the main checkout's locks dir? It proposes
git rev-parse --path-format=absolute --git-common-dir. Decide this in spec, before exec; the third test-plan bullet is blocked on the answer⚠ Order: land after 908 — both edit src/lib/locks/lock-manager.ts, and this resolveLocksDir change is the smaller of the two to rebase
────────────────────────────────────────────────────────────────
admarble commentedon Aug 8, 2026
Plan Complete
AC Checklist
resolveLocksDirresolves against the shared git checkout root, notprocess.cwd()SEQUANT_LOCKS_DIRand the explicitlocksDiroption keep top priority over git-derived resolutionImplementation Plan
git rev-parse --path-format=absolute --git-common-dirhelper insrc/lib/locks/lock-manager.ts, resolving to the parent directory (shared checkout root across main + worktrees), with a swallowed-error fallback to today's cwd-relative resolution.resolveLocksDirto use it as the new default (below explicit/SEQUANT_LOCKS_DIR, above plain cwd fallback).LockManager/CheckoutLockconstruction is the single choke point.Key Decision
Resolves the issue's open question in favor of sharing the locks directory between the main checkout and its linked worktrees (via
--git-common-dir), rather than giving each worktree its own. This matches the intent of both lock types: the checkout lock represents "the tree," and the per-issue lock exists specifically to catch collisions across concurrent sessions — including sessions that are each in a different worktree of the same repo.Workflow
Phases: spec → exec → qa (no
/test— backend-only; no/testgen— targeted tests sufficient for abug-labeled single-function fix)admarble commentedon Aug 8, 2026
/fullsolve Complete
Issue: #909
Status: READY_FOR_MERGE
Summary
resolveLocksDirto pre-fix behavior makes the new AC-1/AC-2 tests fail exactly as expectedRoot cause & fix
resolveLocksDirresolved.sequant/locksagainstprocess.cwd(), whilepre-tool.sh's checkout guard reads it from the git toplevel — the two only agreed when the CLI ran from the repo root. Fixed viagit rev-parse --path-format=absolute --git-common-dir, which also unifies a linked worktree with the main checkout's locks dir (a deliberate improvement over the issue's own--show-toplevelfix sketch, documented in the CHANGELOG entry). No call-site changes needed — every consumer already routes through this one function.Iterations
PR: #918
Commit:
ee35fd085e9531d6049268af02334c286b64a4e7Ready for human review and merge.
admarble commentedon Aug 8, 2026
Companion follow-up parked hereMoved to #919 — #909 was already in flight in another session, so the #908 steal-restore residual is tracked as its own issue instead. Nothing here is in #909's scope.fix(#909): close QA gaps -- old-git robustness, end-to-end hook proof…
fix(#909): resolveLocksDir resolves against the shared git checkout r…