Shell: killed and reclaimed commands skip output token counting
The 01:30Z profile showed aft-reclaim-kill threads each spending about 4 s of CPU in token counting.
Cause: this isn't a slow tokenizer. On 128 KiB inputs, including long unbroken runs, base64 and progress output, exact counting takes at most about 155 ms in a debug build and scales normally. The cost comes from volume:
- One reclaim-kill thread handles every eligible task for a root in sequence, with no batch cap.
- Each newly killed task was assembled twice before routing dedupe, and each assembly counted both the combined output tail (up to 256 KiB) and the rendered output. That's up to four tokenizer calls per task, roughly 0.35 to 0.75 s per task.
Fix: kill, timeout and reclaim publication now uses the existing skipped-metrics state before reading or tokenizing output. So does survivor cleanup of already-completed tasks and memory-limit kills. Ordinary completed and failed commands keep their exact counts. Agents see no change, since the OpenCode and Pi reminders don't render token fields.
Tests: aft-tokenizer/tests/long_runs.rs adds timing guards on the pathological inputs and parity with the snapshot and legacy BPE. A real-kill test asserts that the output is unchanged and that no counting happens.
Verification: tokenizer tests, parity, formatting and the release-input gate passed on the build server. The agent library recompile after fixing three test callers, the integration tests and the Windows compile check didn't run, because the build servers refused 12-core jobs tonight (job ids are in the delivery report). This PR's CI is the gate.
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Skips token counting for killed and timed-out shell commands so reclaim kills, memory-limit kills, and deleted-root cleanup spend far less CPU.
- Routes kill, timeout, and reclaim publication through the existing skipped-metrics state instead of tokenizing raw and rendered output (up to four tokenizer calls per task).
- Ordinary Completed and Failed commands keep exact token counts; command output and agent-visible behavior are unchanged.
- Adds long-run tokenizer timing guards (2 s ceiling on 128 KiB pathological inputs, CRLF-normalized fixture) and a real-kill test asserting output is preserved and no counting happens.