Skip to content

D-CODEGRAPH-0 slice C: lance-graph-codegraph — callers, callees, impact and structural diagnostics - #1921

Merged
AdaWorldAPI merged 7 commits into
mainfrom
claude/clone-repositories-71a5sw
Nov 2, 2026
Merged

AdaWorldAPI merged 7 commits into
mainfrom
claude/clone-repositories-71a5sw

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

This adds a new workspace-excluded crate, crates/lance-graph-codegraph. It reads the ruff_charon store artifacts (rows v2, from ruff #132, merged ed8fd4194f) and answers code queries over one xlog cube. It reads the artifact files by #schema column name, the same way ruff_r2il::sink does, and does not depend on ruff_charon or Charon.

Graph. Every symbol becomes a position in natural row order: 15 on the rev1 fixture. One cube holds six relations:

  • CALLS: confirmed calls, caller to callee.
  • NODE: each position paired with itself.
  • MAY: possible dispatch, caller to trait method.
  • IMPL: impl method to the trait method it implements.
  • RCONF: CALLS reversed.
  • RPOSS: the possible reverse edges, built from dispatch and dynamic calls.

Position masks cover functions, public, impl, synthetic, referenced, called, dynamic callers and stored owner.

Queries. Each answers as a mask graded confirmed, possible or unknown. MAY_DISPATCH is never counted as confirmed. A dyn call or function-pointer call is unknown, never "unaffected".

  • callers and callees use cube support over bound joins, with site counts from bag_count.
  • references uses a row scan into a mask.
  • impact uses the cached RCONF⁺ and RPOSS⁺ closures.
  • cube().stats().rows_materialized == 0 after the whole suite, so no answer path builds tuples.

Diagnostics. They follow crai-rs's review semantics: grade COMPILER, POSSIBLE is a qualifier, and the run status can say NOT_RUN, so no finding set is reported as clean when the check never ran.

  • Dead function: a function that is not public, not an impl method, not synthetic, and is never called or referenced. For a binary crate the check is refused with NO_ENTRY_FACTS.
  • Unresolved call.
  • Dangling call: the callee belongs to a stored crate that no longer defines it. The finding status is stale.
  • Unused import: always NOT_RUN with reason NO_IMPORT_FACTS, because LLBC has no use items.

Deferred, surfaced as typed refusals. Closure is limited to 64 positions (ClosureWidth) and a tile to 256 symbols (TooMany), so every cube query on mask-risc (459 functions) is refused today and reported as UNKNOWN. Tiled closure and multi-tile cubes need their own D-id.

Test Plan

Fixture stores in tests/data: rev1, rev2, mixed (cg_lib rev2 with cg_app rev1) and fnref.

tests/oracle.rs, 20 tests. Every expected answer was hand-checked against the stores:

  • impact(double) on rev1: confirmed {Square::area, run}, possible {area_of}, unknown {area_dyn}.
  • impact(double) on rev2: 4 confirmed, including the two-hop checked.
  • callees(run) on rev2: 3 callees across 4 sites, so caller count and site count are tested separately.
  • Dead function: rev1 reports private_unused, which matches rustc's dead_code. fnref reports unused_private and stays silent on the pointer-only helper.
  • Dangling call: the mixed store reports exactly run → area_dyn. rustc reports E0425 at cg_app/src/lib.rs:7 on the same tree. rev1 and rev2 report nothing, even though they contain an external callee (core::panicking::assert_failed).

tests/guards.rs, 7 tests:

  • a 70-function chain is refused with ClosureWidth(70);
  • a 300-symbol store is refused with TooMany(300);
  • a version-1 file is refused;
  • a short line is an arity error;
  • permuted columns read identically;
  • a PARTIAL crate gives a PARTIAL run;
  • an uncalled private impl method is not dead.

Disable runs. Twelve, each turning its own test red:

  • the impact closure;
  • the IMPL edge in RPOSS;
  • the dynamic-call edge;
  • each of the four dead-function exclusions;
  • the stored-owner filter;
  • sites counted versus support;
  • the version check;
  • the ClosureWidth surfacing;
  • the PARTIAL status.

The impl-method exclusion first stayed green, because Charon marks every impl method of a public trait public. The synthetic store in guards.rs now covers it.

Release timing (examples/timing.rs), in ns per call: callers 5103, callees 3643, references 184, impact 387. Opening takes 166 µs and the first closure 5 µs; both are one-time costs, reported but not gated.

Checks:

  • cargo clippy --all-targets -- -D warnings and cargo fmt are clean.
  • entries_index.py --check, append_only_gate.py origin/main and the supersession index are all current.

Board:


Generated by Claude Code

…RAPH-0 slice C)

Reads the ruff_charon store artifacts by schema column name, interns symbols
in natural row order, and builds one xlog cube (CALLS, NODE, MAY, IMPL, RCONF,
RPOSS) plus position masks. Workspace-excluded, like sag-ra-probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X6y3drwKSE2zSgoexheLFX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X6y3drwKSE2zSgoexheLFX
…ved call, dangling call, unused import NOT_RUN)

Each finding follows crai-rs's review semantics: grade COMPILER, run status
COMPLETE / PARTIAL / NOT_RUN / REFUSED, so a diagnostic that did not run is
never reported as clean. Unused imports are NOT_RUN: LLBC has no use items.

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

Queries answer as confirmed / possible / unknown masks over the xlog cube:
support and bag_count over bound joins, and the RCONF / RPOSS closures for
impact. MAY_DISPATCH is never confirmed; a dyn or pointer call is UNKNOWN.
Oracles are hand-checked against the rev1 / rev2 / mixed / fnref stores;
guards cover ClosureWidth(70), TooMany(300), version, arity, permuted columns
and the PARTIAL run status.

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: 4aaaf0f2-7a5c-403b-86f1-f1a2dceae6e2
  • 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-02T07:01:19.859738Z 09484d1 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.

@AdaWorldAPI
AdaWorldAPI merged commit 4ab93bf into main Nov 2, 2026
11 checks passed

@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: 09484d1bc5

ℹ️ 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 on lines +93 to +96
let scan = cube.scan(rel)?;
let bound = cube.bind(table, scan, bound_col, u32::from(v))?;
let node = cube.scan(NODE)?;
let join = cube.join(bound, join_col, node, 0)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reuse query views instead of retaining new nodes on every call

When a Codegraph is reused for repeated caller/callee queries, every invocation of partners permanently adds four nodes to Cube::nodes: scan, bind, and join all append through Cube::push, and those nodes are never reclaimed. Even repeating the same query therefore grows memory without bound despite the graph remaining unchanged; dispatch queries amplify this through or_partners. Cache and reuse the views for each relation/position/direction, or provide a way to release temporary query nodes after the terminals finish.

Useful? React with 👍 / 👎.

_ => {}
}
}
let overall = if partial { Run::Partial } else { Run::Complete };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require extraction evidence before reporting a complete run

If the supplied directory contains no *.rows.tsv files, Codegraph::open succeeds, and this default reports Complete with empty findings for dead functions, unresolved calls, and dangling calls. I reproduced this against an empty temporary directory. The same problem occurs with a header-only artifact lacking a CRATE row: no extraction has been established, yet consumers receive a clean, completed verdict. Track whether completion evidence was present and return NotRun/Refused (or reject the intake) when it is absent.

Useful? React with 👍 / 👎.

AdaWorldAPI pushed a commit that referenced this pull request Nov 2, 2026
…fixture scale)

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
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