Skip to content

An abandoned tech-debt ID reservation is released by nothing, and the cleanup meant to prevent one fails under exactly the conditions that create it

Id: TD-PPagop-26082427 · Status: resolved · Filed: 2026-08-24 · Resolved: 2026-08-28 · Ref: #841

What. A td/<id> reservation lock has exactly three ways to be released: the filing lands on main and .github/workflows/release-td-branch.yml deletes it; _techdebt_unfile deletes it in the moment a half-finished techdebt_file_debt gives up; or a human runs git push origin --delete td/<id>. scripts/sweep-orphan-branches.sh deliberately touches none of them — a bare td/<ID> carrying only its reservation commit is explicitly excluded (issue #545) — and lib/tech-debt-file.sh’s own header concedes the consequence: “a branch left behind here is left for good”.

The gap is that _techdebt_unfile is best-effort by construction — “a DELETE that fails is logged and swallowed, so cleaning up after one failure can never raise a second” — with no retry and no later reconciliation. It runs once, on the failure path, against the same GitHub API whose failure put it on that path. The correlation is near-total: a transient window that fails the base_sha lookup or the POST /git/refs that precedes it is the same window that fails the DELETE meant to undo it. A cleanup that only ever runs during the incident it is cleaning up after will leak precisely when it is needed and never otherwise.

Why it matters. Observed on Poetic-Poems/agent-ops at 2026-08-23T16:23:03Z–16:24:05Z: fourteen reservations, TD-PPagop-26082407 through TD-PPagop-26082420, pushed at a regular ~4.7-second cadence, each a single reservation commit touching zero files, with no tech-debt/<id>.md, no td-record/<id> branch and no pull request behind any of them. The absent td-record/ branches place the failure at or before the branch-create call, so _techdebt_unfile did run — and its reservation DELETE failed fourteen times consecutively, which a per-call transient does not explain but a window-shaped outage does. A wider sweep the same day found 25 orphaned locks in total; nine older than abandoned_draft_after_hours were released by hand, and the sixteen inside that window were left alone precisely because nothing distinguishes an abandoned lock from one an agent is still using.

Beyond the litter, each stale lock permanently advances the counter: reserve-tech-debt-id.pl starts from max(filed_max, reserved_max) + 1, so a leaked reservation burns its NN for that date forever, and the register’s IDs skip. The 2026-08-24 sequence had already reached 26082423 with a single record filed against it.

Where. lib/tech-debt-file.sh (_techdebt_unfile, around line 152, and the failure paths in techdebt_file_debt that call it); scripts/sweep-orphan-branches.sh’s issue-#545 exclusion for bare reservation locks; TECH-DEBT.md’s “Filing an item”, which names the hand delete as the only fallback. Adjacent but distinct: TD-PPagop-26082310 covers the filing pull request closed without merging case; this record is the reservation that never reached a pull request at all.

Suggested fix. Two halves, and the second is the one that matters. (1) Give _techdebt_unfile’s two DELETEs a bounded retry so a single transient does not strand the lock. (2) Make an abandoned reservation recoverable after the fact rather than only at the moment of failure, since no in-process cleanup can be trusted to survive the outage that invoked it: relax the issue-#545 exclusion in sweep-orphan-branches.sh from “never touch a reservation lock” to “never touch a reservation lock that is younger than abandoned_draft_after_hours, or whose <id> has a record on the default branch, an open td/<id> pull request, or an open td-record/<id> pull request” — the four conditions that distinguish a live lock from a dead one, all cheaply checkable, all of which this examination had to evaluate by hand. Note that issue #545’s reasoning was about not mistaking a live lock for work; an age floor plus those three reachability checks preserves that intent.

Noticed while clearing 25 orphaned reservation locks and five stranded filing pull requests by hand on 2026-08-23.