feat(scripts): queue heavy gates behind a machine-wide slot lock - #36988
Conversation
Greptile SummaryThe PR adds a machine-wide slot queue around heavy developer gates to limit concurrent resource usage across worktrees.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| Makefile | Heavy public targets now acquire a slot before delegating to inner targets; the prior lint setup bypass is fixed. |
| scripts/gate_slot_lock.py | Implements configurable machine-wide file-lock slots, inherited re-entry markers, command execution, and fail-open filesystem handling. |
| scripts/pre_commit_lint.sh | Re-executes through the slot wrapper before running any lint work while preserving symlink-hook operation. |
| scripts/ruff_strict_gate.py | Runs the Ruff budget gate within the shared slot context. |
| scripts/type_check_gate.py | Runs environment preparation and type-check budget processing within the shared slot context. |
| scripts/type_discipline_gate.py | Runs the type-discipline budget gate within the shared slot context. |
| tests/test_litellm/test_gate_slot_lock.py | Exercises capacity limits, queueing, re-entry, cleanup, exit propagation, fail-open behavior, and lint target ordering. |
| tests/test_litellm/test_pre_commit_lint.py | Verifies pre-commit locking, held-slot re-entry, and symlink-based hook installation. |
Reviews (2): Last reviewed commit: "fix(make): acquire the gate slot before ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit eafddaa. Configure here.
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 17f5c90. Configure here.
TLDR
Problem this solves:
make checkruns across worktrees thrash one machineHow it solves it:
scripts/gate_slot_lock.py: machine-wide fcntl slot lock, 2 slotsmake check/bootstrap/lintand the budget gates queue through itmake linttakes its slot first, so even its dependency setup queuesLITELLM_GATE_SLOTSoverrides the count;0disables; errors fail openUser Flow
Before: a developer running several agent sessions has three worktrees run
make checkat once, and the machine becomes unusablemake checkin their own litellm worktree at the same timeAfter: the same three runs queue two at a time and all pass
make checkin their own litellm worktree at the same timegate_slot_lock: all 2 machine-wide slots are busy; queueing (set LITELLM_GATE_SLOTS=0 to disable)and waitscheck: PASSlike the othersLITELLM_GATE_SLOTS=0(or another slot count) and the lock steps asideRelevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Before, at the merge base 870a8cf: three parallel
make checkruns across three bootstrapped worktrees all execute at once, nothing queues or throttles themAfter, at this PR's tip 17f5c90: the same three runs queue two at a time, the third prints the queueing notice, and all three pass
Direct
make lintat 17f5c90 joins the queue before doing any setup: with both slots held by long-running checks, its first output is the queueing notice, anduv sync/git fetchonly run once a slot frees (at the parent commit the setup deps ran before the queue was joined); the run then passesThe header-documented hook flow still works at the tip. Linked worktrees resolve
.git/hooksto the shared main checkout, so this demo pins the same script viacore.hooksPath; a fresh-cloneln -sinstall goes through the identical entrypoint and is pinned by a regression testNotes from the QA run:
make lintalways runs full checks; onlymake checkscopes (unchanged)Type
🚄 Infrastructure
Caveats (if any)
make -jN checksub-make may warn "jobserver unavailable"; inner targets are serial anywayFinal Attestation