fix(reviewer-bot): mutation-intent routing and git-ref CAS state lock#405
Conversation
✅ Deploy Preview for scrc-coding-guidelines ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@plaindocs would you be able to review this? I don't know much about GH Actions' concurrency primitives |
|
@felix91gr I'm in the same boat. But if we need a scapegoat to click "approve" and hope I'm game :-D |
Now I do - they suck 🤣 that's why Pete has to implement a mutex and a whole data structure just to make GHA behave. |
|
I thought about it and I believe we're probably better off just doing this, since the vanilla GHA behavior is so broken. It's a trade of one broken thing for one thing that... in the worst case scenario, will be broken as well. And we have no real way to test this other than testing it in prod 🫠 Let's see how we do! 🧯 |
felix91gr
left a comment
There was a problem hiding this comment.
(see my last comment; I think this is the best course of action even in the worst case)
|
@felix91gr agreed, although I'm not sure what the broken build is about. :-p |
|
@plaindocs huh, you're right CC @PLeVasseur there's a failing build: Run uv run python scripts/reviewer_bot.py
(details omitted)
Installed 56 packages in 50ms
ERROR: Unexpected status while acquiring reviewer-bot lease lock (status 400): {"message":"Bad Request","documentation_url":"https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api#use-conditional-requests-if-appropriate","errors":["Conditional request headers are not allowed in unsafe requests unless supported by the endpoint"],"status":"400"}
Event: pull_request_review, Action: submitted
Error: Process completed with exit code 1.
|
2f51959
Summary
If-Match) on IssuePATCH.Root Cause
If-Matchagainst the state issue update endpoint.pull_request_reviewevents, that failure happened before deferral/handoff logic, so reconcile never ran.What This PR Does Now
main()with explicit intents:mutatingnon_mutating_defernon_mutating_readonlymutatingpaths.scripts/reviewer_bot.py:refs/heads/reviewer-bot-state-lock)force=false) with retry/backoff on conflictsIf-Match; state saves now occur under lock without unsupported conditional headers..github/workflows/reviewer-bot-reconcile.ymltocontents: writeso reconcile can participate in lock acquire/release.concurrencyfrom.github/workflows/reviewer-bot.ymlso serialization is lock-driven and does not rely on pending-run replacement.Fork PR Approval Flow (Current)
pull_request_review/submittedrun is non-mutating and defers.workflow_runreconcile acquires CAS lock, mutates state issue#314, and releases lock./rectifyremains available as manual fallback.Validation
uv run ruff check --fix scripts/reviewer_bot.py .github/reviewer-bot-tests/test_reviewer_bot.pyuv run pytest .github/reviewer-bot-tests/test_reviewer_bot.py(93 passed)