Skip to content

feat: sync Rust xray crate from internal repository - #2126

Open
unsupo wants to merge 4 commits into
developmentfrom
feat/rust-xray-sync
Open

unsupo wants to merge 4 commits into
developmentfrom
feat/rust-xray-sync

Conversation

@unsupo

@unsupo unsupo commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Syncs the Rust xray engine (rust/) from the internal repository — the graph-based code analysis engine that powers xray's Java and Kotlin analysis.

Crates updated

Crate Files Purpose
rust/xray-cli ~10 CLI entry point + 7 e2e test suites
rust/xray-core ~160 Graph engine, compiler, binding, extraction, analysis
rust/xray-benchmarks 5 Performance benchmarks for evaluators
rust/spike_patterns 3 Pattern prototype scripts

xray-core highlights

  • Graph CSR engine: compressed sparse row adjacency, wire format, symbol/string tables
  • Compiler: Rust-based compilation pipeline with diagnostics and rustc driver
  • Binding engine: scope resolution, family inference, narrowing, receiver analysis, type qualifiers
  • Extractors: full Java and Kotlin language support
  • Analysis: memory ceiling estimation, process-level graph analysis
  • 55+ regression test files covering bugs 1794–1956 and acceptance criteria

Notes

  • Existing Cargo.lock is preserved (the internal repo's .gitignore blocks *.lock)
  • rust-toolchain.toml and rust-automation.sh also synced
  • No internal references found in Rust source (no EVO tickets in .rs files)

Scrubbing applied

  • Internal ticket references (EVO-NNNNN) removed where found
  • Disclosure scan passed (no secrets, AWS IDs, internal hostnames, or PII)

Relationship to other PRs


Merge order: this PR depends on PR #2123 (feat/rust-shared-types) landing first — both touch rust/xray-core/src/compiler/ and share the preamble/graph_preamble type paths.

Update the Rust xray engine (xray-cli and xray-core) from the internal
repository. This brings the graph-based code analysis engine up to date
with the latest development.

xray-cli (1 file, 155KB):
- Main entry point for the Rust xray analysis engine
- 7 e2e test suites covering graph analysis, cross-toolchain,
  graph handles, observability, dead code, lifetime analysis, refinement

xray-core (~105 source + ~55 test files):
- Graph engine: CSR adjacency, builder, code graph, wire format,
  symbol table, string table, repo index, user facts
- Compiler: pipeline, preamble, diagnostics, rustc driver, assembler
- Graph binding: admission, budget-bind, depth, families, narrowing,
  receiver, resolve, scope, name-index, same-class-qualified
- Graph analysis: memory ceiling, process analysis
- Extractors: Java (full), Kotlin (full), local index
- Supporting: cache, child-group-reaper, dynlib, evaluators, finding,
  confidence, budget (completeness, ladder, referenced-bits),
  fused graph, graph cache, identity, reasons, refine, languages,
  owned-node, scanner, validator

xray-benchmarks: bench.sh + 4 evaluator benchmarks
spike_patterns: 3 pattern prototype scripts

Existing Cargo.lock preserved. Internal references scrubbed.
Jonathan Arndt added 3 commits November 6, 2026 16:05
- Add the 3 crate-internal imports (debug_log, FactsHandle/GraphHandle,
  DeclarationKind/EdgeReason/SymbolId/UserFact/Visibility) to
  ALLOWED_IMPORTS with per-entry safety rationale
- Rewrite doc comment and assert message to describe the invariant
  without explaining how to bypass the validator
- Move ASSEMBLED_INTO_EVERY_EVALUATOR to assemble.rs as ASSEMBLED_PARTS
  (the module that owns the assembly functions is the authoritative
  source for the list of assembled constants)
- Clamp to rlim_cur (not rlim_max) so the sandbox can never raise
  an inherited soft limit — only lower it
- Move env-var read from spawn_rustc_child to run_rustc_with_timeout
  and pass the parsed limit as a parameter (testable without set_var)
- Rewrite env-mutating test as a direct spawn_rustc_child call with
  a known limit to avoid data races in parallel test execution
- Lower test constant from 1 GiB to 64 MiB to stay below CI hard limits
- Cap line_content_at output to 1024 bytes on a char boundary
  (a minified or binary-ish line can be arbitrarily large)
- Use into_iter + move instead of iter + clone in the JSON output
  branch (result.findings is consumed only once there)
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