Repository navigation
fix(admission): Release the job slot when job creation fails - #289
Conversation
admit() took a job slot and then called jobs.create outside any try, so a raise there left the semaphore one permit short with no owner to return it. jobs.create now has its own try that releases the slot and re-raises unchanged. The test asserts the very same error propagates and the slot is released once. Resolves F-B23-65.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Graphify reviewed this change.
Code graph out of date: Health delta baseline: last indexed commit be14bc2, 2 commit(s) behind this PR's base. Impact and hotspot numbers below may be wrong.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).
Not verified on this run: admit (vacuous: never exercised).
Graphify review — findings
Fixes a job-slot leak in admit(): jobs.create now runs in its own small try that calls release_job_slot() and re-raises the original exception, so a failed create no longer leaves the semaphore one permit short. The release is imported straight from scrobblescope.worker rather than going through the routes facade, so a test or caller patching the slot functions on the facade won't intercept this path. The existing START_FAILED handling stays separate to avoid a double release, and the new test checks the slot is freed once and the same error propagates. The rest is bookkeeping: F-B23-65 moves to the findings archive, the PLAYBOOK gets a log entry, and the pinned test count goes from 3158 to 3159.
Worth a look
- create-failure path bypasses the routes facade for slot release —
scrobblescope/routes/admission.py:53· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 119 functions depend on the 116 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
admit()— 9 callers, 5 callees
Verification — 119 functions in the blast radius were not formally verified this run (proofs are advisory here).
Health delta baseline: last indexed commit be14bc2, 2 commit(s) behind this PR's base.
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 119 function(s) in the blast radius were not formally verified this run
Formal verification
Could not verify: Could not verify admit.
The verifier did not have enough to check admit, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: not verifiable: all 256 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly TypeError — names the real obstacle, not a sampling gap)
· 1 more finding(s) on lines outside this diff (see the check run).
Summary
Closes F-B23-65.
admit()inscrobblescope/routes/admission.pytook a job slot and then calledjobs.create(params)outside itstry, so ifjobs.createraised, nothing released the slot: the semaphore stayed one short for the life of the process, and enough such failures would make the app refuse every job as at capacity until a restart.jobs.createnow sits in its own smalltrythat releases the slot and re-raises the same exception unchanged. Thestart_job_threadfailure path is untouched (start_job_threadalready releases the slot there, so movingjobs.createinto that existingtrywould have released it twice).An outside agent (DeepSeek) wrote the patch in an isolated worktree from a spec-tight prompt; a before-and-after snapshot of the main checkout confirmed it wrote nothing outside its worktree. An independent review approved it and reproduced the red proof; of seven planted defects the test caught six. The landing strengthened the test to catch the seventh (re-raising a different exception: the test now asserts the propagated error is the same object) and dropped an assertion that could never fail. One new test,
test_a_create_failure_frees_the_slot_once_and_propagates, because no existing test reached this path.Was stacked on PR #288 (pin the pip-audit action, now merged); retargeted to
main, so this PR's own change is the one commitfb71af6d.State
jobs.createraisesValidation at this head
Head
fb71af6d. Scoped gates (owner ruling 2026-10-31), run by an independent gate runner at this head:suite-core907 passed (the root test files, wheretests/test_admission.pyand the route tests live),pre-commit run --all-files(all 10 hooks pass) anddoc_state_sync.py --checkpass. Fullpytest -qat landing: 3159 passed (pinned). Red proof: the new test fails on the unpatchedadmission.py("Expected 'release' to have been called once. Called 0 times.") and passes at this head.Codex: waived by the owner until the usage limits reset. CI: green at this head on all four jobs (run 41229350731: checks 2999 passed, 4 skipped, 156 deselected; browser ran). Codacy 0 new issues, qlty no blocking issues, no open review threads.
Checklist
pytest -qpasses (update SESSION_CONTEXT Section 1 if test count changed)pre-commit run --all-filespasses (all hooks)python scripts/doc_state_sync.py --checkexits 0- Batch WP: inside
DOCSYNC:CURRENT-BATCH-START/ENDmarkers- Side task: after
DOCSYNC:CURRENT-BATCH-ENDmarker(or deviation is logged in the Section 4 entry)