Skip to content

fix: a quota save no longer fails a login renewal that already saved its token - #417

Merged
ualtinok merged 1 commit into
mainfrom
fix/saved-refresh-quota-race
Oct 21, 2026
Merged

ualtinok merged 1 commit into
mainfrom
fix/saved-refresh-quota-race

Conversation

@antauth-alfonso

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

Copy link
Copy Markdown

A local login renewal could report failure after its new token was already saved. The renewal captures reset markers before the token exchange and checks them again when it records that the new token is valid. A quota poll completing in between (quota saves run in the background since 2.1.0) moved the quota marker, so recording the validation was refused and the renewal returned failed. What users saw: OpenCode 1 kept a 401 instead of resending, OpenCode 2 gave up its 401 retry, and Pi ended the stream with an error. The saved token was never lost, and nothing was disabled; the next request revalidated it.

Recording validation for a known account only replaces credential proof and never writes quota state, so it now checks only the refresh-error reset marker (a user's reset during the exchange still refuses it). First-identity publication keeps checking every marker, because it also discards metadata not yet confirmed to belong to the account. Exact credential, version and account-binding checks are unchanged.

Red-first: a Core regression holds the real quota writer and releases it inside the refresh provider; the same interleaving on OpenCode 1, OpenCode 2 and Pi now serves the saved successor with one exchange; a refresh-error reset still refuses. Mutation row known-validation-ignores-quota-only-marker-drift CAUGHT. The original Prime rotation test is unchanged.


Summary by cubic

A login renewal no longer reports failure after its new token was already saved. A quota poll completing during the exchange (quota saves run in the background since 2.1.0) moved a reset marker, so recording the validation was refused and the renewal returned failed — OpenCode 1 kept a 401 instead of resending, OpenCode 2 gave up its 401 retry, and Pi ended the stream with an error. The saved token was never lost.

What changed

  • Known-account validation now checks only the refresh-error reset marker because it only replaces credential proof and never writes quota state.
  • First-identity publication still checks every reset marker since it also discards metadata not yet confirmed to belong to the account.
  • A refresh-error reset during the exchange still refuses validation; credential, version, and account-binding checks are unchanged.

Written for commit 3bfaa25. Summary will update on new commits.

View guided diff Turn on auto-fix

Known-account validation publishes only credential proof, so compare its captured refresh-error reset without rejecting unrelated quota marker changes. Preserve current quota metadata and all credential, binding and first-identity reset checks.

The two known-validation quota-drift refusal cases intentionally change contract: they encoded the overbroad fence that caused after-persist failures. They now require current reset state to survive proof publication; malformed marker schemas, refresh-error resets and first-identity drift remain refused.

Controlled Core regression is red first; restoring the old fence also reddens OC1, OC2 and Pi checks. Direct catalogue replay catches the named mutant with refresh-reset companion green. Scoped Core tests: 236 pass; host regressions: 3 pass; all three packages typecheck. Original Prime unchanged, 30 fresh-process runs: 28 pass and 2 existing-deadline timeouts, no saved-refresh refusal. Full breadth retained unrelated journal timeout and vault-routing assertion failure; no rerun-until-green or deadline changes.
@ualtinok
ualtinok merged commit 3bfaa25 into main Oct 21, 2026
11 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