Repository navigation
Description
Problem
Companion to #539. Once realtime ingestion lands, conversations are in the archive within seconds. The remaining gap is the recall surface — how a fresh Claude Code (or Codex) session in a project repo reaches recent-session context without a human pasting chatlog excerpts, and how the archive is queryable for power workflows beyond recall.
The MCP surface (`polylogue/mcp/`) already has `search`, `list_conversations` (rich filter chain), `get_conversation` (projection flags), `neighbor_candidates`, `session_profile`, `archive_coverage`, `get_session_tree`, `stats`. The fragmentation isn't in coverage — it's in parameter language: filter chain lives only on `list_conversations`, projections only on `get_conversation`, and projection flags are individual booleans rather than a coherent set. The CLI mirrors this fragmentation.
This issue is a clean revamp — no backwards-compatibility shims, no deprecation paths. Names that are wrong get renamed; flags that don't compose get unified.
Real gaps for session-recall
- `cwd_prefix` filter missing. The current `path` parameter on `list_conversations` filters by file paths referenced in conversations (via tool_use). There's no filter on the working directory the session ran in. Claude Code records carry `cwd`; never indexed as a pushdown. Required for "sessions in this repo."
- `path` is overloaded. Rename to `referenced_path` to distinguish from the new `cwd_prefix`.
- Recaps not surfaceable. Claude Code emits `type=summary` records (mid-session compaction summaries). They're regular messages with a distinct type — already in the archive — but `message_type` isn't a filter primitive on read paths. Once it is, `get_messages(id, message_type=summary)` returns recaps. No special table, no special tool — they are messages.
- No paginated message access. `get_conversation` returns whole conversations including all messages — too much for long sessions. Need `get_messages(id, ..., limit, offset)`.
Power axes (in scope)
- `since_session(id)` filter — "everything in this cwd after that session." Common workflow.
- `raw_records(id, limit, offset)` — paginated raw provider records (debugging, fidelity-preserving views).
- MCP resources for stable URIs (cheaper than tool calls; LLM clients can attach as context):
- `polylogue://conversation/{id}`
- `polylogue://messages/{id}`
- `polylogue://session-tree/{id}`
- `polylogue://provider/{name}/recent`
Power axes deferred to follow-up issues
These are noted here so they're not lost. Each gets a separate issue when there's demand:
- Saved/named filter chains — persisted, callable by name from CLI/MCP.
- `compare(id_a, id_b)` — diff two conversations (shared topics, divergent paths).
- Topic similarity beyond `neighbor_candidates` — alternate similarity strategies.
- Dedicated file-touch index — currently subsumed by `referenced_path` filter via tool_use action records.
Solution
Filter chain (CLI + MCP, identical parameter names)
Extend `ConversationFilter` (`lib/filters.py`); CLI flags and MCP params propagate from there.
- `cwd_prefix(path)` — new pushdown. Codex parity contingent on whether codex records carry cwd; investigate during impl. If absent for codex, document as Claude-Code-only.
- `referenced_path(path_terms)` — rename of current `path`.
- `message_type(types)` — first-class read-path filter (currently partial / role-centric). Surface `summary`, `tool_use`, `tool_result`, `thinking`.
- `since_session(conversation_id)` — "newer than this session's most-recent message timestamp, same cwd or unscoped per the surrounding filter."
Projection (granular flags, consistent across read tools)
Keep granular flags only — they compose. No `mode` enum.
- `no_code_blocks`, `no_tool_calls`, `no_tool_outputs`, `no_file_reads`, `prose_only`
- `message_role` (already exists)
- `message_type` (new — see filter chain above)
These apply consistently to `get_conversation`, `get_messages`, `raw_records`.
Pagination
`limit` + `offset` on every read tool returning lists:
- `list_conversations` (already has limit; add offset)
- `get_messages` (new)
- `raw_records` (new)
- `get_session_tree` (add)
`get_conversation` returns header + summary stats (no message body); message body goes through `get_messages`. This is a clean shape change — old shape is dropped without a compat path.
New MCP tools
- `get_messages(conversation_id, *, message_role=None, message_type=None, no_code_blocks=False, no_tool_calls=False, no_tool_outputs=False, no_file_reads=False, prose_only=False, limit=50, offset=0)` — paginated, projected message list.
- `raw_records(conversation_id, *, limit=50, offset=0)` — paginated raw provider records.
MCP resources
- `polylogue://conversation/{id}` — header + stats.
- `polylogue://messages/{id}` — first page of messages, default projection.
- `polylogue://session-tree/{id}` — existing tree.
- `polylogue://provider/{name}/recent` — recent N for one provider.
CLI revamp (same scope)
CLI mirrors MCP. Concrete changes:
- New flags: `--cwd-prefix`, `--since-session`, `--message-type`, `--offset`.
- Rename: `--path` → `--referenced-path`.
- Verify projection flags exist on relevant verbs (`show`, `list`).
- New verbs (or option on existing): `messages ` (paginated), `raw ` (paginated raw).
Schema
No new tables. `message_type` filter pushdown may need an index if the existing schema doesn't support it efficiently (existing precomputed columns include `has_thinking`, `has_tool_use` — adding `type` direct filter is a small extension).
Acceptance
- `--cwd-prefix` end-to-end (CLI + MCP), tested against real Claude Code records.
- `--path` → `--referenced-path` rename complete; no `path` synonym remains.
- `get_messages(id, message_type=summary)` returns Claude Code recap records.
- `get_messages` + `raw_records` paginated tools functional with consistent projection flags.
- MCP resources: 4 URIs listed above resolve.
- `--since-session ID` works.
- CLI flag names match MCP param names exactly.
- Tests for each filter, projection, pagination, resource.
Verification
```bash
session-recall workflow
nix develop -c polylogue --cwd-prefix /realm/project/polylogue --order recent --limit 3 list
nix develop -c polylogue messages --message-role user --limit 5
nix develop -c polylogue messages --message-type summary # recaps
pagination
nix develop -c polylogue messages --limit 50 --offset 0
nix develop -c polylogue messages --limit 50 --offset 50
MCP resource resolution (via test client)
nix develop -c pytest -q tests/unit/mcp/
devtools verify
nix develop -c devtools verify
```
Depends on
- Realtime ingestion for Claude Code + Codex via filesystem watcher #539 (realtime ingestion) — without it, recall sees stale data.
Follow-ups
- Sinnix sibling PR: SessionStart hook invoking the new query surface; global CLAUDE.md instruction.
Activity
[-]Session-recall MCP surface: generic session lookup, recap capture, context injection[/-][+]MCP + CLI session-recall surface: filters, pagination, resources[/+]Sinity commentedon Apr 27, 2026
Adding to deferred axes above:
Saved/named projections— same as named filter chains, but for projection presets (e.g., "my-default-recap-view" =message_role=user,assistant + no_tool_calls + no_tool_outputs). Combine with named filters for callable composed views. Separate follow-up issue alongside saved filters.feat(sources): live filesystem watcher for Claude Code + Codex (#541)
Sinity commentedon Apr 27, 2026
First slice landed via #543:
cwd_prefixfilter end-to-end (spec → plan → record_query → SQL pushdown → CLI--cwd-prefix→ MCPcwd_prefixparam). Tests: 11 covering full chain + escape behaviour. The MCP wire-schema witness (tests/data/witnesses/mcp-tool-schemas.json) has been regenerated.Codex parity: codex records carry
git.repository_urlnotcwd.cwd_prefixmatches Claude Code only until a codex-side cwd-extraction lands.Remaining acceptance items from issue body:
path→referenced_pathclean rename (no compat shim).message_typefirst-class read filter (recaps queryable viaget_messages(id, message_type=summary)).since_session(id)filter.get_messages(id, ..., limit, offset)MCP tool + CLI verb.raw_records(id, limit, offset)MCP tool + CLI verb.polylogue://conversation/{id},polylogue://messages/{id},polylogue://session-tree/{id},polylogue://provider/{name}/recent.feat(query): cwd_prefix filter for session-recall (#543)
fix: rename --path to --referenced-path, restore FTS triggers after b…
Sinity commentedon Apr 29, 2026
Already implemented. All requested features exist in the current codebase:
cwd_prefixfilter — SQL pushdown via JSON_EXTRACT on provider_meta (lib/filter/builder.py)referenced_pathrename — CLI flag, MCP param, and filter method all use this namemessage_typefilter — first-class filter on messages and conversationssince_sessionfilter — time+CWD-based filteringlimit+offseton all read toolsget_messagesMCP tool — paginated, projected message list (mcp/server_tools.py:242)raw_recordsMCP tool — paginated raw provider records (mcp/server_tools.py:303)--cwd-prefix,--since-session,--message-type,--offsetall wired in click_option_groups.pySinity commentedon May 1, 2026
2026-05-01 query/read supersession note
This issue is closed and should stay closed as historical session-recall surface work, but current read-surface naming is now owned by #621/#635.
Target read commands:
raw_recordsshould not remain the public/API name for current raw artifact behavior. Reserveprovider_recordsfor true per-provider-event paging. Machine output is--format jsononly; do not preserve--jsonaliases.Ref #621
Ref #635
feat(sources): live filesystem watcher for Claude Code + Codex (#541)
feat(query): cwd_prefix filter for session-recall (#543)
fix: rename --path to --referenced-path, restore FTS triggers after b…