1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Canonical id derivation from paths (the r5 trio helpers).
use *;
/// Strip the on-disk `agent-` filename prefix to the bare-hex canonical agent id (the
/// value the transcript record's `agentId` field AND the workflow journal carry). The
/// single source of truth for this rule - used by `make_subagent` and by the
/// `recover` / `session` / `files` subcommands so a subagent row's printed `session_id`
/// is the SAME bare hex `agents` prints, hence joinable across surfaces.
/// The CANONICAL session id for a transcript file: its jsonl basename, with a
/// subagent's `agent-` filename prefix stripped to the bare-hex id ([`bare_agent_id`]).
///
/// This is the SINGLE derivation used by every per-file `session_id` emission
/// (`list` / `search` / `files` / `recover` / `turns`) so the SAME subagent transcript
/// always reports the SAME id, whichever subcommand prints it - id-form unification.
/// A top-level session uuid has no `agent-` prefix and passes through unchanged. An
/// empty / stem-less path yields an empty string (never panics).
/// The re-feedable PARENT session uuid for a transcript path, or `None` when the path is a
/// top-level `<uuid>.jsonl` (which IS its own session). A subagent transcript lives at
/// `…/<PARENT-UUID>/subagents/[workflows/wf_*/]agent-<hex>.jsonl`, so the parent uuid is the
/// directory component immediately BEFORE the `subagents` segment. This is what makes a
/// search/files subagent match re-feedable: its bare-hex `session_id` is NOT a re-feedable
/// `@<uuid>` target, but the `parent_session_id` this returns is (`csift verbatim @<parent>` works).
/// True when `path` is a SUBAGENT transcript (lives under a `subagents/` segment) rather
/// than a top-level `<uuid>.jsonl` session file.