Skip to content

Add per-parent-task delegation tree (cross-process linkage)#54

Merged
Jason-Vaughan merged 1 commit into
mainfrom
feat/delegate-parent-task-tree
Jun 19, 2026
Merged

Add per-parent-task delegation tree (cross-process linkage)#54
Jason-Vaughan merged 1 commit into
mainfrom
feat/delegate-parent-task-tree

Conversation

@Jason-Vaughan

Copy link
Copy Markdown
Owner

What

Link each delegated sub-call back to the specific top-level task that spawned it, across the
orchestrator → MCP-delegate-child process boundary — the deferred stretch item of the scatter-gather
epic (#39), whose entry criterion was a live-verification spike.

Mechanism: run_once mints a task_id per routed task → the orchestrator CLI adapter injects it
as TANGLEBRAIN_TASK_ID into the orchestrator subprocess env (gated on inject_delegate) → the
orchestrator forwards env to the MCP delegate child → run_delegate reads it back and stamps each
delegate record's parent_task_id. The rollup gains a by_parent grouping
("Linked to: N parent task(s)"); sub-calls run outside a propagated task group as unlinked.

New record fields (task_id, parent_task_id) are written only when present, so existing usage
records and readers are unaffected.

Why

#39 was core-complete with this one stretch item deferred precisely because it can't be tested
hermetically — it depends on a real orchestrator CLI forwarding env to the MCP child it spawns.

Test plan

  • 393 hermetic tests pass (CI: make test on 3.10/3.11/3.12). New unit coverage: env-injection
    gating, env read-back, record write/omit, by_parent grouping + unlinked sentinel, router-path
    task_id threading, all-unlinked format.
  • Live-verified: ran tanglebrain through the real router → claudedelegate_local; the
    parent task record (model: claude, task_id: X) and the delegate record (model: gpt-oss-120b,
    parent_task_id: X) shared the same id. The --stats tree rendered "Linked to: 1 parent task(s)".
  • codex orchestrated but didn't call the delegate tool (a known codex tool-use trait); gemini's
    delegate MCP isn't registered. The env-forwarding hop is identical across CLIs, so claude proves
    the mechanism. Documented as a load-bearing assumption in delegate.py (degrades safely to
    unlinked, never errors).

Independent Critic reviewed (diff-only): SHIP; both SHOULD-FIXes addressed (router-path opts test +
load-bearing comment) plus NITs (all-unlinked format, CHANGELOG wording).

Closes #52.

Link each delegated sub-call back to the top-level task that spawned it,
across the orchestrator→MCP-child process boundary. The CLI mints a
task_id per routed task; the orchestrator CLI adapter injects it as
TANGLEBRAIN_TASK_ID into the orchestrator subprocess (only when the
delegate tool is injected); the orchestrator forwards env to the MCP
delegate child; run_delegate reads it back and stamps each delegate
record's parent_task_id. The rollup groups delegates by_parent
("Linked to: N parent task(s)"); sub-calls run outside a propagated
task group as "unlinked".

New fields are written only when present, so existing usage records and
readers are unaffected. Manually verified live end-to-end through the
real claude→MCP-delegate boundary (parent + delegate records shared the
same id). The orchestrator-forwards-env hop is a load-bearing assumption,
not a TangleBrain guarantee — a delegate that loses the env degrades
safely to "unlinked", never an error.

Closes the deferred entry-criterion spike for the scatter-gather epic.
@Jason-Vaughan Jason-Vaughan force-pushed the feat/delegate-parent-task-tree branch from e856e1d to 9f6a0fc Compare June 19, 2026 05:42
@Jason-Vaughan Jason-Vaughan merged commit 203e5d7 into main Jun 19, 2026
3 checks passed
@Jason-Vaughan Jason-Vaughan deleted the feat/delegate-parent-task-tree branch June 19, 2026 05:42
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.

[feature] Per-parent-task delegation tree (cross-process linkage)

1 participant