Skip to content

fix(reconcile): survive target-read throttling - #1146

Merged
steipete merged 10 commits into
mainfrom
steipete/reconcile-throttle-resilience
Aug 12, 2026
Merged

steipete merged 10 commits into
mainfrom
steipete/reconcile-throttle-resilience

Conversation

@steipete

@steipete steipete commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The 2026-08-12T19:46Z dead-letter cycle around run 31634514031 completed successfully but recovered nothing: inspected_targets=3, skipped_targets=125, recovered_targets=0, and skip_reasons={"http_403":1,"not_inspected_abort":2}. At the same time, the repository_actions bucket was under sustained pressure while the target_app bucket was nearly idle.

The root cause was a credential-boundary mismatch combined with conservative all-or-nothing discovery. Standard target REST checks, parked-review REST checks, and batched GraphQL canonical discovery all read GITHUB_TOKEN; the scheduled workflow bound that variable to ${{ github.token }}, so public target inspection competed with artifact and Actions API traffic on repository_actions.

This PR mints read-only contents, issues, and pull-request tokens from the existing ClawSweeper GitHub App installation for each target owner. The operator reuses the Worker's canonical App credential, signing, installation, and token plumbing; GraphQL batches remain owner-homogeneous. Artifact discovery/download, queued-run remediation, and signed Worker inventory/resolve/recover calls keep their prior credentials and ownership boundaries.

The owner decision is explicit: cross-owner recovery must be preserved. A genuinely absent or revoked target installation is a structured installation_missing skip, never a cycle abort or a fallback to the repository Actions token. Successful installation tokens and confirmed setup-throttle rejections are cached per owner for the cycle. Installation-missing outcomes are cached per repository, so a missing repository in a selected-repositories installation cannot suppress a later accessible repository under the same owner. Per-repository REST/GraphQL reads still enforce the token/repository pairing and fail closed on authorization or missing-resource responses.

Target reads default to explicit github-app mode. Key-only, App-ID-only, and entirely absent App configuration are hard failures naming the missing field before any queue or GitHub request. GH_TOKEN/GITHUB_TOKEN can be used for target reads only through the explicit EXACT_REVIEW_TARGET_TOKEN_MODE=actions opt-in. Both checked-in operator workflows select github-app and pass the private-key secret.

Nothing else changes: target-read throttles keep the existing bounded skip policy, ordinary target authorization failures keep the conservative abort, and all existing target, recovery, GraphQL batch, terminal-recheck, and inventory caps remain in force.

Review finding disposition

  • Round 1 preserved the abort for non-throttle 403 responses while continuing only for confirmed rate-limit or abuse responses.
  • Round 2 minted and cached target-read credentials per target owner, preserving cross-owner recovery when one owner has no installation.
  • Round 3 classified throttled installation lookup and token mint calls as bounded github_throttled scope=app_setup skips. A cached owner throttle counts once toward the three-call fuse; three distinct throttled owners still stop the phase.
  • Round 4 made the App credential pair mandatory at startup and placed the repository Actions-token route behind explicit actions mode.
  • Round 5 resolves the accepted P1 from the prior ClawSweeper verdict: installation_missing promises now use a normalized repository key until their outcome is known. Only a successful installation token or a confirmed setup throttle is promoted to the owner cache. The selected-repositories regression proves repo A can return an installation 404 while repo B under the same owner mints and recovers in the same cycle.
  • The round-5 pre-commit code review, proof-package review, and final committed-branch Codex review all reported no accepted/actionable findings.

Token routing before and after

Request class Before After
Target issue/PR REST checks repository_actions via ${{ github.token }} target owner's target_app installation token
Canonical GraphQL identity discovery repository_actions via ${{ github.token }} owner-homogeneous batches using that owner's target_app token
Prior reconcile artifact list/download repository_actions unchanged: repository_actions
Stuck queued-run Actions inspection/remediation repository_actions unchanged: repository_actions
Signed queue inventory/resolve/recover operator HMAC secret, not GitHub unchanged

Real-behavior proof

Claim: App target-read mode fails at startup for every incomplete App credential pair and never silently uses the repository Actions token. With complete App credentials, successful installation tokens and setup throttles remain owner-scoped, while an installation-missing repository cannot hide an accessible sibling repository. Confirmed setup or target-read throttles remain bounded skips; genuine authorization failures remain fail-closed.

Exercised surface: the real scripts/exact-review-dead-letter-operator.mjs CLI process, checked-in workflow YAML parsing, real App JWT signing with an ephemeral test key, and loopback HTTP selected through GITHUB_API_URL for queue, installation lookup, token mint, REST, and GraphQL traffic.

Round-5 red/green: the new same-owner selected-repositories test failed before the cache fix with recovered_targets=0 instead of 1, while both existing owner-throttle cases passed. After the fix, all three focused cases passed. The complete operator file passed 80/80 on Node 24.

Environment and receipt: Docker-backed Crabbox provider=local-container, lease cbx_2c2320c8c201 (crimson-hermit-97fb), image node:24-bookworm, Node 24.19.0, and pinned pnpm 11.10.0. The final run passed 27/27 focused real-process scenarios and stopped the lease automatically. docs/proof/reconcile-throttle-resilience/receipt.json binds code head 5a89572fa541de992d34afad7cf5d674208eccd0, the proof harness, executable inputs, and sanitized transcripts by SHA-256. Final branch head 3ae7bf80a9afb742ecad8a118c5466aa2670ffe1 adds only that refreshed proof receipt and transcript. TruffleHog 3.96.0 reported zero verified or unknown secrets.

Full gate: pnpm run check passed on Node 24, including static policy and documentation checks, formatting, all builds, type-aware lint, changed coverage, and the full coverage suite.

Limits: GitHub installation, token, throttling, and queue responses are deterministic loopback fixtures. No production credential, live GitHub quota exhaustion, or production queue mutation was exercised. The receipt proves credential selection, cache behavior, classification, and bounded CLI/HTTP behavior, not live GitHub App issuance.

OpenClaw Bay

OpenClaw Bay is unaffected. This changes internal operator credential caching only; there is no observer data contract or action surface, and Bay remains observer-only.

Current head: 3ae7bf80a9afb742ecad8a118c5466aa2670ffe1.

@steipete
steipete requested a review from a team as a code owner August 12, 2026 20:04
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P1 Urgent regression or broken agent/channel workflow affecting real users now. 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. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 5:56 PM ET / 21:56 UTC.

ClawSweeper review

What this changes

The PR moves dead-letter target reads to scoped GitHub App credentials, adds bounded throttle handling, and records loopback recovery proof.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for normal landing review. The final branch addresses the prior per-owner negative-cache finding with repository-scoped installation-missing handling; no new discrete patch defect is evidenced, but the current failing pnpm check must be resolved before merge.

Priority: P1
Reviewed head: 3ae7bf80a9afb742ecad8a118c5466aa2670ffe1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong scoped runtime proof and the resolved prior finding support a good patch rating; the currently failing required check remains a landing gate.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR contains a committed Docker-backed Crabbox receipt and sanitized transcript for the real operator process using loopback GitHub endpoints, with after-fix recovery scenarios passing.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR contains a committed Docker-backed Crabbox receipt and sanitized transcript for the real operator process using loopback GitHub endpoints, with after-fix recovery scenarios passing.
Evidence reviewed 4 items Current-main boundary: Current main's latest reconcile fix concerns stuck-run remediation throttling, not the PR's per-target credential-routing change, so it does not make this PR redundant.
Prior finding addressed: The final branch's stated cache rule keeps installation-missing outcomes repository-scoped until known, allowing another repository under the same owner to receive its own installation lookup.
Current proof: The committed receipt and transcript report 27/27 focused real CLI-process scenarios in Docker-backed Crabbox, including the selected-repositories case, with a final documentation-only commit refreshing the receipt.
Findings None None.
Security None None.

How this fits together

The exact-review dead-letter operator reads target GitHub metadata before asking the queue service to recover review work. This change selects target credentials and classifies read failures before those recovery decisions.

flowchart LR
  A[Dead-letter inventory] --> B[Target owner lookup]
  B --> C[GitHub App token]
  C --> D[REST and GraphQL inspection]
  D --> E[Throttle or authorization decision]
  E --> F[Queue recovery]
  F --> G[Reconciled review work]
Loading

Before merge

  • Resolve merge risk (P1) - The current GitHub context reports a failing pnpm check; its logs and any resulting repair must be resolved on the current head before merge.
  • Resolve merge risk (P1) - The scheduled reconciliation path now requires the configured GitHub App key; the supplied proof covers startup validation and loopback behavior, but not live credential issuance.
  • Complete next step (P2) - The open PR already owns the repair; clear the current required check and complete normal maintainer landing review rather than dispatching another fix PR.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Change composition implementation +480/-71, tests +973/-31, proof docs +333 The patch materially changes the scheduled operator while adding substantial focused regression coverage and proof material.

Merge-risk options

Maintainer options:

  1. Clear the current operator check (recommended)
    Inspect and resolve the failing current-head pnpm check, then refresh review status before merging this workflow and reconciliation change.

Technical review

Best possible solution:

Preserve explicit GitHub App target-read mode, repository-scoped installation-missing caching, and fail-closed authorization handling, then land after the current-head required check is green.

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

Yes: the supplied proof defines a loopback CLI path for installation lookup, token minting, REST, and GraphQL throttling, including the same-owner selected-repositories case; this review did not rerun it locally.

Is this the best way to solve the issue?

Yes: reusing the existing GitHub App signing and installation-token primitives while caching only confirmed owner-wide outcomes is the narrowest maintainable repair.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The PR repairs target-read throttling that can prevent scheduled dead-letter recovery from reaching affected review work.
  • merge-risk: 🚨 automation: The diff changes scheduled workflow credential inputs and the exact-review reconciliation operator.
  • 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 (linked_artifact): The PR contains a committed Docker-backed Crabbox receipt and sanitized transcript for the real operator process using loopback GitHub endpoints, with after-fix recovery scenarios passing.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR contains a committed Docker-backed Crabbox receipt and sanitized transcript for the real operator process using loopback GitHub endpoints, with after-fix recovery scenarios passing.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Authored the current-main reconcile throttling repair and several later changes to the dead-letter operator. (role: recent reconcile contributor; confidence: high; commits: 3d09c5f72ab2, 88fbe4aab561, ae04c61896ef; files: scripts/exact-review-dead-letter-operator.mjs)
  • Martin Cleary: Authored the earlier queue quota-headroom work that predates the operator's target-read pressure handling. (role: adjacent queue contributor; confidence: medium; commits: 13f8ffdea32a; files: scripts/exact-review-dead-letter-operator.mjs)

Rank-up moves

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

  • Resolve the failing current-head pnpm check and refresh the review status.

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 (5 earlier review cycles)
  • reviewed 2026-08-12T20:07:58.425Z sha 6fb3b96 :: needs changes before merge. :: [P1] Preserve the abort for non-throttle 403 responses
  • reviewed 2026-08-12T20:20:06.752Z sha 202970d :: found issues before merge. :: [P1] Preserve access for every reconciled target
  • reviewed 2026-08-12T20:43:35.207Z sha 165f1f7 :: needs changes before merge. :: [P1] Classify rate-limited App setup calls as throttles
  • reviewed 2026-08-12T21:14:15.450Z sha 9ee2eba :: needs changes before merge. :: [P1] Fail closed when the scheduled App key is absent
  • reviewed 2026-08-12T21:44:30.897Z sha 0ac82e6 :: needs changes before merge. :: [P1] Do not cache a missing installation by owner

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Aug 12, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Aug 12, 2026
@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 status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 12, 2026
@steipete
steipete merged commit c8a9737 into main Aug 12, 2026
21 of 22 checks passed
@steipete
steipete deleted the steipete/reconcile-throttle-resilience branch August 12, 2026 22:07
steipete added a commit that referenced this pull request Aug 12, 2026
Accounting-only change: every skip path in the dead-letter operator now emits a stable reason class, and a tested invariant guarantees skip_reasons explains 100% of skipped_targets.

Motivation: post-#1146 reconcile run 31646150689 reported inspected=3, recovered=0, skipped=125 with an EMPTY skip_reasons map - the stuck DLQ tail (191 open) could not be diagnosed from the summary. New classes: inventory_incomplete, discovery_failed, identity_not_actionable, blocked_alias, active_work, no_eligible_rows, inspection_cap, terminal_recheck_cap, closed_state_changed, head_mismatch, recovery_capacity, duplicate_resolution_partial, recovery_mutation_skipped; existing throttle/HTTP/installation classes unchanged. Bounded skip_samples for the interesting classes (head_mismatch, no_eligible_rows). Zero behavior change.

Proof: Crabbox local-container receipt at this exact head (docs/proof/operator-skip-taxonomy/); mixed-scenario invariant sum(skip_reasons)==skipped_targets; operator suite 82/82; full gate 3395/0. Verdict clean (Findings: None) on 1cfe160.
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. 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