Skip to content

refactor(dashboard): unify GitHub App authentication - #1115

Merged
steipete merged 4 commits into
mainfrom
steipete/unify-github-app-auth
Aug 11, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/unify-github-app-auth

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

ClawSweeper had two independent copies of its GitHub App authentication stack in the dashboard
Worker and exact-review queue. Eleven functions were byte-identical, while githubAppJson had
already drifted: the queue classified timeout, network, rate-limit, validation, and response-body
failures with GitHubRequestError; the Worker exposed plain errors. Keeping two cryptographic and
request implementations made future auth drift likely while making a mechanical consolidation
unsafe without an explicit error-boundary decision.

Why This Change Was Made

dashboard/github-api.ts is now the single canonical owner of all 12 functions and uses the
queue's richer classified implementation. The queue imports that implementation directly. The
Worker imports thin wrapper exports that preserve its former observable error surface: classified
timeout and HTTP failures become plain Error values with the same message, response-body errors
pass through, and non-timeout fetch rejections rethrow the original rejection object unchanged.

The shared module privately associates a classified request failure with its original transport
rejection. That preserves the queue's GitHubRequestError contract without exposing new fields or
changing its constructor, while allowing only the Worker adapter to restore the merge-base
behavior. A controller-owned timeout remains distinct from an independent AbortError rejection.

User Impact

No intended observable behavior change. GitHub App signing, key normalization, installation
lookup, token requests, and queue classification now have one implementation. Every Worker
failure shape pinned from the merge-base implementation remains unchanged.

Drift Evidence

Before this change, the two monoliths contained duplicate implementations of credentials parsing,
installation lookup, JSON requests, JWT signing, private-key normalization, PKCS1-to-PKCS8
conversion, PEM decoding, DER wrapping, DER element/length encoding, byte concatenation, and
base64url encoding. The only implementation drift was githubAppJson: the queue had the richer
classified error behavior and the Worker used plain errors. This PR resolves that drift by the
coordinator decision above rather than choosing one surface implicitly.

Production code changes remain a net reduction. The complete PR is larger because it commits the
required reusable real-runtime proof and redacted evidence.

Accepted Finding Disposition

The P2 transport-compatibility finding is resolved at current head
cdf2a6ead92276bd467bdda1e42d1f51880b6caf. At the merge base, the Worker awaited fetch(...).finally(...)
without a catch, so a fetch rejection propagated unchanged. The adapter now rethrows the original
non-controller transport rejection object. The focused test pins both TypeError("fetch failed")
and DOMException("request aborted", "AbortError") by object identity, constructor, and message,
while separately pinning the controller-owned timeout path.

Real Behavior Proof

  • Claim: the signed Worker and exact-review queue routes use the same canonical App-auth bytes
    while preserving their entry-point behavior.
  • Exercised surface: a real local Wrangler Worker, its SQLite-backed ExactReviewQueue Durable
    Object, both signed HTTP routes, the production App signer/request client, and a real loopback
    GITHUB_API_URL HTTP listener.
  • Scenario: the proof concurrently sends a signed maintainer issue_comment webhook and a signed
    branch-authority request. The loopback server holds both initial App-auth requests until they are
    present, then compares the complete JWT and canonical auth-header bytes before allowing both
    workflows to finish.
  • Local command/environment: docs/proof/unify-github-app-auth/run-proof.sh; Node 24.19.0,
    Wrangler 4.107.0, real loopback sockets.
  • Observable result at current head: PROOF_RC=0; Worker status 202 with status comment 777;
    queue status 202; openclaw/gogcli#598 resolved through the Durable Object; byte-identical JWT
    and canonical App-auth header bytes; zero unexpected loopback requests.
  • Artifacts: committed proof README, redacted HTTP trace, Wrangler log, and machine-readable proof
    summary under docs/proof/unify-github-app-auth/; current-head reruns used isolated temporary
    output so historical committed artifacts remain immutable.
  • Limits: the GitHub endpoint uses synthetic credentials and controlled responses. No production
    GitHub write, workflow dispatch, deployment, or live queue mutation occurs.

Docker-backed Crabbox proof used a clean
--fresh-pr openclaw/clawsweeper#1115 --no-hydrate checkout at
cdf2a6ead92276bd467bdda1e42d1f51880b6caf, Corepack with pnpm 11.10.0, and a
checksum-verified jq 1.8.1 (jq-linux-amd64: OK). The local-container runtime proof printed
PROOF_RC=0 and CONTAINER_PROOF_RC=0. Provider local-container, image
node:24-bookworm, lease cbx_b2244ab2ed15 (jade-barnacle-ceda); Crabbox exited 0 and reports
leaseStopped=true.

