Add /flow — capture, link, and draw investigation flows - #24
Merged
Conversation
Adds /flow: a local capture layer that records the investigations you run, enriches their citations with real document text, and finds the connections between them — including between conversations that never shared context. Capture hooks GleanClient._post, so every Client API call is recorded through one funnel. Chat turns group by the chatId the API returns, making threading exact rather than time-guessed. Data lives in ~/.gleancode/flow.db (0600), partitioned by instance, mode, and act_as so fictional corpus rows can never link to real tenant content. Capture defaults to mock only; recording live data is opt-in via flow_capture, because a local cache has no permission model. Linking runs in three tiers — shared ticket identifiers, shared phrases anchored on document titles, and cross-session links through a shared or linked document — and every link stores the evidence for it. /flow show draws the result as a vertical rail: sessions are nodes, and a connection branches off on a yellow bridge with the two documents that link stacked around an arrow carrying the shared evidence. Ordering is by what tells you something, not by score: a shared-citation link scores 1.00 and says only "you ran this twice", while the linked-document link that found something scores lower, so kind outranks score. Documents a thread returned to lead the list; the rest hold citation order, since sorting by rank interleaves the turns (every turn's citations restart at rank 0). Colour is decoration only — piped or under NO_COLOR the glyphs still carry the structure — and no line exceeds the terminal width at any size. /flow timeline renders the same graph as a self-contained HTML page with no external references. Three MCP tools expose the graph to an agent. Also: per-datasource colours in ui.py so a source looks the same wherever it appears, unknown sources falling back to grey rather than impersonating a known one; an optional width on ui.rule(); and session_links now recording both ends of a link, with an additive column migration for databases written before that column existed. 835 tests pass. Full guide: docs/FLOW_MAPPER.md Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The rebase onto main brought the teaser along, leaving the README saying /flow was shipped in Overview and forthcoming eighteen lines later. Git merged both edits cleanly because they touch different lines, so nothing flagged it. Moves the section beside MCP server, its closest sibling in kind, keeps the preview image, and adds the Contents entry. Coming soon goes back to holding only the VS Code extension. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The connection-overflow line nested same-type quotes inside an f-string — PEP 701 syntax, which is 3.12+. The project targets 3.9, so CI failed to import anything at all on 3.9, 3.10 and 3.11 while passing on 3.12 and 3.13. It compiled locally because the dev interpreter is 3.14. Computes the plural before the f-string, matching how the document-overflow line above it already does it. Verified with /usr/bin/python3 (3.9.6): all files compile and the full suite passes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
/flow— a local capture layer that records the investigations you run, enriches their citations with real document text, and finds the connections between them.Replaces the "coming soon" teaser on main with the real thing.
The case it exists for
Two conversations that share no vocabulary, connected anyway:
Neither conversation mentions the other. The QBR refers to "the checkout incident" in prose — no ticket number, nothing to join on.
How it works
Capture hooks
GleanClient._post, so every Client API call is recorded through one funnel. Chat turns group by thechatIdthe API returns, making threading exact rather than time-guessed.Linking runs in three tiers, and every link stores its evidence so it can be explained rather than asserted:
Privacy
Data lives in
~/.gleancode/flow.db(0600), partitioned by instance, mode, andact_as, so fictional corpus rows can never link to real tenant content.Capture defaults to mock only. In live mode this file becomes a copy of company content with the permission model stripped off, so recording there is a deliberate act via
flow_capturerather than a default.Rendering
/flow showdraws a rail. Connections are ordered by what they tell you, not by score — ashared-citationlink scores 1.00 and says only "you ran this twice", while thelinked-documentlink that found something scores lower. Colour is decoration only: piped or underNO_COLORthe glyphs still carry the structure, and no line exceeds the terminal width at any size./flow timelinerenders the same graph as a self-contained HTML page with no external references.Also in here
get_flow,get_flow_summary,get_flow_collapsedui.py, so a source looks the same wherever it appears. Unknown sources fall back to grey rather than impersonating a known onewidthonui.rule()/getdocumentsreturning no document contentTests
835 total, 58 new in
tests/test_flow.py— capture gating, linking, partition isolation, ordering, the schema migration, and the renderer at four terminal widths with colour on and off.Full guide: docs/FLOW_MAPPER.md
🤖 Generated with Claude Code