Archiving a task cancels its pending permission request. The reply handler checked whether to resume the task, released the state lock, then reacquired it to write Running; an archive finishing in between left running on disk, so the task came back outside the archive after a restart. The handler now records the answer and resumes the task under the same state lock, so a later archive still takes effect. A regression test overlaps settlement with archiving and checks the persisted Archived status and the recorded answer.
Fixes#6583
Co-authored-by: principalwater <[email protected]>