Tests green. Review done.
Review — fix/1870-pi-subagent-session-id
Bug fixed: Every Pi subagent transcript named session.jsonl. Old extractSessionIDFromPath collapsed path via filepath.Base → literal "session". All runs keyed same ID → staged captures + shadow archive overwrite each other → checkpoints read wrong transcript.
Fix: Model Pi subagents as real subagents. Parse <ts>_<uuid>/<sub>/run-N/session.jsonl → parent UUID as SessionID, distinct <sub>-run-N as SubagentID. Route through SubagentStart/SubagentEnd. Stage each run at own path, surface via new Event.SubagentTranscriptPath.
Verdict
Solid. Clean design, path parsing defensive, security-conscious (validates before path use), well-tested (4 targeted repro tests + extended table test). Tests pass.
Strengths
parsePiSubagentPath returns ok=false on every non-matching shape → safe fallback to parent parsing. Good.
- Path-safety validated at two chokepoints (
parsePiSubagentPath + captureTranscript). Defense in depth.
- New
SubagentTranscriptPath field keeps generic AgentTranscriptPath convention intact — opt-in override, no regression risk to other agents.
- Tests hit the exact corruption (T4: run-0 transcript survives run-2 ending).
Minor findings
1. Validator mismatch — cosmetic, harmless. lifecycle.go:452
parsePiSubagentPath validates subagentID with ValidateAgentID (allows leading dash). captureTranscript re-validates same ID with ValidateSessionID (rejects leading dash). If a Pi <sub> dir starts with -, ID passes parse but capture returns "" → no transcript staged. Fails safe (no crash, no traversal), just silent miss on exotic dir name. Real Pi subdirs are hex → never triggers. Leave or note.
2. SessionRef inconsistent between Start and End. lifecycle.go:182 vs 223
SubagentStart sets SessionRef: payload.SessionFile (raw subagent path). SubagentEnd sets SessionRef: derivePiParentTranscript(...) (parent path). Intentional? If downstream SubagentStart handler reads SessionRef expecting parent conversation ref, mismatch. Worth confirming handler doesn't care. Likely fine (Start just snapshots pre-task state).
3. Parent ref not captured/staged for subagent. lifecycle.go:221
derivePiParentTranscript returns raw Pi <seg>.jsonl path, uncaptured. The whole captureTranscript rationale = survive user deleting Pi sessions. Subagent's parent SessionRef points at deletable raw path. Sub transcript itself IS captured, so checkpoint content safe; only the parent back-ref is fragile. Acceptable given scope.
No blockers
Ship-ready after you confirm finding #2 and run full mise run check. Findings 1 + 3 are notes, not fixes.