Review follow-up for #141944.
- The whole child store hops off a running loop, not only child.reserve:
the child is built, run and closed inside delegate_task's callback, and
its constructor already reads the store (ContextCompressor
.bind_session_state). Under NeMo Relay that tripped the sticky
synchronous_rpc_on_event_loop refusal and every child came back
status=error, api_calls=0.
- A child that finishes itself (early close after a failed constructor or a
refused sibling) ends its own session row; parent retirement and restart
only select live children, so that row stayed open forever.
- session.create on an owner-reserved child merges its constructor facts
(max_iterations, reasoning_config, ...) beside the _delegate_from marker
instead of losing them to the keep-existing upsert.
- Descendant lookups use a primary-key range instead of substr(), so a
no-child finish is one index probe, not a table scan.
- Invariant tests: depth refusal, child profile_name == parent's, a forged
parent claim refused on the request path, a draining refusal receipt,
mid-batch refusal closes built siblings, an early store close settles the
child, constructor facts persisted, and a real-daemon Relay leg.
Change-detectors, tautologies, source-reading tests, redundant duplicates,
mock-echo tests and dead/unrunnable tests. Per-test rationale in the lane
ledger (category + reason for every removal).
Four fix-forwards from the adversarial post-merge audit of the Aug 7
unreviewed merge batch:
- estop (#81148): is_engaged() now fails SAFE (engaged) on stat errors;
the gateway estop gate lets recognized slash commands and replies owned
by in-flight work (update prompts, clarify, slash-confirm, tool
approvals, running sessions) through instead of consuming them; new
gateway /pause [reason|off] command gives messaging-only operators an
in-band engage/resume path (busy_policy=dispatch so it works mid-run).
- cron monitor mode (#81138): execution-mode invariants (monitor x
no_agent, monitor_script x monitor_url, no_agent-requires-script) now
have ONE owner (_validate_job_mode_invariants) called from BOTH
create_job and update_job, so the create-time invariant can no longer
be silently violated through the update door.
- cron notepad (#81139): remove_job now clears the job's notepad rows
(clear_notepad was dead code -> orphaned KV state forever); clear is
best-effort and no-ops without creating notepad.db.
- delegation batch gate (#81141): template-marker regex narrowed to
multi-word placeholder shapes only (<feature name>, {file_path}) so
generics (Vec<T>), HTML tags, JSON snippets, glob braces and f-string
style no longer reject legitimate batches; duplicate-goal rejection
removed (best-of-N fan-outs are legitimate).
Reject malformed tasks=[...] batches before any child agent is spawned:
- exact-duplicate goals (case/whitespace-normalized), error names both
task indices
- placeholder goals: bare 'TODO', bare 'task N', unexpanded <...> or
{...} template markers, or goals shorter than 10 chars after strip
- 1-task batches, with an error pointing the model at the single
`goal` form instead
All checks are batch-only — the single-goal form is exempt by design
(short goals like goal="test" are valid there). Error strings are
actionable: each tells the model exactly how to fix the call.
Tool schema is unchanged (byte-stable); validation is runtime-only in
the existing batch-validation region.
Existing tests using terse batch goals ("A"/"B"/"C") updated to
realistic distinct goals per the new contract.
Inspired by: MoonshotAI/kimi-code agent-swarm.md validation rules (MIT)