|
| 1 | +# Workflow comment-spam hardening implementation plan |
| 2 | + |
| 3 | +> **For agentic workers:** execute this plan test-first. Do not broaden workflow permissions or execute pull-request head code with a write-capable token. |
| 4 | +
|
| 5 | +**Goal:** Reduce GitHub Actions noise and runner consumption caused by `issue_comment` while preserving issue-comment translation and the PR readiness gate's ability to invalidate a ready PR when CodeRabbit reports new findings. |
| 6 | + |
| 7 | +**Architecture:** Keep `issue_comment` only where GitHub offers no narrower native trigger: real-time issue-comment translation. Revalidate CodeRabbit readiness from its `CodeRabbit` commit status using the default-branch-only `status` event, then resolve the status SHA to exactly one open PR before the privileged gate writes anything. Make `gui-screenshot-waived` the immediate maintainer-controlled waiver trigger while preserving legacy maintainer-comment recognition on later PR events for compatibility. |
| 8 | + |
| 9 | +**Tech stack:** GitHub Actions YAML, `actions/github-script`, Bun tests, existing PR-gate scripts. |
| 10 | + |
| 11 | +## Global constraints |
| 12 | + |
| 13 | +- PR targets `dev`. |
| 14 | +- Workflow changes become live only after promotion to default branch `main`. |
| 15 | +- Never checkout or execute PR-head code in a workflow with write permissions. |
| 16 | +- Preserve real-time non-English issue-comment translation. |
| 17 | +- Preserve CodeRabbit/Codex review-thread verification as the source of truth; review/comment bodies are trigger signals only, never trusted gate evidence. |
| 18 | +- Do not claim that a job-level `if` removes an `issue_comment` workflow-run entry: it only prevents runner allocation for filtered comments. |
| 19 | + |
| 20 | +## Task 1: Stop PR and bot comments from allocating issue-quality runners |
| 21 | + |
| 22 | +**Files:** |
| 23 | +- Modify: `.github/workflows/enforce-issue-quality.yml` |
| 24 | +- Modify: `tests/ci-workflows.test.ts` |
| 25 | + |
| 26 | +- [ ] Add regression assertions requiring the `translate-comment` job to run only for `issue_comment` events on real issues and non-bot authors. |
| 27 | +- [ ] Run the focused workflow test and confirm it fails against the current workflow. |
| 28 | +- [ ] Add the minimal job-level guard: exclude `github.event.issue.pull_request != null` and bot-authored comments before checkout/setup/AI steps. |
| 29 | +- [ ] Re-run the focused workflow test and confirm it passes. |
| 30 | + |
| 31 | +## Task 2: Replace CodeRabbit status-comment gate triggers with a trusted commit-status signal |
| 32 | + |
| 33 | +**Files:** |
| 34 | +- Modify: `.github/workflows/enforce-pr-target.yml` |
| 35 | +- Replace: `tests/zz-pr-coderabbit-readiness-revalidation.test.ts` |
| 36 | + |
| 37 | +- [ ] Require no `issue_comment`, `pull_request_review`, or PR-controlled signal workflow for CodeRabbit revalidation. |
| 38 | +- [ ] Consume CodeRabbit's successful `CodeRabbit` commit status through the default-branch-only `status` event. |
| 39 | +- [ ] Resolve the status SHA with `listPullRequestsAssociatedWithCommit` and continue only when exactly one open PR has that SHA as its current head. |
| 40 | +- [ ] Treat status-triggered runs as signal-only head evidence and re-read live review threads/bodies before any write. |
| 41 | +- [ ] Keep the write-capable checkout pinned to the trusted default branch for status events. |
| 42 | + |
| 43 | +## Task 3: Move GUI screenshot waiver from maintainer comments to a label |
| 44 | + |
| 45 | +**Files:** |
| 46 | +- Modify: `.github/workflows/enforce-pr-target.yml` |
| 47 | +- Modify: `tests/ci-workflows.test.ts` |
| 48 | +- Modify: `docs-site/src/content/docs/contributing/pr-quality.md` |
| 49 | + |
| 50 | +- [ ] Add regression assertions for `labeled` / `unlabeled` PR-target events and `gui-screenshot-waived` semantics. |
| 51 | +- [ ] Confirm the new assertions fail against current behavior. |
| 52 | +- [ ] Use `gui-screenshot-waived` as the only immediate GUI-waiver trigger, while preserving legacy maintainer-comment recognition on later PR events for compatibility. |
| 53 | +- [ ] Document that the label is maintainer-controlled and that adding/removing it immediately re-evaluates the gate. |
| 54 | +- [ ] Re-run focused workflow tests. |
| 55 | + |
| 56 | +## Task 4: Verification and PR |
| 57 | + |
| 58 | +- [ ] Run `bun test tests/zz-pr-coderabbit-readiness-revalidation.test.ts tests/ci-workflows.test.ts`. |
| 59 | +- [ ] Run `node --test .github/scripts/*.test.cjs` because the gate still consumes those helpers. |
| 60 | +- [ ] Run `bun run typecheck`. |
| 61 | +- [ ] Run `git diff --check`. |
| 62 | +- [ ] Verify the final diff contains no temporary implementation workflow or helper. |
| 63 | +- [ ] Open a draft PR against `dev` with deployment note: event-driven workflow changes take effect only after promotion to `main`. |
| 64 | + |
| 65 | +## Expected effect |
| 66 | + |
| 67 | +- CodeRabbit PR status-comment edits no longer invoke `enforce-pr-target`. |
| 68 | +- Ordinary maintainer PR comments no longer invoke `enforce-pr-target` merely to carry a GUI waiver. |
| 69 | +- PR and bot comments still create an `Enforce issue quality` workflow-run record because GitHub cannot filter `issue_comment` by PR-vs-issue at trigger time, but the translation job is skipped before runner allocation. |
| 70 | +- Real issue comments from humans continue to translate in real time. |
| 71 | +- New CodeRabbit reviews can still invalidate a previously completed findings claim through CodeRabbit's commit status and a default-branch, write-capable gate without executing untrusted PR code or trusting an ambiguous SHA-to-PR association. |
0 commit comments