Skip to content

fix: a valid token no longer waits behind a proactive refresh - #414

Merged
ualtinok merged 3 commits into
mainfrom
fix/refresh-join-cause
Oct 20, 2026
Merged

ualtinok merged 3 commits into
mainfrom
fix/refresh-join-cause

Conversation

@antauth-alfonso

@antauth-alfonso antauth-alfonso Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

A request whose own token was valid could wait behind another row's refresh for the same account, because any in-flight refresh for that account and credential epoch made admission join it, with no overall bound.

Joining is now keyed on why the refresh is running, recorded when the job starts:

  • Refresh after a 401 on this token: the request waits for it, since re-sending a rejected token only earns another 401, and never receives a token another joiner saw rejected. One overall join deadline (2 s, Core's existing short join budget) replaces stacked lock waits; on expiry it fails retryably with the existing fixed reset error while the refresh continues.
  • Proactive refresh, or a different credential version: a request with a proven unexpired token that has no recorded rejection is admitted at once through the lock-free path.

Refresh locks, single-use refresh-token protection, attempt caps, backoff and persistence are unchanged.

Red-first regressions on OpenCode 1, OpenCode 2 and Pi (proactive refresh doesn't delay a valid token, a 401 refresh never re-serves the rejected token, the deadline refuses retryably). Mutation rows refresh-join-checks-cause and refresh-join-has-overall-deadline CAUGHT.


Summary by cubic

Fixes a bug where a request carrying a valid token could wait behind a proactive refresh for the same account, because any in-flight refresh made it join with no overall bound.

Joining is now keyed on why the refresh is running:

  • A refresh caused by a 401 on the request's own token: the request waits, capped by a single 2-second overall deadline instead of stacked lock waits. On expiry it fails retryably with the existing fixed reset error while the refresh continues. A validation-retry refusal is also skipped for that token so it can be replaced.
  • A proactive refresh, or a refresh for a different credential version: a request with a proven, unexpired token that has no recorded rejection is admitted immediately through the lock-free path.

A token rejected by any caller in the shared job is never served again. Refresh locks, single-use refresh-token protection, attempt caps, backoff, and persistence are unchanged. Serving exclusions such as refresh backoff, permanent errors, and account policy are still checked before joining.

Written for commit d466263. Summary will update on new commits.

View guided diff Turn on auto-fix

Admit proven unexpired tokens while proactive or different-token recovery is running. Record the initial job cause and additional 401 rejections; bound rejected-token callers to one two-second wait without cancelling shared rotation or altering its leases and retries.

Strengthen the prior per-caller adoption test: when another joiner reports a 401 for the would-be adopted token, neither caller may serve it. The old first-caller success expectation intentionally becomes rejected-access-unchanged; the existing rejecting-caller refusal and zero-exchange claims remain.

Add red-first OC1/OC2/Pi join coverage and two CAUGHT catalogue controls. Affected selection: 438 pass, one unchanged vault Prime network-error test exceeded its five-second deadline; not retried. Typecheck, builds, lint/format, restored named controls and Pi host smoke pass.
Always check serving admission before deciding whether a rejected token joins recovery, including after job completion. Preserve the existing validation-retry exception for explicitly caller-rejected material; refresh backoff, permanent errors and external account policy still win. Add red-first coordinator coverage for held proactive/401 recovery and policy exclusions without altering exchange locks, retries or deadlines.

The reported CI assertion failed only in its no-backoff positive control: the original fallback bearer was still valid and could be served while proactive rotation ran. Per the parent's explicit decision, that control now requires dispatch from the selected fallback using either of its two known bearers, rather than requiring rotation to win a race. The excluded-backoff half is unchanged.

Ran full Core, OpenCode index and Pi suites once: Core 2033 pass/1 fail (initially exposed rejected-token validation-retry behavior, fixed in production and the 151-test impacted selection passed); OpenCode index 304 pass/1 unrelated profile hook timeout, original CI case passed; Pi 317 pass. No full-suite retries or deadline increases. Final types, 9 host join cases, lint/format, catalogue tests, updated cause mutation and restored named baselines pass.
A rebase conflict resolution placed it under the published 2.1.2 heading.
@ualtinok
ualtinok force-pushed the fix/refresh-join-cause branch from bd9eaca to d466263 Compare October 20, 2026 21:33
@ualtinok
ualtinok merged commit d466263 into main Oct 20, 2026
12 checks passed
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.

1 participant