Skip to content

feat: select GitHub issue imports and cap list volume - #116

Open
unbraind wants to merge 1 commit into
mainfrom
feat/import-issue-selection
Open

unbraind wants to merge 1 commit into
mainfrom
feat/import-issue-selection

Conversation

@unbraind

@unbraind unbraind commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Agents tracking a single GitHub issue currently have to approximate with --since, which can import unrelated issues in a busy repository. This adds exact selection and a bounded list mode.

pm github import owner/repo --issue 189 fetches only that issue endpoint. Comma-separated numbers, #N, and same-repository references deduplicate before fetch; malformed or cross-repository references and conflicting list flags fail with usage errors. All selected numbers are fetched before tracker writes. A missing number refuses the batch, while dry runs report missingIssues; PR numbers require --include-prs. Comments, dependency linking, atomic transactions, gates, custom types, and provenance idempotency retain the shared import pipeline.

--limit n requests newest-updated order and stops list pagination after one extra eligible issue proves truncation. Results carry limit and truncated. Help, importer and legacy command examples, and README describe both flags. PR #115 blocker code is untouched.

Before: tracking one issue needed a timestamp window and a check for accidental imports. After: --issue 189 fetches one endpoint; re-import updates the same gh:owner/repo#189 item.

Validation:

  • Recorded public REST fixtures for pm-web #189/chore(deps): bump the codeql-action group across 1 directory with 2 updates #96/PR #175 and pm-slack-standup chore(deps-dev): bump pm-ops from 2026.10.4 to 2026.10.5 in the pm-toolchain group #113, replayed over HTTP into real temp trackers; 26 focused regressions and packed CLI dispatch.
  • PM-linked regression: 1/1 commands, 26/26 tests, zero failures/skips/cancellations; 300-second budget. The first run hit the default 120-second budget; result persistence is disabled by existing project policy, so comments retain both receipts.
  • Behavioral revert: restoring only runImport fails the selection test 0/1 with AssertionError (2 imports instead of 1). Restoring only buildIssuesUrl/fetchAllIssues fails the cap-plus-probe test 0/1 (3 issues instead of 2). Unchanged tests ran in disposable candidate copies; production source remained unchanged.
  • Live packed-candidate scratch acceptance: pm github import unbraind/pm-web --issue 189 --dry-run planned one import and left zero items; a real import created exactly one provenance-tagged item.
  • Isolated Git identity: npm run release:check and bun run release:check each pass 546/546 tests with zero failures/skips/cancellations/todo and exact 100/100/100/100 coverage across 12 authored modules. The Bun release chain's coverage runner invokes Node.
  • Type checks, documentation, lint, zero duplication, privacy, production audit (zero vulnerabilities), packing, regenerated changelog/check, and publish-attestation checks pass at unchanged thresholds.

Package owner and full evidence: pm-github-6srd. Item remains in progress with its claim released.

Summary by Sourcery

Support exact GitHub issue imports and bounded list imports while preserving safe, idempotent tracker synchronization.

New Features:

  • Add exact GitHub issue selection with deduplicated numbers and repository references.
  • Add a bounded list-import mode that orders issues by most recently updated and reports truncation.

Bug Fixes:

  • Prevent partial imports by validating all explicitly selected issues, missing numbers, and pull requests before tracker writes.

Enhancements:

  • Expose selection and limit metadata in import results while preserving the existing import pipeline and provenance-based idempotency.
  • Update GitHub importer help, examples, and README documentation for the new options.

Documentation:

  • Document exact issue selection, list limits, validation behavior, and result metadata.

Tests:

  • Add fixture-backed regression and CLI coverage for issue selection, missing issues, pull-request handling, pagination limits, metadata, and pipeline compatibility.

Summary by cubic

Adds exact issue selection and a bounded list mode to pm github import. Previously, tracking a single issue meant approximating with --since, which could pull in unrelated issues in a busy repository; --issue 189 now fetches only that issue endpoint, and --limit n caps list-mode imports.

Details

  • --issue accepts comma-separated numbers, #N, and same-repo owner/repo#N references; references deduplicate before fetch, and malformed or cross-repo references fail with usage errors.
  • Every selected number is fetched and validated before any tracker write; a missing number aborts the batch (dry runs report missingIssues instead), and PRs require --include-prs.
  • --limit fetches newest-updated order and stops after one extra eligible issue proves truncation; results carry limit and truncated.
  • --issue conflicts with state/label/since/assignee/milestone filters and with --limit; both flags compose with comments, dependency linking, atomic imports, gates, and custom types, and re-imports update the same gh:owner/repo#N item.

