fix(kvb-org-organize): count only real git markers in the council gate
An empty /tmp/.git (2026-11-11 19:47, owner unknown) made council.py gate treat all of /tmp as a git worktree: every unclaimed Edit or Write under /tmp was blocked and test_council turned every skills gate red. A parent now counts only when its .git is a directory holding HEAD or a regular file starting with gitdir:, as git itself requires, so normal repos, linked worktrees and submodules still block unclaimed edits. A FIFO named .git is never opened, so it cannot hang the hook. Root fix proposed by the chair Main. 🎯 Fix: 94 % 💥 Break: 3 % 💸 Cost: 100 % ⏱️ Time: 100 % 🛡️ Security: 100 % 🏆 Score: 91 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ab13b6e65
commit
9f598a56ab
2 files changed
+38
-6
No files matched your search
@@ -11,7 +11,9 @@ Environment:
|
||||
Exit codes:
|
||||
0 done, 2 usage error, 3 office held by a live session,
|
||||
4 office held by a dead session (take it over with `takeover`),
|
||||
gate: 2 blocks the tool call.
|
||||
gate: 2 blocks the tool call: an edit without a claim of this session
|
||||
below a directory whose .git is a directory holding HEAD or a file
|
||||
starting with gitdir:.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -284,8 +286,21 @@ def cmd_list(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def is_git_marker(marker: Path) -> bool:
|
||||
if marker.is_dir():
|
||||
return (marker / "HEAD").is_file()
|
||||
# is_file() first: opening a planted FIFO named .git would hang this hook.
|
||||
if not marker.is_file():
|
||||
return False
|
||||
try:
|
||||
with marker.open("rb") as handle:
|
||||
return handle.read(7) == b"gitdir:"
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def in_git_worktree(target: Path) -> bool:
|
||||
return any((path / ".git").exists() for path in (target, *target.parents))
|
||||
return any(is_git_marker(path / ".git") for path in (target, *target.parents))
|
||||
|
||||
|
||||
def cmd_gate(_: argparse.Namespace) -> int:
|
||||
|
||||
Reference in new issue
Block a user