Skip to content

refactor(auth): extract shared provider auth helpers (C1-C7) - #1433

Merged
TheGreatAxios merged 3 commits into
mainfrom
cl-10665-auth-de-dupe-shared-callbackloginsessionstorelock-h
Oct 15, 2026
Merged

TheGreatAxios merged 3 commits into
mainfrom
cl-10665-auth-de-dupe-shared-callbackloginsessionstorelock-h

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • Extracts seven shared provider-auth helpers (C1–C7) from near-identical codex/xai twins into src/auth/: callback-server skeleton, login-flow skeleton, token-session lifecycle (session cache + refresh-basis CAS), auth-store definitions, bearer-header builders, scope-check probe, and a unified file lock. Provider files become thin named entry points; every blocker invariant from the ticket stays a hook, not a knob — the codex inter-process refresh lock is a serializeRefresh? hook (xai intentionally lock-free), accountId merge and token expiry stay per-provider, the divergent stale horizons (5s store vs 120s refresh) carry must-not-unify comments, and exact-code vs substring error matching is untouched. Lock contention still never surfaces as credential_failure.
  • One deliberate behavior delta, now test-pinned at both levels: the unified lock propagates non-ENOENT fs failures where the old codex refresh path swallowed every fs error (the store lock's contract was the stronger one); file-lock.test.ts pins the primitive, refresh-lock.test.ts pins the refresh path.
  • Security-chain semantics preserved: sanitizedRefreshFailure flows through both shared refresh paths; redaction/provenance untouched; sorted diff on the token wire contract (TokenSession shape) shows line-for-line equivalence.

Verification

  • bun run check exit 0: 8955 pass / 0 fail across 581 files (twice).
  • Scoped: src/auth/codex 66 tests, src/auth/xai 17, src/auth 177 total, provider-token-session 7 (incl. absent-hook contract + concurrent-winner CAS pin), new file-lock suite green.
  • Auth-adversarial review (2 rounds): round-1 verdict behavior-preserving with the lock-delta under-pinned; round 2 landed the tests this PR carries. Deliberate provider-policy splitting verified from node_modules/@corbits/oauth-core typings.

Fixes CL-10665

~250 lines of near-identical callback/login/session/store/lock twins
across codex and xai collapse onto seven shared helpers, each taking a
small provider spec of explicit hooks. Deliberate provider differences
stay hooks, not knobs: the codex inter-process refresh lock is a
serializeRefresh hook (xai has none by design), accountId merge and
token expiry stay per-provider, the divergent stale horizons carry
must-not-unify comments, and exact-code vs substring error matching is
untouched. Lock contention still never surfaces as credential_failure.

One deliberate delta: the unified file lock propagates non-ENOENT fs
errors where the codex refresh lock used to swallow every fs error;
the store contract was the stronger one. The propagation is pinned at
both levels — this suite exercises the refresh path and file-lock.test
pins the primitive.
@linear-code

linear-code Bot commented Oct 14, 2026

Copy link
Copy Markdown

CL-10665

@corbits-triage

corbits-triage Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by the comment below.

@corbits-triage

corbits-triage Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by the comment below.

@corbits-triage

corbits-triage Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

@TheGreatAxios
TheGreatAxios changed the base branch from cl-10659-providerauth-pins-codex-provider-oauth-core-ws-remov to main October 15, 2026 20:59
The shared lock and session helpers stay. Remove the second copy of
cases already pinned by the store and refresh-lock suites, unused
file-lock exports, and comments that only restated the extraction.
@TheGreatAxios
TheGreatAxios merged commit 76a499a into main Oct 15, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant