feat: /sessions path command for concept-based session traversal (Phase 3 Task 3.2.2) #12
Notifications
Due Date
No due date set.
Blocks
#9 feat: /sessions recommend subcommand for cross-session learning
terraphim/agent-tasks
Reference: terraphim/agent-tasks#12
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
Phase 3 Task 3.2.2 of the session-search spec is unchecked: there is no
/sessions pathcommand that finds a chain of sessions connecting two starting points via shared concepts./sessions related { session_id }(line ~2244 ofhandler.rs) returns direct neighbours of one session, and/sessions concepts { concept }returns sessions sharing a named term, but neither answers the question "show me how session A and session B are connected through the knowledge graph." Without a path surface,/sessions recommend(#9) cannot justify recommendations with an audit trail, and users cannot trace how two pieces of past work relate.Current State
grep SessionsSubcommand::Pathreturns zero hits incrates/terraphim_agent/.SessionIndexincrates/terraphim_sessions/src/index/already stores per-sessionconcepts: Vec<String>and per-conceptsession_ids: Vec<SessionId>inverted lists.RoleGraph(crates/terraphim_rolegraph) exposes BFS/DFS traversal primitives over(concept -> doc -> concept)edges.commands.rs(line ~1317) ends atSessionsSubcommand::Index; noPathvariant exists.Acceptance Criteria
SessionsSubcommand::Path { from: String, to: String, max_hops: Option<usize> }added tocommands.rs./sessions path <from_id> <to_id> [--max-hops N]and/sessions path <from_id> <to_id> --format json.handler.rsperforms a bounded BFS over the session-concept bipartite graph and returns an ordered list ofPathStep { session_id: SessionId, shared_concepts: Vec<String>, hop: usize }.max_hops(default 5), the response carries an emptysteps: []andmeta.reason: "no_path_found"rather than an error envelope.steps: [from, to]when the two sessions already share at least one concept./sessions pathrespects the existingOutputMode(interactive table vs JSON envelope).cargo test -p terraphim_sessions --lib search::pathpasses.cargo test -p terraphim_agent --features repl-full handler_pathpasses.cargo clippy --workspace -- -D warningspasses.Proposed Approach
find_path(&self, from: SessionId, to: SessionId, max_hops: usize) -> Option<Vec<PathStep>>toterraphim_sessions::searchor a newterraphim_sessions::pathmodule.SessionId; expand neighbours via the concept inverted index; prefer neighbours with the highest concept overlap.SessionsSubcommand::Pathand REPL wiring incommands.rs+handler.rs.{ steps: [...], meta: { total_hops, total_concepts_shared } }.SessionIndexfixture (3-4 sessions, known shortest path).Files affected:
crates/terraphim_sessions/src/search.rsor newcrates/terraphim_sessions/src/path.rs(~150 LOC)crates/terraphim_agent/src/repl/commands.rs(~30 LOC variant + parser)crates/terraphim_agent/src/repl/handler.rs(~80 LOC handler)Dependencies
Depends on Task 3.1 (Session Enrichment Pipeline): sessions must have concept annotations for the path search to traverse. If 3.1 is still in flight, a fallback path search on raw tokens can ship first.
Blocks: F5.3 bullet three in #9 (
/sessions recommendwith path-based justification).Verification
Scope
Single PR, estimated 300-400 LOC including tests. Completes Phase 3 Task 3.2.2.
Upstream: Implements
docs/specifications/terraphim-agent-session-search-tasks.mdPhase 3 Task 3.2.2 for terraphim/terraphim-ai.