Port PR pre-review/welcomer script to a GitHub Action
Summary
Port the PR pre-review/welcomer workflow from its current polling-script implementation to a GitHub Action, mirroring the pattern already used for issue enrichment (#13075) and i18n (#13061). Sub-task of #13160.
Current state
The logic already exists and runs today via python3 pam.py prs (a minute-polling script run from ~/Projects/openlibrary-pam / ~/Projects/pm), which invokes Claude inline per new community PR. Behavior (see pr-prereview.md in the pm PAM repo):
- Gives every non-draft, non-staff community PR a first-touch welcome comment: signal gathering (
new_pr_bot.pyor directghcalls), completeness checks (description, linked issue), a wait-time/queue estimate. - Assigns a reviewer (currently Copilot, or notes
@openlibrary-botis available). - All public actions post via
gh-bot(@openlibrary-bot), nevergh. - Skips: draft PRs, staff-authored PRs, bot-authored PRs, PRs a human has already commented on, PRs already carrying the
<!-- ol-pr-bot -->idempotency marker. - Complex/maintenance cases (rebase needed, CI broken, squash needed) get logged to
state/pr-exceptions.jsonlrather than acted on automatically.
What needs to change for the GH Action port
- Trigger on
pull_request: types: [opened](plus considerreopened) instead of polling. - Same non-write-actor permission consideration as #13161 — most PR authors on a public repo have only read access, so the action needs
allowed_non_write_users(or equivalent) configured correctly, and should be validated with a fresh PR event, not a rerun (see #13161's finding on why reruns don't retest this). - The reviewer-assignment step currently assumes Copilot is available — GitHub discontinued free Copilot credits for OSS maintainers, so this step needs to either point at the new Code Review Action (once built, see #13160) or be temporarily changed to just note
@openlibrary-botavailability without an automatic assignment. - Preserve the "ignore comments/PRs from
openlibrary-botitself" safety rule (same class of bug as #13138). - Maintenance-case logging (
state/pr-exceptions.jsonl) needs an equivalent mechanism once there's no long-running polling process to write to a local file — likely a labeled-issue or PR-comment fallback instead.
Related
- #13160 — Epic: AI Workflows (parent)
- #13075 — Issue Enrichment via claude-code-action (the pattern this mirrors)
- #13161 — non-write-actor permission bug found while porting issue enrichment; same class of risk applies here
- #13138 — bot-comment feedback-loop bug (ignore-openlibrary-bot's-own-actions class)
[!WARNING] This issue requires access to internal infrastructure, production systems, or institutional knowledge unavailable to community contributors. It can only be resolved by a maintainer or staff member.
Template assessment
- Problem / Opportunity — present, though implicit: the "Current state" section explains what runs today (
pam.py prs, invoked from~/Projects/openlibrary-pam/~/Projects/pm) and why a port is wanted (parity with the #13075/#13061 pattern), but doesn't state a measurable impact (e.g. current welcome-comment latency, PR volume affected). - Proposal — present and concrete: trigger change, permission handling, reviewer-assignment fallback, self-ignore rule, and exception-logging replacement are all named specific changes.
- Breakdown — informal but sufficient: the "What needs to change" list functions as a breakdown even without a formal checklist/stakeholders block.
Context
- The pattern this should mirror is
issue_enrichment.yml:claude-code-action@v1driven by a markdown instructions file, posting viaOL_BOT_PAT. - This issue's own "non-write-actor permission" callout is directly live right now: #13161 is an open, unresolved investigation into whether
allowed_non_write_users: "*"(issue_enrichment.yml#L46-L51) actually bypasses the actor-permission gate for a genuinely non-write actor — no confirmed-successful test against a real non-staff, non-write account exists yet. Since most PR authors on a public repo are non-write, this new action would hit the identical unconfirmed code path. - There's a second, distinct trigger-type decision this issue doesn't mention: the repo already has a precedent for
pull_request_target(not plainpull_request) to get write-level permissions on fork PRs — seenew_pr_labeler.yml. The issue proposes plainpull_request: opened, which (likeissues: opened) only gets a read-only token for fork PRs and would need the sameallowed_non_write_usersbypass rather than the_targetapproach. Worth deciding explicitly which pattern to follow, sincepull_request_targetcarries its own well-known risk (running with base-branch permissions against untrusted head-branch code) that the existing labeler workflows sidestep by never checking out PR code. - No file in this checkout implements
new_pr_bot.py,pam.py, orpr-prereview.md— confirms the source logic lives entirely outside this repo, in the PAM directories named in the issue body. - Searched open/closed issues and PRs for prior attempts at this specific port (
pam,welcomer,pre-review,new_pr_bot) — found none; #13162 is not a duplicate of existing work.
Issue Assessment
Open questions
- [x] Is there an existing PR or in-repo file implementing this port already? (Answer: No — grepped the codebase and searched issues/PRs; nothing matches. Not a duplicate.)
- [ ] Which trigger pattern should this use — plain
pull_request(matching this issue's proposal, needsallowed_non_write_usersbypass) orpull_request_target(matchingnew_pr_labeler.yml's existing precedent, different trust trade-offs)? This is a maintainer call given the security implications either way. - [ ] Should this action wait on #13161's non-write-actor bypass being confirmed working (not just merged) before going live, given it would exercise the identical code path against real community PRs?
- [ ] What should the reviewer-assignment step do in the interim — silently note
@openlibrary-botavailability, or is there a decision to gate on the not-yet-built Code Review Action (#13160) first? - [ ] What should the
state/pr-exceptions.jsonlreplacement be (labeled issue vs. PR comment)? The issue names both as options without picking one.
🔔 Stakeholders
No additional stakeholder beyond the assignee — this is a subtask of an epic already owned end-to-end by the assignee.
Full triage checklist
- [x] Triage — correct labels applied or removed
- [x] Problem / opportunity — problem is clear, audience identified (bot maintainers), actionable
- [x] Scope — well-scoped; one specific script port, not bundled with unrelated work
- [x] Justification — reasoning given (parity with shipped #13075 pattern, Copilot credit loss); no quantified impact metric
- [ ] Success & testing criteria — no explicit "done" definition or test plan given (compare to #13075's PR, which had one)
- [x] Proposal & breakdown — concrete plan present; actionable
- [ ] If bug: environment & repro steps — n/a, this is a feature/port, not a bug
- [x] Risks, concerns, open questions — identified and surfaced (permission bypass, trigger-type choice, reviewer fallback)
- [x] Richy context — relevant code, commits, related issues/PRs reviewed; no duplicate found
- [x] References — linked to #13160, #13075, #13161, #13138
[!NOTE] This comment was automatically generated by Richy, Open Library's issue enrichment assistant, on behalf of @mekarpeles. This is NOT a sign-off. This issue needs lead review before work begins.
Opened #13164 — PR auto-responder GitHub Action, ports pr-prereview.md/pam.py prs. Closes this issue on merge.