Skip to content

Extend evolution metrics, what-if, and visualization (9 slices)#1

Merged
singaraiona merged 9 commits intomainfrom
feat/extend-architectural-metrics
May 1, 2026
Merged

Extend evolution metrics, what-if, and visualization (9 slices)#1
singaraiona merged 9 commits intomainfrom
feat/extend-architectural-metrics

Conversation

@singaraiona
Copy link
Copy Markdown
Contributor

Summary

Closes nine architectural-telemetry gaps in raysense across evolution metrics, what-if simulation, scanner extraction, and the HTML visualization. Each commit is independently verifiable; cumulative diff is +1036/-89.

What changed

Evolution metrics

  • Temporal hotspotsrisk_score = commits * max_cyclomatic_complexity per file, top 10 surfaced in CLI and the raysense_evolution MCP tool. (093ef32)
  • File age window — first/last commit timestamps per file from a 500-commit lookback, plus derived age_days and last_changed_days. (2541b7b)
  • Change coupling pairs — top 20 pairs of files ranked by Jaccard similarity of their commit sets, capped at 50 files per commit to bound the quadratic. (f8b32c3)

Scanner / facts

  • Brace-import fan-outuse a::{b, c, d} now produces three import facts that resolve to their underlying files independently, instead of a single under-resolved target. (802665a)
  • Inline base-class extractionTypeFact carries bases parsed from the type's defining line (Python parens, Java/Kotlin/TS extends/implements, Scala extends/with, C++/C# colon). The plugin's abstract_base_classes list now actually flips is_abstract on subclasses. (203cd9b)
  • Comment ratio — per-file comment_lines count at scan time, aggregated into SizeMetrics.comment_ratio. Heuristic detector handles //, #, --, ;, /* */. (82fd546)

What-if

  • Typed action chainAction enum + simulate_sequence in core; the existing untyped MCP loop now uses them and surfaces the failing step index via SequenceError.index. JSON shape stays backward-compatible. (5219613)

Visualization

  • Color modesmono / age / risk / instability joins language / lines / churn. (5bfc94d)
  • Focus filter — language / directory scoping. (5bfc94d)
  • Adjacency map + dep-route highlight — file-level adjacency for imports / calls / inherits, both directions, injected as JSON. Click on a file outlines upstream / downstream cells in distinct colors and dims the rest. (e1ae0fb)
  • Edge filterall / imports / calls / inherits chooses which edge type seeds reachability. (e1ae0fb)
  • Impact-radius focus — hides every file outside the selected file's reachable set under the active edge filter. (e1ae0fb)
  • Entry-point focus — shows only files marked as binaries / examples / tests. (e1ae0fb)

Numbers

  • 9 commits, +1036/-89 lines.
  • raysense-core unit tests: 92 → 105 (+13 new).
  • 0 vendor-name mentions in tracked content.
  • 0 license-header violations.

Test plan

  • cargo fmt --check — must be clean.
  • cargo test --workspace — all 105 raysense-core tests + downstream crates pass.
  • cargo run -q -p raysense-cli -- health . — confirm new fields appear: temporal_hotspots, oldest_files, change_coupling, comment_ratio in size line.
  • cargo run -q -p raysense-cli -- visualize . --output /tmp/r.html — open in browser, exercise color modes, edge filter, focus modes (entry / impact), click a file to verify upstream/downstream highlighting.
  • cargo run -q -p raysense-cli -- mcp over stdio — call raysense_evolution and raysense_what_if with an actions array, confirm responses include the new fields.
  • Forbidden-name scan on diff — clean.
  • License-header scan on touched files — clean.

Combines per-file commit churn with the file's max cyclomatic complexity to
flag volatile and intricate files where bugs historically concentrate. Already
in CLI health output and the raysense_evolution MCP tool.
Captures the oldest and newest commit timestamps for each scanned file within
the git log lookback, then derives age_days and last_changed_days. Surfaces
the top-20 oldest files in CLI health output and the raysense_evolution MCP
tool. Bounded by the 500-commit lookback window — older history is invisible.
Counts co-commits across the 500-commit lookback for every pair of scanned
files (capped at 50 files per commit to bound the quadratic), then ranks
the top 20 pairs by Jaccard similarity. Surfaces them in CLI health output
and the raysense_evolution MCP tool. Pairs with fewer than three co-commits
are excluded so transient noise does not dominate.
A single use_declaration like \`use crate::facts::{FileFact, ImportFact};\`
previously produced one ImportFact with the literal brace string as its
target, which underresolved to the parent module. The scanner now expands
the brace group into one ImportFact per item, so each one resolves to the
underlying file independently.
TypeFact now carries inline base classes parsed from the type's defining
line (Python parens, Java/Kotlin/TS extends/implements, Scala extends/with,
C++/C# colon syntax). The plugin's abstract_base_classes list now actually
matters: a concrete subclass whose declared bases include a configured
abstract name is itself flagged is_abstract, restoring the contract the
config schema implied.
Replaces ad-hoc per-step JSON handling in the MCP handler with a typed
\`Action\` enum and \`simulate_sequence\` in raysense-core. Failing steps now
surface their position via \`SequenceError.index\` so callers can pinpoint
which action in the chain went wrong, and the JSON shape stays
backward-compatible with the existing \`raysense_what_if\` actions array.
Extends the file grid in raysense visualize with: mono / age / risk /
instability color modes alongside the existing language / lines / churn,
and a focus filter that scopes the grid by language or directory. Each
file cell now carries data-age, data-risk, data-instability, and
data-directory attributes derived from the new evolution metrics, so
recoloring and filtering happen entirely client-side without any server.
…etrics

Adds a heuristic comment-line counter at scan time, stored on FileFact, and
aggregates total_lines / total_comment_lines / comment_ratio into SizeMetrics.
The detector recognises //, #, --, ;, * (block continuation), and /* */
blocks across most languages — best-effort for cross-language comparability,
not exact per-language counts. Surfaced in CLI health output.
…nt focus

Builds a per-file adjacency map (imports / calls / inherits, both directions)
into the visualization page and wires four new client-side controls:
* Edge filter chooses which edge type seeds reachability.
* Click on a file highlights upstream and downstream cells along the
  selected edge type with distinct outline colors.
* Impact-radius focus mode hides every file outside the selected file's
  reachable set.
* Entry-point focus mode shows only files marked as binaries / examples /
  tests by the scanner. Detail panel now lists per-file edge counts and
  whether the file is an entry point.
@singaraiona singaraiona merged commit d11434f into main May 1, 2026
1 check passed
@singaraiona singaraiona deleted the feat/extend-architectural-metrics branch May 1, 2026 09:37
@singaraiona singaraiona mentioned this pull request May 1, 2026
3 tasks
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