Skip to content

ruff_charon: Rust intake arm reading Charon LLBC (D-CODEGRAPH-0 slice A) - #129

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/ruff-charon-intake
Nov 2, 2026
Merged

AdaWorldAPI merged 1 commit into
mainfrom
claude/ruff-charon-intake

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

A new crate, crates/ruff_charon, is the Rust intake arm of the Codegraph route Charon → ruff → lance-graph + crai-rs (lance-graph plan d-codegraph-0-resident-codegraph-v1.md, PR AdaWorldAPI/lance-graph#1918). It reads Charon's LLBC through charon-lib from the AdaWorldAPI Charon fork, library only, on stable 1.99. It reports only what Charon witnessed, in three modes:

  • calls: one line per local function, byte-identical to lance-graph crates/sag-ra-probe/tools/llbc_calls.py, the reference this crate is checked against.

  • rows: relation rows in the crai-rs vocabulary, each graded COMPILER and carrying its byte span. A receipt checks harvested == represented + residual, so nothing is dropped silently.

    Charon resolution Row
    resolved function, or a known trait impl CALLS_RESOLVED
    trait method through a generic bound (Clause) or other trait reference MAY_DISPATCH
    function pointer or dyn vtable slot UNRESOLVED_CALL

    A MAY_DISPATCH row is never counted as a confirmed caller.

  • kythe: Kythe entries in the shape kythe_entries.py writes: defines, ref/call and childof edges, plus a file node with each file's text, which Kythe needs to serve anchors.

Impl methods are named with Charon's own formatter. The two Shape::area impls in the fixture therefore stay distinct, including when called from another crate. Under the path-only spelling the Python tools use, both print as cg_lib::shapes::Impl::area.

The crate is excluded from the ruff workspace, like ruff_r2il and ruff_metta_spo, because it path-depends on a sibling checkout (../../../charon/charon, built with default-features = false). The only change outside the crate is that root exclude line.

Test Plan

  • cargo test --manifest-path crates/ruff_charon/Cargo.toml: 3 unit and 6 integration tests pass. They run on committed LLBC of lance-graph's sag-ra-probe/fixtures/codegraph/rev1 (tests/data, provenance in its README), with llbc_calls.py's output as the reference:
    • the calls report equals the reference byte for byte;
    • the bound call is MAY_DISPATCH and the dyn call is UNRESOLVED_CALL, neither CALLS_RESOLVED;
    • the call inside assert_eq!, made through the alias t3, is witnessed at its exact byte span;
    • the two Shape::area impls get distinct names, and cg_app::run names the Square one;
    • the receipt conserves (16 = 16 + 0 on cg_lib);
    • the Kythe entries carry the macro call's ref/call anchor and its file text.
  • Disable runs, each turning exactly its own test red:
    1. bound dispatch counted as resolved;
    2. no file nodes;
    3. callee id dropped from the report;
    4. impl names by path only.
  • cargo clippy --all-targets -- -D warnings and cargo fmt --check are clean.
  • cargo metadata on the ruff workspace still resolves with the new exclude entry.
  • Outside the committed tests:
    • On lance-graph-mask-risc (441 MB of LLBC, 459 functions), calls is byte-identical to llbc_calls.py, in 5.6 s release. rows conserves 16,149 = 16,149 + 0: 459 DEFINES, 15,684 CALLS_RESOLVED, 2 MAY_DISPATCH, 4 UNRESOLVED_CALL.
    • Kythe v0.0.76 /xrefs over the kythe output returns 3/3 hand-read call pins; without the file nodes it returns 0/3.

Producing LLBC needs the fork's charon binary on its pinned nightly-2026-09-17, built with --no-default-features --features rustc: the default minirust feature needs a git submodule. That step is not in CI here.


Generated by Claude Code

Reads Charon's LLBC through charon-lib (AdaWorldAPI fork, library only,
stable) and reports what Charon witnessed:
- calls: byte-identical to lance-graph sag-ra-probe/tools/llbc_calls.py;
- rows: DEFINES / CALLS_RESOLVED / MAY_DISPATCH / UNRESOLVED_CALL (crai-rs
  vocabulary, grade COMPILER) with byte spans, residuals, and a receipt
  checking harvested == represented + residual;
- kythe: defines, ref/call and childof entries plus file nodes, in the
  shape kythe_entries.py writes.

A call through a generic bound or a trait object is never a confirmed
caller. Impl methods are named by Charon's formatter, so the two
Shape::area impls stay distinct across crates. Excluded from the ruff
workspace, like ruff_r2il.

Tests run on the codegraph fixture's LLBC with llbc_calls.py's output as
the reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X6y3drwKSE2zSgoexheLFX
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b1ca0146-708d-4729-9268-91288b53a910
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T05:54:34.664334Z ec0ac5d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec0ac5da24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ruff_charon/src/lib.rs Resolved
Comment thread crates/ruff_charon/src/lib.rs Resolved
@AdaWorldAPI
AdaWorldAPI merged commit 9913e90 into main Nov 2, 2026
34 of 37 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Nov 2, 2026
…129 review)

Two Codex findings on #129:

- A call through `TraitRefKind::TraitImpl` was a CALLS_RESOLVED row naming
  only the trait, so two impls of one trait gave one target, the row matched
  no DEFINES, and the Kythe ref/call edge pointed at the trait. It now names
  the function it resolves to: the impl's own method from
  `TraitImpl.methods`, else the trait's default method. An impl or method
  missing from the LLBC is a TRAIT_IMPL_METHOD_NOT_FOUND residual, never a
  row pointing at the trait.
- A local function without a structured body was harvested once but
  represented by its DEFINES row and also counted as a residual, so the
  receipt could not conserve and `rows` exited 3. The body is now harvested
  as its own item.

Tests: a_call_through_a_known_impl_names_the_resolved_function (real LLBC of
a one-file crate, calls rewritten into TraitImpl calls: impl method, trait
default, and a missing impl); an_opaque_body_keeps_the_receipt_conserved.
Charon emits no TraitImpl calls for any source tried here (fixture,
mask-risc, method/qualified/default-method calls), hence the rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X6y3drwKSE2zSgoexheLFX
AdaWorldAPI added a commit that referenced this pull request Nov 2, 2026
ruff_charon: fix prek and the four Codex findings from #129 and #130
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.

2 participants