Skip to content

fix(workflow): make direct PR webhook intake canonical#703

Closed
brokemac79 wants to merge 1 commit into
mainfrom
codex/csw-046-ingress-terminal-control
Closed

fix(workflow): make direct PR webhook intake canonical#703
brokemac79 wants to merge 1 commit into
mainfrom
codex/csw-046-ingress-terminal-control

Conversation

@brokemac79

Copy link
Copy Markdown
Contributor

Summary

  • Makes the direct GitHub App pull_request webhook the canonical exact-review ingress for PR events.
  • Prevents the legacy pull_request_target repository-dispatch compatibility path from creating a second durable review intent, runner, and queue handoff.
  • Keeps distinct later PR deliveries (synchronize and edited) and maintainer issue_comment commands eligible.

Problem and evidence

One OpenClaw PR push entered the durable exact-review control plane twice:

  • openclaw/openclaw#110767 received head a1e94e165a58a0ac86ec30744ddca8499937e3d3 at 10:19 UTC.
  • The direct GitHub App webhook run (29683139308) had sourceEvent=pull_request, sourceAction=synchronize, performed the real review, and queued publication.
  • The legacy compatibility run (29683141001) originated from pull_request_target and durably enqueued the same intent again.
  • A later duplicate (29683229621) deferred on the same-head lease, but only after consuming control-plane work.

This is ingress duplication, not a head-SHA dedupe problem: later body edits, revisions, and maintainer commands can be meaningful and must continue to enqueue.

Implementation

The legacy queue-intake job now skips only a repository-dispatch payload whose pair is:

source_event = pull_request_target
item_kind    = pull_request

The guard is at the job condition, before runner allocation and before the durable enqueue request. It does not suppress direct pull_request webhook deliveries, issues, or issue_comment command flows.

The regression coverage:

  • models the direct-plus-legacy route boundary and asserts that only the legacy pull_request_target PR route is excluded;
  • sends two independent direct GitHub webhook deliveries for the same PR: synchronize followed by edited, and verifies the queue records revision 2 with the later body-update decision;
  • retains the existing command-path tests for issue_comment maintainer review commands.

Relationship to #674 and terminal behavior

Draft #674 owns the per-item generation, live terminal-target checks, and terminal reconciliation work. It does not address duplicate direct-plus-legacy ingress. This PR deliberately avoids duplicating or conflicting with #674; prompt terminalization/supersession of closed or merged targets remains its dependency and should land through #674.

Validation

pnpm run build:all
node --test test/clawsweeper.test.ts test/dashboard-worker.test.ts
# 230 passed, 0 failed

pnpm exec oxfmt --check .github/workflows/sweep.yml test/clawsweeper.test.ts test/dashboard-worker.test.ts
git diff --check
# YAML parse and extracted legacy-intake Bash syntax check passed

actionlint is unavailable on this host. The workflow change is a GitHub-expression-only job guard; the existing legacy intake script was extracted from YAML and passed bash -n.

Codex review closeout:

codex review --uncommitted
codex review --base origin/main

Both completed with no accepted or actionable findings. The second review ran after rebasing onto current origin/main (639d459f22).

Risk and rollout

The direct GitHub App webhook is already the source that completed the observed PR review. After deployment, only the redundant legacy pull_request_target compatibility delivery is skipped; a new direct webhook delivery remains a separate durable intent. No gate, dispatch, review, label, or merge behavior changes.

This touches .github/workflows/sweep.yml, so GitHub OAuth/workflow-scope policy may require a maintainer-owned replacement branch in environments that reject workflow-file updates. No new permissions or token scopes are requested.

@brokemac79
brokemac79 requested a review from a team as a code owner July 19, 2026 12:18
@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor

Closing after maintainer deep review. The duplicate-ingress evidence is credible, but this guard removes a documented reliability boundary rather than deduplicating it.

docs/target-dispatcher.md explicitly keeps the Actions dispatcher as a compatibility fallback and bridges its legacy delivery into the durable queue. Skipping every pull_request_target PR dispatch before queue admission means a missing or delayed direct GitHub App webhook now loses the event entirely. The production example proves that both routes can arrive; it does not prove that the direct route always arrives.

The safe shape is semantic cross-route dedupe at the durable queue boundary: coalesce a matching direct and legacy delivery, while still admitting a legacy-only delivery and preserving later synchronize, edited, and maintainer-command revisions. That changes queue policy and needs a separate maintainer decision/proof contract, so I am not widening this PR into it.

Author context was positive: @brokemac79 is a write collaborator/read-only maintainer with a substantial history of merged ClawSweeper queue fixes. This close is about the fallback ownership boundary, not contributor quality.

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.

2 participants