Skip to content

PR-API channel: optional collect-pr command for review comments (#5) - #17

Merged
mmcky merged 2 commits into
mainfrom
pr-channel
Aug 28, 2026
Merged

PR-API channel: optional collect-pr command for review comments (#5)#17
mmcky merged 2 commits into
mainfrom
pr-channel

Conversation

@mmcky

@mmcky mmcky commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Closes #5, implementing the design note posted there (2026-08-28) — phase 4 of the plan in #8.

What it adds

A new textstrata collect-pr <config> subcommand, the package's only network-touching code (authenticated gh, REST with pagination). It records one line per review comment anchored to a configured document into pr_channel.jsonl, with a pr_channel.json summary: PR and its state (open / merged / closed-unmerged — half the point of the channel), document and line, author login resolved to a roster role (unresolved logins recorded raw, never guessed), a bot flag (Copilot and other bot reviewers are collected and separable, not dropped), suggestion fences with an extracted before (comment's diff-hunk tail) / after (fence body) pair, and reply threading.

The determinism boundary holds as designed: scan neither reads nor writes the channel — no change to any existing artefact, blame, or metric — and the collector lives in its own module the scan never imports. The channel is opt-in per edition via a pr_channel: {repo: owner/name} config block (slug explicit because a checkout's remote may be a fork); the three reference configs gain theirs.

Acceptance (per the design note)

Run against the real lecture-python-programming.zh-cn: 84 review comments on 12 documents — 17 human (12 editor, 5 maintainer), 67 bot, 28 suggestions — with 15 records from closed-unmerged PRs. Humphrey's engine-critique comments surface as required, 6 of his 12 document-anchored comments coming from closed-unmerged PRs that git records nowhere. The counts reconcile with QuantEcon/project-translation#22's repo-wide tallies (Copilot 80 / mmcky 16 / editor 13): the channel is document-scoped by design, so comments outside the files glob account for the differences.

CI runs no network: the collector is tested over a stubbed API (glob and since filtering, roster resolution, suggestion extraction, closed-unmerged states, pagination concatenation). Full suite green including the pinned regression.

🤖 Generated with Claude Code

Implements the #5 design note: a new `collect-pr` subcommand — the package's
only network-touching code, requiring an authenticated gh — records review
comments and suggestion fences per document into pr_channel.jsonl with a
pr_channel.json summary. Authors resolve to roster roles by GitHub login
(unresolved logins recorded raw), bot reviewers are flagged rather than
dropped, suggestion fences carry an extracted before/after pair, and
closed-unmerged PRs contribute records — the signal squash merges and
closed PRs hide from git entirely.

`scan` neither reads nor writes the channel, so its determinism contract is
untouched and nothing is blended into blame; joins happen downstream on
document path. The three reference configs gain opt-in pr_channel blocks.

Acceptance on lecture-python-programming.zh-cn: 84 review comments on 12
documents (17 human: 12 editor, 5 maintainer; 67 bot; 28 suggestions), 15
records from closed-unmerged PRs, Humphrey's engine-critique comments among
them. Tests run over a stubbed API; no network in CI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 28, 2026 04:27

Copilot AI 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.

Pull request overview

Adds an optional PR-API “review comment” channel that can be collected via textstrata collect-pr <config> (using authenticated gh + REST pagination) into pr_channel.jsonl plus a pr_channel.json summary, without affecting the deterministic scan artefacts.

Changes:

  • Introduces src/textstrata/pr_channel.py implementing collection, roster resolution by GitHub login, bot flagging, and suggestion fence before/after extraction.
  • Extends config + CLI to support an opt-in pr_channel: block and a new collect-pr subcommand.
  • Adds docs and tests for the collector (explicitly no-network via a stubbed API).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_pr_channel.py New unit tests covering filtering, roster resolution, bot detection, suggestion extraction, and pagination concatenation.
src/textstrata/pr_channel.py New collector module implementing gh api pagination parsing, comment filtering, record writing, and summary generation.
src/textstrata/config.py Adds PrChannelConfig and wires pr_channel into config loading/validation.
src/textstrata/cli.py Adds collect-pr subcommand and error handling for collector failures.
docs/method.md Documents the PR-API channel’s purpose and output artefacts.
docs/configuration.md Documents pr_channel config block and since example.
configs/quantecon/python-zh-cn.yml Enables pr_channel.repo for the python zh-cn reference config.
configs/quantecon/programming-zh-cn.yml Enables pr_channel.repo for the programming zh-cn reference config.
configs/quantecon/intro-zh-cn.yml Enables pr_channel.repo for the intro zh-cn reference config.
CHANGELOG.md Notes the new optional PR-API channel collector.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/textstrata/pr_channel.py
Comment thread src/textstrata/pr_channel.py
Comment thread src/textstrata/pr_channel.py
…losed-unmerged state

A missing gh binary now raises GhError with an actionable message instead of
an uncaught FileNotFoundError; _concat extends one list instead of copying
per page; and pr_state says "closed-unmerged" rather than GitHub's raw
"closed", matching the stated output contract (re-verified live: programming
reads closed-unmerged 15 / merged 69).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mmcky
mmcky merged commit 5bb27e2 into main Aug 28, 2026
3 checks passed
@mmcky
mmcky deleted the pr-channel branch August 28, 2026 05:37
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.

PR-API channel for review comments and suggestion-accepts

2 participants