Repository navigation
Description
What
plugins/magpie-pr-management/skills/pr-triage/guards/mark_ready.py enforces Golden rule 1b: never add the "ready for maintainer review" label while the PR head still has GitHub Actions runs awaiting approval. It decides whether a gh pr edit adds that label with:
label = ctx.opt("", "--add-label")ctx.opt() is _opt_value() (tools/agent-guard/src/agent_guard/__init__.py:204-212), which returns the value of the first matching flag and stops. gh pr edit accepts --add-label more than once, and each value can be a comma-separated list, so two forms add the ready label without the guard looking at it. Using the same fake gh as test_mark_ready_pending_denied (two runs awaiting approval), through dispatch():
DENY gh pr edit 5 --repo o/r --add-label "ready for maintainer review"
ALLOW gh pr edit 5 --repo o/r --add-label triaged --add-label "ready for maintainer review"
ALLOW gh pr edit 5 --repo o/r --add-label "triaged,ready for maintainer review"
Why it matters
The guard is the deterministic check behind rule 1b. In the two forms above it does not see the ready label, so the rule is left to the skill's instructions alone. The guard's fail-open paths (no PR number, a failed gh lookup) are deliberate; this one is not.
#1246 fixed the neighbouring class, flag values mistaken for positionals. It did not cover repeated or comma-separated values.
Suggested fix
- Add a multi-value accessor next to
opt()on the guard context that returns every value of a flag, in both--flag valueand--flag=valueform. - In
mark_ready.py, split each--add-labelvalue on commas and deny when any of them equals the ready label (trimmed and case-insensitive, as today). - Add the two ALLOW cases above to
tools/agent-guard/tests/test_skill_guards.pyas DENY cases.
Found via
An architecture pass over how agent-guard parses gh argv; reproduced through dispatch() on main (37670575).
Related
- fix(agent-guard): consume gh flag values so guards cannot be bypassed by flag order #1246: fix(agent-guard): consume gh flag values so guards cannot be bypassed by flag order.
command_kinds()(__init__.py:686-687) still classifies aghcall byargv[1], sogh -R o/r pr edit ...is kindgh:-R. No shipped guard triggers on agh:<group>kind today (they all declare["gh"]), so this is latent.gitalready goes throughgit_subcommand_index();gh_subcommand()could do the same job forgh.
Activity
fix(pr-triage): check every --add-label value in the mark-ready guard (…
feat(bitbucket): add guarded cloud PR merge (#1471)
feat(tools): add asf-nexus and wire Nexus staging check into verify-rc (