Skip to content

feat(loop): verified completion and delegation with a completion contract (CLEAN-156, CLEAN-157) - #30

Merged
maksymhryzodub-prog merged 1 commit into
feat/CLEAN-155-boundary-compactionfrom
feat/CLEAN-156-verified-completion
Oct 26, 2026
Merged

maksymhryzodub-prog merged 1 commit into
feat/CLEAN-155-boundary-compactionfrom
feat/CLEAN-156-verified-completion

Conversation

@maksymhryzodub-prog

Copy link
Copy Markdown
Contributor

Stacked on #29 → #28 → #27 → #26 → #25 → #24. US5 and US6 of specs/001-ecc-agent-principles (tasks T071–T084). Both live in the loop's final-response path, so they ship as one PR covering two tickets.

Verified completion (US5, CLEAN-156)

  • Every write-effect tool call of a turn is recorded (tool, outcome, result head). When any exist, the final LLM call does not stream and the draft goes through VerificationService: the aux model compares it with the outcomes → {ok:true} or a factual rewrite quoting the real error / status / block reason. Bounded by verification.timeoutMs; on timeout the draft is delivered with (unverified). Read-only turns never call the verifier; a verifier failure or odd answer lets the draft through.
  • extractJsonObject (fence- and prose-tolerant) now parses both the verifier's and the instinct curator's answers — the earlier first-brace/last-brace slice broke on explanations containing braces.
  • Eval tests/evals/completion-claims.jsonl (no-false-done): 12/12 live — 7 false claims rewritten without repeating the claim, 5 honest replies passed.

Delegation (US6, CLEAN-157)

  • delegate_task (admin): sub-tasks run as internal child tasks with a fresh history (goal + context), the parent's identity, and the parent's tools minus DELEGATE_BLOCKED (delegate_task, spawn_agent, memory_save, telegram_send, tts, skill_*, secret_set/delete, cron_*, approve_user, set_access_strategy, every channel_*). Concurrent up to tools.delegate.maxParallel, per-worker budget, summary cut to summaryChars; a timed-out worker is aborted and reported with its partial output.
  • Completion contract in the loop: when the model wants to end a turn while its workers still run, the loop waits up to the delegate budget, cancels the rest, and injects a system note listing what finished / what was cancelled for one more iteration — once per turn, never inside a worker.
  • /tasks indents workers under their parent; spawn_agent's description now points to delegate_task for in-runtime sub-tasks.

Plan deviation

DelegateService lives in runtime/loop/domain/ rather than agent/task/domain/ as the plan said: it runs workers through LoopService, and agent → runtime would break the slice dependency rule. The types and the blocked set stay in agent/task/domain/delegate.types.ts.

Tests

  • bun test: 305 pass (+17: verification service 7, loop verification 3, delegate service 4, loop contract 2, parser 1), 1 pre-existing Windows-only failure.
  • bun run eval: guardrails 31/31 · skill-selection 96/100 · corrections 13/13 · completion-claims 12/12.
  • tsc --noEmit: clean apart from the pre-existing bridleAttachments.spec.ts.

Jira: https://dreamvention.atlassian.net/browse/CLEAN-156 · https://dreamvention.atlassian.net/browse/CLEAN-157

🤖 Generated with Claude Code

…ract (CLEAN-156, CLEAN-157)

US5 and US6 of the ECC harness principles (specs/001-ecc-agent-principles,
T071-T084). Both land in the loop's final-response path, so they ship as
one change.

Verified completion (US5):
- Every write-effect tool call of a turn is recorded (tool, outcome, result
  head). When any exist, the final LLM call does not stream and the draft
  reply goes through VerificationService: the auxiliary model compares it
  with the outcomes and either passes it or rewrites it into a factual
  report quoting the real error, status or block reason. Bounded by
  verification.timeoutMs; on timeout the draft goes out as "(unverified)".
  Read-only turns never call the verifier.
- Model answers are parsed with a fence- and prose-tolerant JSON extractor,
  shared with the instinct review.
- tests/evals/completion-claims.jsonl + "no-false-done" mode: 12/12.

Delegation (US6):
- delegate_task runs sub-tasks as internal child tasks with a fresh history,
  the parent's identity and tools minus everything that leaves the
  conversation (messaging, memory, skills, secrets, cron, channels, further
  delegation), concurrently up to tools.delegate.maxParallel, each with a
  time budget and a summary cut to summaryChars.
- Completion contract: a turn cannot end while its workers run; the loop
  waits up to the budget, cancels the rest and hands the model a note of
  what finished and what was cancelled for one more iteration.
- /tasks shows workers under their parent; spawn_agent is pointed at
  external coding work.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@maksymhryzodub-prog
maksymhryzodub-prog force-pushed the feat/CLEAN-156-verified-completion branch from 649fd95 to a8d1b43 Compare October 26, 2026 14:26
@maksymhryzodub-prog
maksymhryzodub-prog merged commit 70d96c7 into main Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant