openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

AI Actions & Workflows: Automate Issue & PR lifecycle

Open mekarpeles opened this issue 4 months ago • 8 comments

Living status — rewritten in place (2026-11-03). This body is the single tracker; it is rewritten as state changes, not appended to. History is in GitHub's edit log. Per-unit detail lives in each unit's own issue/PR.

Summary

Migrate PAM's issue/PR automation from ad-hoc polling (pam.py) to GitHub Actions triggered on repo events, using a Claude subscription token — the pattern first established for i18n (#13061). Also the vehicle for replacing code-review coverage lost when GitHub discontinued free Copilot credits for OSS maintainers.

The point — why this goal exists

As of 2026-11-14 the repo carries ~227 open PRs, and the project-management cost of that backlog is overwhelming the team. That overhead is the problem this goal exists to kill. The point of the automation is not more dashboards or more process — it is to make the machine manageable by a small team:

  • Every PR (and issue) is assessed, reviewed, and checked automatically, and the checks are gates that run before a human is asked to look — not reports produced after.
  • A PR reaches a human only when it is genuinely ready: gates green, nothing a check could have caught still outstanding. The "ready for human review" queue should get smaller, not larger.
  • When a PR is not ready, the next step routes back to the contributor (fix the failing check, answer the question, fill the template) — not to staff. Staff attention is the scarcest resource and is spent only where a gate cannot stand in for human judgement.

The success metric is the size of the human-review queue, not the count of automations. An automation that adds steps without shrinking what staff must personally review is not serving this goal.

Epics (quarterly) under this goal

This yearly goal is delivered through two coherent, quarterly epics — one per half of the pipeline:

  • PR — Checks & Automations · #14461 — the PR half: code review → e2e testing → merge gating, as SHA-bound checks + actions + a ruleset. (Code-review required gate shipped.)
  • Issues — Checks & Automations · #14472 — the issue half: triage → enrichment → readiness, steering contributors to workable issues before code is written.

(The sub-initiatives below are the individual deliverables; they roll up under one of the two epics.)

The approved security pattern (the two-job split)

Every agentic workflow that lets a model read untrusted PR/issue content must split in two:

  • analyze reads the untrusted input holding no write permission and no PAT — a read-only tool allowlist, no gh. Its only output is a machine-validatable artifact.
  • post holds the write credential, runs no model, and re-validates that artifact against the source before writing.

A prompt injection can change what the automation says (a public comment either way) but cannot reach a write API, because the process that read the untrusted input has nothing to write with.

Reference implementation: #13620 (merged 2026-10-05, live as the Code Review Action). Documented — general pattern in the ADA skill docs/skills/two-job-untrusted-input.md; OL-specific bindings in ol-kb wiki/agentic-two-job-pattern.md.

Cross-cutting rule

Every action under this epic ignores openlibrary-bot's own actions, to avoid feedback loops (origin: #13138).

The four sub-initiatives

  • [x] Issue Enricher (#13075) — live (hardened single-job, not yet two-job). Contributor checklist suppressed on assigned/staff issues (#13734, merged 2026-10-28). Shipped earlier: Bash(gh api:*) removed (#13621, merged). Known defect: roughly half its runs fail since 2026-10-18 with Reached maximum number of turns (30) (--max-turns 30 in issue_enrichment.yml); see Open work. Draft #13242 (gate up front, assert it actually posted) has been untouched since 2026-07-31.
  • [x] PR Auto-Responder (#13164) — live (hardened single-job). Known defect: its reviewer-request step (requests copilot-pull-request-reviewer[bot]) has never reliably assigned a reviewer — see Open work.
  • [x] Code Review Action (#13744, supersedes closed #13163) — live, the first workflow on the two-job pattern. #13620 merged 2026-10-05; the OL_BOT_REVIEW_PAT secret is set (2026-09-30). Triggered when auto_assign_reviewer requests openlibrary-bot; openlibrary-bot reviewed 8 PRs created since 2026-10-15 (#13939, #14033, #14056, #14057, #14059, #14061, #14063, #14229). Follow-up #13781 (withheld-finding private route) is still open; on 2026-10-23 @mekarpeles floated switching to pr-agent instead.
  • [ ] Issue Follower — not built. It was deferred (2026-07) to @jimchamp's #13157, but #13157 was closed without merging (2026-08-31), so event-driven Needs: Response labeling never shipped. What runs today is the daily new_comment_digest.yml cron (issue_comment_bot.py), which still applies Needs: Response once a day. Fires-on-comment re-labeling still needs filing and building.

Conformance: one live workflow uses the two-job pattern

The Code Review Action (#13620) is the first live two-job workflow. The Enricher and Auto-Responder still run the older single-job shape (model + OL_BOT_PAT in one job), hardened with allowed_non_write_users scrubbing and allowlist gating but not conformant. Upgrading them is no longer blocked (#13620 proved the pattern), but is not a mechanical port — their output (free-form comments, label decisions) is harder to validate in a token-less post step than a structured review is.

Decisions pending (Mek)

  • ~~Set the OL_BOT_REVIEW_PAT secret value~~ — done (set 2026-09-30); the Code Review Action is live.
  • #13781 withheld-finding route — approve the encrypt-to-committed-public-key design (needs no new credential; preserves the two-job boundary) and name the recipient set, or decide whether to replace the Code Review Action with pr-agent (raised on #13781, 2026-10-23).
  • team.json — leave the graduated jimchamp on the public recognition page, or remove? (He is still listed in openlibrary/templates/about/team.json; #13797 deliberately left it; recommendation: leave.)
  • ~~jimchamp's 5 lead areas + ~30 open Lead: @jimchamp issues~~ — resolved 2026-11-03: @RayBB reassigned all 27 open Lead: @jimchamp issues to active leads; none remain.

Open work

  • [ ] Fix the Enricher's max-turns failures. Since 2026-10-18 about half of issue_enrichment runs end with Reached maximum number of turns (30) and exit 1. Decide between raising --max-turns, trimming the prompt's steps, and #13242's gate-up-front approach.
  • [ ] Upgrade Issue Enricher to the two-job pattern — unblocked: #13620 proved the pattern.
  • [ ] Upgrade PR Auto-Responder to the two-job pattern — unblocked.
  • [ ] Reviewer-wiring fix. The Auto-Responder's Copilot-reviewer request has never reliably succeeded. (auto_assign_reviewer is fine — it requests openlibrary-bot, which now triggers the Code Review Action, and correctly excludes bot-authored PRs.)
  • [ ] Single source of truth for the staff/lead list (config/staff.json, does not exist yet), per the ol-kb agentic-workflows-staff-allowlist page — collapses the ~9 drifting hardcoded copies into one.
  • [ ] Issue Follower — file and build (no-op first pass); replaces the daily Needs: Response cron with event-driven labeling.
  • [ ] Shared model-token capacity. All three agentic workflows (issue_enrichment, pr_autoresponder, code_review_action) now use the one OL_BOT_CLAUDE_OAUTH_TOKEN. The 2026-10-01 cluster of intermittent 401/403 claude execution failed self-recovered (consistent with subscription usage that resets, not a dead credential). Pressure grows with every workflow on that token; watch for recurrence.

Done

  • [x] Staff allowlist cleanup (#13796 → #13797, merged). Removed graduated jimchamp from all live allowlists / lead-routing / the slack-digest INCLUDE_AUTHORS; added missing lokesh to the stale-ticket exempt list. The agent found the drift was ~9 files, wider than the 6 first enumerated. code_review_action.yml's gate entry was removed separately in #13620; team.json left for Mek (above).
  • [x] new_pr_labeler skipped PRs opened as drafts (#13764 → #13785, merged). External contributor added the ready_for_review trigger; reviewed PASS. Forward-fix only — the ~23 already-mislabeled draft-opened PRs are not retroactively relabeled.

Related PR-lifecycle fixes (adjacent openlibrary-bot surface)

  • [x] Lead auto-assignment broken 2026-09-01 → 2026-10-26 (#13743) — the lead/leadName key mismatch in new_pr_labeler.mjs; fixed by #13745 (merged 2026-10-26). Together with the merged #13785 (draft-opened PRs get evaluated), PRs that close an issue with a Lead: label now get that lead assigned (confirmed: assigner github-actions[bot] on #14113, #14191, #14224).
  • [x] PRs still unassigned after the fix (#14254). Since 2026-10-26, 89 non-bot PRs: 25 link an issue with no Lead: label, 18 only say "Part of #N" or similar, 15 reference no issue, and 5 had the lead label added after the PR opened. Shipped (all merged):
    • #14255 — new_pr_labeler also reads non-closing references ("Part of", "Refs", "Related to", "Follow-up to", "Works on", "Towards"), falls back to the parent epic's lead, and writes its decision to the job summary. New pm_pr_lead_sweep (14:00 and 02:00 UTC) applies the same decision to open PRs that have never had an assignee. First live run assigned 4 "Part of" PRs.
    • #14256 — the lead is assigned even when they wrote the PR, so they decide what happens to it.
    • #14259 — the sweep always writes (dry-run mode removed); PR and issue numbers in its summary are links.
    • #14260 — the sweep also keeps Needs: Lead on exactly the open issues with no Lead: label (templates add it on creation, but nothing updated it afterwards). Still unassignable by design: PRs whose issue has no lead (now surfaced via Needs: Lead) and PRs that reference no issue (56 of 65 in the 30 days to 2026-11-03 were by staff).

Prior art

  • #13061 — i18n pipeline migration; established the Claude-token GitHub Action pattern.
  • #13075 — first OL-native example of the pattern (issue_enrichment.yml).
  • #13138 — bot's own comments triggering Needs: Response; origin of the cross-cutting rule.

mekarpeles avatar Jul 15 '26 21:07 mekarpeles

[Auto-posted artifact — not status. The PR-autoresponder commented on this epic as if it were a contributor PR. Superseded; current status is in the issue body. Kept as history.]

⚠️ Contributors, this issue will be ready to work on once:

  • [ ] Triage — maintainers will add Priority: * and Lead: @*
  • [ ] Needs: Investigation — the Code Review Action sub-initiative explicitly requires research into how Copilot structures its inline review comments before design can start
  • [ ] Needs: Breakdown — two of the three sub-initiatives (Code Review Action, Issue Follower) have no standalone tracking issue yet, and PR Auto-Responder's is explicitly noted as unfiled

Context

  • The epic's baseline assumption — that Issue Enrichment (#13075) is "already shipped" — only became fully true today. issue_enrichment.yml rejected every issue opened by a non-maintainer from 2026-07-07 onward due to an actor-permission gate in claude-code-action; the fix (#13154) merged 2026-07-15, the same day this epic was opened.
  • The Copilot/gh-aw-based predecessor this epic's pattern replaced is still present in the tree: issue_refinement.md and its compiled issue_refinement.lock.yml (1144 lines, per #13075's own description). The corresponding GitHub Actions workflow ("Issue Refinement Assistant") is disabled_manually, but the files were never removed — candidate cleanup under this epic's "Theme: Bots" scope.
  • #13138 (openlibrary-bot's own comments incorrectly triggering Needs: Response) — cited by this epic's cross-cutting rule — is still open and unresolved (Needs: Response, Needs: Staff Decision). Every sub-initiative that follows the "ignore our own bot" rule will need to either depend on that fix or reimplement the same guard independently.
  • Existing, already-shipped PR-lifecycle automation that the PR Auto-Responder and Issue Follower sub-initiatives should coordinate with rather than duplicate: new_pr_labeler.mjs (labels/assigns new PRs from their linked issue), pr_changes_requested.yml (labels Needs: Submitter Input on changes-requested), and pm_stale_pr_messenger.yml (nags stale PRs waiting on submitter input).

Issue Assessment

Open questions

  • Should Code Review Action's staff-only trigger reuse the allowed_non_write_users actor-permission pattern just fixed in #13154, or does a code-review action — which would presumably need broader tool access to read/comment on PR diffs — warrant a stricter actor gate given the larger blast radius versus the issue-only tool scope issue_enrichment.yml uses?
  • Should the three sub-initiatives block on #13138 landing first (shared "ignore self" utility), or ship independently and retrofit once it's resolved?

Action items

  • [x] Confirm whether PR Auto-Responder has been filed as its own tracking issue yet (Answer: no — searched open and closed issues for matching titles/keywords, found none).
  • [ ] File the standalone tracking issue for PR Auto-Responder, porting the pam.py prs / pr-prereview.md logic referenced in the epic body.
  • [ ] File the standalone tracking issue for Code Review Action, gated on the Copilot inline-review-comment research called out in the epic body.
  • [ ] File the standalone tracking issue for Issue Follower (a no-op first pass is acceptable per the epic body).
  • [ ] Decide whether to remove the superseded issue_refinement.md / issue_refinement.lock.yml now that the disabled workflow they define has no active successor role left to play.

Suggested breakdown

  • [ ] File tracking issue: PR Auto-Responder
  • [ ] File tracking issue: Code Review Action (blocked on Copilot inline-review research)
  • [ ] File tracking issue: Issue Follower
  • [ ] Remove/retire issue_refinement.md + issue_refinement.lock.yml
  • [ ] Land #13138 fix as a shared "ignore openlibrary-bot" utility usable by all three sub-initiatives

None of the above are Good First Issue candidates — each requires GitHub Actions/automation context and coordination with the external pam/pm repos referenced in the epic body.


🔔 Stakeholders

@jimchamp — owns the existing PR-lifecycle automation (new_pr_labeler.mjs/.yml) that PR Auto-Responder and Issue Follower would sit alongside; worth a look given file-ownership overlap.


Full triage checklist
  • [x] Triage — Needs: Lead, Needs: Triage, Needs: Breakdown, Needs: Investigation applied this pass; Priority:/Lead: still pending staff
  • [x] Problem / opportunity — problem, audience (maintainers/contributors relying on issue/PR automation), and rationale are clear
  • [x] Scope — bundling three sub-initiatives is expected for an Epic; each is independently well-defined
  • [ ] Justification — motivation stated (replace polling scripts, replace lost Copilot credits) but no measurable success metric for the epic as a whole
  • [ ] Success & testing criteria — no epic-level "done" definition; each sub-initiative needs its own
  • [ ] Proposal & breakdown — two of three sub-initiatives lack a filed tracking issue
  • [x] If bug: environment & repro steps — not applicable, this is an Epic, not a bug
  • [x] Risks, concerns, open questions — surfaced above
  • [x] Richy context — codebase, git history, and related issues/PRs reviewed; no duplicate epic found
  • [x] References — related issues (#13061, #13075, #13138) already linked in the epic body

[!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.

openlibrary-bot avatar Jul 15 '26 21:07 openlibrary-bot

[Superseded 2026-10-04 — Issue Enricher is live; see the issue body. The write-permission concern was resolved in the enrichment hardening.]

Filed #13161 — the issue-enrichment write-permission bypass (#13154) is not yet confirmed working for real non-write actors; likely a GitHub Actions workflow-resolution lag for issues-triggered events. See that issue for full evidence.

mekarpeles avatar Jul 15 '26 21:07 mekarpeles

[Superseded — #13162 became the PR Auto-Responder, shipped as #13164 (merged, live). Current status in the issue body.]

Filed #13162 — PR auto-responder port, first sub-initiative tracking issue.

mekarpeles avatar Jul 15 '26 22:07 mekarpeles

[Superseded — #13163 is closed; the Code Review Action is now tracked in #13744, built in draft #13620. See issue body.]

Filed #13163 — Code Review Action (Copilot replacement), second sub-initiative tracking issue.

mekarpeles avatar Jul 15 '26 22:07 mekarpeles

[Superseded — #13164 merged; PR Auto-Responder is live. See issue body.]

Opened #13164 (closes #13162) — first working implementation under this epic.

mekarpeles avatar Jul 15 '26 22:07 mekarpeles

[Superseded — this deferral no longer holds: #13157 is closed and @jimchamp has graduated. Issue Follower is re-opened as an open question in the issue body.]

Issue Follower: deferring to @jimchamp's #13157, which already implements event-driven Needs: Response labeling (replacing the old daily issue_comment_bot.py cron). Posted proposals there (missing config file, retiring the old digest workflow, an LLM-classification follow-on for the Fonzie taxonomy's other labels) rather than opening a competing PR. No separate PAM PR planned for this sub-initiative as long as #13157 lands.

mekarpeles avatar Jul 15 '26 23:07 mekarpeles

[Superseded — the NOP scaffold is being replaced by the real Code Review Action in draft #13620. See issue body.]

Opened #13167 — Code Review Action trigger scaffold (NOP placeholder), progresses #13163.

mekarpeles avatar Jul 15 '26 23:07 mekarpeles

Known problems — issue & PR automation (living list)

A single tracked list of the open problems in our issue/PR lifecycle automation. Checked = solved. Edited in place as things land; this comment is the source of truth, not a thread.

Issue intake

  • [ ] New issues don't get the right initial labels on open — the create action should tag Needs: Enrichment, Not Ready for Work!, Needs: Triage, Needs: Lead (today labels come only from template front-matter)
  • [ ] Enrichment doesn't clear its own flag — after an issue is enriched, Needs: Enrichment should be removed, while Not Ready for Work! and triage/lead stay until a human clears them
  • [ ] Issues get public bot comments before anyone has approved them for work
  • [ ] Issues are acted on under-researched (no enforced research step before work begins)
  • [ ] Too many issues sit needing a response from a lead

PR review

  • [ ] PRs can merge without a code review (fork and non-bot coverage gaps)
  • [ ] Reviews get requested on PRs we don't actually want reviewed
  • [ ] Code-review findings on a contributor (non-bot) PR aren't automatically addressed — the review emits applicable suggestions, but nothing picks them up and acts
  • [ ] Code-review status can stay red after findings are resolved in place, with no new commit to re-trigger it (#14450)

Testing

  • [ ] PRs can merge without an automated end-to-end test
  • [ ] End-to-end (Docker) testing is still run by hand

Assignment & strategy

  • [ ] Contributors ask to be assigned by hand where we'd rather auto-assign
  • [ ] PRs get opened that don't match current priorities, with no early signal
  • [ ] PRs land that don't follow repo conventions

Known limitations

  • [ ] Withheld security findings can't be viewed — the review gate withholds the whole review when a finding is security-sensitive, and today the only way to see those findings is to re-run an adversarial review locally

openlibrary-bot avatar Nov 18 '26 18:11 openlibrary-bot