DIVE-972: enforce per-loop token ceilings + digest burn (0.6.22)
Self-hosted AI team: Claude Code, Codex and more, from your phone
Brought to you by:
fivedive
Originally created by: lodar
Closes DIVE-972. Per-loop token ceilings were advisory — nothing ever wrote loop_runs.tokens_spent (static 0), so every spent >= ceiling check read 0 and never fired. Now enforced.
_loop_refresh_spend recomputes real spend from the child tasks' assignees' transcripts (same limit-moving metric as 5dive usage: input+output+cache-write, cache-read excluded) and persists it. _loop_spent wraps it with a 20s throttle for the hot --wait poll; all 6 poll/round sites now read live spend._hb_loop_ceiling_sweep) is the backstop for fire-and-forget (non --wait) loops — the common case that previously had nothing policing spend. Each tick it refreshes running loops and, on breach, halts (status=escalated + kill_requested) and escalates-with-proof on the originating task. Never ships best-so-far silently (design §4).🔄 Loop burn section + .loops JSON (total/capped/byLoop, atCeiling).All 7 existing loop suites green + new loop_ceiling_enforce_unit.sh (3/3) proving real-transcript spend → breach. Additive schema-free change (reuses existing loop_runs.tokens_spent).
🤖 Generated with Claude Code
Ticket changed by: lodar