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
Deny edits to tracked files in a main checkout on its default branch #16905
Owner, 2026-11-17: sessions started in a repository's main folder "all should be creating worktrees. Sometimes they don't." The shared agent instructions now say to create a worktree first (melodic-software/dotfiles#1642), but nothing enforces it: the guardrails hooks on Write, Edit and NotebookEdit check secrets, hardcoded paths, Windows temp paths and settings writes only, and the source-control hooks gate only where git worktree add puts a worktree (finding of the dotfiles#1641 session; re-verify with file:line).
Owner decision (Q19, "Go with recommendations."): build a guard.
Outcome
A guardrails PreToolUse hook on Write, Edit and NotebookEdit denies an edit to a tracked file when the target is in a repository's main checkout (its git dir equals its common dir) on the remote default branch, and the denial says how to create and enter a worktree by the repository's convention. It denies and never asks, because a background session cannot answer a prompt.
Open design choice (owner)
The exemptions. Candidates: git-ignored and untracked paths; paths outside a repository; repositories worked on their default branch by design (the chezmoi source, melodic-software/control-hub, a repository with no remote), and how a repository or a person declares that. Send the hub the list with a recommendation and its Basis before building. State the known limit in the docs: writes made through shell commands are not seen.
Done when
The owner's exemption choices are recorded here.
Tests cover a denied edit, each exemption, a linked worktree, a detached head and a non-default branch in the main checkout.
A live session shows the denial text and a session following it into a worktree.
Size: Medium
Complexity: Medium
Uncertainty: Knowable
Flags: intent
Blocked by: none
Blast radius: the guardrails plugin's PreToolUse hooks on Write, Edit and NotebookEdit, its tests and docs; every session that edits files in a repository's main checkout.
Reversible: yes; remove the hook registration or revert the change.
Open questions:
Which exemptions apply, and how does a repository or a person declare them? Candidates: untracked and git-ignored paths, paths outside a repository, repositories worked on their default branch by design (chezmoi source, control-hub, a repository with no remote).
RECOMMENDED: exempt untracked or git-ignored paths, paths outside any repository, and repositories with no remote default branch. For by-design default-branch repositories, use a per-repository opt-out (a git config key such as guardrails.allowDefaultBranchEdits=true, readable without prompting), with no per-person override. Basis: judgment; the issue states the denial must never ask, and a per-repository declaration keeps the choice with the repository.
Understood: add a deny-only hook that blocks edits to tracked files in a main checkout (git dir equals common dir) on the default branch, with denial text explaining how to create and enter a worktree. Docs should state that shell-command writes are not seen. The live-session done-when item is a host step and does not hold triage.
No open issue or merged PR duplicates this.
To answer, post a comment that starts with this line:
Not admitted to the issue lane: its done-when asks for what an unattended lane run cannot perform: item 1 (tracker-output: "The owner's exemption choices are recorded here."); recommended split: keep the other items here as the admissible issue and move these to a child issue for the host queue (host-run).
Owner decisions, 2026-11-17 ("for questions, go w/ recomendations", each question restated with its options): the guard also denies creating a new untracked file, with only git-ignored paths exempt; no per-repository opt-out key now; the design's other points as proposed (target resolved from the file path, default branch from refs/remotes/origin/HEAD, allow with a hint where that is unset, one per-person off switch, deny never ask); on by default for everyone who installs guardrails, with the release note saying an update adds a new denial and how to turn it off.
Live session, Claude Code 2.1.327, real setup with the branch's guardrails loaded, in a throwaway repository on its default branch (hub session, driven in tmux at the owner's request, 2026-11-17): an Edit of the tracked README.md was denied with the BLOCKED: text; asked to follow the denial, the session ran /source-control:worktree create, got a worktree on a new branch from origin/main, and made the edit there by absolute path without entering it. The main checkout stayed unchanged.
Follow-ups from pr-verify's notes are not part of this issue: the guardrails README intro still says "twenty safety guards" while the manifest says 25.
Activity
github-actions commentedon Nov 17, 2026
Size: Medium
Complexity: Medium
Uncertainty: Knowable
Flags: intent
Blocked by: none
Blast radius: the guardrails plugin's PreToolUse hooks on Write, Edit and NotebookEdit, its tests and docs; every session that edits files in a repository's main checkout.
Reversible: yes; remove the hook registration or revert the change.
Open questions:
RECOMMENDED: exempt untracked or git-ignored paths, paths outside any repository, and repositories with no remote default branch. For by-design default-branch repositories, use a per-repository opt-out (a git config key such as
guardrails.allowDefaultBranchEdits=true, readable without prompting), with no per-person override. Basis: judgment; the issue states the denial must never ask, and a per-repository declaration keeps the choice with the repository.Understood: add a deny-only hook that blocks edits to tracked files in a main checkout (git dir equals common dir) on the default branch, with denial text explaining how to create and enter a worktree. Docs should state that shell-command writes are not seen. The live-session done-when item is a host step and does not hold triage.
No open issue or merged PR duplicates this.
To answer, post a comment that starts with this line:
Automated triage. A maintainer reviews it.
melodic-automation-lanes commentedon Nov 17, 2026
The triage verdict left this issue at
needs-owner-decision:Reason:
intentmelodic-automation-lanes commentedon Nov 17, 2026
Not admitted to the issue lane: its done-when asks for what an unattended lane run cannot perform: item 1 (tracker-output: "The owner's exemption choices are recorded here."); recommended split: keep the other items here as the admissible issue and move these to a child issue for the host queue (
host-run).kyle-sexton commentedon Nov 17, 2026
Owner decisions, 2026-11-17 ("for questions, go w/ recomendations", each question restated with its options): the guard also denies creating a new untracked file, with only git-ignored paths exempt; no per-repository opt-out key now; the design's other points as proposed (target resolved from the file path, default branch from refs/remotes/origin/HEAD, allow with a hint where that is unset, one per-person off switch, deny never ask); on by default for everyone who installs guardrails, with the release note saying an update adds a new denial and how to turn it off.
docs(guardrails): name the main-checkout denial in the manifest
fix(guardrails): run git only in an owned repository, with command ke…
docs(guardrails): keep the manifest description under 500 characters
kyle-sexton commentedon Nov 18, 2026
Delivered by #16954 (merged). Done-when, each line:
BLOCKED:text; asked to follow the denial, the session ran/source-control:worktree create, got a worktree on a new branch fromorigin/main, and made the edit there by absolute path without entering it. The main checkout stayed unchanged.Follow-ups from pr-verify's notes are not part of this issue: the guardrails README intro still says "twenty safety guards" while the manifest says 25.