Originally created by: 5dive-bot
DIVE-8692 — self-improving loops (lodar 2026-11-18, ships with dev2's Tasks screens; main cuts the tag for both).
A per-loop switch, off by default, on scheduled loops. After each run:
Floor: a change whose new text carries a term the loop's text does not is refused. The terms come from goal add's Tier-2 floor (_GATE_T2_FLOOR_RX), plus a reach list (post, send, message, recipients, emails/handles/links/phone numbers, tools, plugins, installs, buying, accounts).
Undo: puts the text back exactly as it was before the change, and also undoes any kept changes built on top of it.
Cost: one headless claude --print call per run (haiku, no tools, no MCP, no session left on disk) on the seat that closed the run. It runs detached, so task done never waits on it. A seat's tool shell doesn't carry its sign-in, so the call reads the auth lines from the same env files the seat's unit loads, into env and never argv. total_cost_usd is recorded per run. Measured: about $0.004 per run.
task loop improve <loop> on|offtask loop improve <loop> log --json: {improved, score_start, score_now, criteria, entries:[{id, at, change, reason, target, status, kept, score_before, score_after, cost_usd}], runs:[{run, score, cost_usd}]}task loop improve <loop> undo <id>: {undone, also_undone}task ls --recurring --json gains self_improving (bool) and score.tests/loop_improve_unit.sh (new, 64 arms, nightly tier + changed-harness on this PR) covers keep, drop, tie=drop, a run older than the change, a cancelled trial run, hand edit, the floor (8 term arms + an end-to-end refusal), small/once/append, idempotence, garbage from the model, the detached kick, undo exactness + cascade, off with a trial open, and outcome loops refused. Mutations: tie (>→>=), undo cascade, floor, find-once, close hook and prior-run judging are each caught. Neighbours re-run green: loop_scores 40/40, loop_runtime_score 54/54, loop_outcome 43/43, heartbeat_materialize_recurring 73/73, recurring_template_tz 54/54, task_ls_brief 10/10, task_start_recurring_guard 7/7, pace_default_95 20/20.scripts/smoke-loop-improve.sh: a real recurring loop in a scratch state dir with the real default model path (no stub). Run on poke-two as the dev seat, 2 runs: graded 70 then 75, change [#1] "Adds temperature and conditions to the note" kept, [#2] on trial, about $0.004 per run. It lives in scripts/ (not tests/) because it needs a signed-in seat.Not done here: a box-level smoke through the tagged binary. It reaches boxes at the next CLI tag, and main cuts that.
🤖 Generated with Claude Code
Ticket changed by: lodar