fix(#705): paginate all open issues in pre-scribe backlog fetch - #708
fix(#705): paginate all open issues in pre-scribe backlog fetch#708fullsend-ai-coder[bot] wants to merge 5 commits into
Conversation
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
|
🤖 Finished Review · ✅ Success · Started 3:12 PM UTC · Completed 3:27 PM UTC |
ReviewFindingsMedium
Low
Previous runReviewFindingsMedium
Low
Previous run (2)ReviewFindingsMedium
Low
Previous run (3)ReviewFindingsMedium
Low
Labels: PR modifies scribe agent pre-script (scripts/pre-scribe.sh) and adds scribe-specific tests |
|
/fs-fix |
|
🤖 Finished Fix · ✅ Success · Started 1:13 PM UTC · Completed 1:22 PM UTC Commit: |
- Fetch repo open_issues_count from GitHub API and compare against paginated issue count to dynamically set open_issue_total and backlog_truncated (addresses incomplete-metadata-update and scope-design-nuance findings) - Replace perl -pi -e with sed -i using | delimiter in test mock to avoid regex metacharacter issues (addresses test-robustness finding) - Add test_metadata_truncated test case for truncation=true scenario - Update metadata test jq template to use separate open_total/truncated args matching the production template Addresses review feedback on #708
🔧 Fix agent — iteration 1 (human-triggered)Addressed 3 of 6 review findings with code fixes: made open_issue_total and backlog_truncated dynamic via repo API comparison, replaced fragile Perl regex substitution with sed in tests, and added a truncation=true test case. Disagreed with 3 findings: protected-path (informational), test-coverage-gap (acknowledged trade-off), stale-docs (protected path, consistent pattern). Fixed (3):
Disagreed (3):
Tests: passedNext steps:
|
|
🤖 Review · Commit: |
|
🤖 Finished Review · ✅ Success · Started 1:36 PM UTC · Completed 1:52 PM UTC Commit: |
|
/fs-fix |
|
🤖 Finished Fix · ✅ Success · Started 2:01 PM UTC · Completed 2:09 PM UTC Commit: |
…pped PR_COUNT Compare PAGINATED_TOTAL (all items including PRs from paginated response) directly against REPO_OPEN_COUNT instead of subtracting PR_COUNT from gh pr list --limit 100, which caps at 100 and produces false-positive backlog_truncated=true on repos with >100 open PRs. Save raw paginated response to count total items before filtering, then derive OBSERVED_PR_COUNT from the difference. Update test pipeline to mirror the two-step approach and add test_truncation_detection_logic covering the bash arithmetic (including the >100 PRs edge case). Addresses review feedback on #708
🔧 Fix agent — iteration 2 (human-triggered)Fixed 2 of 5 review findings. The edge-case finding (PR_COUNT cap at 100 causing false-positive truncation) was the substantive bug — restructured truncation detection to compare paginated total directly against API count, eliminating the dependency on capped PR_COUNT. Added test coverage for the truncation detection bash logic with 5 test cases including the >100 PRs edge case. Disagreed with 3 findings: protected-path (informational), stale-docs (protected path, consistent pattern), test-robustness (theoretical only per reviewer). Fixed (2):
Disagreed (3):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 2:10 PM UTC · Completed 2:24 PM UTC Commit: |
|
/fs-fix |
|
🤖 Finished Fix · ✅ Success · Started 10:33 AM UTC · Completed 10:40 AM UTC Commit: |
- Add TRUNCATION_TOLERANCE=5 to truncation detection to absorb small discrepancies from API timing between the paginated issue fetch and the repo metadata call, preventing false-positive backlog_truncated - Replace sed -i placeholder substitution in build_mock_gh with a side-file approach — the mock reads the fixture path from .gh-fixture at runtime, safe regardless of temp path characters - Add 3 test cases for tolerance boundary: within tolerance (3), at boundary (5), and above boundary (6) Addresses review feedback on #708
🔧 Fix agent — iteration 3 (human-triggered)Addressed 2 of 4 review findings. Fixed the API timing race condition in truncation detection by adding a 5-item tolerance margin, preventing false-positive backlog_truncated=true. Eliminated sed -i placeholder substitution in test mock with a side-file approach, handling any temp path characters safely. Added 3 boundary test cases. Disagreed with 2 findings: protected-path (informational) and stale-docs (protected path, consistent existing pattern). Fixed (2):
Disagreed (2):
Tests: passed
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 10:41 AM UTC · Completed 10:55 AM UTC Commit: |
Summary
gh issue list --limit 1000withgh api --paginateinscripts/pre-scribe.shto fetch all open issues, eliminating the truncation that caused duplicate issue creation on repos with >1000 open issuesopen_issue_totalandbacklog_truncatedmetadata fields toscribe-meta.jsonfor backlog coverage observabilityscripts/pre-scribe-test.shwith 7 tests covering pagination, PR filtering, body truncation, empty repos, null bodies, metadata fields, and label/milestone preservationContext
The scribe agent's pre-script used
gh issue list --limit 1000which 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 --paginatewith the REST API, which followsLinkheader pagination to fetch all pages. The REST/issuesendpoint includes pull requests in the response, so the pipeline filters them withselect(.pull_request == null)and mapshtml_url→urlfor format compatibility.Test plan
pre-scribe-test.shpasses all 7 testspost-scribe-test.shpasses (one pre-existing failure due to missingbcin sandbox — unrelated)backlog.jsonscribe-meta.jsonincludesopen_issue_totalandbacklog_truncatedfieldsCloses #705
Post-script verification
agent/705-paginate-backlog-issues)91f61f3441baedf3f912c9afd4bd574c98793b96..HEAD)