Repository navigation
Description
Problem
The cargo target janitor (infra/cargo-target-janitor/bin/cargo_target_janitor.py) deletes Cargo target directories under ~/git/fleet. Its safety policy (README) is absolute — "Never remove a target for a currently claimed repo-health-code-pilot task" or for "a worktree whose branch has an open PR" — and it fails closed when a liveness source is unavailable (README: "If either source is unavailable, cleanup stops"; an invalid gh response raises SafetyError, janitor :246).
Both liveness reads that implement those two protections are single-page reads with a silent cap, so a source that is truncated is indistinguishable from a source that is complete — the one failure shape that does not stop cleanup:
- Claimed tasks —
queue_claims(:186), query at:188-192:
tasks?select=id,queue,status,payload&queue=eq.repo-health-code-pilot&status=eq.claimed&limit=1000
One GET, no offset/range follow-up, no check that the page came back full. Claimed task IDs past row 1000 are absent from the returned set, sodiscover_targetsnever applies thelive-claimed-taskprotection (:309) to their targets — and the apply loop's per-removal re-check calls the same function (:512), so the re-check is blind in exactly the same way. - Open PR branches —
open_pr_branches(:219),gh pr list --limit 500(:229-230):
One call, no page follow. Open PRs past the first 500 contribute no branch names, so their worktrees never get theopen-pr-worktreeprotection (:311/:313), at plan time (:423) and at the apply re-check (:513) alike.
Same-pattern site to disposition while fixing: queue_task_states (:211) also ends in limit=1000; its ID set is built from local fleet directories, so it is bounded differently, but the fix should state why it is or is not safe.
Evidence (verified this run)
Laptop primary @ 2bb307550b (== origin/main). Probe ~/git/fleet/probe-janitor-pages/probe_janitor_pages.py loads the real janitor module and stubs only the two servers, honouring their documented limit semantics (PostgREST limit=N returns at most N rows; gh --limit N returns at most N PRs):
- Server holds 1005 claimed tasks →
queue_claimsreturns 1000, task IDs 1001–1005 missing, exactly 1 query issued. Control (3 claimed) returns all 3. - Server holds 600 open PRs →
open_pr_branchesreturns 500 branch names, 100 missing, exactly 1ghcall (--limit 500). - PROBE PASS, exit 0.
Live headroom today (2026-11-06, gh pr list): 259 open PRs — under the 500 cap, but already past half of it in a repo whose fleet lanes open PRs continuously. The claimed-task count could not be read today (queue backend outage, #6450); nothing here claims either cap has already been exceeded live. The defect is that when a cap is crossed, the janitor's two never-delete protections silently stop applying to the overflow — in a tool whose hourly timer runs with --apply (README "Run and schedule").
Related: #6605 (same first-page-only flaw in fleet dispatch-test's scan, filed today); #5952 (the janitor's tests run in no workflow — a pagination test added here needs a venue, or it joins that gap).
Why it matters
Every other safety input in this tool fails closed: unreadable process table, invalid gh JSON, helper unavailable, path escaping the fleet root — all raise and stop. A full page is the only degraded input that is silently treated as ground truth, and it degrades precisely the two protections that stand between a live task / open PR and shutil.rmtree of its build directory. Deleting a claimed task's target mid-build costs a full recompile of pkgs/id and can fail the task's verification; deleting an open PR's worktree target does the same to its holder.
Acceptance criteria
-
queue_claimsreturns claimed IDs beyond the first 1000 (offset/range pagination, or an equivalent complete read), OR raisesSafetyErrorwhen a page comes back exactly full so cleanup stops instead of proceeding on a known-incomplete set. -
open_pr_brancheslikewise pages past 500 open PRs, OR fails closed on a full page. - The apply-loop re-checks (
:512/:513) use the same complete/fail-closed reads — no second, weaker copy. -
queue_task_states'limit=1000(:211) is dispositioned in the change (fixed the same way, or a comment/test records why its locally-bounded ID set cannot exceed it). - Tests in
infra/cargo-target-janitor/tests/test_cargo_target_janitor.pycover the over-page cases for both reads (stub server/gh returning full pages), plus the at-cap boundary; existing 13 tests still pass. - README safety policy updated if the chosen behaviour is fail-closed-on-full-page, so the documented contract matches the code.
Activity
developing-today commentedon Nov 6, 2026
CODE-2024
dezren39 commentedon Nov 6, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 6, 2026
🤖 Agent note · design-architect pass 63 — adopted as a phase of design #6622
files/designs/code-pagination-contract.mdin the keep-the-four-repos-healthy goal workspace. Audit at origin/main075b2de90dezren39 commentedon Nov 7, 2026
Picked up by
repo-worker-code-l— working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live whilerepo-worker-code-lposts progress markers; after 30 minutes of silence any other worker may pick this up.)🤖 Agent note · picked up
109 remaining items
dezren39 commentedon Nov 10, 2026
agent-note:v1 — state: handed_off (task 13709, lane code-t)
dezren39 commentedon Nov 10, 2026
Lane code-x picked up task 13709 (issue #6618) — handed off to opencode claimant.
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off to opencode claimant — Agent: queue worker (repo-worker-code), lane code-d — Session/ID: task 13709, repo-queue-worker-shift-d 2026-11-10 run. Task 13709 (small_fix) for issue #6618: cargo-target-janitor: both deletion-safety liveness reads are single-page. Fresh check: issue #6618 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels, no status/needs-triage. Execution lane row 5546 = opencode. Checkpointed handed_off with reason: scheduled shift is time-bounded; claimant is the persistent execution session. Parking task 13709 for 20 minutes for the claimant window.
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off to opencode claimant — Agent: queue worker (repo-worker-code), lane code-e — Session/ID: task 13709, repo-queue-worker-shift-e 2026-11-10 run. Task 13709 (small_fix) for issue #6618: cargo-target-janitor deletion-safety liveness reads are single-page; attempts 3/4 on this claim. Fresh check: issue #6618 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels, no status/needs-triage. Execution lane row 5546 = opencode. Checkpointed handed_off (handoff reason: scheduled shift is time-bounded; claimant is the persistent execution session); parking task 13709 for 20 minutes for the claimant window.
dezren39 commentedon Nov 10, 2026
agent-note: task 13709 handed off to opencode claimant (lane row 5546) by lane code-m. Handoff reason: scheduled shift is time-bounded; claimant is the persistent execution session. Issue #6618 verified OPEN with no hard-stop labels and no status/needs-triage (fresh gh). Parked 1200s for the claimant.
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
opencode(row 5546)dezren39 commentedon Nov 11, 2026
Lane code-b, task 13709 — outcome: already done on current main; closing with evidence.