The two hand-flag gathers still aggregate inside `gh api --paginate --jq`, so an issue with a timeline past one page reads a garbage `labelled_at`
Id: TD-PPagop-26082701 · Status: resolved · Filed: 2026-08-27 · Resolved: 2026-09-10 · Ref: https://github.com/Pullwright/agent-ops/pull/1356
Noticed while reviewing PR #823 (agent-ops#816), which introduced a third
instance of this pattern in lib/candidate-gather.sh and fixed it in the same
pull request; these two predate it and are out of that PR’s scope.
TD-PPagop-26081306 established the rule and resolved it for
scripts/gather-review-feedback.sh: gh api --paginate re-runs its --jq
filter once per page and prints each page’s result as its own document, so an
aggregate written inside the filter is computed per page and disagrees with
itself the moment the endpoint returns more than one. The remedy that record
names — and that lib/handoff.sh, scripts/detect-classifier-escapes.sh and
scripts/autonomy-stage-report.sh all already follow — is to stream one value
per line and aggregate afterwards.
Two reads still take the aggregate inside the filter, both of them
repos/<slug>/issues/<n>/timeline, whose page size is GitHub’s default of
thirty rather than a hundred:
scripts/gather-unvoid-requests.sh:128—[.[] | select(.event == "labeled" …)] | sort_by(.created_at) | last | .created_at // emptyscripts/gather-hand-flagged-refinements.sh:110— the same filter, projecting{at, by}instead of the bare stamp
Why it matters
Section titled “Why it matters”Both scripts read the timeline for exactly one fact — when the human’s label last went on — and both refuse to guess it when it cannot be read, which is the safe half of the behaviour and is pinned by requirements 34f/34g’s own tests. The unsafe half is that a wrong read does not look like a failed one. On an issue whose timeline runs past thirty events with the label applied, removed and re-applied across a page boundary, each matching page contributes its own document:
gather-unvoid-requests.shassigns the concatenation tolabelled_at, so the request carries a multi-line stamp where a single ISO-8601 one belongs.gather-hand-flagged-refinements.shrunsjq -r '.at // ""'over the multi-document value, which prints one line per document, and[[ -n "$at" ]]passes — so the entry’slabelled_atis multi-line too.
Downstream, labelled_at is compared against block and cycle timestamps to
decide whether a hand-flag request is fresh enough to act on. A value that
parses as no date at all is not a conservative default in either direction on
purpose; it is simply unspecified. And the issues most likely to trip it are
exactly the ones a human has been round with more than once — the busy
timelines, which are where a re-applied label means “asking again”.
Where only one page carries a match — the common case — both reads are correct, which is why this has not been seen: the bug needs a long timeline and a re-application across the page boundary.
scripts/gather-unvoid-requests.sh— thelabelled_attimeline read.scripts/gather-hand-flagged-refinements.sh— thelabelledtimeline read.tech-debt/TD-PPagop-26081306.md— the resolved record that states the rule and the remedy.lib/candidate-gather.sh— requirement 38b’s orphan sweep, whose own timeline read was written this way and corrected on PR #823’s review; its inline comment cites TD-PPagop-26081306 and is the worked example of the fix.
Suggested fix
Section titled “Suggested fix”Take the aggregate out of the filter in both, the way PR #823 did for the
third instance: emit one created_at (or one {at, by} object) per line
across every page, then pick the latest outside — sort | tail -1 for the
bare stamp, jq -s 'sort_by(.at) | last' for the object. Both scripts have
stub-driven tests (test/gather-unvoid-requests.test.sh,
test/needs-refinement.test.sh) whose gh stub already answers the timeline
endpoint, so a multi-page case can be pinned by having the stub emit two
documents for one call.
Migrated to https://github.com/Poetic-Poems/agent-ops/issues/1000.