Written for commit e0aae13. Summary will update on new commits.

View guided diff Turn on auto-fix

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Sorry @unbraind, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 22 hours and 53 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c941a9c6-36f3-41c8-a1b1-10408d1f5bbc

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR adds exact GitHub issue endpoint selection and a capped, newest-updated list mode, wiring both through validated CLI options and the existing atomic/idempotent import pipeline, with comprehensive fixture-backed integration coverage and updated documentation.

Sequence diagram for selected GitHub issue import

sequenceDiagram
    participant CLI
    participant Importer
    participant GitHub
    participant Tracker

    CLI->>Importer: parseImportOptions(options)
    Importer->>Importer: parseIssueNumbers(repo, input)
    loop selected issue numbers
        Importer->>GitHub: GET /repos/{repo}/issues/{number}
        GitHub-->>Importer: issue or HTTP 404
    end
    alt missing issue during normal import
        Importer-->>CLI: error, no issues imported
    else valid selection
        Importer->>Tracker: import selected issues
        Tracker-->>Importer: imported, updated, skipped
        Importer-->>CLI: result with missingIssues when applicable
    end
Loading

Sequence diagram for capped GitHub issue list import

sequenceDiagram
    participant CLI
    participant Importer
    participant GitHub
    participant Tracker

    CLI->>Importer: parseImportOptions(options)
    Importer->>GitHub: GET /repos/{repo}/issues?sort=updated&direction=desc&per_page=n+1
    loop pagination
        GitHub-->>Importer: issue page and Link header
        Importer->>Importer: applyClientFilters(issues, opts)
        alt more than n eligible issues
            Importer-->>Importer: retain n+1 and stop pagination
        else no truncation proven
            Importer->>GitHub: follow next page
        end
    end
    Importer->>Tracker: import first n eligible issues
    Tracker-->>Importer: import result with limit and truncated
    Importer-->>CLI: bounded import result
Loading

Flow diagram for GitHub import mode validation

flowchart TD
    A[GitHub import command] --> B{--issue provided?}
    B -->|Yes| C[parseIssueNumbers]
    C --> D{Conflicting flags or invalid reference?}
    D -->|Yes| E[Usage error]
    D -->|No| F[Fetch selected issue endpoints]
    B -->|No| G{--limit provided?}
    G -->|Yes| H[Validate positive integer]
    H --> I[Fetch newest-updated list with one-item probe]
    G -->|No| J[Fetch existing list mode]
    F --> K[Shared import pipeline]
    I --> K
    J --> K
    K --> L[Atomic and idempotent tracker writes]
Loading

File-Level Changes

Change Details Files
Add exact GitHub issue selection with validation, deduplication, preflight fetching, and batch-safe failure behavior.
  • Parse numeric, #N, and same-repository references while rejecting malformed, cross-repository, duplicate, or conflicting inputs.
  • Fetch selected issue endpoints directly, including missing-issue dry-run reporting and pull-request gating.
  • Preserve the existing import pipeline and result metadata across plain, atomic, dry-run, comment, dependency, gate, custom-type, and idempotent re-import paths.
index.ts
test/import-selection.test.ts
test/fixtures/import-selection/README.md
test/fixtures/import-selection/pm-web-189.json
test/fixtures/import-selection/pm-web-96.json
test/fixtures/import-selection/pm-web-175.json
test/fixtures/import-selection/pm-web-175-comments.json
test/fixtures/import-selection/pm-slack-standup-113.json
Add bounded list-mode imports ordered by most recently updated issue, with truncation detection.
  • Validate positive integer limits and reject combining --limit with explicit selection.
  • Request updated-descending pages and retain one extra eligible issue as a truncation probe while applying existing client-side filters.
  • Expose limit and truncated fields consistently across import result paths.
index.ts
test/import-selection.test.ts
Document and expose both import modes through the CLI, legacy command, and project documentation.
  • Add flag help, usage text, and examples for --issue and --limit.
  • Describe selection semantics, missing and PR behavior, pagination probing, and result metadata.
index.ts
README.md
Record the feature work and validation evidence in project PM artifacts.
  • Add the feature specification/history records.
.agents/pm/features/pm-github-6srd.toon
.agents/pm/history/pm-github-6srd.jsonl

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant