/**
 * W0 shared injection seams (DEPENDENCY-CYCLE BREAKER) — PLAN_RELAY_AGENT §2 / T2.
 *
 * These are intra-`agent/` seam *types only*. NO cross-plan frozen contract lives here —
 * those stay in `relay-contracts/`. Declaring them once at W0 lets W2/W3 transport tasks
 * (T7/T10/T12/T14) consume a stable type WITHOUT a task-level cycle (see §3 T10↔T14 note).
 *
 * This module MUST remain side-effect-free and runtime-dependency-free (type-only): a test
 * asserts importing it pulls in no `ws`/crypto runtime, so W2/W3 can depend on it freely.
 */

/**
 * Minimal WS surface the transport layer needs. dial/tunnel/backoff/loopback share it so no
 * per-task redeclare and no drift. Adapters wrap the real `ws` socket into this shape.
 */
export interface WsLike {
  send(d: Uint8Array): void
  on(ev: 'message' | 'close' | 'error', cb: (...a: unknown[]) => void): void
  close(): void
}

/** Why a host stopped tunnelling. `renewal-refused`/`goaway-revoked` ⇒ do NOT reconnect. */
export type RevokeReason = 'renewal-refused' | 'goaway-revoked' | 'operator'

/**
 * Revocation seam — T14 IMPLEMENTS it; T10's reconnectLoop only CONSUMES `isRevoked()`.
 * One-way edge (T14 → wires T10's loop), so there is no task cycle.
 */
export interface RevocationState {
  isRevoked(): boolean
  markRevoked(reason: RevokeReason): void
}

/**
 * Minimal timer seam so heartbeat (T9) / cert rotation (T13) are testable with fake timers
 * without depending on Node's global timer types leaking into the transport surface.
 */
export interface TimerLike {
  setTimeout(cb: () => void, ms: number): unknown
  clearTimeout(handle: unknown): void
  setInterval(cb: () => void, ms: number): unknown
  clearInterval(handle: unknown): void
}
