Skip to content

fix(#705): paginate all open issues in pre-scribe backlog fetch - #708

Open
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/705-paginate-backlog-issues
Open

fix(#705): paginate all open issues in pre-scribe backlog fetch#708
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/705-paginate-backlog-issues

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

  • Replace gh issue list --limit 1000 with gh api --paginate in scripts/pre-scribe.sh to fetch all open issues, eliminating the truncation that caused duplicate issue creation on repos with >1000 open issues
  • Add open_issue_total and backlog_truncated metadata fields to scribe-meta.json for backlog coverage observability
  • Add scripts/pre-scribe-test.sh with 7 tests covering pagination, PR filtering, body truncation, empty repos, null bodies, metadata fields, and label/milestone preservation

Context

The scribe agent's pre-script used gh issue list --limit 1000 which returns issues ordered by most recently updated. On repos with >1000 open issues (e.g., ~1,879 at time of failure), issues not updated recently fell out of the agent's matching context. The agent then filed duplicate new issues for topics that already had trackers — even when meeting notes acknowledged those existing issues.

The fix uses gh api --paginate with the REST API, which follows Link header pagination to fetch all pages. The REST /issues endpoint includes pull requests in the response, so the pipeline filters them with select(.pull_request == null) and maps html_urlurl for format compatibility.

Test plan

  • New pre-scribe-test.sh passes all 7 tests
  • Existing post-scribe-test.sh passes (one pre-existing failure due to missing bc in sandbox — unrelated)
  • Secret scan passes
  • Verify on a repo with >1000 open issues that all issues appear in backlog.json
  • Verify scribe-meta.json includes open_issue_total and backlog_truncated fields

Closes #705

Post-script verification

  • Branch is not main/master (agent/705-paginate-backlog-issues)
  • Secret scan passed (gitleaks — 91f61f3441baedf3f912c9afd4bd574c98793b96..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

Replace `gh issue list --limit 1000` with `gh api --paginate` to
fetch all open issues regardless of repo size. The previous limit
caused the scribe agent to miss issues not updated recently on
repos with >1000 open issues, leading to duplicate issue creation.

The REST API `/issues` endpoint includes pull requests, so the
pipeline filters them with `select(.pull_request == null)` and
maps `html_url` to `url` to match the expected backlog format.

Add `open_issue_total` and `backlog_truncated` metadata fields to
`scribe-meta.json` for observability of backlog coverage.

Add `pre-scribe-test.sh` with tests covering pagination, PR
filtering, body truncation, empty repos, and metadata fields.

Note: pre-commit hooks could not run (network restrictions in
sandbox). shellcheck was not available. The post-script runs an
authoritative pre-commit on the runner.

Closes #705
@fullsend-ai-review

fullsend-ai-review Bot commented Aug 6, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 3:12 PM UTC · Completed 3:27 PM UTC
Commit: b8b36ad · View workflow run →

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Medium

Low

  • [incomplete-metadata-update] scripts/pre-scribe.sh:179backlog_truncated is hardcoded to false and open_issue_total is set to the same value as backlog_issues. Since --paginate fetches all issues, truncation cannot occur, making these values correct. However, neither field can ever carry a different value than its companion — the new fields add no dynamic runtime information beyond what backlog_issues already provides. See also: [scope-design-nuance] finding on this file.

  • [scope-design-nuance] scripts/pre-scribe.sh — If gh api --paginate silently fails partway (e.g., rate limit mid-pagination), backlog_truncated would still report false. A dynamic check (e.g., comparing fetched count against an API total) would more robustly fulfill the issue Scribe: backlog truncation (--limit 1000) causes duplicate new issues for stale open issues #705 acceptance criterion. See also: [incomplete-metadata-update] finding on this file.

  • [test-coverage-gap] scripts/pre-scribe-test.sh:54 — The run_backlog_fetch function duplicates the gh api/jq pipeline from pre-scribe.sh rather than sourcing the actual script. This is a reasonable trade-off given Drive credential requirements, but future pipeline changes in pre-scribe.sh require a parallel update in the test.

  • [test-robustness] scripts/pre-scribe-test.sh:43build_mock_gh escapes only forward slashes in the fixture path before Perl regex substitution. Characters special to Perl regex (., +, $) in mktemp paths could theoretically cause failures, though in practice Linux mktemp paths are safe.

  • [stale-docs] agents/scribe.md:36 — The agent prompt documents metadata as containing only cutoff_date and notes_url. The PR adds open_issue_total and backlog_truncated. The existing pattern omits other pre-existing fields too (repo, backlog_issues, etc.), so this is consistent — but if the agent should act on the new fields, the prompt needs updating.


Labels: PR modifies scribe agent pre-script (scripts/pre-scribe.sh) and adds scribe-specific tests

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the review comment for full details.

Comment thread scripts/pre-scribe.sh
@@ -176,7 +179,7 @@ if [[ "${DOC_COUNT}" -eq 0 ]]; then
--argjson closed_count "${CLOSED_COUNT}" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] incomplete-metadata-update

backlog_truncated is hardcoded to false and open_issue_total is set to the same value as backlog_issues. Since --paginate fetches all issues, truncation cannot occur, making these values correct. However, neither field can ever carry a different value — the new fields add no dynamic runtime information beyond what backlog_issues already provides.


local escaped_fixture="${fixture_file//\//\\/}"
perl -pi -e "s/FIXTURE_PLACEHOLDER/${escaped_fixture}/g" "${MOCK_BIN}/gh"
chmod +x "${MOCK_BIN}/gh"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] test-coverage-gap

The run_backlog_fetch function duplicates the gh api/jq pipeline from pre-scribe.sh rather than sourcing the actual script. This is a reasonable trade-off given Drive credential requirements, but future pipeline changes in pre-scribe.sh require a parallel update in the test.


if [[ -n "${JQ_EXPR}" ]]; then
jq -r "${JQ_EXPR}" "${FIXTURE}"
else

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] test-robustness

build_mock_gh escapes only forward slashes in the fixture path before Perl regex substitution. Characters special to Perl regex (., +, $) in mktemp paths could theoretically cause failures, though in practice Linux mktemp paths are safe.

@fullsend-ai-review fullsend-ai-review Bot added requires-manual-review Review requires human judgment scribe-agent labels Aug 6, 2026
@ascerra

ascerra commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

/fs-fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scribe: backlog truncation (--limit 1000) causes duplicate new issues for stale open issues

1 participant