You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a mock-LLM end-to-end test for new_task parent-to-child delegation #196
Recursive task decomposition (new_task: synchronous nested HeadlessSession, shared BudgetTracker, depth cap, checkpoint lineage) has only ever been unit-tested against fakes — docs/gap-audit.md records it has never run end-to-end, even against a mock LLM. The parent→child contract (handoff message, budget sharing, event-feed lineage) can drift without any integration signal.
Architecture (independent solution)
Add a mock-LLM end-to-end test; no real model, no cost:
Use the existing e2e harness idiom (scripts/e2e/run.sh mock OpenRouter, or the FakeLlmClient DI in src/engine/__tests__/loop.test.ts if a full script is heavier than needed — pick the lighter one that still crosses a real parent→child boundary).
Script the fake parent to call new_task once with a bounded child task; script the fake child to do one read/edit and complete. Assert: child session exists with correct parent lineage fields, child's spend debits the shared tracker (a child-only overspend trips the cap — the design's core risk), child checkpoints tag into the parent's lineage, parent resumes and completes after observing the child result.
Wire it where the other engine tests run so npm test -- <filter> reaches it; keep runtime in the same class as neighboring suites.
Scope / non-goals
No real-LLM run (that needs an owner key/budget decision), no fixing the same-turn attempt_completion+new_task bug here (separate issue — if this test exposes it, file/link, don't silently fix).
Acceptance
Parent→child run passes deterministically offline, twice in a row.
Child-only budget overspend demonstrably trips the shared cap in the test.
Tests (happy / sad / bad)
This issue is a test; still cover: happy (delegation completes), sad (child errors → parent sees a tool error, not a hang), bad (child attempts recursion past depth cap → refused as tool error).
Contributor notes
Good first issue for someone comfortable with the existing fake-client tests. Start from src/engine/__tests__/loop.test.ts.
src/engine/tests/new-task.test.ts (happy-path delegation now does a real parent→child read+edit with lineage + resume assertions; helpers extracted, gate-clean)
Baseline (before)
ok new_task: child completes and its result flows back to the parent
ok new_task: recursion depth cap refuses as a recoverable tool error (parent continues)
ok new_task: budget is SHARED — child spend trips the one cap (total parent+child)
ok new_task: called alongside another tool is refused, sibling still executes
ok new_task: child edits checkpoint into the SAME shadow-git history, lineage-tagged
ok new_task: child bounded failure surfaces as an honest error, not fabricated success
ok new_task: malformed child completion fails closed
All 7 tests passed
Baseline (after)
Run 1: All 7 tests passed
Run 2: All 7 tests passed
ok new_task: child read+edit, parent resumes (parent delegates via new_task; fake child reads seed.txt + writes child.txt via real tools; result flows back; parent+child event feeds carry parentSessionId/recursionDepth; parent completion lands after child result)
(sad: child bounded failure → honest tool error, pre-existing suite; bad: depth-cap + malformed completion refusals, pre-existing suites)
Full npm test: FAILS at pre-existing src/campaigncontrol/__tests__/repair-known-v2-cli.test.ts — identical failure on clean HEAD (verified via throwaway worktree at HEAD~1), unrelated to this change.
Residual risk / notes
The same-turn attempt_completion+new_task interaction noted in the issue was NOT touched; if the new happy-path ever exposes it, file/link as follow-up.
Full-repo check-architecture reports 157 NEW findings on this branch vs 154 on clean HEAD~1; none name new-task/uwuchat files (grep verified); gate was already red before this change.
Activity
w4ffl35 commentedon Dec 5, 2026
Issue 196 — Closing Report
Files changed
Baseline (before)
Baseline (after)
Boot check
npx tsc --noEmit: clean.npm test: FAILS at pre-existingsrc/campaigncontrol/__tests__/repair-known-v2-cli.test.ts— identical failure on clean HEAD (verified via throwaway worktree at HEAD~1), unrelated to this change.Residual risk / notes
PR: #203
Merge pull request #203 from Capsize-Games/issues/w14-2026-12-05