Skip to content

review-cycle.sh's per-repository label ensure has no wiring test, so its call shape is pinned only by review

Id: TD-PPagop-26082318 · Status: resolved · Filed: 2026-08-23 · Resolved: 2026-08-23 · Ref: https://github.com/Poetic-Poems/agent-ops/pull/731

test/gathered-repo-labels-wiring.test.sh pins the implementation pipeline’s side of requirement 6a mechanically: it extracts the labels block out of agent-cycle.sh’s gather loop, stubs labels_ensure_stamped, and asserts on the argv of every call the loop issues and on the labels-ensured event it logs. review-cycle.sh’s own ensure (R5.0b, review_one) has no equivalent. Nothing in test/ reads that call site at all: no test asserts which helper it reaches, what arguments it passes, or that a non-empty report still reaches log_event.

The property that matters there is which helper it calls. R5.0b requires the plain, unstamped labels_ensure_role, because a repository is selected for review at most once per min_days_between_reviews days — longer, in every shipped configuration, than labels_ensure_interval_hours — so a stamp never saves a listing and does open a window in which a deleted pr_label costs a whole review at gh pr create --label time. That is a one-line distinction between two helpers with near-identical names, sitting inside a several-hundred-line function, guarded by nothing but the comment above it.

It has already gone wrong once, in the change that introduced the stamped helper. PR #713 swapped review-cycle.sh’s unconditional labels_ensure_role for labels_ensure_stamped while adding the per-gathered-repository ensure to agent-cycle.sh, and the substitution survived to a second review round: it was caught by a human-facing reviewer reading the diff, twice, and never by a test. The implementation pipeline’s equivalent regression could not have got that far, because the wiring test asserts on the argv.

The cost of the missing pin is asymmetric with how the bug presents. A review run that loses its pr_label does not fail loudly at the ensure; it fails at the very end, at gh pr create --label, having already spent up to timeout_review minutes of model time — the most expensive single run in the system. A regression here is therefore both easy to introduce (the two helper names differ by one word) and expensive to discover.

Add test/review-repo-labels-wiring.test.sh on the pattern test/gathered-repo-labels-wiring.test.sh already establishes: extract the labels block from review_one, stub labels_ensure_role and labels_ensure_stamped so that reaching the wrong one is itself a failure, and assert on the argv of the call actually issued — the config file, the schema file, the repository slug, the review role and the resolved pr_label — plus the labels-ensured event a non-empty report logs and the silence an empty one produces. The existing test’s extraction helper is the model for reaching a block inside a large function without sourcing the whole script.

Noticed while reviewing PR #713, which is where the substitution this would have caught was introduced and twice refused.