refactor(capture-kit): state each snapshot source's circuit scope

Merged
TH
5d ago
+85-48

Summary

Applies the optional items from the #4308 review. Part of #4205. No behavior change.

  1. Circuit scope union. SnapshotSourceChannel.circuit is { scope: 'route' } or { scope: 'runner-session'; sessionChanged() }. A runner-session channel must supply sessionChanged, and a route channel cannot declare one. The runner bridge is runner-session; the local guest channel is route. A new test proves the local route keeps a retired generation's circuit across a runner session change.
  2. Shared layering helper. scripts/layering/executable-policies.ts evaluates every executablePolicies entry. It replaces platformImportsFromRouter and daemonImportsFromSnapshotFacet.
  3. JSDoc. RunnerSessionCircuit states that only a runner-session circuit can set sessionDisabled. A duplicate comment in lifecycle.fixtures.ts is removed.

Validation

At 69621eb183 (base 0e7df74a1a):

  • pnpm check:affected --run --head 69621eb183: all runnable checks passed, exactCommit=true (41 passed).
  • Vitest capture-kit + platform-apple, node --test scripts/layering/*.test.ts, pnpm typecheck, pnpm check:layering: pass.
  • Mutation controls (reverted): local channel as runner-session → the local-route test fails. Runner channel as route → 4 session-circuit tests fail. Helper filter or policy roots broken → the helper tests fail.

No device run: route behavior is unchanged.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.