Skip to content

Add /flow — capture, link, and draw investigation flows - #24

Merged
barkz merged 3 commits into
mainfrom
feat/flow-mapper
Aug 20, 2026
Merged

Add /flow — capture, link, and draw investigation flows#24
barkz merged 3 commits into
mainfrom
feat/flow-mapper

Conversation

@barkz

@barkz barkz commented Aug 20, 2026

Copy link
Copy Markdown
Owner

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:

  ●─ 1  what happened in the checkout incident?
  │     ▪ confluence Postmortem: Checkout Latency Incident (INC-1183)
  │     ▪ jira       INC-1183 — Elevated 5xx on checkout API
  │
  ├──◆ linked-document  0.60  →  2 ──────────────────────────────
  │    Postmortem: Checkout Latency Incident (INC-1183)
  │      ↓  shares: incident, checkout
  │    Customer QBR — Northwind Retail
  │
  ●─ 2  what are the risks going into the Northwind renewal?

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 the chatId the 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:

  1. Identifier — a shared ticket key or repo reference. Exact, score 1.0
  2. Phrase — a shared bigram, or a word from one document's title appearing in the other's text. The title anchor is what makes it precise: ranking by rarity alone surfaces accidents like "across" and "percent", while a title is a curated human label, so prose echoing one is a genuine reference
  3. Session — two sessions connect through a shared citation, or through a document cited by one that links to a document cited by the other

Privacy

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. 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_capture rather than a default.

Rendering

/flow show draws a rail. Connections are ordered by what they tell you, 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. 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.

Also in here

  • Three MCP tools — get_flow, get_flow_summary, get_flow_collapsed
  • Per-datasource colours in ui.py, so a source looks the same wherever it appears. Unknown sources fall back to grey rather than impersonating a known one
  • width on ui.rule()
  • Fixes mock /getdocuments returning no document content

Tests

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

barkz and others added 3 commits August 19, 2026 22:07
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>
@barkz
barkz merged commit 28af12c into main Aug 20, 2026
7 checks passed
@barkz
barkz deleted the feat/flow-mapper branch August 20, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant