# Streaming — deferred nice-to-have cleanup

Non-blocking follow-ups from the drain-convergence final convergence review
(2026-07-16). None block shipping the migration; each is an isolated
convergence-quality improvement.

- **Finish inverting the composition root.** `drain_coordinator.py` imports
  `drain_teardown.py`, which mixes the generic `DrainSessionTeardown` protocol +
  default with the Pi-specific `PiDrainSessionTeardown`, so importing the stable
  drain contract pulls in Pi policy. Split: keep `DrainSessionTeardown` /
  `TeardownReport` / `DefaultDrainSessionTeardown` in a neutral module; move
  `PiDrainSessionTeardown` to a Pi-specific module. Also inject descendant
  cancellation into resident cleanup through `drain_plan_factory.py` as Pi already
  is, instead of `resident_drain.py` building
  `build_spawn_application_service_from_roots()` internally (`resident_drain.py:322-330`).

- **Remove completed-migration compatibility scaffolding.** Production-unused
  tracker/ledger façades and test-only coordinator mutation ports remain; convert
  the tests that need them to behavioral setup and delete the seams
  (`pi_subspawn_tracker.py:277-326`, `pi_work_ledger.py:124-137`,
  `pi_drain.py:429-467,534-537`, `resident_drain.py:409-423`,
  `completion_contracts.py:15-22`, `completion_coordinator.py:454-463`). Resolve
  the residual `Cleaning`-phase remnant vs the post-publication async teardown
  model (the completion cycle now publishes before cleaning), and delete the
  stale phase-4 fold TODO in `drain_plan_factory.py`'s resident branch.

- **Consolidate migration characterization test debt.** `test_pi_characterization.py`,
  `test_pi_quiescence.py`, `test_pi_quiescence_disk_races.py`,
  `test_pi_descendant_evidence.py`, and `test_resident_drain.py` separately
  construct substantially the same coordinator scenario and overlap on priority
  pins / coordinator mechanics / manager behavior; some reach into private state
  (e.g. `test_pi_quiescence_disk_races.py:678-683`). Add one Pi drain scenario
  builder under `tests/support/`, move pure priority cases into compact
  profile/unit table tests, keep a few manager/file-backed smokes, then delete
  the superseded Phase 0 duplicates (don't merely split the large files).
