Skip to content

fix(webhook): grant pull request fast-ack tokens pull_requests write - #1082

Merged
steipete merged 2 commits into
mainfrom
fix/pr-fast-ack-hardening
Aug 9, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/pr-fast-ack-hardening

Conversation

@steipete

@steipete steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Problem

Since PR #1078 deployed (2026-08-09 04:10Z), every pull_request opened/ready_for_review webhook delivery to clawsweeper.openclaw.ai returned HTTP 500 (Cloudflare 1101, Worker uncaught exception) until #1079 (04:53Z) moved the fast ack behind a bare .catch(() => undefined) — which stopped the 500s but left the receipt ack silently broken: no PR has received its 🦞👀 comment since.

Root cause (verified live)

acknowledgePullRequestReceipt mints its App installation token with permissions: { issues: "write", pull_requests: "read" }. Posting a comment on a pull request via POST /repos/{repo}/issues/{n}/comments requires pull_requests: write for App tokens. GitHub answers 403 "Resource not accessible by integration", githubTokenJson throws. Replaying the worker's exact sequence (WebCrypto JWT replica included) from Actions with the production key reproduced it: every step 200/201 until the comment POST 403s with pull_requests: read; flipping to write posts successfully. The working comparison is the maintainer-command ack path, which has always minted pull_requests: "write".

Bonus finding from the same replay: createGithubAppTokenFor sends repository_names in the mint body — a parameter the GitHub API does not have. It is silently ignored and tokens come back repository_selection: "all" (installation-wide) instead of scoped to the named repo. The documented parameter is repositories (verified: yields "selected", 1 repo).

Changes

  • acknowledgePullRequestReceipt: mint pull_requests: "write" (matches the command-ack path).
  • Webhook call site: log swallowed fast-ack failures (console.error) so the next regression shows up in wrangler tail; webhook still never fails on ack errors.
  • createGithubAppTokenFor (dashboard queue) and createInstallationToken (src/repair/comment-webhook.ts): repository_names → repositories, restoring real repo scoping.
  • Tests: mint-body assertions (repositories + pull_requests: write), and the ack-failure case now uses the production-shaped 403 response instead of a thrown mock error.

Impact assessment of the incident

Delivery-log audit of the outage window (04:12:08–04:52:37Z): 500s hit only opened/ready_for_review; enqueue ran before the throw, and reconcile lanes absorbed the rest — every PR opened in the window is either already reviewed or pending in the queue. No redelivery batch needed.

Proof

  • pnpm run check green (coverage 81.34% lines / 74.05% branches / 87.37% functions).
  • Targeted: node --test test/dashboard-worker.test.ts test/exact-review-publication-batches.test.ts — 386 pass, 0 fail; the 403 regression test logs ClawSweeper pull request fast ack failed: ClawSweeper ack comment 403: … and returns 202/queued.
  • Live validation: Actions replay of the exact ack sequence with pull_requests: write posted the receipt comment on fix: enable Slack native approvals for Enterprise Grid installs openclaw#120874 (the PR whose lost delivery started this investigation).

The PR receipt fast ack minted its installation token with
pull_requests: read, but posting a comment on a pull request through the
issues API requires pull_requests: write for App tokens. GitHub answered
403 Resource not accessible by integration, the ack threw, and between
PR #1078 and #1079 that uncaught throw returned HTTP 500 to every
pull_request opened/ready_for_review webhook delivery (outage window
2026-08-09 04:12-04:52Z); after #1079 the same failure was swallowed
silently, so no PR ever received its receipt comment.

Also mint App installation tokens with the documented repositories
parameter instead of repository_names, which GitHub ignores - tokens
were silently granted installation-wide repository_selection=all instead
of being scoped to the named repository. Log swallowed fast-ack failures
so the next regression is visible in wrangler tail.
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 9, 2026, 2:41 AM ET / 06:41 UTC.

ClawSweeper review

What this changes

This PR grants the webhook receipt acknowledgement a pull-request write token, scopes GitHub App tokens with the documented repository list, logs swallowed acknowledgement failures, and updates focused assertions.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 4 items remain

Keep open. The runtime repair is narrowly aligned with current source and the reported incident, but the PR needs inspectable redacted real-behavior proof and should remove its release-owned changelog entries.

Priority: P1
Reviewed head: 12592a0f506f710ea540bc9edef166291367be1c

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and source-aligned, but current policy requires inspectable real behavior proof before merge.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The PR body asserts a successful live replay, but contains no inspectable redacted Actions log, request/response trace, or linked artifact showing the selected-repository token and successful acknowledgement. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR body asserts a successful live replay, but contains no inspectable redacted Actions log, request/response trace, or linked artifact showing the selected-repository token and successful acknowledgement. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current acknowledgement behavior: Current main mints the receipt-comment token with issues: write and pull_requests: read, then posts through the pull-request issue-comment endpoint; the PR changes only the latter permission to write.
Current scope request: Both shared token helpers currently send the unsupported repository_names key; the proposed repositories key is consistently applied to the dashboard and repair webhook helpers.
Feature history: Recent history identifies the two merged receipt-ack rollouts as the relevant lineage: commit 1ab43503 introduced fast acknowledgement and 06bc47a5 moved it to webhook receipt.
Findings 1 actionable finding [P3] Remove release-owned changelog entries
Security None None.

How this fits together

The Cloudflare webhook worker receives pull-request events, queues review work, and posts a quick receipt acknowledgement using a GitHub App installation token. Dashboard and repair-comment paths mint comparable tokens, so their requested repository scope affects the least-privilege boundary for automation.

flowchart LR
  A[GitHub pull request webhook] --> B[Webhook worker]
  B --> C[Queue review]
  B --> D[Mint installation token]
  D --> E[Repository scope and permissions]
  E --> F[Receipt acknowledgement]
  C --> G[Review workflow]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR body asserts a successful live replay, but contains no inspectable redacted Actions log, request/response trace, or linked artifact showing the selected-repository token and successful acknowledgement. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Remove release-owned changelog entries (P3) - CHANGELOG.md is release-owned under the repository policy, so these normal PR release notes should be removed and the behavior context retained in the PR body or commit message instead.
  • Resolve merge risk (P1) - The token-body correction is least-privilege hardening, but without an inspectable redacted live trace a malformed request could leave acknowledgement failures non-fatal yet invisible to users beyond logs.
  • Resolve merge risk (P1) - The two CHANGELOG.md entries are release-owned content and should not land as part of this normal repair PR.

Findings

  • [P3] Remove release-owned changelog entries — CHANGELOG.md:44-45
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Runtime and test delta runtime +7/-6; tests +11/-2; changelog +2 The small runtime change is concentrated in token authorization and webhook acknowledgement, with focused regression assertions.

Root-cause cluster

Relationship: canonical
Canonical: #1082
Summary: This PR is the direct repair candidate for the acknowledgement failure introduced by the preceding receipt-ack rollout.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Capture scope proof and remove release notes (recommended)
    Attach a redacted mint-and-comment trace for the current head, then remove the two release-owned changelog entries while retaining the focused token repair.

Technical review

Best possible solution:

Land the narrow runtime and regression-test repair without release-owned changelog edits after attaching a redacted production-boundary trace showing selected-repository token scope and a successful acknowledgement.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible with high confidence: current main requests pull_requests: read before posting a receipt comment, and the PR supplies a production-shaped 403 account. The actual live trace is not attached for independent inspection.

Is this the best way to solve the issue?

Yes for the runtime repair: correcting the permission and documented repository-list key is the narrowest shared fix. The release-owned changelog edit is not part of the appropriate solution.

Full review comments:

  • [P3] Remove release-owned changelog entries — CHANGELOG.md:44-45
    CHANGELOG.md is release-owned under the repository policy, so these normal PR release notes should be removed and the behavior context retained in the PR body or commit message instead.
    Confidence: 0.98

Overall correctness: patch is correct
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6971afb72029.

Labels

Label changes:

  • add P1: The reported live regression suppressed pull-request receipt acknowledgement and previously made affected webhook deliveries return HTTP 500.
  • add merge-risk: 🚨 security-boundary: The patch changes installation-token repository scoping and pull-request write authorization.
  • add merge-risk: 🚨 automation: The patch changes the webhook acknowledgement path used by review automation.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body asserts a successful live replay, but contains no inspectable redacted Actions log, request/response trace, or linked artifact showing the selected-repository token and successful acknowledgement. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The reported live regression suppressed pull-request receipt acknowledgement and previously made affected webhook deliveries return HTTP 500.
  • merge-risk: 🚨 security-boundary: The patch changes installation-token repository scoping and pull-request write authorization.
  • merge-risk: 🚨 automation: The patch changes the webhook acknowledgement path used by review automation.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body asserts a successful live replay, but contains no inspectable redacted Actions log, request/response trace, or linked artifact showing the selected-repository token and successful acknowledgement. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current acknowledgement behavior: Current main mints the receipt-comment token with issues: write and pull_requests: read, then posts through the pull-request issue-comment endpoint; the PR changes only the latter permission to write. (dashboard/worker.ts:2469, 6971afb72029)
  • Current scope request: Both shared token helpers currently send the unsupported repository_names key; the proposed repositories key is consistently applied to the dashboard and repair webhook helpers. (dashboard/exact-review-queue.ts:13096, 6971afb72029)
  • Feature history: Recent history identifies the two merged receipt-ack rollouts as the relevant lineage: commit 1ab43503 introduced fast acknowledgement and 06bc47a5 moved it to webhook receipt. (dashboard/worker.ts:1202, 06bc47a5bde8)
  • Shared repair-token path: The repair comment webhook has the same incorrect token-body key, so correcting it prevents installation-wide tokens on that independent comment path as well. (src/repair/comment-webhook.ts:469, 6971afb72029)
  • Proof record: The PR body reports a production-shaped Actions replay and successful receipt comment, but it does not include a redacted job log, request/response trace, or linked artifact that a reviewer can inspect. (12592a0f506f)

Likely related people:

  • steipete: Recent history attributes both receipt-ack rollout commits and the current main follow-up to Peter Steinberger. (role: recent receipt-ack feature author; confidence: high; commits: 1ab4350383c2, 06bc47a5bde8, 6971afb72029; files: dashboard/worker.ts, dashboard/exact-review-queue.ts)
  • Martin Cleary: Feature history shows Martin Cleary among the recent contributors to the dashboard worker and repair-webhook area, though the specific acknowledgement lineage is primarily Peter’s. (role: adjacent dashboard contributor; confidence: medium; commits: 80720568fa82, ddae19e06391; files: dashboard/worker.ts, src/repair/comment-webhook.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted current-head trace showing token mint scope, comment success, and the acknowledgement response.
  • Remove the release-owned CHANGELOG.md entries.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit dc6fc0b into main Aug 9, 2026
20 checks passed
@steipete
steipete deleted the fix/pr-fast-ack-hardening branch August 9, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant