refactor(daemon): extract shutdown handling from session-state dispatcher
Merged
TH
11d ago+369+369+012345678901234567890123456789-329-329-012345678901234567890123456789
Summary
Part of #3424 (CRAP burn-down, umbrella #3414). Layer 2 of 4; stacks on #3455 (boot extraction).
Extracts the shutdown path: handleShutdownCommand moves from src/daemon/handlers/session-state.ts to src/daemon/handlers/session-shutdown.ts with its exclusive helpers (isDaemonRuntimeFailure, describeShutdownError, requestForegroundShutdownAfterRelease, resolveShutdownWaitMs) and the module-local terminal-state constants. session-state.ts's shutdown branch delegates. No behavior change.
handleShutdownCommand: 15 (already < 30; moved so the dispatcher keeps shedding complexity).handleSessionStateCommands: 20 at this layer (34 before layer 1; 4 at stack top).- Tests split one-to-one:
session-boot-shutdown.test.ts→session-shutdown.test.ts(boot half already lives insession-boot.test.tsfrom layer 1). The descriptor source-slice test (command-descriptor-shutdown-runtime-execution.test.ts) retargets tosession-shutdown.ts— its contract is "the dispatcher does not execute runtime calls", so it follows the moved code, not the filename.
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:layering: pass;session-shutdown.tsregistered indaemon-layer-manifest.json(daemon-sessions).
Created by Apex.