Prevents brief pauses in tool replies when AFT drains a held bash call while task state is busy. The module loop now answers from worker-published metadata instead of reading task state or awaiting blocking work.
Terminal facts for refused/failed run-on commands publish with the metadata, so drain replies no longer report them as still starting; the canonical rendered reply stays byte-for-byte once ready, and shared cache slots keep pre-registration and replayed tasks consistent.
Remote handback classification and drain deadline lookup stay off the module loop; a thread-local lock ban replaces the old lock-contention timing inference, and a registration gate keeps replay cache publication on the winner so stale rehydration cannot overwrite live facts.
Confidence Score: 5/5
The PR appears safe to merge; the latest change prevents losing replays from overwriting live reply data.
Summary
This PR lets the module loop answer held bash calls from shared reply data instead of waiting for task state.
Restart drains answer held bash calls without waiting on task state.
Deferred waits check remote hand-back timing off the module loop.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Recovered task] --> B{Already registered?}
B -->|Yes| C[Keep live task and reply data]
B -->|No| D[Publish recovered reply data]
D --> E[Register task]
F[Module drain] --> G[Read shared reply data]
G --> H[Answer without reading task state]