Skip to content

Finishing touches: per-language rules, MCP cache, tree-sitter types, edge overlay, new memory tables#2

Merged
singaraiona merged 5 commits intomainfrom
feat/finishing-touches
May 1, 2026
Merged

Finishing touches: per-language rules, MCP cache, tree-sitter types, edge overlay, new memory tables#2
singaraiona merged 5 commits intomainfrom
feat/finishing-touches

Conversation

@singaraiona
Copy link
Copy Markdown
Contributor

Summary

Closes the remaining 5 polish/accuracy items identified in the post-PR-1 audit. Each commit is independently verifiable and tested.

What changed

Behavioral

  • Per-language rule overrides (2334220) — RuleConfig.language_overrides: BTreeMap<String, LanguageRuleOverride> lets one language declare stricter or looser thresholds than the global ones for: function complexity, cognitive complexity, file lines, function lines, fan-in/out (file & function), large-file size. Resolution order: language override > plugin field > global.
  • Tree-sitter base-class extraction (0d18a51) — for Python and TypeScript, the AST now produces TypeFact.bases from class_definition.superclasses / class_heritage instead of the line-based parser. Handles multi-line declarations and generic type arguments correctly. Line parser stays as fallback.

Internal quality

  • MCP health cache + declarative invalidation (af0a5de) — McpState.cached_health keyed by (root, config-signature). Mutating tools (session_*, rescan, what_if, baseline_save, config_write, plugin_*) clear it via the HEALTH_INVALIDATING_TOOLS list. Read tools (health, hotspots, architecture, evolution, dsm) consult the cache first.
  • New memory tables (f03bf17) — splayed tables for temporal_hotspots, file_ages, change_coupling, and inheritance (one row per (type, base) pair from TypeFact.bases). Coupling strength stored as integer milli (×1000) to fit the i64 column type.

UX

  • File-level edge overlay (e9c90e0) — SVG overlay over the file grid renders lines between cell centers for each adjacency edge, color-coded by type (imports/calls/inherits). Off by default, toggleable. Lines dim when a file is selected unless they're on its route. Adjusts to resize, focus, and edge-filter changes.

Numbers

  • 5 commits, +681/-23 lines.
  • raysense-core unit tests: 105 → 110 (+5 new for language overrides and tree-sitter type extraction).
  • raysense-cli unit tests: 2 → 3 (+1 for MCP cache).
  • raysense-memory unit test: extended row/column assertions for the four new tables.
  • 0 vendor-name mentions in tracked content (commits, code, branch).
  • Browser smoke-tested: file edges render (37 → 22 under imports filter), dim logic works on click.

Test plan

  • cargo fmt --check — clean.
  • cargo test --workspace — all unit tests pass.
  • cargo run -q -p raysense-cli -- health . — confirm output unchanged on this repo (no per-language overrides configured here).
  • cargo run -q -p raysense-cli -- visualize . --output /tmp/r.html — open in browser, toggle "show edges", switch edge filter, click a file → confirm dimming.
  • cargo run -q -p raysense-cli -- mcp over stdio — call raysense_health twice in a row and confirm the second is fast (cache hit). Then call raysense_rescan and confirm the next raysense_health re-scans.

Adds RuleConfig.language_overrides — a per-language map of optional
threshold overrides for the per-file rules: function complexity, cognitive
complexity, file lines, function lines, fan-in/out for files and
functions, and large-file threshold. Resolution order is: language
override > plugin field > global. Languages whose idioms make a global
threshold either too strict or too lax (Rust match arms vs flat Python
conditionals, for example) can now declare their own caps without
loosening the global ones.
…nce as memory tables

Adds four splayed tables to RayMemory: temporal_hotspots, file_ages,
change_coupling, and inheritance (one row per (type, base) pair derived
from TypeFact.bases). Coupling strength is stored as integer milli to
fit the i64 column type — divide by 1000 on read to recover the
[0, 1] Jaccard. RayMemory.summary and save_splayed wire them through
end-to-end.
Adds an MCP-level health cache keyed by (root, config-signature) and a
HEALTH_INVALIDATING_TOOLS list. Read tools (health, hotspots,
architecture, evolution, dsm) now consult the cache first; mutating tools
(session_start/end, rescan, what_if, baseline_save, config_write, plugin
mutations) clear it before they run. Repeated reads in the same MCP
session no longer re-scan.
Adds an AST-driven type extractor that walks class_definition (Python)
and class_declaration (TypeScript) nodes, picking up bases from the
language-specific child fields (Python superclasses, TypeScript
class_heritage / extends_clause / implements_clause). When tree-sitter
parses cleanly the AST result wins; line-based extraction stays as a
fallback for languages without grammar support and merges any
plugin-driven abstract-base flags. Multiline class declarations and
generic type arguments now produce accurate bases without confusing the
line parser.
Adds an absolutely-positioned SVG overlay above the file grid that draws
lines between cell centers for each adjacency edge under the active edge
filter. Edges are off by default (toggle in the controls) to avoid clutter
on large repos. Lines are color-coded by edge type (imports / calls /
inherits) and dim when a file is selected unless they participate in its
upstream or downstream route. Resize, focus changes, and edge-filter
changes all re-render the overlay.
@singaraiona singaraiona merged commit b147653 into main May 1, 2026
1 check passed
@singaraiona singaraiona deleted the feat/finishing-touches branch May 1, 2026 10:06
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