Skip to content

refactor(core): extract platform auth-health lifecycle #595

Description

@jamezrin

Part of #583. Depends on #584, #585 and #593. Can ship in one PR with #596.

Problem

Auth health has no owner in the #583 plan, but it gates almost everything: ticks, channel points, the Kick challenge job, the Twitch Extensions lane, and heartbeats. It lives in the controller as authRefreshGeneration, probeAuthHealth, persistAuthHealth, beginAuthRefresh, refreshAuthHealth, reportAuthSetupFailures, checkAuthHealth and invalidateAuthHealth (roughly controller.ts lines 1860–2100 and 2990–3020 as of v1.14.0). Hosts also wrap it: the extension's invalidateAuthHealth handler calls extensionHost.invalidate({ forgetCompletion: true }) before delegating. The CLI derives credential availability from its file/env store (packages/cli/src/authStore.ts).

Auth code also calls its dependents directly: persistAuthHealth, reportAuthSetupFailures and invalidateAuthHealth each contain if (platform === "twitch") await stopTwitchChannelPointsPush(emit). That puts a Twitch-only branch and a channel-points dependency inside a platform-neutral service.

Scope

Acceptance criteria

  • A superseded probe or refresh cannot overwrite newer auth health or publish activity.
  • A Twitch auth transition cannot block or change Kick, and the reverse.
  • Logout and account change cancel dependent work (channel-points push, claim-only jobs, Twitch Extensions sessions, heartbeats) through after-commit hooks, with no direct calls from this service into its dependents. AuthHealthService has no platform === "twitch"/"kick" branches and no reference to channel points.
  • The missing_credentials / rejected / transiently-unavailable classification is unchanged on both hosts, covered by the refactor(core): define host ports and explicit runtime capabilities for the extension and CLI #593 core contract suite for both capability sets.
  • pnpm test, pnpm typecheck and the CLI tests pass. No new stored credentials or localized diagnostic keys.

Out of scope

Changing probe requests, credential sources or the auth-health model.


Names the direct channel-points calls to remove, from the 2026-09-25 architecture review. Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    • Status
      Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions