Tracker #79686 P1 (slices 2+3). Closes#76508.
- Durable retained-child registry in state.db (async_delegations gains
retained/retained_at/tombstoned_at/child_session_id/children_json/
owner_profile/usage_json via backwards-compatible column reconciliation).
Completed delegations auto-retain; recover_abandoned_delegations now
rehydrates/validates the reconnectable retained set after restart.
- delegate_task background dispatch returns an admission handle: per-child
subagent_id, durable session_id, and model in the immediate payload
(persisted as the children_json manifest); per-task results now carry
child_session_id + subagent_id.
- delegate_task(follow_up=<child_id>): running child -> steer receipt
(queued); completed retained child -> its persisted transcript is
re-opened via resolve_resume_session_id lineage and the follow-up runs
as the child's next user turn on its own session (cached prefix and
role alternation preserved). Follow-ups are budget-exempt: no spawn
depth, no concurrency slot, and they bypass the spawn-pause switch.
- Persisted child-usage attribution: delegation_child_usage ledger records
each child's usage + resulting aggregate keyed on parent session/turn;
CLI resume reapplies totals on load so parent subagent cost aggregates
survive restarts (reapply-on-load design replacing #62206's lost
one-shot write).
- Tombstone deletes: removing a retained child only de-registers it from
follow-up messaging; transcripts and artifacts are never erased.
- Ownership/authority: compression-lineage session ownership
(SessionDB.get_compression_lineage_root) rejects foreign-profile,
sibling, branch/delegate/tool, and cycle follow-ups. Authority model
design credit: @0xbWy (#76512), reimplemented in the registry layer.
- Config: delegation.max_retained (10) and delegation.retained_ttl_hours
(72) with TTL + cap pruning.