fix(kvb-org-queue): an exclusive job held only by live load is no longer starved

Behind an exclusive entry that only live load holds back (its verdict is its loaded reason), from the queue or outside it, head or not, no later entry but a light one starts any more (loaded_exclusive()): a job started beside it would keep it out once the load drops, so the exclusive job waited forever. Such an entry now reads 'waits behind exclusive <id>' with the step 'exclusive <id> blocked ahead: load holds it, <kind> beside it would keep it out'. Light kinds still pass.

Applied cleanly onto blocked (9d313f2); neither file changed on master since its base 2aea6d1.

Tests: tests/test_queue.py ran once on these exact bytes before the commit (operator exception): 129 OK, including the new starving-head cases.

Security: MEDUSA over the staged tree on master: 100, no findings, both files covered.

🎯 Fix: 92 %
💥 Break: 5 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 87
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-22 21:39:08 +00:00
1 parent 9d313f227d
commit 0ba6e1506f
2 files changed
+44 -8

No files matched your search

+19 -1
View File
@@ -705,7 +705,10 @@ def evaluate(entries: list[dict], free_gb: float, floor: float, stage: str, memo
later one but light ones waits behind a
hotfix head, and behind any head whose kind is exclusive or that live
load holds while queue jobs run; light ones wait too while load the
queue causes holds a hotfix head. An entry never passes an active,
queue causes holds a hotfix head. Behind an exclusive entry that only
live load holds, from the queue or outside it, head or not, no later
entry but a light one starts (loaded_exclusive()): it would keep that
entry out once the load drops. An entry never passes an active,
granted or waiting entry enqueued before it that shares one of its
claims (claims(): worktree, compose stack, slot): those form its
line, which runs by enqueue time alone (in_lines()), never by rank,
@@ -777,6 +780,9 @@ def evaluate(entries: list[dict], free_gb: float, floor: float, stage: str, memo
s := held_for(kind, need, share, h, counts, slot_limits, exclusive, light, pools, floor, budget))), None)
if why:
reason, step = f"reserved for {why[0]}", f"reserved for {why[0]}: {why[1]}"
gate = None if reason is not None or kind in light else loaded_exclusive(able, verdicts, loaded, exclusive)
if gate:
reason, step = f"waits behind exclusive {gate}", f"exclusive {gate} blocked ahead: load holds it, {kind} beside it would keep it out"
for claim in () if isinstance(loaded.get(entry["id"]), Outside) else mine:
if reason is None or claim in lifted:
lines[claim] = entry["id"]
@@ -859,6 +865,18 @@ def behind(entry: dict, mine: list[str], lines: dict[str, str], blocked: list[di
return None
def loaded_exclusive(able: list[dict], verdicts: dict[str, str | None], loaded: dict[str, str],
exclusive: set[str]) -> str | None:
"""Returns:
The id of the first entry of able (blocked, not unstartable()) whose
kind is exclusive and that only live load holds back (its verdict is
its loaded reason), whether the queue or something outside it causes
the load; a job of a kind that is not light, started now, would keep
it out once the load drops (alone_reason()). None when there is none.
"""
return next((e["id"] for e in able if e["kind"] in exclusive and e["id"] in loaded and verdicts[e["id"]] == loaded[e["id"]]), None)
def drained(order: list[dict], verdicts: dict[str, str | None], drain: str | None, could: set[str],
now: float) -> str | None:
"""Returns: