Recognise a protected repository by its origin, and fail loudly on a misplaced checkout #235
No reviewers
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/tools!235
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/rails-remote-identity"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Owner summary
originnames, not only by where it is checked out. Checked out in the wrong place,allod change beginandallod change recordrefuse (exit 8) and the git hook blocks commits, pushes, rebases and merges on the protected branch; each message names the expected and the actual path.agent/*branches in worktrees is not blocked.allod changesuite (270) and the Go tests pass, and the hook suite goes red when the remote match is disabled.allod/archetypes, so nothing changes anywhere until that input is bumped and home-manager rebuilds. After the rebuild, confirm by hand: a commit onmasterfrom a worktree of a protected repo is blocked, and a commit on anagent/*branch there goes through.allod/archetypesbump. The forge still rejects an agent's push to a protected branch whatever the local rails do.Closes allod/tools#112
What was decided
The rule lives twice, held together by one table. The tool is Go and the hook is a single bash file that
allod/archetypescopies alone to~/.config/git/. Of the three packaging options the issue thread lists, this takes accepted duplication: no change inallod/archetypes, no second deployed file, and no dependency of the hook on theallodbinary.tests/fixtures/protection-cases.tsvis read bycmd/allod/protection_test.goand bytests/git-hooks/protected-refs-policy.sh, so the two cannot drift without a red test.The rule. The lookup key is the repository a checkout belongs to: for a linked worktree the main repository, otherwise the checkout itself (which is also right for a submodule and for
--separate-git-dir). An entry whose path equals that key answers first. Failing that,owner/repois taken fromgit remote get-url origin, and an entry whose path isowner/repoor ends in/owner/repomeans the checkout is misplaced. The remote identity is compared without case, as the forge does; the path match stays exact.What each rail does with a misplaced checkout. The tool refuses
beginandrecordoutright, on any branch, since the fix is to move the checkout. The hook blocks exactly what it would block on the protected branch at the right path, and requires signing likewise, and leaves other branches alone.A new flake check,
git-hook-suites. Nothing rantests/git-hooks/*.shautomatically, so the bash half of the shared table would never have been exercised.Risk
R3. The hook sits on the path of every commit and push in every repository on a dev machine, and the agent cannot exercise it as deployed. The worst credible failure after these checks pass is the hook refusing legitimate work on some repository state no fixture covers, which a human undoes by reverting and rebuilding; the other direction, falling open, leaves the forge's server-side protection in place. No state is destroyed either way.
Known limits:
foo/team/repo,bar/team/repo) both read asteam/repo; the error is in the blocking direction.cmd/flake-update-cascadealso readsprotected-branches, and is unchanged. It builds its key aswork/<repo>from the registry name and never looks at the checkout, so it cannot notice a misplaced one and misses any entry not written in that form. That deserves its own issue.protected-branchesremains a hand-maintained mirror of the forge's rules.Validation
Run by the integrator on
fba6d3f:nix build .#checks.x86_64-linux.go-checks .#checks.x86_64-linux.allod-parity .#checks.x86_64-linux.git-hook-suitesbash tests/git-hooks/protected-refs-policy.shbash tests/git-hooks/setup-tracked-hooks.sh(insidegit-hook-suites)bash tests/allod-change.shagainst a binary built from this branchgo vet ./...,go test -count=1 ./cmd/allod/ ./internal/gitremote/remote_identitymade to failcase flat-checkout: pre-commit blocked, "hook allowed the commit"Reported by the implementing agent and not repeated by the integrator: a red run before each of the six fixes below and a green one after; sabotage of the Go remote match and of the hook's worktree resolution.
Not run:
nix flake checkas a whole (one check needs a network input, and the other suites are untouched); the deployed hook.Review
One cold review by
gpt-5.6-solathigheffort, of8c7ce55, followed by one fix round. Seven defect findings (six medium, one low) and twelve comment findings.--separate-git-dir)e841cfffbd81bd; an absent list stays unprotecteda6a5b83$HOMEcompared as text; an entry's trailing slashff537eeacec5d1awk -vrewrites backslashes in a path67f67b5b44fac0; section dividers in the hook suite were shortened to match the file's existing style, not removed.GITsuffix