Skip to content

Knowledge graph: typed edges, junk-link suppression, and graph health stats - #335

Merged
rahilp merged 2 commits into
feat/v3-team-editionfrom
feat/graph-edge-quality
Sep 4, 2026
Merged

Knowledge graph: typed edges, junk-link suppression, and graph health stats#335
rahilp merged 2 commits into
feat/v3-team-editionfrom
feat/graph-edge-quality

Conversation

@rahilp

@rahilp rahilp commented Sep 4, 2026

Copy link
Copy Markdown
Owner

What

Turns the knowledge graph into a real typed graph instead of 94% generic relates_to edges, per the amended v3 plan.

  • Typed edge inference at capture time: follows, caused_by, decided drawn in addition to generic relates_to (junk-link suppression prevents near-duplicate confusion from creating misleading connections).
  • Update and merge paths re-infer edges so the graph stays current when content changes; typed edges replace only inferred relates_to pairs, never explicit links.
  • Nightly backfill can emit follows when an entry's kind is already classified; refuses long-mirrored sources.
  • Insight calls parse a relationship + direction before the insight gate, retiring only inferred relates_to edges.
  • GET /stats/graph (admin only, gated behind ?deep=1, unscheduled) reports graph health with gap distribution and EXPLAIN-planned query assertions.
  • Weekly sweep instead of nightly (~7x cheaper amortized).
  • MCP link tool description now explains each edge type and direction; kind gating wired into POST /link and MCP link.

Constraints honored

  • Brain-agnostic, zero added AI/LLM calls, no recall-scoring changes, free-tier D1/Workers AI/subrequest budgets respected (edge writes batched 5→2 subrequests).

Verification

  • 3379 tests passing (from 3266 baseline, +113)
  • tsc --noEmit clean; check:scope 99 queries / 53 exceptions
  • ADR/decisions: ?deep=1 stays manual/unscheduled (no edges(workspace_id) index, user decision; ~5M row-visit cost documented)

…uppression, and graph health stats

Capture-time inference now draws typed edges (follows, caused_by, decided) in
addition to generic relates_to. Update and merge paths re-infer edges so the
graph stays current when content changes; typed edges replace only inferred
relates_to pairs, never explicit links. The nightly backfill can emit follows
when an entry's kind is already classified and refuses long-mirrored sources.

Insight calls now parse a relationship and direction before the insight gate,
retiring only inferred relates_to edges. GET /stats/graph (admin only, gated
behind ?deep=1, unscheduled) reports graph health with gap distribution and
EXPLAIN-planned query assertions. The dangling-edge sweep runs weekly instead
of nightly (~7x cheaper amortized).

MCP link tool description now explains each edge type and direction. Kind
gating is wired into the POST /link and MCP link paths.
@rahilp
rahilp merged commit 04f8a03 into feat/v3-team-edition Sep 4, 2026
2 of 3 checks passed
@rahilp
rahilp deleted the feat/graph-edge-quality branch September 4, 2026 05:26
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