techdebt_file_debt's --label makes an absent pr_label fatal to the whole filing, so the record is discarded rather than merely unlabelled
Id: TD-PPagop-26082804 · Status: open · Filed: 2026-08-28
What: techdebt_file_debt (lib/tech-debt-file.sh) now ends with gh pr create -R "$repo" --base main --head "$branch" --title … --body-file … --label "$pr_label" (PR #837, TD-PPagop-26082426). gh resolves label names to ids as part of the create, so a pr_label that does not exist in $repo fails the call outright and no pull request is created. Control then reaches the [[ -z "$pr_url" ]] branch, which by this function’s own documented invariant (lib/tech-debt-file.sh header; requirement 42a; TD-PPagop-26082203) calls _techdebt_unfile: td-record/<id> is deleted and the td/<id> reservation released.
Why it matters: the failure mode the change was made to fix was a filing that lands but no gatherer can see. In this one case the change replaces it with a filing that does not land at all — the record the Approver or the Enabler judged worth writing is discarded, and the only trace is a warning event naming tech-debt-file.err. The rollback itself is clean rather than a strand, and the exposure is one every other pipeline gh pr create --label already carries, so this is not a defect in the change. What makes it worth a record is that the two call sites are not equally protected:
- the Approver files against
$selected_repo, andagent-cycle.shgives that repository an unconditional, unstampedensure_labels_for "$repo_slug" targetimmediately before the Implementer stage —selected_repoandrepo_slugare bothwork_order_json.repo, so it is the same repository, ensured earlier in the same cycle.agent-cycle.sh’s own comment there says why: a fresh stamp only proves the label existed at the last listing, and “the Implementer is onegh pr create --labelaway from losing its whole run to that gap”.techdebt_file_debtis now onegh pr create --labelaway from losing a filing to the same gap, and on this path it is covered by the same ensure. - the Enabler files against
$e_repo, read from the escalation record (lib/enabler.sh,e_repo="$(jq -r '.repo // ""' <<<"$ex")"), which need not be the cycle’s selected repository and need not be a repository the fleet gathers at all.lib/enabler.shensures only theescalationrole catalogue, and only insidecreate_escalation_issueon the path that actually creates an issue — notpr_label, and not on thefile_debtpath. So this call site relies entirely on the rate-limited gather-loop ensure, which is deliberately periodic rather than synchronous (labels_ensure_interval_hours, default 24h) and deliberately best-effort —lib/labels.sh’s own header states it “can never fail a cycle”, so a token without label-create permission yields a report and nothing else.
Three sites in this codebase meet the same case and degrade rather than fail. create_escalation_issue (lib/enabler.sh) ensures the catalogue and then retries the create without the label, on the stated reasoning that the ensure “makes the label likely, not certain, and an escalation must be raised either way”. landing_open_question_label_project (lib/landing.sh) names the case outright — “a repo where the label was never created is the practical case, ordinarily self-healed by labels_ensure’s own periodic sweep” — and returns failed while its caller carries on, because “losing the label costs a filter, losing the gate would cost the hold”. refinement_label_add (lib/refinement.sh) self-heals through labels_ensure_one and retries. Here, losing the label costs a filter; losing the filing costs the record — the same asymmetry all three already resolve the same way.
Where: lib/tech-debt-file.sh’s techdebt_file_debt, the gh pr create call and the [[ -z "$pr_url" ]] rollback immediately below it; the file_debt block in maybe_run_enabler (lib/enabler.sh), which is the unprotected call site; docs/IMPLEMENTATION-PIPELINE-SPEC.md requirement 42a, which specifies the command form gh pr create --base main --head td-record/<id> --label PR_LABEL and so constrains any remedy, plus requirement 36c for the Enabler’s own path; the acceptance check for test/tech-debt-file.test.sh in the same document.
Suggested fix: three shapes, each with precedent in this repository, and they compose rather than compete. Give the Enabler’s file_debt path the same unconditional ensure the Implementer path already has (ensure_labels_for … target, agent-cycle.sh), which closes the asymmetry above and nothing else. Or call labels_ensure_one "$repo" "$pr_label" inside techdebt_file_debt before the create, the way refinement_label_add self-heals — noting lib/tech-debt-file.sh does not currently source lib/labels.sh. Or make the create itself degrade, the way create_escalation_issue immediately above it already does: retry unlabelled when the labelled create fails, and follow with a best-effort gh pr edit --add-label, a filed-but-unlabelled record being strictly better than no record and self-healing on the next labels_ensure pass regardless. Any remedy that changes the command form needs requirement 42a and the acceptance check to state the fallback, and test/tech-debt-file.test.sh needs a case where the stub fails the labelled create.
The fourth option is to decide this is already correct: since TD-PPagop-26082426’s whole finding is that an invisible filing is worse than none, refusing to open one that cannot be labelled is a defensible posture rather than a defect. That is a judgement for this item’s author to make explicitly; the point of this record is that it is currently implicit.
Noticed while reviewing https://github.com/Poetic-Poems/agent-ops/pull/837. The Enabler/Approver asymmetry was first identified by that pull request’s previous Reviewer round, in a review comment (https://github.com/Poetic-Poems/agent-ops/pull/837#issuecomment-5433425727) that judged the degradation graceful enough not to file; this record exists because nothing sweeps review bodies for unfiled debt, and that round’s session ended before it could carry the point further.
Migrated to https://github.com/Poetic-Poems/agent-ops/issues/1009.