fix(railguard): skip test hook when runner missing; add path-fence guidance rules#35
Merged
Conversation
…idance rules - post-test-runner.sh: treat a missing test runner binary (e.g. pytest on a fresh box) as "no runnable suite" and exit 0 instead of emitting a blocking PostToolUse error (#29) - add rules/common/railguard.md codifying Write-tool-over-heredoc guidance so fenced path strings in file content don't trip the Bash path fence, and so switching to Write after a fence block isn't treated as evasion (#26) - import the new rules file from CLAUDE.md ahead of the railguard-managed block Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The fence's "project directory" is the hook cwd at each call, not a root captured at session start. Persistent shell cwd means a cd into a nested dir re-anchors the fence there, and cd back to the repo root asks (#26). Allow ~/github, ~/Github, ~/Bitbucket so cwd drift inside any repo under them stays fenced-in. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
|
Upstream follow-up filed and submitted for the fence anchor drift root-caused here:
The upstream PR captures the project root once at Once that lands in a release, the |
ulises-c
marked this pull request as ready for review
June 10, 2026 06:42
ulises-c
added a commit
that referenced
this pull request
Jun 10, 2026
…ified stack (#36) Merge origin/main (PRs #28 powerlevel10k/LACT, #35 railguard fixes, #38 claude-hud) into the unification branch. The two PRs that touched the legacy setup stack landed while this branch converted it to shims, so their features are ported into the unified system as part of the conflict resolution: - packages.json gains zsh-theme-powerlevel10k (arch/yay, high) and lact (arch/yay, medium) — the entries main added to the now-deleted linux-desktop/linux_desktop_packages.json. - The shared desktop flow (lib/core.sh) deploys ~/.p10k.zsh from linux-desktop/p10k.zsh.example via deploy_config — the step main added to the legacy linux-desktop/setup.sh, which stays a shim. - Everything else from main merges clean: zshrc.examples, ghostty font, p10k.zsh.example, LACT configs/docs, railguard and claude-hud config. Gate: per-platform full-flag dry-run diffed against the pre-merge snapshot — macOS and server unchanged (timestamp only); ubuntu/arch show exactly the intended additions (p10k deploy, the two arch packages, and the zshrc update caused by main's new zshrc.example content). dryrun-smoke 4/4; shellcheck + jq clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
16 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the two open Railguard issues.
#29 — Railguard Hooks Error (blocking
pytest: command not found)post-test-runner.shauto-detectspytestfor any project with apyproject.toml/pytest.ini/setup.py, then fails with a blocking PostToolUse error when the runner isn't installed. Added a guard after test-command discovery:A missing runner binary now means "no runnable suite — skip" (consistent with the hook's existing no-suite behavior) instead of a blocking error. This covers all detected runners (
pytest,cargo,go,npm,make) and.claude/test-cmdoverrides, without requiring a global pytest install.Closes #29
#26 — path-fence false positives on fenced paths in command text
Added
rules/common/railguard.md(imported fromCLAUDE.md, outside the railguard-managed block so it survives regeneration) codifying:Write/Edittools overcat <<EOF >/echo >/printf >for authoring file content.Writeand passed by path (--body-file,--file).Writetool is the intended remediation, not evasion.Since
~/.claude/CLAUDE.mdand~/.claude/rules/are symlinked into this repo, the guidance is live immediately.Closes #26
#26 follow-up —
cdapproval prompts (fence anchor drift)Root-caused the constant
cdprompts in monorepo/submodule work: the fence's "project directory" is the hook's cwd at each call, not a root captured at session start. Since the shell cwd persists across Bash calls, acdinto a nested dir re-anchors the fence there, andcdback to the repo root resolves "outside the project" → approval prompt. Reproduced live (the repo root itself failed the fence after a nestedcd).Workaround in
railguard.yaml: added~/github,~/Github,~/Bitbuckettofence.allowed_pathsso cwd drift inside any repo under them stays fenced-in. Details in the #26 comment.Out of scope / follow-ups
railguardbinary change, not fixable in this repo.SessionStart(launch cwd orgit rev-parse --show-toplevel) and fence against that stable root instead of the per-call cwd.post-test-runner.shmacOS portability —date +%s%3N, missingtimeout) touches the same script but is a separate fix, left out of this PR.Security review run on the staged diff: no findings (the hook change adds a read-only, quoted
command -vcheck; the rest is markdown).🤖 Generated with Claude Code