Stranded daemon fixes: bash persistence after eviction, shutdown flush, disk limits, head scopes, scoped inspect

AF
11h ago
+4085-318

Accepted agent delivery; branch-keyed search descriptor included.


Summary by cubic

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.

RetriggerView in GreptileConfidence Score: 4/5

Fix the replay delivery-state bug before merging; reconnecting agents can receive results they already acknowledged.

Findings

  1. P1 Acknowledged results return ▶

Summary

The PR improves daemon recovery, shutdown reporting, disk sweeps, head-scope lookup, and scoped inspect reuse.

  • Bash tasks survive late database setup and root reconnects.
  • Shutdown reports search-index flushes that fail or miss their deadline.
  • Blob-limit sweeps measure stored sizes without reading overflow pages.
  • Head-scoped routes refresh their policy after a carrier refusal.
  • Scoped dead-code inspect reuses matching project-wide work.

Diagram

%%{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]

Reviews (5) · Last reviewed commit: "mason: recover requested bash tasks befo..." · Reviewed by Greptile