Merge branch 'fix/kvb-org-queue-backfill' into unify/skills-20261114

# Conflicts:
#	skills/kvb-org-queue/SKILL.md
#	skills/kvb-org-queue/scripts/queue.py
This commit is contained in:
Kevin Veen-Birkenbach committed 2026-11-14 21:49:10 +00:00
commit 041851d296
9 files changed
+5017 -197

No files matched your search

@@ -349,7 +349,7 @@ def outcome(groups: dict[str, list[dict]], gone: list[dict]) -> dict[str, list[s
def send(cls: str, to: list[str], text: str) -> None:
radio.transmit(cls, to, text, STATION, [])
radio.transmit(cls, to, text, STATION, [], True)
def capped(ids: list[str]) -> str:
+38 -33
View File
@@ -1,12 +1,12 @@
---
name: kvb-org-queue
description: >
Queue every heavy job (gate, deploy, build, swarm), never ask the chair:
hotfix first, then rank.
Queue heavy jobs (gate, deploy, build, swarm) without the chair: hotfix,
then rank; FIFO per worktree.
---
`${CLAUDE_SKILL_DIR}/scripts/queue.py` replaces asking the chair for heavy
slots with one queue that every waiting agent evaluates by the same rules.
`${CLAUDE_SKILL_DIR}/scripts/queue.py` is one queue all waiting agents
evaluate alike, never the chair.
## Run a heavy job
@@ -14,14 +14,14 @@ slots with one queue that every waiting agent evaluates by the same rules.
queue.py hold --kind <kind> --task <register task> -- <command>
```
Start it in the background (`run_in_background` or equivalent) and end the
turn: hold runs the command on its grant and exits with its code.
Background it and end the turn; hold runs the command on grant, exiting with
its code.
- `<kind>`: a key of `slot_need_gb` in `~/.claude/agents-council/config.json`.
- `<register task>`: your open `kvb-org-rasci` task; its rank places you.
- `--hotfix <slug>`: the job proves the register row `hotfix/<slug>`
(`kvb-git-hotfix`) and goes first.
- `--need-gb <N>` overrides the learned disk need.
- `--need-gb <N>` overrides learned disk need.
- Start hold in the job's worktree: its git toplevel is the workdir. Other
runtimes add `--session <id>`.
- In a worktree the command stays `gate.py run|hold` (`kvb-check-gate`):
@@ -32,52 +32,57 @@ through hold with kind `test`, and a light kind refuses it.
## Order and grant
Every 20 s each waiting hold evaluates the queue under one lock:
Every 20 s each waiting hold evaluates the queue, locked:
1. Hotfix jobs first, then the register rank (`rasci.py show`), one place
1. Hotfixes first, then the register rank (`rasci.py show`), one place
earlier per whole hour waited, then arrival; an open `after` task holds a
job.
2. In that order, a job is blocked at disk stage stop or critical, at warn
when it needs disk, at memory stage stop, during a radio-silence mayday,
while its kind's slots are taken, or while its workdir runs another job;
`exclusive_kinds` run only beside `light_kinds`.
3. A job whose disk need would cut below the stop threshold, or whose
footprint would push the running ones past `budget_percent`, reserves it
against the jobs behind it but `light_kinds`, which meet only running and
granted jobs, so a stream of light jobs can delay a heavy head; a job
alone always fits.
job. Main first needs Main in `rasci.py agents` (else no tiebreak); a job
aged an hour still passes Main's.
2. A job waits at disk stage stop or critical, at warn when it needs disk,
at memory stage stop, during a radio-silence mayday, while its kind's
slots are taken, or behind an earlier job of its worktree, compose stack
or `INFINITO_INSTANCE` slot; a job passes one that can never start, a
light job one awaiting only the machine, a hotfix all but hotfixes and
running jobs; `exclusive_kinds` run
only beside `light_kinds`.
3. A job fits if its disk need keeps the stop threshold free and its
footprint the running ones within `budget_percent` (alone always), and
passes blocked jobs, but the head (a blocked hotfix, an exclusive job
running jobs keep out, one stuck a minute or an hour old, or for other
lines a Main job whose line runs or awaits the machine) only taking
nothing it lacks, its last slot included, and only light while it is a
hotfix, exclusive or held by queue load.
4. An unblocked job counts as granted for the jobs behind it.
5. Every job, alone too, needs CPU, and RAM used plus what it and the
running jobs may still take, below `load_limits`.
running jobs may still take, below `load_limits`; outside load makes no
head and holds no line.
6. A stall escalates itself (`ESCALATION` in queue.py).
## History and learning
Every finished job appends a row to `queue-history.jsonl`, from which disk
need, slot limits and footprints are learned; read `learning.md` next to this
file before changing a seed or a limit.
Finished jobs teach disk need, slot limits and footprints via
`queue-history.jsonl`; read `learning.md` before changing a seed or limit.
## Inspect and cancel
```bash
queue.py list
queue.py list [--json]
queue.py history
queue.py cancel <id>
```
`list` shows each job's position, ETA and blocking reason, `history` the
learned values, `cancel` removes your own waiting job.
`list` shows position, ETA and blocking reason (`--json`: rule trace), `history` the learned values, `cancel` removes your waiting job.
## Rules
- Never ask the chair for a heavy slot or announce a grant; the chair handles
only exceptions such as a stuck queue or a hung job (`capacity.md` of
`kvb-org-organize`).
only a stuck queue or hung job (`capacity.md` of `kvb-org-organize`).
- A running job is never cut short for the queue; only the operator orders
one down, and `kvb-git-hotfix` may void a gate. A `kvb-org-queue-cleanup`
round deletes only entries whose lock no living process holds.
one down, and `kvb-git-hotfix` may void a gate. `kvb-org-queue-cleanup`
deletes only entries whose lock no living process holds.
- With `queue_enforce: true`, the `block` hook (PreToolUse on Bash) refuses
`heavy_commands`, image builds, `make install|test*|quality*|verify-*`,
tests beyond one unit file and `gate.py run|hold` outside `queue.py hold`.
- Without the config, hold exits 2: tell the operator and ask the chair
(`kvb-org-organize`) until it exists. A waiting hold rereads it every poll
(a broken file keeps the last good one), so a limit change needs no re-hold.
- Without the config, hold exits 2: tell the operator, ask the chair
(`kvb-org-organize`). A waiting hold rereads it every poll
(a broken file keeps the last good one).
File diff suppressed because it is too large. Load diff
+3 -2
View File
@@ -28,7 +28,7 @@ status, result or question that can wait.
## Radio: immediate
`send` reaches the addressee at its next tool step and wakes it when idle:
a full turn of every receiver, very expensive.
a full turn per receiver, very expensive.
| Class | Addressee | Use |
| --- | --- | --- |
@@ -38,7 +38,8 @@ a full turn of every receiver, very expensive.
| pan-pan | all | urgent trouble that blocks others and needs help soon |
| mayday | all | shared state in danger (disk full, a broken shared branch, a leaked credential) |
A mayday also holds radio silence for two hours: a hook refuses every
A mayday holds radio silence two hours, except `--no-silence` or under
another's silence, which notify the operator instead: a hook refuses every
Edit, Write and Bash command except those the config's `never_block` and
`mayday_allow` start with and bare `radio.py` calls (text in single quotes,
no shell operators), until its sender runs `radio.py clear` once resolved. The sender keeps working; an agent that
+23 -9
View File
@@ -17,12 +17,15 @@ Environment:
Args:
send <class> "<text>" [--to <name> ...] [--wake] [--sid <id>]
[--session <id>]: the radio, delivered at the addressee's next tool
step and waking it.
[--no-silence] [--session <id>]: the radio, delivered at the
addressee's next tool step and waking it.
call needs --to; broadcast, security, pan-pan and mayday go to all
and take no --to. direct is the old alias: with --wake a call,
without it a post. mayday also sets radio silence
(<root>/radio-silence.json) for two hours. Prints `ts: <ts>`, the
(<root>/radio-silence.json) for two hours, unless --no-silence or
while the silence of another sender holds, which it never replaces;
--no-silence goes with mayday only; a mayday that sets no silence
tells the operator through the notify argv at once. Prints `ts: <ts>`, the
stored row's ts, flushed right after it is stored, then `sent ...`
and `wake: SendMessage to <name>` for every addressee without a live
listener. --sid pins a call with a single --to to that session as in
@@ -373,10 +376,14 @@ def store(entries: list[dict]) -> float:
return entries[-1]["ts"]
def transmit(cls: str, to: list[str], text: str, caller: str | None, sessions: list[str]) -> int:
def transmit(cls: str, to: list[str], text: str, caller: str | None, sessions: list[str], silencing: bool) -> int:
"""Args:
sessions: the session ids of the addressees, kept under
`to_sessions` beside their names; none keeps the row as before.
silencing: whether a mayday sets radio silence; it never replaces
the active silence of another sender, and renewing its own keeps
its helpers. A mayday that sets no silence runs the notify argv
itself, since no silence brings it to the hooks.
"""
if cls in ADDRESSED and not to:
fail(f"{cls} needs --to")
@@ -391,11 +398,15 @@ def transmit(cls: str, to: list[str], text: str, caller: str | None, sessions: l
with organize("nofollow").locked(ROOT, LOCK, 0o600, None):
ts = store([{"from": sender, "to": to, "text": text, "class": cls, "v": VERSION, **({"to_sessions": sessions} if sessions else {})}])
print(f"{STORED}{ts!r}", flush=True)
if cls == "mayday":
active = (silence() or {}) if cls == "mayday" else {}
silenced = silencing and active.get("by", sender) == sender
if cls == "mayday" and silenced:
write_atomic(
SILENCE,
json.dumps({"since": ts, "until": ts + SILENCE_SECONDS, "by": sender, "text": text}),
json.dumps({**active, "since": ts, "until": ts + SILENCE_SECONDS, "by": sender, "text": text}),
)
if cls == "mayday" and not silenced:
notify_once({"since": ts, "by": sender, "text": text})
print(f"sent {cls} to {', '.join(clip(name) for name in to) or 'all'}")
if cls in RADIO:
for name in unreached(cls, to, sid, sessions):
@@ -411,11 +422,13 @@ def cmd_send(args: argparse.Namespace) -> int:
fail("--wake only with direct; a call always wakes")
if args.sid and (cls != "call" or len(args.to or []) != 1):
fail("--sid takes a call with a single --to")
return transmit(cls, args.to or [], args.text, args.session, [args.sid] if args.sid else [])
if args.no_silence and cls != "mayday":
fail("--no-silence goes with mayday only")
return transmit(cls, args.to or [], args.text, args.session, [args.sid] if args.sid else [], not args.no_silence)
def cmd_post(args: argparse.Namespace) -> int:
return transmit("post" if args.to else "newsletter", args.to or [], args.text, args.session, [])
return transmit("post" if args.to else "newsletter", args.to or [], args.text, args.session, [], False)
def cmd_clear(args: argparse.Namespace) -> int:
@@ -672,7 +685,7 @@ def cmd_feedback_send(args: argparse.Namespace) -> int:
fail("--sid takes a single --to")
chosen = read_json(FEEDBACK)
for name in args.to:
transmit(feedback_of(chosen, args.sid or name), [name], args.text, args.session, [args.sid] if args.sid else [])
transmit(feedback_of(chosen, args.sid or name), [name], args.text, args.session, [args.sid] if args.sid else [], False)
return 0
@@ -685,6 +698,7 @@ def main() -> int:
p.add_argument("--to", action="append")
p.add_argument("--wake", action="store_true")
p.add_argument("--sid")
p.add_argument("--no-silence", action="store_true")
p.add_argument("--session")
p.set_defaults(func=cmd_send)
p = sub.add_parser("post")