Skip to content

perf(github): route sweep public reads off App tokens - #1062

Merged
steipete merged 3 commits into
mainfrom
steipete/sweep-public-read-routing
Aug 8, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/sweep-public-read-routing

Conversation

@steipete

@steipete steipete commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The sweep lanes—scheduled and exact-event review, publication, comment sync, and apply—still performed target-repository reads on the shared GitHub App installation token. That installation has been exhausting its 15,000 requests/hour allowance and producing 403s in production.

This extends the incumbent CLAWSWEEPER_PUBLIC_GH_TOKEN convention from #1034, hardened by #1054, to the sweep runtime. It uses the same route classification and bounded once-per-run App-token throttle fallback.

It also flips the exact-event review runtime and two verified-read-only steps to the repository-conditional workflow-token pattern already used by the live-item probe, removes every github.token fallback from Codex proof-inspection tokens, and gives apply proof a dedicated read-only App inspection mint.

OpenClaw Bay is unaffected: this changes internal GitHub credential routing only, with no observer data-contract or action-surface change.

Review finding disposition

  • Resolved the header-read P1: the shared public-read classifier accepts the safe gh api -i <endpoint> form used by timeline hydration, while the same shape with --method PATCH remains on the App token.
  • Resolved the scheduled-review P1: the regular Review shard now receives the repository-conditional workflow token in CLAWSWEEPER_PUBLIC_GH_TOKEN, while retaining its target App credential in GH_TOKEN for bounded fallback.

Proof

  • Claim: sweep public reads, including scheduled review and header-bearing timeline hydration, route away from the shared App token while mutations and bounded fallback behavior remain intact.
  • Current head: c8898f9d807bb5eed7b1bb872c22544b76e04505.
  • Exercised surface: compiled sweep GitHub runtime and execution boundary, scheduled and exact-event review routing, public-token throttle handling, App fallback, and the shared repair classifier.
  • Scenario: gh api -i repos/openclaw/openclaw/issues/123/timeline?per_page=100; the public route is deterministically throttled, the App route succeeds once, and a second public throttle cannot claim the App fallback again.
  • Environment: Docker node:24-bookworm inside Crabbox provider aws, lease cbx_d72f87c5ebd6, run run_6b73750759b3.
  • Observable trace: public,app,public; first throttle result app-fallback-success; second throttle result GitHubRateLimitError; invariant pass.
  • Exact assertions: scheduled workflow-token routing, header-read public routing, and once-per-run fallback all passed in the Docker-backed run (3 passed, 0 failed).
  • Content binding: .github/workflows/sweep.yml SHA-256 2bb0c3500f49d1a9e274f93afe04ed8790c941eaa6a5442e0bb9b9fbb8cdcbe8; src/github-public-read.ts SHA-256 88ac66a302a9f25331dd0be09b028fd78738aea812bd993725563d329dff7cb3; test/sweep-workflow.test.ts SHA-256 fd8d4e4483aa9393001c3827532fde72cfd27e91125717b43b4a119ea5e0c3a4; test/repair/exact-review-batch-workflow.test.ts SHA-256 ac93fb1779a198e38aeb4b7a396640a57dda7386bdddf070cbd4f62401b17120.
  • Full local gate: pnpm run check passed on Node 24 in 272 seconds: 3,196 tests, 3,187 passed, 9 skipped, 0 failed; all builds, lint, formatting, and coverage thresholds passed.
  • Review: fresh pre-commit and committed-branch autoreviews reported no accepted/actionable findings.
  • Limits: the 403 is injected deterministically through the real compiled runtime/subprocess boundary; production token exhaustion was not induced and no credential values were recorded.

@steipete
steipete requested a review from a team as a code owner August 7, 2026 23:25
@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: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 8:23 PM ET / August 8, 2026, 00:23 UTC.

ClawSweeper review

What this changes

Routes safe public OpenClaw issue and pull-request reads in sweep workflows through a workflow token while retaining GitHub App credentials for privileged operations and one bounded throttling fallback.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this active PR open: the two prior P1 findings are addressed on the current head, and the reviewed routing, fallback, and workflow changes have no actionable defect.

Priority: P1
Reviewed head: c8898f9d807bb5eed7b1bb872c22544b76e04505

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong current-head runtime proof and focused coverage support a normal mergeable review rating.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides current-head Docker-backed compiled-runtime throttle evidence with observable public/App/public routing and after-fix recovery; no credentials were recorded.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides current-head Docker-backed compiled-runtime throttle evidence with observable public/App/public routing and after-fix recovery; no credentials were recorded.
Evidence reviewed 5 items Current-head workflow routing: The supplied current-head diff injects the conditional public token into the scheduled Review shard and routes exact OpenClaw event review through the workflow token while retaining target App credentials where required.
Safe read classification: The current-head patch extends the established classifier to recognize header-bearing gh api -i reads, while later method flags remain disqualifying; this resolves the previous timeline-hydration finding without routing PATCH calls publicly.
Existing boundary provenance: Current main attributes the public OpenClaw read-only classifier to the merged isolation work, establishing that this PR extends an existing constrained credential pattern rather than adding a parallel mechanism.
Findings None None.
Security None None.

How this fits together

ClawSweeper sweep jobs read GitHub items before publishing review results or applying guarded actions. The changed GitHub runtime chooses a public workflow token for tightly classified OpenClaw REST reads, while writes and fallback remain on the target App credential.

flowchart LR
  A[Sweep workflow] --> B[GitHub command runtime]
  B --> C{Safe public OpenClaw read?}
  C -->|Yes| D[Workflow read token]
  C -->|No| E[GitHub App token]
  D --> F{Token throttled?}
  F -->|First throttle| E
  F -->|Later throttle| G[Rate-limit deferral]
  E --> H[GitHub API]
Loading

Before merge

  • Resolve merge risk (P2) - This changes a shared operational credential boundary; an incorrect route could restore production 403s, although the current proof covers token selection, first-fallback success, and repeated-throttle failure.
  • Complete next step (P2) - No repair-lane routing is needed: this active PR has sufficient proof and no concrete current-head finding.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +116/-22; tests +191/-11 The patch adds more focused regression coverage than production code across the runtime and workflow credential boundary.

Merge-risk options

Maintainer options:

  1. Merge with the bounded fallback (recommended)
    The current proof exercises public routing, one App-token fallback, and fail-closed repeated throttling, which is the appropriate protection against restored sweep 403s.

Technical review

Best possible solution:

Merge the constrained classifier and workflow wiring with the existing bounded fallback intact, then observe normal sweep runs for reduced App-token pressure.

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

Yes, at source level: the current main path uses the App credential for scheduled review reads, and the PR’s controlled compiled-runtime throttle scenario exercises the after-fix route and fallback behavior.

Is this the best way to solve the issue?

Yes: extending the existing narrow read-only classifier and once-per-run fallback avoids duplicating credential-routing policy while retaining App credentials for mutations and explicit-token calls.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides current-head Docker-backed compiled-runtime throttle evidence with observable public/App/public routing and after-fix recovery; no credentials were recorded.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The reported App-token exhaustion produces production HTTP 403s that interrupt sweep processing.
  • merge-risk: 🚨 availability: A credential-routing or fallback regression could prevent scheduled sweeps from reading target items while a token is throttled.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides current-head Docker-backed compiled-runtime throttle evidence with observable public/App/public routing and after-fix recovery; no credentials were recorded.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides current-head Docker-backed compiled-runtime throttle evidence with observable public/App/public routing and after-fix recovery; no credentials were recorded.

Evidence

What I checked:

  • Current-head workflow routing: The supplied current-head diff injects the conditional public token into the scheduled Review shard and routes exact OpenClaw event review through the workflow token while retaining target App credentials where required. (.github/workflows/sweep.yml:4168, c8898f9d807b)
  • Safe read classification: The current-head patch extends the established classifier to recognize header-bearing gh api -i reads, while later method flags remain disqualifying; this resolves the previous timeline-hydration finding without routing PATCH calls publicly. (src/github-public-read.ts:3, c8898f9d807b)
  • Existing boundary provenance: Current main attributes the public OpenClaw read-only classifier to the merged isolation work, establishing that this PR extends an existing constrained credential pattern rather than adding a parallel mechanism. (src/github-public-read.ts:1, 2c3ad8f46c9a)
  • Fallback provenance: Merged commit f6f6bfca introduced the bounded public-read throttle fallback that this PR applies to the sweep runtime. (src/repair/github-cli.ts:345, f6f6bfca7d65)
  • Real behavior proof: The PR body records a Docker-backed compiled-runtime fault injection at the current head: public/App/public routing, one successful fallback, a fail-closed second throttle, and three passing assertions. (test/repair/exact-review-batch-workflow.test.ts:107, c8898f9d807b)

Likely related people:

  • steipete: Authored the current PR and the earlier merged public-read credential-routing work used as its pattern. (role: recent area contributor; confidence: high; commits: a47ccbacd24a, 1f4345dee918, c8898f9d807b; files: src/github-public-read.ts, src/clawsweeper-github-runtime.ts, .github/workflows/sweep.yml)
  • giodl73-repo: Authored the merged bounded App-token fallback whose retry semantics are reused by this sweep-runtime change. (role: fallback behavior contributor; confidence: high; commits: f6f6bfca7d65; files: src/repair/github-cli.ts, src/clawsweeper-github-execution.ts)

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-07T23:29:19.762Z sha ac9be19 :: needs real behavior proof before merge. :: [P1] Route safe header reads through the public token
  • reviewed 2026-08-07T23:56:53.791Z sha 7980e04 :: needs changes before merge. :: [P1] Route scheduled review reads through the public token

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Aug 7, 2026
Extend the existing public-read token convention to sweep review, publication, comment-sync, audit, and apply paths while preserving App credentials for mutations and proof inspection. Public-token throttles consume at most one ambient App-token fallback per process.
@steipete
steipete force-pushed the steipete/sweep-public-read-routing branch from 7980e04 to c8898f9 Compare August 8, 2026 00:15
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 8, 2026
@steipete
steipete merged commit d3810a0 into main Aug 8, 2026
21 checks passed
@steipete
steipete deleted the steipete/sweep-public-read-routing branch August 8, 2026 00:25
steipete added a commit that referenced this pull request Aug 8, 2026
…pools (#1064)

PR #1062 moved the exact-event review runtime's reads (~30 calls per
review, the largest single stream) onto the per-repo Actions token pool,
which the comment router, dashboard CI, and support lanes already share.
Concentrating both major read streams on one bucket exhausted it while
the App installation bucket idled. Review hydration returns to the App
read token; with apply-guard memoization and the router offload in
place, the two pools now each carry roughly half the read load.
steipete added a commit that referenced this pull request Aug 8, 2026
The 450/h trim ducked App installation 403s at ~30 API calls per review.
Apply-guard memoization (#1060) cut that per-item cost and the read-pool
split (#1062/#1064) moved router and public reads onto the Actions token
pool, so the App bucket now carries only memoized hydration and writes.
Post-#1064 telemetry shows ~336 ok reviews/h with near-empty throttle
backoff at the 450 cap; restoring the historical 600/h uses the
recovered headroom.
steipete added a commit that referenced this pull request Aug 12, 2026
…etter recovery (#1146)

Makes the dead-letter reconcile lane throttle-resilient so the DLQ can drain during busy hours instead of only when the system is idle.

Production evidence: the 19:46Z cycle recovered 0 targets - one 403 on a live-target check aborted canonical discovery and skipped all 125 remaining targets (skip_reasons not_inspected_abort), while the repository_actions bucket sat exhausted (~1,900 throttled item_metadata reads) and target_app had headroom.

Five review-hardened layers landed together: (1) target REST/canonical reads route to per-owner App-minted target tokens per the two-bucket doctrine (#1062), reusing the publication path's minting stack in dashboard/github-api.ts - artifact downloads stay on repository_actions; (2) throttle/abuse 403/429 degrade per target with a three-consecutive-throttle fuse instead of abort-all (the #973 abort's quota-protection intent is preserved by the fuse); (3) throttled App installation lookup/minting takes the same bounded skip path (scope=app_setup) with per-owner negative caching; (4) partial App-credential configuration is a hard startup failure naming the missing field - repository-token reads require explicit EXACT_REVIEW_TARGET_TOKEN_MODE=actions, never a silent fallback; (5) installation-missing 404s cache per repository, not per owner, so selected-repositories installations cannot orphan accessible siblings. Auth failures on valid installations remain fail-closed; installation_missing is a structured skip.

Proof: Docker-backed Crabbox local-container receipts at each round's head, final 27/27 scenarios (docs/proof/reconcile-throttle-resilience/); operator suite 80/80; full gate green. Verdict clean (Findings: None) on 3ae7bf8. The prior pnpm-check failure was an actionlint CDN 503, rerun green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant