Skip to content

feat: github rest client for dataset proposals#383

Open
Scr4tch587 wants to merge 3 commits into
kai/react-specfrom
kai/github-client
Open

feat: github rest client for dataset proposals#383
Scr4tch587 wants to merge 3 commits into
kai/react-specfrom
kai/github-client

Conversation

@Scr4tch587

Copy link
Copy Markdown
Collaborator

What changed

New `core/github/` package: a minimal GitHub REST client (`GitHubClient`) used by the upcoming dataset-proposal endpoint to open PRs with a bot token. Methods:

  • `get_branch_sha` / `commit_files_to_new_branch`: commits a set of files as a single commit on a new branch via the git data API (tree → commit → ref)
  • `create_pull` + `request_reviewers`: opens the PR and requests reviewers best-effort — the PR author is filtered out (GitHub refuses author-as-reviewer), and if a batch request fails (e.g. one login isn't a collaborator) each reviewer is retried individually so one bad entry can't drop the rest; failures log warnings and never fail the flow
  • `open_pr_with_files`: the one-call orchestration the service layer uses
  • errors surface as `GitHubError` (carries HTTP status); an existing proposal branch raises the `BranchAlreadyExistsError` subclass (422 "already exists")
  • config from env: `GITHUB_TOKEN` (required), `GITHUB_REPO`, `GITHUB_API_URL` (override used to e2e-test against a local fake GitHub)

Built on `requests` (already a production dependency). Tests mock at the transport-adapter layer — no network.

Why

Dataset creation is being added as a PR-based flow: submissions become pull requests so code review stays the gate for anything that executes on the server (per the trust model in SPEC-backend). This client is the transport for that. First PR of the dataset-creation stack (on top of the react migration stack).

Benefit

One clean commit per proposal, reviewer auto-assignment that degrades gracefully, and a client that's fully testable offline.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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