Skip to content

refactor(twitch): isolate channel-points and claim-only jobs #590

Description

@jamezrin

Part of #583. Depends on #584, #585, #587 (for ObserverSlot), #593 and #599. This is a lifecycle extraction of the existing channel-points work that shipped in v1.13.0 (#407 dedicated alarm, #471 claiming during manual watch). It is not a new claim feature.

Scope

Move Twitch channel-points push ownership, its claim queue, and Twitch's channel-points claim-only job coordination out of the shared controller. The service uses existing PlatformAdapter capabilities, the shared state transaction boundary (#585), and auth transitions (#595). Keep account/session policy explicit in the Twitch service, while leaving common reward-claim behavior in the shared engine. Cross-platform drop-claim jobs and the post-claim handoff belong to #597.

Push observer. Move twitchChannelPointsPush onto #587's ObserverSlot, deleting its hand-copied lifecycle (controller.ts around 4920–5060). It then uses the slot helper's observersOpen gate, and stops reading the discovery signals' discoverySignalLifecycleOpen. Its failed-start rule (stop and clear) is already the one the helper uses, so the push's behavior doesn't change. The push stops through its own after-commit hook on auth and settings changes. The auth code's direct stopTwitchChannelPointsPush calls are removed in #595.

CLI parity. This issue is the only owner of the CLI channel-points cadence change. The extension claims channel points on a dedicated 1-minute alarm (lurkloot.twitch-channel-points). The CLI's createAlarm is a no-op, so unless push claiming is active, the CLI claims channel points only as a side effect of a tick at pollIntervalMinutes. #593 provides the job scheduler port but leaves this job disabled on the CLI, so its refactor PR changes no behavior. This issue enables it, in two PRs:

  1. Structural extraction. The Twitch service registers the channel-points job through the refactor(core): define host ports and explicit runtime capabilities for the extension and CLI #593 port. The CLI host keeps it disabled, so the CLI still claims at tick cadence. This PR must pass test(core): capture background controller ownership and concurrency contracts #584 unchanged.
  2. Behavior change (labelled behavior-change, with a changelog entry). Enable the job on the CLI so it runs every minute, like the extension. The tick-side channel-points claim keeps working. The push connection is reconciled from the tick today, and that must keep working on the CLI.

Take over the channel-points claim effect from #599's interim executor handler: the Twitch service registers the handler for that effect type and the interim one is deleted. Remove this service's entries from #584's locked-I/O allowlist.

Acceptance criteria

  • The controller no longer owns channel-points push connection state or its claim-in-flight set.
  • The push runs on ObserverSlot, with no lifecycle code of its own and no reference to discoverySignalLifecycleOpen.
  • The channel-points claim effect has exactly one handler, the Twitch service's. The interim refactor(core): split scheduler decisions from side effects #599 handler and this issue's allowlist entries are gone.
  • Duplicate notices coalesce. Disable, auth loss, reset, and shutdown stop the push and in-flight claims, through after-commit hooks.
  • Channel-points or claim-only failures do not back off the farming scheduler or affect Kick.
  • Manual-watch claiming and post-claim handoff retain their current eligibility and ordering. Manual-watch claiming is declared inert on the CLI (refactor(core): define host ports and explicit runtime capabilities for the extension and CLI #593, refactor(core): extract manual watch, playback telemetry and managed-tab closure ownership #596).
  • After the behavior-change PR, the CLI runs the channel-points job every minute, like the extension, and a CLI test covers it. A job fire that overlaps a tick's channel-points claim for the same channel sends one request.
  • A successful claim is recorded as a fact, and its activity and notification publish exactly once.
  • Focused timing/cancellation tests and extension/CLI parity checks pass. pnpm test, pnpm typecheck and the CLI tests pass.

Out of scope

Changing Twitch claim payloads, reward rules, or channel-points feature settings.


Moved the push onto #587's ObserverSlot, 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

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions