#31712·eliza

fix(core): stop task admission before runtime shutdown

Author: lalaluneCreated Sep 18, 2026Updated Sep 18, 2026

A task whose asynchronous shouldRun validation is pending can begin execution after TaskService.stop() has returned. During real assistant teardown this also allows POST_TURN_MEMORY to reach a room queue after runtime shutdown closes admissions, recording a task failure/backoff during shutdown.

Reproduced at integration fe66ed82b70cd12df624521f8ff6f361a8a1e31b with the real TaskService and PGlite: start runTick, block shouldRun, await stop, release shouldRun. The worker executes once; expected zero, with its persisted task unchanged.

Acceptance: stop new task admissions synchronously during the existing runtime prepareStop phase; recheck admission after asynchronous validation and between tasks; drain already executing work; preserve pending durable tasks without artificial failure/backoff. Existing timer/daemon and task lifecycle tests must remain passing. This is a focused completion repair for #31532.

Evidence: deterministic real-database reproduction and live message-pipeline teardown logs are captured locally. No UI or native-platform changes.