Skip to content

gather-review-feedback.sh aggregates inside --jq, so a PR past one page of reviews or comments reads wrong

Id: TD-PPagop-26081306 · Status: resolved · Filed: 2026-08-13 · Resolved: 2026-08-13 · Ref: https://github.com/Poetic-Poems/agent-ops/pull/341

gh api --paginate emits its --jq filter’s result once per page, as separate JSON documents — so an aggregate written inside the filter is computed per page and disagrees with itself past the endpoint’s default page size, which is thirty for these endpoints and not a hundred. lib/handoff.sh’s _handoff_blocking_reviewers documents this and avoids it by streaming one object per line and aggregating afterwards.

scripts/gather-review-feedback.sh wraps the aggregate inside the filter on four reads, all predating this record:

  • repos/<slug>/pulls/<n>/reviews — --jq '[.[] | … ]'
  • repos/<slug>/issues/<n>/comments — --jq '[.[] | … ]'
  • repos/<slug>/issues/<n>/timeline — --jq '[.[] | … ]'
  • repos/<slug>/pulls/<n>/comments — --jq '[.[] | … ]'

Past one page each becomes two or more concatenated arrays. The script’s jq -e 'type == "array"' guards do not catch it: jq evaluates the filter once per input document and exits on the last one’s truth, so the guard establishes “every document is an array”, not “this is one array”. Downstream, --argjson cannot parse the multi-document value and the read fails.

The failure direction is currently safe but silent. handoff_round_answered (lib/handoff.sh) answers unknown on an extraction it cannot run, and this script’s [[ … == "unanswered" ]] || continue skips anything that is not a definite unanswered — so a pull request past thirty reviews or thirty comments quietly drops out of the review-feedback candidate selection while a human’s CHANGES_REQUESTED sits unanswered. That is requirement 3c’s own starvation failure arriving by a different road than PR #205’s, and the comment threads on this system’s long-running pull requests reach thirty routinely: a Reviewer findings comment, a Reviewer completion comment and an Implementer reply land per cycle.

The blocking and round_start computations read the same multi-document values, so a PR in that state can also pick the wrong blocking review or the wrong round boundary before the predicate is ever consulted.

Fix: stream each of the four reads one object per line and slurp with jq -s afterwards, the way _handoff_blocking_reviewers and (since PR #335) scripts/sweep-human-visibility.sh’s _sweep_round_answered do. Requirement 3c’s design note and the script’s header should record the streaming read as the rule the whole script follows rather than a per-call detail, and test/review-feedback.test.sh’s stub should emit a listing over more than one page so a regression is caught there rather than in production.

Noticed while reviewing PR #335, which fixed the same defect in the sweep’s own copy of these reads; the pre-existing instances here were left alone to keep that diff to its item.