fix(hook): wire CLI allowlist into hook dispatch (follow-up to #191)
User description
Follow-up after #191 merged before all review feedback landed.
Problem
writ hook always used HookRuntime::default(), so global --allowed-owners (and the same resolved allowlist as gh-safe / worktree) never reached hook dispatch. PreToolUse also validated gh via SafeGhCommand::new, which only reads env—not the CLI override.
Changes
- Pass
OwnerAllowlist::from_cli_or_envintorun_hookandHookRuntime.allowed_owners. - PreToolUse: enforce
ghwithSafeGhCommand::with_allowlistusing the hook runtime allowlist (alongside existing mergecwdguards from main). - Contract tests in
hook.rsandhook_cli.rs, including CLI-over-env override. - Clarify in
safe-verified-commit-to-pr.mdthat GitHub MCP PR operations are outside the writ hook boundary; agents must still verify owner scope before MCP mutations. - Extract
assert_hook_rejectsso the force-push and allowlist hook CLI tests no longer duplicate the spawn-and-reject sequence (CodeScene code duplication).
Integration
Merged current main so the branch is mergeable again; hook remains register-only for worktree events per main.
Related
Does not address every stale bot thread from #191.
Linear Issue: RM-983


Summary by cubic
Fixes writ hook so the global --allowed-owners flag and resolved allowlist reach hook dispatch and gh command checks.
- PreToolUse enforces
ghcommands with the hook runtime allowlist instead of env only, with CLI values taking precedence over env. - Contract tests cover the CLI flag path and CLI-over-env override and share a single reject assertion; the docs note GitHub MCP PR operations sit outside the writ hook boundary.
CodeAnt-AI Description
Apply the configured owner allowlist to GitHub commands run through hooks
What Changed
- Hook-run GitHub commands now reject repository targets outside the configured owner allowlist.
- The hook uses the same allowlist as the rest of the CLI, with the command-line setting taking precedence over environment settings.
- GitHub MCP and other tools outside writ hooks still require explicit owner checks before changes.
Impact
✅ Fewer out-of-scope GitHub changes through hooks
✅ Consistent owner checks when command-line settings override environment settings
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
@codeant-ai ask: Your question here
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
@codeant-ai ask: Can you suggest a safer alternative to storing this secret?
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
@codeant-ai: Your feedback here
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
@codeant-ai: Do not flag unused imports.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
@codeant-ai: review
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.