Fixes several daemon-safety issues: bash task persistence when the DB attaches late or after eviction, search-index flush timing during graceful shutdown, disk-limit sweeps reading overflow pages, head-scope policy resolution across reconnects, and scoped inspect reuse for verified inputs.
Changes
Bash tasks completed before the DB attaches are backfilled from disk; replay is scoped per project/session, merges disk task records, reopens persistence on evicted-root rebind, resumes a bounded batch in maintenance with its disk scan and recovery outside lifecycle admission, continues the saved scan through maintenance completion, and recovers requested tasks in flight, so unbind and other roots on the transport loop are never blocked.
Graceful shutdown now names each failed or unfinished root after a bounded search-index flush wait, without extending the exit deadline.
The disk-limit sweeper no longer reads overflow pages when collecting eviction candidates; it scans BLOB lengths in place and fetches epochs from the covering index.
Head scope policy is resolved from the latest observed epoch at or before the parent's attested epoch, including tombstones; confirmed scope ends persist revocation so older policies cannot outlive them. Cached scopes are revalidated on each bind, refusals no longer suppress later lookups, and each decision is logged with its channel, root, and reason.
Scoped dead-code inspect reuses the existing project rollup when generation, graph revision, contributions, configuration, public API files, and roles are unchanged, and resolves runtime-note producers lazily when raw notes exist, cutting median TypeORM request time from 7.1s to 3.0s.
Migration
allow_paths validation now reports a missing head policy as head_policy_unknown instead of head_not_held.
Confidence Score: 4/5
Fix the replay delivery-state bug before merging; reconnecting agents can receive results they already acknowledged.
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Project replay] --> B[Load replayable DB rows]
A --> C[Scan one disk batch]
B --> D[Merge tasks]
C --> D
D --> E[Recover tasks]
E --> F{Disk scan complete?}
F -->|No| G[Keep request pending]
G --> H[Maintenance claims next batch]
H --> C
F -->|Yes| I[Remove pending request]