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
Two attribution modules that walk session structure and produce per-node cost rollups. They land together because both produce tree-shaped output and share the "build a hierarchy then attribute cost to each node" pattern.
Scope
subagent_tree.rs (port of subagent-tree.ts, ~640 LoC)
Port SubagentTreeNode, BuildSubagentTreeOptions, SubagentTypeStats types.
Port buildSubagentTree(turns, options) — walks parent-uuid chains to construct the tree of dispatched subagents per session.
Port aggregateSubagentTypeStats(turns) — flat aggregation over subagent type names.
Sidechain reconciliation rules (sidechain → parent linkage) are upstream in relayburn-reader; this module just consumes the subagentType / parentUuid fields.
claude_md.rs (port of claude-md.ts, ~402 LoC)
Port MarkdownSection, ParsedClaudeMd, SessionClaudeMdCost, SectionCost, ClaudeMdAttributionResult, AttributeClaudeMdInput, TrimRecommendation types.
Port findClaudeMdFiles(projectPath) — filesystem walk for CLAUDE.md in cwd + parents + .claude/CLAUDE.md.
Port loadClaudeMdFile(path), parseClaudeMd(path, text) — markdown section parser; lines starting with # open new sections, body accumulates until next header, indentation level encodes section nesting.
Port attributeClaudeMd(input) — attributes per-session token cost to specific markdown sections weighted by token share.
Port buildTrimRecommendations(result) and renderUnifiedDiffForRecommendation(rec, parsed) — produces a unified-diff string for a section to be removed; keep the diff format (---/+++/@@ headers, - line prefixes) byte-identical to TS, since CLI consumers may grep on it.
cargo test -p relayburn-analyze green for both modules.
Public surface for subagent: buildSubagentTree, aggregateSubagentTypeStats, BuildSubagentTreeOptions, SubagentTreeNode, SubagentTypeStats.
Public surface for claude-md: findClaudeMdFiles, loadClaudeMdFile, parseClaudeMd, attributeClaudeMd, buildTrimRecommendations, renderUnifiedDiffForRecommendation, plus all listed types.
Tree node ordering deterministic (sort by ts asc, then uuid asc within siblings) and matches TS.
Unified-diff output matches TS byte-for-byte on the trim-recommendation fixture corpus.
Parent: #244
Depends on: #242, #266 (foundation), #268 (findings)
Context
Two attribution modules that walk session structure and produce per-node cost rollups. They land together because both produce tree-shaped output and share the "build a hierarchy then attribute cost to each node" pattern.
Scope
subagent_tree.rs(port ofsubagent-tree.ts, ~640 LoC)SubagentTreeNode,BuildSubagentTreeOptions,SubagentTypeStatstypes.buildSubagentTree(turns, options)— walks parent-uuid chains to construct the tree of dispatched subagents per session.aggregateSubagentTypeStats(turns)— flat aggregation over subagent type names.relayburn-reader; this module just consumes thesubagentType/parentUuidfields.claude_md.rs(port ofclaude-md.ts, ~402 LoC)MarkdownSection,ParsedClaudeMd,SessionClaudeMdCost,SectionCost,ClaudeMdAttributionResult,AttributeClaudeMdInput,TrimRecommendationtypes.findClaudeMdFiles(projectPath)— filesystem walk forCLAUDE.mdin cwd + parents +.claude/CLAUDE.md.loadClaudeMdFile(path),parseClaudeMd(path, text)— markdown section parser; lines starting with#open new sections, body accumulates until next header, indentation level encodes section nesting.attributeClaudeMd(input)— attributes per-session token cost to specific markdown sections weighted by token share.buildTrimRecommendations(result)andrenderUnifiedDiffForRecommendation(rec, parsed)— produces a unified-diff string for a section to be removed; keep the diff format (---/+++/@@headers,-line prefixes) byte-identical to TS, since CLI consumers may grep on it.Conformance gate
packages/analyze/src/subagent-tree.test.ts(326 lines)packages/analyze/src/claude-md.test.ts(360 lines)Acceptance
cargo test -p relayburn-analyzegreen for both modules.buildSubagentTree,aggregateSubagentTypeStats,BuildSubagentTreeOptions,SubagentTreeNode,SubagentTypeStats.findClaudeMdFiles,loadClaudeMdFile,parseClaudeMd,attributeClaudeMd,buildTrimRecommendations,renderUnifiedDiffForRecommendation, plus all listed types.Files
packages/analyze/src/subagent-tree.ts+subagent-tree.test.tspackages/analyze/src/claude-md.ts+claude-md.test.ts