Extend evolution metrics, what-if, and visualization (9 slices)#1
Merged
singaraiona merged 9 commits intomainfrom May 1, 2026
Merged
Extend evolution metrics, what-if, and visualization (9 slices)#1singaraiona merged 9 commits intomainfrom
singaraiona merged 9 commits intomainfrom
Conversation
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.
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.
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
risk_score = commits * max_cyclomatic_complexityper file, top 10 surfaced in CLI and theraysense_evolutionMCP tool. (093ef32)age_daysandlast_changed_days. (2541b7b)f8b32c3)Scanner / facts
use a::{b, c, d}now produces three import facts that resolve to their underlying files independently, instead of a single under-resolved target. (802665a)TypeFactcarries bases parsed from the type's defining line (Python parens, Java/Kotlin/TS extends/implements, Scala extends/with, C++/C# colon). The plugin'sabstract_base_classeslist now actually flipsis_abstracton subclasses. (203cd9b)comment_linescount at scan time, aggregated intoSizeMetrics.comment_ratio. Heuristic detector handles//,#,--,;,/* */. (82fd546)What-if
Actionenum +simulate_sequencein core; the existing untyped MCP loop now uses them and surfaces the failing step index viaSequenceError.index. JSON shape stays backward-compatible. (5219613)Visualization
mono / age / risk / instabilityjoinslanguage / lines / churn. (5bfc94d)5bfc94d)e1ae0fb)all / imports / calls / inheritschooses which edge type seeds reachability. (e1ae0fb)e1ae0fb)e1ae0fb)Numbers
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_ratioin 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 -- mcpover stdio — callraysense_evolutionandraysense_what_ifwith anactionsarray, confirm responses include the new fields.