Repository navigation
refactor(license): one refresh path — the upload drain, plus one retry on 401 - #151
Merged
Merged
Conversation
…y on 401 Phase 1b of simplifying auth. With recording decoupled from token freshness (#150), refreshing ahead of need buys nothing, so the license is refreshed in one place: the upload drain, just before it sends, and once more with the local expiry check bypassed when the server answers 401. Removed: - the retry daemon's per-sweep refresh and look-ahead (maybeRefreshLicense); the daemon only drains; - the SessionStart refresh; SessionStart spawns a detached drain instead of uploading in-process, so it never waits on the network (this also finishes the SessionStart half of the earlier endpoint-trust work); - the Stop-triggered recovery worker, lib/hook-license-recovery.js; - the backoff_exhausted terminal state: transient failures keep retrying at the 30-minute cap, so an outage recovers without restarting Claude Code; a record left by an older version is ignored; - aheadMs / renewSkewSeconds and the now-unused retryFailedLogs / retryFailedTranscripts wrappers. Kept: the single-flight refresh lock, backoff, the 401/410 and 402 terminal states, and SessionStart clearing a terminal state for one new attempt. The sign-in banner now decides from the state the session found, before that clear. A 401 on upload is not charged against the chunk's retry budget. Net source change: +94 / -220 lines. ADR 001 gets a dated amendment superseding decision 2 and the Stop-recovery amendment; the plugin README's refresh and retention paragraphs follow (the latter was left stale by #150). Simulation (the earlier session-verification harness, drains only per tick): a 3-hour refresh outage lost 255 events and stayed dark until restart; now 0 events are lost and the same session recovers within one 30-minute backoff step. A steady 8-hour session still makes 8 refreshes and loses nothing; the token is briefly expired between refreshes, which only delays uploads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tsook
approved these changes
Sep 26, 2026
Contributor
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (17)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
minarc
added a commit
that referenced
this pull request
Sep 26, 2026
Found mechanically: a scan of every export for uses outside its own module, a scan for functions referenced only by their definition, and a grep for concepts #150/#151 removed. No behaviour changes. Dead code - credstore.setLicenseToken: no production caller since refresh commits through commitRefresh (#148); its one test now simulates the other client's sign-in with commitSignin, the path that client actually uses. - credstore's LICENSE_EXPIRY_SKEW_SECONDS export: its only outside users were the daemon and the Stop recovery, both removed. Comments that described removed behaviour - license-activation: "no reactive force path" (there is one, for 401s); the daemon as a refresh caller. - license-status: the daemon reading the record, a "reactivated" outcome nothing writes, "SessionStart bypasses the refresh lock" (not since #137), and backoff pointing at the superseded ADR 001 decision 2. - transfer: the module header and sealFinalSessionArtifacts said SessionStart and the monitor upload; the function spawns a detached drain itself. - session_start: "even if the daemon gave up last time". Tests - expiry-recovery titles and header named a recovery worker that no longer exists; they now say what they check. - session-start-refresh dropped its unused lock-age fixture branch; retry-daemon dropped endpoint env the daemon no longer uses. ADR 003 gets a dated note: hooks no longer skip on an expired license, backoff_exhausted is gone, and there is no Stop recovery worker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
minarc
added a commit
that referenced
this pull request
Sep 26, 2026
Found mechanically: a scan of every export for uses outside its own module, a scan for functions referenced only by their definition, and a grep for concepts #150/#151 removed. No behaviour changes. Dead code - credstore.setLicenseToken: no production caller since refresh commits through commitRefresh (#148); its one test now simulates the other client's sign-in with commitSignin, the path that client actually uses. - credstore's LICENSE_EXPIRY_SKEW_SECONDS export: its only outside users were the daemon and the Stop recovery, both removed. Comments that described removed behaviour - license-activation: "no reactive force path" (there is one, for 401s); the daemon as a refresh caller. - license-status: the daemon reading the record, a "reactivated" outcome nothing writes, "SessionStart bypasses the refresh lock" (not since #137), and backoff pointing at the superseded ADR 001 decision 2. - transfer: the module header and sealFinalSessionArtifacts said SessionStart and the monitor upload; the function spawns a detached drain itself. - session_start: "even if the daemon gave up last time". Tests - expiry-recovery titles and header named a recovery worker that no longer exists; they now say what they check. - session-start-refresh dropped its unused lock-age fixture branch; retry-daemon dropped endpoint env the daemon no longer uses. ADR 003 gets a dated note: hooks no longer skip on an expired license, backoff_exhausted is gone, and there is no Stop recovery worker. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Merged
minarc
added a commit
that referenced
this pull request
Sep 26, 2026
MINOR: recording no longer depends on the license being fresh (#150), and unsent data is now removed at sign-out and after seven days. Also ships the credential-store hardening (#147, #148) and the single refresh path (#151). #152 and #153 change only docs and leftovers. `paths.js` derives PLUGIN_VERSION from this file, so the sign-in banner and the X-Plugin-Version header follow. Loaded value confirmed: 0.39.0. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behavior change
This is phase 1b of simplifying auth. Now that recording no longer depends on token freshness (#150), refreshing ahead of need buys nothing. The license is refreshed in one place: the upload drain, just before it sends, and once more (bypassing the local expiry check) if the server answers 401.
maybeRefreshLicense)lib/hook-license-recovery.js, deleted)backoff_exhaustedterminal stateaheadMs/renewSkewSeconds,retryFailedLogs/retryFailedTranscriptsKept: the single-flight refresh lock and cooldown, backoff, the 401/410 (re-sign-in) and 402 (revoked) terminal states, and SessionStart clearing a terminal state to give a new session one attempt. The sign-in banner now decides from the state the session found, before that clear.
New: an upload rejected with 401 triggers one forced refresh and a resend of just the rejected files. It isn't charged against the chunk's retry budget, because the token was refused, not the chunk.
Net source change: +94 / −220 lines (8 files; one file deleted).
Simulation (the earlier session-verification harness, re-run on this branch)
mainbefore #150backoff_exhausted; dark until restart, 255 events lostDocs
Telemetry / privacy impact
No change to what is recorded or retained.
Validation
node --test: 457 pass, 0 fail, plus 8 random-order seeds with no failurestest/upload-unauthorized.test.js: a 401 refreshes once and resends; a persistent 401 keeps the chunk without spending its budget; other failures still spend it and trigger no refresh.backoffExhausted, and "the sixth failure is terminal".main's code, the 6 tests that pin the new behavior fail.🤖 Generated with Claude Code