v5.0.5 — hook responsiveness + atomic checkpoint writes
Two reliability improvements to the Token Optimizer hook runtime.
Hook responsiveness
SessionStart and UserPromptSubmit hook handlers now run inside an internal wall-clock budget and exit gracefully if they cannot complete within 8 seconds. The ensure-health SessionStart hook also runs asynchronously with a 15-second outer timeout, keeping /compact and new sessions snappy even on busy machines. The guard saves and restores the prior SIGALRM handler so test runners that install their own are not clobbered.
Atomic checkpoint writes
compact_capture now writes checkpoint markdown files atomically via tempfile.mkstemp + os.replace, matching the pattern already used for quality cache and settings writes. A try/finally sentinel ensures the temp file is cleaned up even when the wall-clock guard fires mid-write, so compact_restore can never surface a partial file as authoritative recovery context.
Other improvements
--triggerargument tocompact-captureis sanitized before it flows into the checkpoint filenamelist_checkpointsfilters in-flight atomic-write dotfiles so they cannot be enumeratedcleanupPeriodDaysis now the first task inensure-health, guaranteed to complete before any slower path can exhaust the budget_write_settings_atomicand_write_quality_cacheuse the sametry/finally + sentinelpattern for consistent cleanup under any exception
No signal math, scoring, or storage layout changes. Rollback via git revert returns to v5.0.4 behavior cleanly.