Skip to content

fix(github): report the correct credential for CLI throttles - #1600

Merged
vincentkoc merged 1 commit into
mainfrom
fix/github-throttle-scope-20260916
Sep 17, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/github-throttle-scope-20260916

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

A later Actions-token request can be reported as a target_app throttle after a public read uses its one App fallback. This points operators investigating queue backoff at the wrong credential.

Related: #1598. This follow-up changes attribution in the shared GitHub CLI owner and does not depend on that PR.

User Impact

GitHub CLI throttle errors identify the credential used by the failed request. Native error output, reset calculation, routing, retry timing, and the existing single fallback allowance stay intact.

Attribution remains deliberately conservative for non-API commands, explicit hostnames, absolute API URLs, and enterprise GH_HOST values: these retain the previous default or propagated scope because this owner cannot prove the native client's credential selection.

Why This Change Was Made

Capture the credential identity from the prepared child environment before dispatch, then carry that fact with the original error. Sync, async, fallback, and limited-pagination wrappers use the same error factory. The HTTP runtime reuses the extracted pure identity classifier while preserving its existing token precedence.

Production delta: +61 lines; tests: +324 lines. The added boundary records the dispatched credential without retaining tokens or replacing native errors. No new configuration or persisted state.

OpenClaw Bay Impact

No Bay projection, queue schema, lifecycle transition, publication count, or public field changes. This corrects the CLI error's existing scope field; the HTTP runtime's classification behavior and telemetry writer remain unchanged. No Bay UI change is needed.

Documentation Impact

Reviewed README.md credential handling, docs/README.md, and CONTRIBUTING.md. Existing credential provisioning and operator commands remain accurate. The operational change is recorded in CHANGELOG.md; its insertion is separate from the other pending queue fixes.

Evidence

  • corepack pnpm run check: 6,259 passed, 19 skipped, zero failures or cancellations; native AWS run run_f62d2550a42d, exit 0. Includes build, formatting, static gates, and the full test suite.
  • Focused CLI tests: 18/18 passed, covering sync/async prepared-token precedence, alternate-host uncertainty, fallback exhaustion, later-page throttles, async environment drift, and native error identity/output. Shared runtime attribution, telemetry, and deadline siblings also passed in the full check.
  • Fresh native Codex review before commit and against the final committed head: no actionable findings.
  • Final head 3e5f0962c7bea9965c6928865ad56e8988376f92; tree 927f11deab4c374e0b4e68be84a053c630018986. Only the changelog bullet moved after the accepted runtime proof; source and test hashes below still match.

Real Behavior Proof

Claim: the actual compiled CLI owner reports the failed request's credential without changing its real gh request sequence or error streams.

Surface and environment: Node 24.18.1, pnpm 12.4.1, native gh 2.46.0, Linux amd64. The same installed dependencies compile the three frozen baseline owners from 02cd682921ca0c796212319c1a28c9b1e4bfac58 inside the owned fixture. No lazy Git fetch or fixture dependency install occurs.

Command: crabbox run --id cbx_098950dee7ea --no-sync --no-hydrate --keep --timing-json --script <reviewed-proof-script>; native run run_3cd091b0cbc6 exited 0. The reviewed script hash and exact source/build identities are below.

Observed trace: all 11 requests were real gh GETs through a strict loopback HTTPS fixture, with credential role labels only.

Case Request sequence Resulting scope
Frozen baseline, sync Actions issue 429 → App issue 200 → Actions pull 429 target_app — reproduced
Candidate, sync Actions issue 429 → App issue 200 → Actions pull 429 repository_actions
Candidate, async Actions issue 429 → App issue 200 → Actions pull 429 repository_actions
Candidate, exhausted fallback Actions issue 429 → App issue 429 target_app, recovery false

Each terminal throttle retained the native JSON response and gh: API rate limit exceeded (HTTP 429) stderr. The same 60-second fallback reset floor, non-authoritative reset provenance, and one-fallback request count were preserved.

Isolation and limits: separate network/PID/user namespaces, only loopback, no external routes, read-only source, private temporary storage, cleared inherited environment, fake credentials, and a short-lived fixture CA with TLS verification enabled. All assertions and strict socket checks passed; owned children closed and the fixture was removed. This proves actual-client transport and attribution under controlled responses, not production quota recovery. Pagination and alternate-host behavior are covered by focused tests, not this real-client fixture. The inherited fixture retains a strict hold on socket errors; this successful run does not claim a general EPIPE lifecycle fix.

Exact proof receipt and final-head binding
{
  "status": "PASS",
  "generated_at": "2026-09-16T09:43:24.266Z",
  "native_run": "run_3cd091b0cbc6",
  "source_base": "02cd682921ca0c796212319c1a28c9b1e4bfac58",
  "exercised_tree": "a2cc43a08f597533071fe0ae7dba89cf6686d995",
  "final_head": "3e5f0962c7bea9965c6928865ad56e8988376f92",
  "final_tree": "927f11deab4c374e0b4e68be84a053c630018986",
  "post_proof_change": "CHANGELOG.md bullet relocation only; runtime and test hashes unchanged",
  "script_sha256": "fbb3c492cec28620c9e88687a4e1f1bf71e8a3c40bff7f8091a2d507b653b1d2",
  "receipt_sha256": "931a3b869fc5ea7af7d75af8a8743c87f09661ff7a552643716fb9bc4a9f3a57",
  "receipt_bytes": 16222,
  "source_sha256": "768d176830fae33dab33bd9f742ced8fd7229a9ddc3588fe4b370eb016c6d2cf",
  "compiled_sha256": "f3c95973ec0bd4dd4f97cb417cd562a018b147ddc4ae648b38ed07199c6a122b",
  "gh_sha256": "80671b8dab3e41893f3e338fb104c997a390b0a51fafc34eb30048e2df99ab54",
  "source_and_test_inputs": {
    "src/github-retry.ts": "cd988d2e48c23847d5bbe95b0a4bea7f04c5344b7cb29e66cffedcaf66aecd51",
    "src/clawsweeper-github-runtime.ts": "24796e67c463de03beabba6328efd92bea35ca6f176364af5e12ae4b720b7046",
    "src/repair/github-cli.ts": "a955c4cb0680b1856d67dd1226ea866894d65b127fb8e1d1649df759d7facc4b",
    "test/github-credential-scope.test.ts": "3e7c07a6d0c2d064e62ee547254570981c91913fe0408c99a9fdafa01808b92b",
    "test/repair/github-cli-scope.test.ts": "901bb4c2dbb359b0ed2b7b52567cb7793159504c6d4baf47c4a54e31ac87aef3"
  },
  "compiled_owners": {
    "dist/github-retry.js": "08d214608737f327b3eb2a208dce74d913b607d698e19156beae4b9b62189c1e",
    "dist/clawsweeper-github-runtime.js": "55e812bc6f5008f8fc3acdceeaffa250b4b746889ce3e3714ba644f7aef9f67c",
    "dist/repair/github-cli.js": "95aae09725d811b678fe531645cff6dbe0a05190be457ec640f37115dc10e08b"
  },
  "scenario_native_exits": [
    {
      "name": "baseline misattributes later Actions throttle",
      "exit": 0,
      "natural": true,
      "stdout_eof": true,
      "stderr_eof": true,
      "wall_ms": 138,
      "scope": "target_app",
      "recovered": true
    },
    {
      "name": "candidate sync attributes later Actions throttle",
      "exit": 0,
      "natural": true,
      "stdout_eof": true,
      "stderr_eof": true,
      "wall_ms": 130,
      "scope": "repository_actions",
      "recovered": true
    },
    {
      "name": "candidate async attributes later Actions throttle",
      "exit": 0,
      "natural": true,
      "stdout_eof": true,
      "stderr_eof": true,
      "wall_ms": 129,
      "scope": "repository_actions",
      "recovered": true
    },
    {
      "name": "candidate exhausted App remains target_app",
      "exit": 0,
      "natural": true,
      "stdout_eof": true,
      "stderr_eof": true,
      "wall_ms": 97,
      "scope": "target_app",
      "recovered": false
    }
  ],
  "source_compiled_dependencies_unchanged": true,
  "owned_fixture_removed": true,
  "owned_children_closed": true
}

Full-check log: 1,079,328 bytes, SHA-256 7ee57669e7348dc65a88cc052bdd00cfcfff351d471480e99b1982153ec80730.

The proof executed tree a2cc43a08f597533071fe0ae7dba89cf6686d995. Its only difference from the final tree is the changelog entry's position. All three production owners and both added tests retain the exact hashes in the receipt.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. 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. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 6:05 AM ET / 10:05 UTC (Revision 2).

ClawSweeper review

What this changes

The PR makes GitHub CLI throttle errors identify the failed request’s credential while preserving native diagnostics, retry timing, and the existing one-shot fallback.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main. No actionable correctness or security findings remain, and the supplied real-client proof supports the change.

Priority: P2
Reviewed head: 3e5f0962c7bea9965c6928865ad56e8988376f92

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-tested repair with strong real-client proof and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied native AWS trace exercises the compiled CLI owner with real gh through controlled HTTPS throttles and demonstrates corrected attribution with unchanged fallback counts and diagnostics; all five source/test input hashes match the reviewed head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied native AWS trace exercises the compiled CLI owner with real gh through controlled HTTPS throttles and demonstrates corrected attribution with unchanged fallback counts and diagnostics; all five source/test input hashes match the reviewed head.
Evidence reviewed 8 items Applicable repository policy: Read the complete root policy; no nested AGENTS.md files exist under src or test, and no maintainer-notes directory was present. Applied focused-proof, Bay-impact, narrow-change, and maintainer-authored keep-open guidance.
Current main still lacks CLI attribution: The current-main CLI retry wrappers construct GitHubRateLimitError without credential scope. The live main API check still returned the pinned base 02cd682.
Introduced behavior and security boundary: Sync and async dispatch capture a scope string before execution and associate it with the original error through a WeakMap. The patch leaves token selection, fallback eligibility, request permissions, retry timing, and persisted formats unchanged; the HTTP classifier extraction preserves its existing behavior.
Findings None None.
Security None None.

How this fits together

ClawSweeper’s shared GitHub CLI wrapper executes requests for review and repair workflows. It turns throttled command failures into structured errors used by callers and operator diagnostics.

flowchart TD
  A[Review and repair requests] --> B[Prepare command credentials]
  B --> C[Capture credential scope]
  C --> D[Execute GitHub CLI]
  D --> E{Request throttled}
  E -->|Eligible public read| F[Existing one-shot App fallback]
  F --> D
  E -->|Terminal failure| G[Original diagnostics with captured scope]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth production +61 net lines; tests +324 lines The body justifies the production growth as dispatch-time attribution that preserves native errors.
Real-client coverage 4 scenarios; 11 HTTPS GETs The trace covers baseline failure, corrected sync/async behavior, and exhausted fallback attribution.

Technical review

Best possible solution:

Keep credential attribution at the shared command boundary, preserving existing routing and native errors without introducing another token-selection policy.

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

Yes. The supplied real-gh trace reproduces the failure using the frozen current-main owners: after successful App fallback, a later Actions throttle is reported as target_app.

Is this the best way to solve the issue?

Yes. Capturing the prepared credential before dispatch fixes the shared error boundary without changing fallback policy; focused coverage also checks environment drift and native error identity.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 02cd682921ca.

Labels

Label justifications:

  • P2: Incorrect credential attribution misleads quota troubleshooting but does not itself change request delivery or authorization.
  • 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 (terminal): The supplied native AWS trace exercises the compiled CLI owner with real gh through controlled HTTPS throttles and demonstrates corrected attribution with unchanged fallback counts and diagnostics; all five source/test input hashes match the reviewed head.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied native AWS trace exercises the compiled CLI owner with real gh through controlled HTTPS throttles and demonstrates corrected attribution with unchanged fallback counts and diagnostics; all five source/test input hashes match the reviewed head.

Evidence

What I checked:

  • Applicable repository policy: Read the complete root policy; no nested AGENTS.md files exist under src or test, and no maintainer-notes directory was present. Applied focused-proof, Bay-impact, narrow-change, and maintainer-authored keep-open guidance. (AGENTS.md:1, 3e5f0962c7be)
  • Current main still lacks CLI attribution: The current-main CLI retry wrappers construct GitHubRateLimitError without credential scope. The live main API check still returned the pinned base 02cd682. (src/repair/github-cli.ts:222, 02cd682921ca)
  • Introduced behavior and security boundary: Sync and async dispatch capture a scope string before execution and associate it with the original error through a WeakMap. The patch leaves token selection, fallback eligibility, request permissions, retry timing, and persisted formats unchanged; the HTTP classifier extraction preserves its existing behavior. (src/repair/github-cli.ts:315, 3e5f0962c7be)
  • Real-client before/after proof: The captured PR body reports native AWS Crabbox lease cbx_098950dee7ea, run run_3cd091b0cbc6, using Node 24.18.1 and real gh 2.46.0 against isolated HTTPS responses. Eleven GETs reproduce baseline misattribution, demonstrate corrected sync/async attribution, and preserve target_app attribution when the App fallback also throttles. Native output, one-fallback limits, and reset behavior were retained. This establishes controlled transport behavior, not live production quota recovery. (3e5f0962c7be)
  • Proof input binding: All three production files and both added tests exactly match the SHA-256 values in the captured proof receipt. The body documents only a changelog relocation after proof. The reported full check passed 6,259 tests with 19 skips; this read-only review did not rerun target code. (test/repair/github-cli-scope.test.ts:1, 3e5f0962c7be)
  • Related work remains distinct: fix(review): avoid admission delays when Actions quota is exhausted #1598 remains open and addresses admission lifetime and delays. Its supplied real-client trace independently records the misattributed optional-read throttle addressed here; it does not replace this attribution fix. (8946dcf43a46)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Sebastien Tardif: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (1 earlier review cycle)
  • reviewed 2026-09-16T09:52:47.621Z sha 3e5f096 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review September 16, 2026 10:02
@vincentkoc
vincentkoc merged commit 4057a61 into main Sep 17, 2026
28 checks passed
@vincentkoc
vincentkoc deleted the fix/github-throttle-scope-20260916 branch September 17, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. 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