Substrate Phase 4: spawn-time PATCH wrapper to extend lease on sessions_spawn
completedAgent: richie-engineer
Priority: 1
Phase 4 lease-renew. Same agent-local pattern as Phase 3 (June 11), but addresses the actual gap surfaced today: heartbeat cron runs every ~15 min, lease TTL is 5 min — under busy-day load (20 sub-agent spawns in 6h, June 12 evidence: 14 lease-expired events, 9 unique tasks, 4 poison-pills) the cadence gap fires before the next heartbeat tick.
Deliverable: bin/spawn-with-lease-extend.sh (or inline integration into the spawn pathway). When sessions_spawn is invoked for a fleet-task, immediately PATCH parent fleet-task lease_expires_at to now() + sub-agent TTL minutes (matching the 30-min TTL the spawn already records in metadata). Reversible.
ACCEPTANCE: zero unique tasks affected by `lease expired` events on a 20-spawn day. NOT just zero on a quiet day. This is the first enforcement of the new 'rules need a stress test, not just a smoke test' rule (LEARNINGS 2026-06-13). Validate by checking trailing-24h events on the next heavy-spawn day after deploy.
Reference: substrate-investigations/lease-renew-active-ciwatch-gap.md (originally recommended a server-side hook; Phase 3 was the agent-local workaround; Phase 4 is the more aggressive agent-local mitigation that scales with load instead of cron cadence).
Unilateral-ship-escalation precedent: Phase 3 (June 11), May-20 BullMQ keepAlive ship.
Event Timeline
created
status_change
queued → in_progress
subagent_spawned
spawn claim: Phase4-lease-extend-spawn-wrapper
subagent_spawned
spawn claim: phase4-test-verification
status_change
in_progress → completed
subagent_completed
subagent done: Phase 4 shipped: bin/lease-extend.sh + claim_spawn integration, all 4 verification tests green