Skip to content

πŸ› [fix] hooks: deny editing a posted πŸ™‹ approval request - #106

Open
chadhuskops wants to merge 1 commit into
EricTechPro:mainfrom
chadhuskops:fix/guard-approval-edit
Open

chadhuskops wants to merge 1 commit into
EricTechPro:mainfrom
chadhuskops:fix/guard-approval-edit

Conversation

@chadhuskops

Copy link
Copy Markdown

Note

⏳ Ready for review Β· βœ… 4/4 AC Β· head 7ae3b8f

Problem

  • Where: a lane's πŸ™‹ request comment (approval-request: / Reason tag: … πŸ™‹)
    • a. A lane posts the request, then edits the same comment to add a detail
    • b. The merge gate (super-board-approval.py) refuses an edited request
  • Who: every card that needs a human
  • What happened: seen in a downstream run. The human's done on edited requests was refused. The rule "never edit a request; post a new one" was in the docs, but nothing enforced it

Solution

  • New PreToolUse(Bash) guard hooks/guard-approval-edit.py, built like guard-protected-push.py (same deny format, fails open)
  • Denies an edit of an existing comment (gh issue|pr comment --edit-last, PATCH issues/comments/<id>, GraphQL updateIssueComment) when the new body carries approval-request: or a πŸ™‹ Reason tag: line. Body found inline, in a heredoc, or via --body-file, -F body=@file, --input, $(cat file) or < file
  • Posting a new comment is never blocked. SB_ALLOW_APPROVAL_EDIT=1 turns it off
  • Wired in hooks/settings-snippet.json (on by default); listed in hooks/README.md and README.md (7 guard hooks)
  • run.md, block-template.md, writing-standard.md: post the request once, as the exit's last GitHub write; a correction is a new comment

Acceptance criteria

  • Every edit route with a request body is denied
    ↳ tests/test-guard-hooks.sh Β· 7 deny cases
  • A new request, a plain-note edit, bad input and the env switch are allowed
    ↳ tests/test-guard-hooks.sh Β· 7 allow cases
  • The hook is installed and wired
    ↳ tests/test-install.sh Β· 24 scenarios
  • New cases fail on main and pass here
    ↳ bash tests/test-guard-hooks.sh Β· stops on main (no hook); 105 cases pass now, on Python 3.7 and 3.12. Guard count in test-get.sh is 7; that suite needs network and wasn't run locally

Risk

🟒 Low · a new deny-only hook.

  • Door: two-way Β· remove the snippet entry to turn it off
  • Blast radius: agents editing comments Β· only edits whose body keeps a πŸ™‹ request are denied

- New PreToolUse(Bash) guard `guard-approval-edit.py`: an edit (`--edit-last`, PATCH `issues/comments/<id>`, `updateIssueComment`) whose body keeps `approval-request:` or a πŸ™‹ `Reason tag:` is denied; posting a new comment never is
- The merge gate refuses an edited request, so the human's `done` was lost (seen in a downstream run)
- Wired in settings-snippet.json (on by default); run.md, block-template and the writing standard: post the request once, as the exit's last write; a correction is a new comment
- test-guard-hooks.sh gains 14 cases; install/get counts move to 7 guard hooks
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more β†’

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account β†’

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us β†’

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants