Skip to content

activate: reset gh cooldown on explicit /sk-activate - #39

Merged
minarc merged 1 commit into
mainfrom
fix/reset-gh-cooldown-on-activate
Apr 21, 2026
Merged

minarc merged 1 commit into
mainfrom
fix/reset-gh-cooldown-on-activate

Conversation

@minarc

@minarc minarc commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

`trySilentGhActivate` writes a 24-hour FAILURE cooldown to `credentials.json` on common fail paths — gh missing, empty token, HTTP 4xx from the activation endpoint, malformed JSON. That cooldown is checked at the top of the same function and short-circuits subsequent calls.

It was designed to protect automated hook paths from hammering GitHub and the activation endpoint on every event. After #35 no hook calls `trySilentGhActivate` anymore — only `activate.js` does, and that is always a deliberate user action triggered by `/sk-activate`.

Concrete bad UX:

  1. User's `gh auth` has wrong scopes. First `/sk-activate` silent path → 403 → 24h cooldown written.
  2. User reads the error, runs `gh auth refresh --scopes read:user,read:org`.
  3. Re-runs `/sk-activate` expecting silent to work now. It doesn't — the cooldown is still active and silent is skipped. Device flow kicks in every time for the next 24h.

Change

Single line in `skillmeter/scripts/activate.js::main()`: call `credstore.setGhFallbackRetryAfter(0)` right before `trySilentGhActivate`. The helper already deletes the key entirely (credstore.js:169-173) when called with 0, so no new API surface.

Not touched:

  • `trySilentGhActivate` still writes cooldowns on failure — harmless, and keeps the invariant that silent callers always see a truthful retry-after.
  • Cooldown classification (FAILURE vs TRANSIENT) unchanged — that's a separate follow-up.

Verified

  • `node -c skillmeter/scripts/activate.js` — syntax clean.
  • Prime cooldown to `now + 86400`, call `setGhFallbackRetryAfter(0)`, confirm:
    • `getGhFallbackRetryAfter()` returns 0
    • The `gh_fallback_retry_after` key is absent from the on-disk JSON (not just set to zero)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced activation process to prevent cooldown delays from blocking explicit activation attempts.

…tivate

trySilentGhActivate writes a 24-hour cooldown to credentials.json on
FAILURE_COOLDOWN paths: gh missing, empty token, HTTP 4xx from the
activation endpoint, or malformed JSON. The cooldown is then checked
at the top of the same function and short-circuits subsequent calls.

The cooldown was designed to protect automated hook paths from
hammering GitHub / the activation endpoint on every event. Since
PR #35 no hook calls trySilentGhActivate — only activate.js does,
and activate.js is always a deliberate user action triggered by
/sk-activate.

Consequence: if a user's `gh auth` scopes are wrong the first run
writes a 24h cooldown. The user fixes `gh auth refresh --scopes
read:user,read:org` and re-runs /sk-activate immediately. Silent
is skipped for the next 24h, so activation is forced through the
device flow every time, even though silent would now succeed.

Fix: call credstore.setGhFallbackRetryAfter(0) at the top of
activate.js::main(), right before trySilentGhActivate. The helper
already deletes the key entirely when called with 0.

Verified:
- node -c activate.js — syntax clean
- Prime cooldown to now+86400, call setGhFallbackRetryAfter(0),
  confirm getGhFallbackRetryAfter() returns 0 and the
  gh_fallback_retry_after key is absent from the on-disk JSON.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3d940846-46c6-48a7-a699-ea6eaab567ad

📥 Commits

Reviewing files that changed from the base of the PR and between b8fc9e6 and 6a94986.

📒 Files selected for processing (1)
  • skillmeter/scripts/activate.js

Walkthrough

The activation flow now clears the GitHub fallback cooldown immediately after validating the device ID and before attempting silent activation, rather than only after successful license exchange. This prevents cached cooldown values from affecting silent activation retries within the same activation attempt.

Changes

Cohort / File(s) Summary
Activation Cooldown Timing
skillmeter/scripts/activate.js
Moved credstore.setGhFallbackRetryAfter(0) to execute earlier in the flow, immediately after deviceId validation and before credstore.trySilentGhActivate(deviceId), ensuring silent activation attempts are not subject to a cached cooldown within the current activation run.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • jhunlee-dev

Poem

🐰 A hop and a skip, the cooldown clears,
Before the silent plea to GitHub appears!
No stale delays shall block our way,
Fresh retries now greet the day! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'activate: reset gh cooldown on explicit /sk-activate' clearly and specifically describes the main change: resetting the GitHub fallback cooldown during explicit activation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/reset-gh-cooldown-on-activate

Comment @coderabbitai help to get the list of available commands and usage tips.

@minarc
minarc requested a review from jhunlee-dev April 21, 2026 18:02
@minarc
minarc merged commit 722cb03 into main Apr 21, 2026
1 check passed
@TheStarkor
TheStarkor deleted the fix/reset-gh-cooldown-on-activate branch September 21, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants