Skip to content

ruff_charon: offline Codegraph store with per-crate incremental refresh (D-CODEGRAPH-0 slice B) - #130

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

Follows #129. ruff_charon::store::Store persists the Codegraph rows across sessions and refreshes them per crate when sources change.

What it stores, per crate:

  • the relation rows (DEFINES, CALLS_RESOLVED, MAY_DISPATCH, UNRESOLVED_CALL, with grade and byte span);
  • the residuals;
  • the FNV-1a digest of every source file the rows came from. Charon keeps each file's contents in the LLBC, so the digests come from what Charon actually read.

Artifact format. The artifacts follow ruff_r2il::sink's discipline: a #version N + #schema <names> header, columns appended never reordered, and readers that key on column names. Readers refuse a newer version or a missing column.

Why not RefinedTruthSink. That trait is typed to R2IL's FlatFact / ResidualLedger / HarvestReport. These rows are call relations (Kythe-side facts), not R2IL, so filing them through it would mix the two representations.

The unit of update is a crate, because Charon translates whole crates:

API Does
import Replaces all of a crate's artifacts (temp file + rename). Nothing of the old version survives, and an unconserved receipt is refused before anything is written.
stale(root) The crates with a recorded file that changed or vanished.
with_dependents Adds every crate that depends on a stale one, transitively, from (dependent, dependency) pairs such as cargo metadata gives.
dangling() Call rows whose callee is a function of a stored crate that no stored crate defines: edges left behind by an incomplete refresh.

A file added to a crate is detected through the file that declares it (mod x;), which changes with it.

CLI: ruff_charon import <dir> <file.llbc> <crate>, stale <dir> <root>, dangling <dir> (exit 1 if any).

Test Plan

The fixture is lance-graph crates/sag-ra-probe/fixtures/codegraph, rev1 → rev2. rev2 deletes triple and area_dyn from cg_lib and drops the area_dyn call from cg_app. Its LLBC is committed in tests/data.

  • tests/store.rs, 6 tests:
    • an incremental refresh equals a clean import, and rev1 differs from rev2, so the comparison is not vacuous;
    • deleted functions leave no rows;
    • refreshing cg_lib without its dependent leaves exactly cg_app::run → cg_lib::area_dyn, and with_dependents names cg_app;
    • stale is empty on unchanged sources, names only cg_lib after a one-byte edit, names both crates on the rev2 tree, and names the crate of a deleted file;
    • the recorded files are the crate's own;
    • readers refuse a newer version or a renamed column.
  • Disable runs, each turning its own test(s) red:
    1. refresh keeps the old rows: 3 tests;
    2. digests never compared: the staleness test;
    3. dangling reports nothing: the dangling test;
    4. dependents not added: the dangling test;
    5. version not checked: the reader test.
  • The full crate passes (3 unit + 6 intake + 6 store); cargo clippy --all-targets -- -D warnings and cargo fmt --check are clean.
  • The same scenario through the CLI: after the two-crate refresh, the store directory is byte-identical to a clean rev2 import (diff -r).

Not in this PR: residency in lance-graph's SoA. Per the sink's own seam, that is a lance-graph-side crate reading these artifacts.


Generated by Claude Code

…sh (D-CODEGRAPH-0 slice B)

store::Store keeps, per crate, the relation rows, the residuals and the
digests of the source files the rows came from, in ruff_r2il::sink's
artifact discipline (#version + #schema, readers key off column names).
RefinedTruthSink itself is not reused: it is typed to R2IL FlatFacts.

- import: replaces a crate's three artifacts (temp file + rename); refuses an
  unconserved receipt;
- stale: crates with a recorded file that changed or vanished;
- with_dependents: adds every crate that depends on a stale one;
- dangling: call rows whose callee no stored crate defines.

Tests on the codegraph fixture rev1 -> rev2 (rev2 deletes triple and
area_dyn): an incremental refresh equals a clean import; deleted functions
leave no rows; skipping the dependent crate leaves exactly the edge
cg_app::run -> cg_lib::area_dyn; stale names exactly the edited crates;
readers refuse a newer version or a renamed column.

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: dabb48b7-bc83-407f-a56f-087308d78aba
  • 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-02T06:07:46.117711Z 502a808 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: 502a80806a

ℹ️ 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/store.rs Resolved
Comment thread crates/ruff_charon/src/store.rs Resolved
@AdaWorldAPI
AdaWorldAPI merged commit 95be2e4 into main Nov 2, 2026
35 of 37 checks passed
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