fix: greenlight gate fails closed on repos missing the Agent label #375
No reviewers
Labels
No labels
Agent
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No assignees
2 participants
Notifications
Total time spent: 23 seconds
Due date
igor
23 seconds
No due date set.
Dependencies
No dependencies set
Reference
joshtronic/igor!375
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/claimable-fail-closed-agent-label"
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?
The bug
forgejo_find_claimablegates the claimable-issue grind with the API queryissues?state=open&labels=Agent. But Forgejo ignores alabels=filter that names a label the repo doesn't have — it returns every open issue instead of none. So a repo that was never given theAgentlabel had no gate: the grind claimed every open, unassigned ticket and built it.Confirmed by direct API test: on sharktankdb.com (no
Agentlabel),issues?labels=Agentreturned an unlabeled issue — identical to the unfiltered query.Impact
sharktankdb.com — the newest repo, onboarded without the
Agentlabel — had two unlabeled tickets claimed straight off; one merged before it was caught. Audited all 11 bot repos: only sharktankdb was missing the label; the other 10 gated correctly.The fix
Re-verify the
Agentlabel client-side in the jq filter (index("Agent") != null), so the gate fails closed no matter what the API returns. A repo missing the label now does no issue work (safe no-op) rather than working everything. The API filter stays as an optimization.Test
bin/test-forgejo.sh— Agent-label requirement, unassigned/assigned-to-reviewer/assigned-to-other rules, Status/Blocked exclusion, oldest-first ordering, and the core regression: a no-Agent-label repo yields nothing claimable.make testgreen; shellcheck clean.Follow-up (not in this PR)
Onboarding (
bin/validate-repo.sh) doesn't check for theAgentlabel, which is how sharktankdb slipped through. Worth adding to the checklist so a missing label is flagged at onboard — but with this fix a missing label is now safe (silent no-op), not dangerous.🤖 Review —
APPROVE(automated)CI for
d30bb1ee: successSmall, focused fix: adds a client-side
Agent-label re-check toforgejo_find_claimable's jq filter so the gate fails closed when Forgejo ignores thelabels=AgentAPI filter, plus a new unit-test script. CI green.and (([.labels[].name] | index("Agent")) != null)correctly drops any issue lacking theAgentlabel; emptylabelsyields[]→indexnull → dropped. Redundant-but-harmless for repos that already gate correctly at the API. Behavior for existing (labeled) repos is unchanged. Sound.1 4 7(Agent+unassigned #1/#7, Agent+assigned-to-reviewer #4; drops unlabeled #2, other-label #3, assigned-to-other #5, blocked #6). ✔7 1 4matchescreated_at. ✔1 7(only unassigned). ✔[], the core regression. ✔_fjafter sourcing is a clean way to stub the API; it doesn't exercise URL construction, but that's outside this fix's scope and the filter logic is what matters here.make testreported green and CI confirmssuccess. No security concerns.Follow-up noted by the author (onboarding label check in
validate-repo.sh) is correctly left out of this PR. Nothing blocking.Independent review by the harness on
claude-opus-4-8(effort: high). The human reviewer is requested once Igor has reviewed; a human still merges.