Context
burn summary --subagent-tree <session> already ships (PR #64, closed #8) but reconstructs the tree solely from TurnRecord.subagent.{agentId,parentAgentId,parentToolUseId,subagentType,description} — see packages/cli/src/commands/summary.ts:30-38, 167-174 and packages/analyze/src/subagent-tree.test.ts.
PR #77 landed a normalized SessionRelationshipRecord substrate exactly so this view doesn't have to keep reconstructing relationships from per-turn fields. From the PR's deferred-work list:
Consumer CLI surface — burn summary --subagent-tree, burn diagnose, burn waste --patterns, burn summary --by-relationship. The execution graph is now persisted, so these can be built on top.
Issue #42's acceptance also explicitly calls this out:
The graph is rich enough that #8 can consume it instead of reconstructing everything from isSidechain and parentUuid alone.
Today the ledger persists relationship rows (via appendRelationships / queryRelationships from PR #77) but the subagent-tree CLI never reads them. That keeps Codex / OpenCode subagent trees blocked on each parser duplicating the per-turn field population, and means the tree command can't show fork / continuation / subagent-of-subagent chains the new graph captures.
Proposal
Migrate burn summary --subagent-tree (and the aggregateBySubagent / subagent-tree builder in @relayburn/analyze) to build the tree from SessionRelationshipRecords (joined to TurnRecord cost data), with TurnRecord.subagent retained as a fallback for sessions ingested before the graph was populated.
@relayburn/analyze gains a builder that takes (turns, relationships) and produces the same tree shape consumers already render.
- The renderer continues to roll up cost / token totals per node from the underlying
TurnRecords, joining child turns via agentId.
- When
relationships is empty for a session (legacy ingest), fall back to today's TurnRecord.subagent-only path so existing data still renders.
- Surface the four
relationshipTypes (root / subagent / fork / continuation) in the rendered output, not just subagents — at minimum, an annotation when a node's relationship type is non-subagent.
Acceptance criteria
Out of scope
Refs
Context
burn summary --subagent-tree <session>already ships (PR #64, closed #8) but reconstructs the tree solely fromTurnRecord.subagent.{agentId,parentAgentId,parentToolUseId,subagentType,description}— seepackages/cli/src/commands/summary.ts:30-38, 167-174andpackages/analyze/src/subagent-tree.test.ts.PR #77 landed a normalized
SessionRelationshipRecordsubstrate exactly so this view doesn't have to keep reconstructing relationships from per-turn fields. From the PR's deferred-work list:Issue #42's acceptance also explicitly calls this out:
Today the ledger persists relationship rows (via
appendRelationships/queryRelationshipsfrom PR #77) but the subagent-tree CLI never reads them. That keeps Codex / OpenCode subagent trees blocked on each parser duplicating the per-turn field population, and means the tree command can't show fork / continuation / subagent-of-subagent chains the new graph captures.Proposal
Migrate
burn summary --subagent-tree(and theaggregateBySubagent/ subagent-tree builder in@relayburn/analyze) to build the tree fromSessionRelationshipRecords (joined toTurnRecordcost data), withTurnRecord.subagentretained as a fallback for sessions ingested before the graph was populated.@relayburn/analyzegains a builder that takes(turns, relationships)and produces the same tree shape consumers already render.TurnRecords, joining child turns viaagentId.relationshipsis empty for a session (legacy ingest), fall back to today'sTurnRecord.subagent-only path so existing data still renders.relationshipTypes (root/subagent/fork/continuation) in the rendered output, not just subagents — at minimum, an annotation when a node's relationship type is non-subagent.Acceptance criteria
burn summary --subagent-tree <session>produces identical output for a Claude session whoseSessionRelationshipRecords are present (vs the legacyTurnRecord.subagent-only path) on a fixture that has both populated.SessionRelationshipRecords populated (per Codex passive reader: populate SessionRelationshipRecord and ToolResultEventRecord #87 / OpenCode passive reader: populate SessionRelationshipRecord and ToolResultEventRecord #93) renders a subagent tree without per-source CLI branches.TurnRecord.subagent(no relationship rows) still renders correctly via the fallback.subagent-tree.test.tsis extended to cover the new graph-based builder; the legacy fallback retains its existing tests.--jsonoutput includes the underlyingrelationshipTypeper node.Out of scope
burn diagnose --execution-graph/burn summary --by-relationshipsurfaces — separate follow-up.TurnRecords).Refs