ADR-0002: CLI OAuth subscription AI mode

Context

Nojoin resolves AI inference through an install-wide provider (Ollama or a BYOK API key). A third, per-user “usage model” was requested: CLI OAuth, which routes a user’s inference through their own Claude Pro/Max subscription via the Claude Code CLI (driven by claude-agent-sdk) running as subprocesses in the worker-io lane.

Using a consumer Claude subscription for programmatic/application inference is contrary to Anthropic’s consumer terms — subscription quota is not licensed for this, and no partner path unlocks it. The owner has chosen to build it anyway for personal use, explicitly accepting that risk. This ADR records that decision and the security posture, so the trust boundary and the accepted risk are documented rather than implicit.

Decision

We will ship CLI OAuth as a per-user, opt-in usage model, off by default, selectable in Settings > AI only after the user connects their subscription. It is a swappable mode that degrades cleanly to the user’s BYOK/Ollama secondary via SecondaryLLMBackend and is never load-bearing.

Amendment (2026-07-10): the fallback was widened from the server secondary to the full server-default chain. A subscription failure now degrades to the server primary first and the secondary only after that, built by nesting SecondaryLLMBackend (user sub → server primary → server secondary). Still swappable and never load-bearing; on installs with no secondary configured the subscription now degrades to the server primary instead of surfacing raw.

Security posture (the trust boundary):

Consequences

Alternatives Considered

Update (2026-07-09): Codex (ChatGPT subscription) as a second provider

The mode is now genuinely provider-neutral: alongside Claude, a user can route inference through their own ChatGPT subscription via the OpenAI Codex CLI (CliOAuthProvider.CODEX). The data model already anticipated this (one CliOAuthCredential row per (user, provider)), so this was additive — no migration of existing Claude rows.