refactor(daemon): extract appstate Apple-session and device-runtime responses
Merged
TH
6d ago+211+211+012345678901234567890123456789-135-135-012345678901234567890123456789
Summary
Part of #3424 (CRAP burn-down, umbrella #3414). Layer 3 of 4; stacks on #3456 (shutdown extraction).
Extracts the two leaf response paths of handleAppStateCommand into:
session-appstate-apple-session.ts—respondAppleAppStateSession(Apple session snapshot/refresh, stale-session retry loop). Per R75 (handler-owned SessionState membership ratchet) this module takes a structuralAppStateSessionRecordview instead of importingSessionState; the adapter lives beside the dispatcher.session-appstate-device-runtime.ts—queryAppStateDeviceRuntime(non-session device-runtime query).
Both new modules use installRuntimeGatewayFromContext (R80 pattern). No behavior change.
handleAppStateCommand: 31 → 21 at this layer; 5.0 at stack top. This layer removes thecheck:coverage-crap --allfinding for the Apple-session/device-runtime branches; the admission branch resolves in layer 4.- New tests mirror source one-to-one:
session-appstate-apple-session.test.ts,session-appstate-device-runtime.test.ts.
Part of the stacked split of session-state.ts for #3424 (umbrella #3414).
Validation
pnpm check:affected --runon this head: all runnable checks passed (2026-10-12).pnpm check:coverage-crap --all: no function ≥ 30 except the admission branch ofhandleAppStateCommand, resolved by layer 4.pnpm check:layering: pass; both modules registered indaemon-layer-manifest.json(daemon-sessions).
Created by Apex.