The same container baselined current origin/main at
1ee584328f2f07e8dde61dc70124c26da6c28af2: its targeted run produced exactly the three known
blob-hydration environmental failures. The PR full suite ran 3,312 tests—3,301 passed, 8 skipped,
and the same 3 failed—so CONTAINER_DELTA_FAILURES=0.

Worker Error-Shape Evidence

test/github-api.test.ts drives the actual signed Worker route and pins the full representative
surface:

  • controller-owned timeout: GitHub App installation timed out as plain Error
  • fetch rejection: fetch failed as the original TypeError object
  • independent abort rejection: request aborted as the original DOMException with name
    AbortError
  • non-2xx: GitHub App installation 503 as plain Error
  • invalid body: Unexpected token 'o', "not-json" is not valid JSON as SyntaxError

The same focused file also verifies a canonical RS256 JWT and the PKCS1-to-PKCS8 conversion against
Node's cryptographic implementation.

Validation

  • pnpm run format:check — passed
  • pnpm run check:limits — passed
  • pnpm run build:all — passed
  • pnpm run test:no-build — 3,312 tests; 3,303 passed; 9 skipped; 0 failed
  • pnpm run lint — passed
  • pnpm run check:active-surface — passed
  • pnpm run check:dashboard-queue-boundary — passed
  • focused signer/error test — 3 passed, 0 failed
  • local committed runtime proof — PROOF_RC=0
  • Docker-backed current-head Crabbox proof — PROOF_RC=0, CONTAINER_PROOF_RC=0, no failure delta
  • pre-commit Codex autoreview — clean, no accepted/actionable findings
  • committed branch Codex autoreview against origin/main — clean, no accepted/actionable findings

OpenClaw Bay Impact

None. This is an internal authentication ownership consolidation and error-boundary compatibility
repair. It changes no lifecycle or review-publication contract, queue semantics, status/telemetry
shape, Bay data contract, control, or observer-only boundary.

Documentation Lifecycle

The proof package is historical evidence tied to the recorded source SHA and re-runnable harness;
it is not an active operator runbook. No active documentation lifecycle changes.

@clawsweeper

clawsweeper Bot commented Aug 11, 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: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal priority bug or improvement with limited blast radius. 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 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 9:57 PM ET / August 11, 2026, 01:57 UTC.

ClawSweeper review

What this changes

The PR moves duplicated GitHub App credential parsing, JWT signing, installation lookup, and request handling into one dashboard module while retaining plain Worker errors and classified queue errors.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still has the two App-auth implementations, while this branch centralizes them with compatibility adapters. No actionable correctness or security defect was found; the current-head Worker/Durable Object proof is sufficient. Likely related people: steipete and Martin Cleary (medium-confidence history routing).

Priority: P2
Reviewed head: cdf2a6ead92276bd467bdda1e42d1f51880b6caf

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The patch has strong boundary-specific runtime proof and focused compatibility coverage, with no actionable review finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The PR records current-head Docker-backed proof through real local Worker and Durable Object routes with loopback transport, observed successful results, and redacted artifacts.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR records current-head Docker-backed proof through real local Worker and Durable Object routes with loopback transport, observed successful results, and redacted artifacts.
Evidence reviewed 5 items Current main still duplicates the authentication owner: On current main, the shared GitHub API module only owns URL validation, while both the Worker and exact-review queue define installation lookup, App JSON requests, and JWT signing locally.
Shared implementation preserves the Worker boundary: The branch adds the common App-auth client and adapts classified request failures back to the Worker's former plain-error or original-transport-rejection surface.
Both production consumers are wired to the common module: The Worker imports plain-error adapters and the queue imports the classified implementation, matching their prior observable contracts.
Findings None None.
Security None None.

How this fits together

The dashboard Worker and exact-review queue authenticate to GitHub as an App before reading or dispatching review work. The shared authentication module now supplies those requests, with each caller retaining its own error behavior.

flowchart LR
  A[Webhook and queue requests] --> B[Dashboard Worker]
  A --> C[Exact-review queue]
  B --> D[Shared GitHub App authentication]
  C --> D
  D --> E[GitHub API requests]
  E --> F[Worker plain errors]
  E --> G[Queue classified errors]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub App signing and installation-token failures can stop dashboard review processing; the proof uses controlled loopback GitHub responses, so production auth-error telemetry should be watched after deployment.
  • Complete next step (P2) - No discrete repair is indicated; this PR is ready for ordinary maintainer merge review with its auth-provider risk understood.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +343, -412; tests +184 The authentication implementation is a net reduction while focused regression coverage was added for signing and Worker error compatibility.
Proof surface 14 files affected; 1 Worker/DO runtime harness The larger diff is primarily reusable proof and redacted runtime evidence for a shared authentication boundary.

Merge-risk options

Maintainer options:

  1. Merge with focused auth observation (recommended)
    The current-head proof and compatibility tests support landing the consolidation while monitoring installation lookup and token-exchange failures after deployment.
  2. Request live staging evidence
    Pause for a maintainer only if controlled loopback proof is insufficient for this deployment's GitHub App credential boundary.

Technical review

Best possible solution:

Retain one App-auth implementation with the Worker compatibility adapters, then merge with focused observation of GitHub App token and installation failures.

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

Not applicable: this is a consolidation of existing authentication behavior, not a user-reported failure.

Is this the best way to solve the issue?

Yes: using one shared implementation with narrow Worker adapters is the maintainable way to remove duplication without replacing the queue's classified-error contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded internal authentication refactor whose failure would affect dashboard review processing but is supported by focused compatibility coverage.
  • merge-risk: 🚨 auth-provider: The diff centralizes GitHub App JWT signing, installation lookup, and token acquisition used by both production entry points.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR records current-head Docker-backed proof through real local Worker and Durable Object routes with loopback transport, observed successful results, and redacted artifacts.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR records current-head Docker-backed proof through real local Worker and Durable Object routes with loopback transport, observed successful results, and redacted artifacts.

Evidence

What I checked:

  • Current main still duplicates the authentication owner: On current main, the shared GitHub API module only owns URL validation, while both the Worker and exact-review queue define installation lookup, App JSON requests, and JWT signing locally. (dashboard/github-api.ts:1, 1ee584328f2f)
  • Shared implementation preserves the Worker boundary: The branch adds the common App-auth client and adapts classified request failures back to the Worker's former plain-error or original-transport-rejection surface. (dashboard/github-api.ts:91, cdf2a6ead922)
  • Both production consumers are wired to the common module: The Worker imports plain-error adapters and the queue imports the classified implementation, matching their prior observable contracts. (dashboard/worker.ts:9, cdf2a6ead922)
  • Real behavior proof: The proof harness exercises a local Wrangler Worker, SQLite-backed Durable Object, signed routes, and loopback GitHub transport; the updated PR body records a current-head Docker-backed rerun with successful proof markers and no test-failure delta. (docs/proof/unify-github-app-auth/README.md:10, cdf2a6ead922)
  • Feature-history routing: Recent main history shows shared ownership of the dashboard Worker and queue paths by Peter Steinberger and Martin Cleary. (dashboard/exact-review-queue.ts:1, 765644804756)

Likely related people:

  • steipete: Peter Steinberger has the largest sampled contribution count in the current Worker/queue/API history and authored recent dashboard review-path changes. (role: recent area contributor; confidence: medium; commits: 765644804756, 80847d16452c, 06bc47a5bde8; files: dashboard/worker.ts, dashboard/exact-review-queue.ts, dashboard/github-api.ts)
  • Martin Cleary: Recent main history shows repeated queue and dashboard reliability work, including GitHub-limit and queue-reconciliation changes. (role: recent queue contributor; confidence: medium; commits: 91272a65e6ff, 3a38d3622a9b, 13f8ffdea32a; files: dashboard/exact-review-queue.ts, dashboard/worker.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 (3 earlier review cycles)
  • reviewed 2026-08-11T01:21:53.237Z sha 075bcf0 :: needs real behavior proof before merge. :: [P2] Record the required Crabbox proof
  • reviewed 2026-08-11T01:28:00.483Z sha 5e892a1 :: needs changes before merge. :: [P2] Preserve Worker transport failures
  • reviewed 2026-08-11T01:52:17.696Z sha cdf2a6e :: needs real behavior proof before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

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

Re-review progress:

@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 status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 11, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: sufficient Contributor real behavior proof is sufficient. labels Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

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

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 11, 2026
@steipete
steipete merged commit 5a964da into main Aug 11, 2026
25 checks passed
@steipete
steipete deleted the steipete/unify-github-app-auth branch August 11, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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