Skip to content

fix(orb): stale-token grace when the broker mint blips in broker mode - #1463

Merged
JSONbored merged 1 commit into
mainfrom
claude/orb-token-grace
Jun 26, 2026
Merged

fix(orb): stale-token grace when the broker mint blips in broker mode#1463
JSONbored merged 1 commit into
mainfrom
claude/orb-token-grace

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

In broker mode a self-host holds no GitHub App key, so a single Orb token-mint failure was fatal
the review failed (→ retry/DLQ) and an Orb blip during the re-mint window stalled the whole fleet
(broker-client.ts: "a mint failure is fatal for that request").

createInstallationToken now wraps the broker mint in stale-token grace: on a mint failure, if the cached
installation token is still within its real expiry, it serves that token — a valid token beats a stalled
review. Tokens re-mint only in their last 2 minutes, so this rescues the common case (a transient Orb blip /
deploy / rate-limit during re-mint) without ever reusing an actually-expired token. A genuine outage with no
usable cached token emits an alertable orb_broker_unavailable log and rethrows, so the queue's existing
retry/DLQ still handles a sustained outage.

Scope

  • src/github/app.ts + its test; cloud (no enrollment secret) is byte-identical — the branch is broker-only.
  • No dangerous reuse: the grace serves only a token still within its real expiry.

Validation

  • npm run typecheck
  • npm run test:coverage — full suite green; 100% changed lines + branches (grace serves cached; no-cache rethrows; expired-cache rethrows).

Roadmap item #2 (broker-mode availability). A full open-circuit cooldown is a possible follow-up, but the queue's exponential backoff already throttles retries to a down Orb.

A brokered self-host holds no GitHub App key, so a single Orb token-mint failure
was fatal — the review failed (→ retry/DLQ) and an Orb blip during the re-mint
window stalled the fleet. createInstallationToken now catches a broker mint failure
and, if the cached installation token is STILL within its real expiry, serves it
(a valid token beats a stalled review; an actually-expired token is never reused).
A genuine outage with no usable cached token emits an alertable structured log
(orb_broker_unavailable) and rethrows so the queue's retry/DLQ handles it.
@dosubot dosubot Bot added the size:S label Jun 26, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jun 26, 2026
@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jun 26, 2026
@JSONbored
JSONbored merged commit cc245fd into main Jun 26, 2026
16 checks passed
@JSONbored
JSONbored deleted the claude/orb-token-grace branch June 26, 2026 10:59
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.44%. Comparing base (2ffd657) to head (658e6da).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1463   +/-   ##
=======================================
  Coverage   95.44%   95.44%           
=======================================
  Files         194      194           
  Lines       21064    21070    +6     
  Branches     7623     7624    +1     
=======================================
+ Hits        20104    20110    +6     
  Misses        383      383           
  Partials      577      577           
Files with missing lines Coverage Δ
src/github/app.ts 97.36% <100.00%> (+0.14%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant