Skip to content

v0.3.0-beta.1 feat: move Sentrux DSM analysis to Rust - #10

Merged
2233admin merged 33 commits into
codex/code-intel-atomic-modelfrom
agent/sentrux-rust-dsm-kernel
Jul 25, 2026
Merged

v0.3.0-beta.1 feat: move Sentrux DSM analysis to Rust#10
2233admin merged 33 commits into
codex/code-intel-atomic-modelfrom
agent/sentrux-rust-dsm-kernel

Conversation

@2233admin

@2233admin 2233admin commented Jul 15, 2026

Copy link
Copy Markdown
Owner

What changed

  • adds a native Rust Sentrux DSM analysis kernel
  • exposes it through code-intel sentrux dsm <repo>
  • routes the production pipeline to Rust by default
  • retains an explicit PowerShell compatibility fallback
  • adds DSM contract, dependency/risk, and routing regression tests

Why

DSM source inventory, function extraction, dependency graph construction, and risk aggregation are CPU-heavy. Keeping this path in PowerShell made normal pipeline runs unnecessarily slow.

Impact

  • benchmark on the code-intel repository improved from about 4307 ms to 1370 ms (3.14x)
  • Rust and PowerShell snapshots matched for 172 files and 2383 functions with zero file/function/module contract differences
  • rollback remains available with CODE_INTEL_SENTRUX_DSM_PROVIDER=powershell

Validation

  • clean-worktree cargo test --manifest-path crates/code-intel-cli/Cargo.toml --quiet: 24 + 3 tests passed
  • staged PowerShell syntax parse passed
  • git diff --cached --check passed
  • pre-push Code Intel acceptance passed (stage=land, project-fast)
  • normal pipeline validation previously completed with 7 passed, 0 failed and Sentrux DSM provider: rust

Beta release candidate

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a710cf0e-da24-43e8-8637-f7e42e5031a4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a Rust-native Sentrux DSM analyzer with source, Git, function, dependency, module, and risk metrics. Exposes it through the CLI and orchestration, and updates the PowerShell pipeline to prefer Rust with PowerShell fallback.

Changes

Sentrux DSM Analysis

Layer / File(s) Summary
Analysis inventory and file metrics
crates/code-intel-cli/src/sentrux_analysis.rs, crates/code-intel-cli/tests/sentrux_analysis.rs
The analyzer discovers governed files, gathers Git signals, parses functions, computes file metrics, and emits stable identifiers; integration tests validate the snapshot contract and function details.
DSM dependency metrics and output
crates/code-intel-cli/src/sentrux_analysis.rs, crates/code-intel-cli/tests/sentrux_analysis.rs
Dependency edges, module metrics, risk scores, and color metadata are derived and serialized; tests validate cross-module edges and risk colors.
CLI and provider integration
crates/code-intel-cli/src/main.rs, crates/code-intel-cli/src/sentrux.rs, orchestration/integrations.json, run-code-intel.ps1, crates/code-intel-cli/tests/sentrux_analysis.rs, docs/plans/sentrux-rust-analysis-kernel-idea.md
The dsm CLI operation and Rust orchestration command are added, while the production script selects Rust by default and falls back to PowerShell on failure. Documentation records the command and rollback variable.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Pipeline as run-code-intel.ps1
  participant CLI as code-intel sentrux dsm
  participant Analyzer as sentrux_analysis::analyze
  participant Fallback as Invoke-SentruxAgentTool.ps1
  Pipeline->>CLI: invoke Rust DSM command
  CLI->>Analyzer: analyze repository path
  Analyzer-->>CLI: return JSON snapshot
  CLI-->>Pipeline: print JSON
  Pipeline->>Fallback: invoke PowerShell DSM on Rust failure
  Fallback-->>Pipeline: return DSM snapshot
Loading

Poem

A rabbit found a Rusty trail,
With modules hopping through the scale.
Git leaves clues and colors glow,
Rust runs first; fallback flows.
“DSM is thumping—off we go!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: moving Sentrux DSM analysis to Rust.
Description check ✅ Passed The description is directly related to the changeset and accurately covers the Rust DSM kernel, fallback routing, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Please focus on Rust/PowerShell DSM contract parity, source inventory exclusions, stable ID generation, dependency/risk calculations, and failure-safe PowerShell fallback routing.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

@2233admin I'll review the PR now, with focus on:

  • Rust/PowerShell DSM contract parity (schema/field-level equivalence)
  • Source inventory exclusion rules (ensuring Rust matches PowerShell's include/exclude filters)
  • Stable ID generation (determinism across runs and parity with PowerShell IDs)
  • Dependency/risk aggregation calculations
  • Failure-safe fallback routing to PowerShell (via CODE_INTEL_SENTRUX_DSM_PROVIDER)

I'll follow up with detailed findings shortly.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request ports the performance-sensitive Dependency Structure Matrix (DSM) analysis from PowerShell to a native Rust implementation within the code-intel CLI, updating the orchestration pipeline to prefer the Rust executable with a PowerShell fallback. The review feedback identifies several critical issues: cross-platform compatibility is broken due to a hardcoded .exe extension in the PowerShell script; the Rust analysis suffers from high memory allocations in a hot loop during Git key resolution; recursive file traversal is vulnerable to stack overflows from symlinks; PowerShell function parsing is fragile to multiple spaces; and complexity calculations are skewed by trailing comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread run-code-intel.ps1
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs Outdated
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (2)
run-code-intel.ps1 (1)

4022-4026: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Fix cross-platform pathing for the Rust CLI.

Using a hardcoded backslash (\) causes path resolution to fail on non-Windows platforms (e.g., Linux/macOS), where PowerShell treats target\debug\code-intel.exe as a single literal file name rather than a directory path. Use a forward slash (/) instead, which PowerShell correctly resolves on all platforms.

(Note: standard Rust builds on Linux also omit the .exe extension, so you may need platform-specific extension logic if this is intended to run locally on Linux without CODE_INTEL_RUST_CLI set).

♻️ Proposed fix for cross-platform pathing
         $sentruxDsmRustCli = if ([string]::IsNullOrWhiteSpace($env:CODE_INTEL_RUST_CLI)) {
-            Join-Path $PSScriptRoot "target\debug\code-intel.exe"
+            Join-Path $PSScriptRoot "target/debug/code-intel.exe"
         } else {
             [IO.Path]::GetFullPath($env:CODE_INTEL_RUST_CLI)
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@run-code-intel.ps1` around lines 4022 - 4026, Update the default path in the
$sentruxDsmRustCli assignment to use forward-slash separators so Join-Path
resolves target/debug/code-intel.exe correctly across platforms. Preserve the
CODE_INTEL_RUST_CLI override behavior; only add platform-specific
executable-extension handling if the default path must support local non-Windows
Rust builds.
crates/code-intel-cli/tests/sentrux_analysis.rs (1)

117-125: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Exercise provider routing instead of matching script text.

This test passes if the commands appear in comments or unreachable branches. It does not prove that Rust is the default, the environment variable selects PowerShell, or a Rust failure triggers fallback. Test an extracted routing function or invoke the script with stub executables and assert the selected provider and failure path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/code-intel-cli/tests/sentrux_analysis.rs` around lines 117 - 125,
Replace the text-presence assertions in
production_pipeline_prefers_rust_dsm_with_explicit_powershell_rollback with
behavioral coverage of the routing logic in run-code-intel.ps1. Exercise the
default path to verify Rust is selected, set CODE_INTEL_SENTRUX_DSM_PROVIDER to
verify PowerShell selection, and make the Rust stub fail to verify fallback
invokes PowerShell; assert the resulting provider and command outcomes rather
than script text.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/code-intel-cli/src/sentrux_analysis.rs`:
- Around line 759-775: Replace the repeated depth-relaxation loop around depths
initialization with SCC condensation: identify strongly connected components
from modules and edges, build the component DAG, and calculate each component’s
execution depth once from its dependencies. Map component depths back to member
modules while preserving the existing depth cap and handling disconnected
modules.
- Around line 630-647: Update c_like_end to avoid extending brace-less
declarations into subsequent functions: recognize declaration terminators such
as Rust semicolons and expression-bodied JavaScript functions, and return the
declaration’s end without waiting for a later `{`. When scanning braces, mask or
otherwise ignore braces inside strings and comments so only structural braces
affect depth and range termination.
- Around line 650-666: Update complexity so the arrow-syntax contribution in
complexity is not applied to JavaScript arrow functions, while preserving
complexity scoring for supported control-flow constructs and other languages.
Use the available language/context information or an appropriate context-aware
check rather than counting every trimmed line containing " => ".
- Around line 694-717: Update import_targets and its callers to resolve each
target relative to the importing source file’s package or crate root. Preserve
Python module filenames such as b.py and Cargo crate paths such as
crates/foo/src/a.rs instead of collapsing them to directory names; resolve use
crate:: imports within that crate without synthetic src-only targets. Ensure
generated targets match source module names and avoid self-edges for flat
projects and workspace crates.
- Around line 685-688: Update the edge accumulation in the import-target loop to
increment the existing count for each repeated (from, target) module pair
instead of resetting it to 1. Preserve the current filtering for self-imports
and known modules, and ensure new pairs still start with count 1 so downstream
edge, coupling, and risk metrics reflect all matching imports.
- Around line 616-625: Update python_end so a decorator line at the current
function’s sibling indentation is treated as the next declaration boundary
rather than skipped as part of the current function. Preserve skipping
decorators that are indented within the current function, and keep the existing
end-index behavior for comments, blank lines, and ordinary sibling code.
- Around line 112-125: Unify the file-discovery policy in source_inventory so
results do not depend on whether rg is installed. Centralize inventory discovery
or apply identical explicit exclusions and path normalization to both the rg
--files path and recursive_files fallback, preserving the existing Inventory
construction.
- Around line 66-68: Update the source-reading logic in the inventory file loop
to propagate fs::read_to_string failures instead of converting them to empty
content. Ensure the enclosing analysis flow returns the error so provider
fallback can run, while preserving normal module processing for successfully
read files.

In `@run-code-intel.ps1`:
- Around line 4031-4039: Add a catch block to the try/finally execution flow
around the $sentruxDsmRustCli invocation, capturing launch exceptions such as
UnauthorizedAccessException and setting the existing DSM result variables to the
values required to trigger the PowerShell compatibility fallback. Preserve the
finally block so $ErrorActionPreference is always restored.

---

Nitpick comments:
In `@crates/code-intel-cli/tests/sentrux_analysis.rs`:
- Around line 117-125: Replace the text-presence assertions in
production_pipeline_prefers_rust_dsm_with_explicit_powershell_rollback with
behavioral coverage of the routing logic in run-code-intel.ps1. Exercise the
default path to verify Rust is selected, set CODE_INTEL_SENTRUX_DSM_PROVIDER to
verify PowerShell selection, and make the Rust stub fail to verify fallback
invokes PowerShell; assert the resulting provider and command outcomes rather
than script text.

In `@run-code-intel.ps1`:
- Around line 4022-4026: Update the default path in the $sentruxDsmRustCli
assignment to use forward-slash separators so Join-Path resolves
target/debug/code-intel.exe correctly across platforms. Preserve the
CODE_INTEL_RUST_CLI override behavior; only add platform-specific
executable-extension handling if the default path must support local non-Windows
Rust builds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd986e1c-08a1-4c78-b843-fb8cb031f582

📥 Commits

Reviewing files that changed from the base of the PR and between 456e1e1 and 3bc551e.

📒 Files selected for processing (7)
  • crates/code-intel-cli/src/main.rs
  • crates/code-intel-cli/src/sentrux.rs
  • crates/code-intel-cli/src/sentrux_analysis.rs
  • crates/code-intel-cli/tests/sentrux_analysis.rs
  • docs/plans/sentrux-rust-analysis-kernel-idea.md
  • orchestration/integrations.json
  • run-code-intel.ps1

Comment thread crates/code-intel-cli/src/sentrux_analysis.rs
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs Outdated
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs Outdated
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs Outdated
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs Outdated
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs Outdated
Comment thread crates/code-intel-cli/src/sentrux_analysis.rs Outdated
Comment thread run-code-intel.ps1
@2233admin

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@2233admin
2233admin marked this pull request as ready for review July 15, 2026 15:45
@2233admin

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@2233admin 2233admin changed the title feat: move Sentrux DSM analysis to Rust v0.3.0-beta.1 feat: move Sentrux DSM analysis to Rust Jul 15, 2026
@2233admin
2233admin merged commit 8e10c62 into codex/code-intel-atomic-model Jul 25, 2026
9 checks passed
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