Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7ac4aff
refactor(extractor-ruby): lift model writer
jgrodziski Nov 21, 2026
d0727d9
feat(core): python profile v2
jgrodziski Nov 21, 2026
538418b
feat(extractor-python): typeshed stdlib table
jgrodziski Nov 22, 2026
9f4ad57
feat(extractor-python): walking skeleton
jgrodziski Nov 22, 2026
c0bee8e
test(core): python fixture gate
jgrodziski Nov 22, 2026
c342265
ci: build and test the Python extractor
jgrodziski Nov 22, 2026
63e5ec0
feat(model-rs): declaredType, annotation arguments
jgrodziski Nov 22, 2026
0197f37
feat(extractor-python): stdlib bases and members
jgrodziski Nov 22, 2026
925483c
feat(extractor-python): Python 2 stdlib, builtins
jgrodziski Nov 22, 2026
438cdcf
feat(extractor-python): read what a body writes
jgrodziski Nov 22, 2026
bdf4788
feat(extractor-python): walk stubs and scripts
jgrodziski Nov 22, 2026
de191ad
feat(extractor-python): bind star imports
jgrodziski Nov 22, 2026
bb17982
fix(extractor-python): lambdas enclose like defs
jgrodziski Nov 22, 2026
8b4d72e
feat(extractor-python): comments and measures
jgrodziski Nov 22, 2026
e64ca39
feat(extractor-python): variables and attributes
jgrodziski Nov 22, 2026
5b80683
feat(extractor-python): resolve every site
jgrodziski Nov 22, 2026
873b029
feat(extractor-python): annotations and decorators
jgrodziski Nov 22, 2026
f2a6cde
feat(extractor-python): synthetic classes, dynamic imports
jgrodziski Nov 22, 2026
9b1aa20
docs(core): python import order, stack, recovery
jgrodziski Nov 22, 2026
1c69737
test(fixtures): grow the python corpus to M22b
jgrodziski Nov 22, 2026
89a6c5b
fix(core): read the python notes as optional
jgrodziski Nov 22, 2026
bbe9057
fix(extractor-python): no value where recovery left no text
jgrodziski Nov 22, 2026
c73a81e
perf(extractor-python): find a repeated edge by index
jgrodziski Nov 22, 2026
79a3e14
perf(extractor-python): keep only what is read
jgrodziski Nov 22, 2026
2fd0e87
perf(model-rs): share key and anchor text
jgrodziski Nov 22, 2026
b9d6f4d
perf(model-rs): box what most entities lack
jgrodziski Nov 22, 2026
487e145
feat(extractor-python): a base read through an alias
jgrodziski Nov 22, 2026
ee9a227
feat(extractor-python): slots are attributes
jgrodziski Nov 22, 2026
5572541
feat(extractor-python): a module import_module returns
jgrodziski Nov 22, 2026
38ca5c8
fix(extractor-python): a slot name is an identifier
jgrodziski Nov 22, 2026
36907a2
fix(extractor-python): an overload is its implementation
jgrodziski Nov 22, 2026
dd0ccea
fix(extractor-python): type parameters scope
jgrodziski Nov 22, 2026
4516af3
test(fixtures): close the M22b list of PLAN §23.6
jgrodziski Nov 22, 2026
9ca91e5
feat(metrics): python grammar
jgrodziski Nov 22, 2026
a883179
test: python fixture in every suite
jgrodziski Nov 22, 2026
c180ac6
fix(core): conftest is a technical word
jgrodziski Nov 22, 2026
4c5ed3e
fix(metrics): a python block's trailing comments
jgrodziski Nov 22, 2026
a0b561f
docs(metrics): a docstring's blank lines
jgrodziski Nov 22, 2026
48f6c42
feat(extractor-python): annotate from the typed
jgrodziski Nov 22, 2026
6ccc773
feat(extractor-python): --trace
jgrodziski Nov 22, 2026
c5b0ad8
fix(extractor-python): a literal import names one
jgrodziski Nov 22, 2026
97ef17d
fix(extractor-python): no foreign root shadows
jgrodziski Nov 22, 2026
7254aa2
fix(extractor-python): a module name may start 0
jgrodziski Nov 22, 2026
1922c8e
fix(extractor-python): a method holds __class__
jgrodziski Nov 22, 2026
702a20d
fix(extractor-python): a grown __all__ is no list
jgrodziski Nov 22, 2026
262fc03
fix(extractor-python): Literal holds values
jgrodziski Nov 22, 2026
c46aabb
docs(core): state redefinition-of-another-kind
jgrodziski Nov 22, 2026
e376253
fix(extractor-python): no class for a result
jgrodziski Nov 22, 2026
4c4bbc9
docs(core): an alias in an annotation
jgrodziski Nov 22, 2026
568eea1
docs(core): the Python audit and oracles
jgrodziski Nov 22, 2026
2ae054e
fix(extractor-python): help says what it walks
jgrodziski Nov 22, 2026
bfa1502
feat(extractor-python): --licenses
jgrodziski Nov 22, 2026
cd97a47
ci: python-native on four runners
jgrodziski Nov 22, 2026
78357fc
feat(homebrew): a formula for codegraph-python
jgrodziski Nov 22, 2026
34d8414
feat(desktop): the catalogue lists codegraph-python
jgrodziski Nov 22, 2026
4d13a10
docs: running the Python extractor
jgrodziski Nov 22, 2026
fdf2289
docs(distribution): codegraph-python
jgrodziski Nov 22, 2026
498267d
docs(metrics): Python rows, the summary as printed
jgrodziski Nov 22, 2026
066889e
docs(metrics): trailing in the how-to's table
jgrodziski Nov 22, 2026
02fc0c4
docs(website): the Python extractor reference
jgrodziski Nov 22, 2026
64ad6fe
docs(website): Python among the languages
jgrodziski Nov 22, 2026
059cccc
docs(readme): the Python extractor
jgrodziski Nov 22, 2026
d51ce2f
docs(model-rs): the Python extractor uses it
jgrodziski Nov 22, 2026
ab38d57
docs(claude): the Python extractor, model-rs
jgrodziski Nov 22, 2026
5f552a6
feat(extractor-python): one key per dotted site class
jgrodziski Nov 22, 2026
9607d01
feat(extractor-python): a stdlib class, one key
jgrodziski Nov 22, 2026
4238a61
feat(extractor-python): reference a written class
jgrodziski Nov 22, 2026
5e82f9f
docs(python): the audit after one key per class
jgrodziski Nov 22, 2026
b267d64
feat(extractor-python): a written class, any member
jgrodziski Nov 23, 2026
02f65dc
docs(python): the written-class rule, re-measured
jgrodziski Nov 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
# model; DeterminismTest pins it), so this is about the committed bytes only.
* text=auto eol=lf

# The Python fixture's byte hazards (PLAN.md §23.8): a Latin-1 file with its
# cookie, a UTF-8 BOM, a Mac's lone carriage returns. Their bytes ARE the test.
fixtures/python/src/src/acme_order/legacy/latin.py -text
fixtures/python/src/src/acme_order/legacy/bom.py -text
fixtures/python/src/src/acme_order/legacy/mac.py -text

# Never normalized, never diffed as text by accident.
*.jsonl -text
*.png binary
Expand Down
104 changes: 89 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
# typescript-smoke the bundled TypeScript extractor on a runner of each OS must
# reproduce its fixture snapshot byte for byte (PLAN.md §14.7):
# Windows paths, CRLF checkouts, case-insensitive walks
# ruby-test the Prism extractor's own suite (PLAN.md §19), then its release
# binary re-extracting the fixture snapshot byte for byte
# ruby-test the Prism extractor's own suite (PLAN.md §19) and the shared
# writer's (extractors/model-rs), then its release binary
# re-extracting the fixture snapshot byte for byte
# ruby-native its binary built on each of the four Unix runners, each one
# reproducing that snapshot; the tap's formula ships these
# python-test the Ruff-parser extractor's own suite (PLAN.md §23), its
# stdlib-table generator's and the shared writer's, then its
# release binary re-extracting the fixture snapshot byte for byte
# python-native its binary built on each of the four Unix runners, each one
# reproducing that snapshot; the tap's formula ships these
# metrics the metrics pass's own suite (PLAN.md §18): join, snapshots, history
# metrics-native its binary built on each of the four Unix runners, re-measuring
# the five fixtures byte for byte; the tap's formula ships these
# the six fixtures byte for byte; the tap's formula ships these
# release on a v* tag, every binary attached to a GitHub Release,
# and the TypeScript extractor published to npm when NPM_TOKEN is set
#
Expand Down Expand Up @@ -161,7 +167,7 @@ jobs:
if-no-files-found: error
retention-days: 14

# The metrics pass (PLAN.md §18): the join's unit tests, the five enriched
# The metrics pass (PLAN.md §18): the join's unit tests, the six enriched
# fixtures byte for byte, and the history side-car over a repository the test
# builds itself — so a shallow checkout is all it needs.
metrics:
Expand All @@ -181,7 +187,7 @@ jobs:

# One binary per RID, each built on a runner of its own OS: the tree-sitter
# grammars are C, compiled by the host's compiler, and a native build needs
# no cross toolchain. Each binary then re-measures the five fixture models and
# no cross toolchain. Each binary then re-measures the six fixture models and
# must reproduce the committed `model.metrics.jsonl` byte for byte — the
# cross-OS proof of the four-decimal number spelling (PLAN.md §18, principle 4).
metrics-native:
Expand All @@ -205,23 +211,24 @@ jobs:
run: |
bin=extractors/metrics/target/release/codegraph-metrics
"$bin" --version
for lang in java csharp typescript elixir ruby; do
for lang in java csharp typescript elixir ruby python; do
"$bin" "fixtures/$lang/expected/model.jsonl" --src "fixtures/$lang/src" --out "out-$lang.jsonl"
cmp "out-$lang.jsonl" "fixtures/$lang/expected/model.metrics.jsonl"
done
echo "the binary reproduces the five enriched snapshots on ${{ matrix.os }}"
echo "the binary reproduces the six enriched snapshots on ${{ matrix.os }}"
- uses: actions/upload-artifact@v4
with:
name: codegraph-metrics-${{ matrix.rid }}
path: extractors/metrics/target/release/codegraph-metrics
if-no-files-found: error
retention-days: 14

# The Ruby extractor (PLAN.md §19): the walker, resolver and writer suites,
# the fixture snapshot byte for byte under CRLF and a reversed creation order,
# then the RELEASE binary re-extracting it. Building needs libclang — bindgen
# reads Prism's C headers — which the runner's clang provides; running needs
# nothing, least of all Ruby.
# The Ruby extractor (PLAN.md §19): the walker and resolver suites, the
# shared writer's (extractors/model-rs, a path dependency — the checkout
# holds it), the fixture snapshot byte for byte under CRLF and a reversed
# creation order, then the RELEASE binary re-extracting it. Building needs
# libclang — bindgen reads Prism's C headers — which the runner's clang
# provides; running needs nothing, least of all Ruby.
ruby-test:
name: ruby extractor
runs-on: ubuntu-latest
Expand All @@ -233,7 +240,8 @@ jobs:
path: |
~/.cargo/registry
extractors/ruby/target
key: ruby-test-${{ hashFiles('extractors/ruby/Cargo.lock') }}
extractors/model-rs/target
key: ruby-test-${{ hashFiles('extractors/ruby/Cargo.lock', 'extractors/model-rs/Cargo.lock') }}
# bindgen loads libclang at build time; a runner image without clang gets it here.
- run: command -v clang >/dev/null || (sudo apt-get update && sudo apt-get install -y libclang-dev)
- shell: bash
Expand Down Expand Up @@ -281,6 +289,72 @@ jobs:
if-no-files-found: error
retention-days: 14

# The Python extractor (PLAN.md §23): the walker, decoding, scope and
# resolver suites, the fixture snapshot byte for byte under CRLF and a
# reversed creation order, the stdlib table's generator, the shared writer
# (extractors/model-rs), then the RELEASE binary re-extracting the fixture.
# Ruff's parser is a git dependency at one tag, its commit in Cargo.lock and
# every build --locked; building needs a C compiler (psm, the parser's stack
# growth), which the runner has; running needs nothing, least of all Python.
python-test:
name: python extractor
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal && rustup default stable
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
extractors/python/target
extractors/python/tools/stdlib-table/target
extractors/model-rs/target
key: python-test-${{ hashFiles('extractors/python/Cargo.lock', 'extractors/python/tools/stdlib-table/Cargo.lock', 'extractors/model-rs/Cargo.lock') }}
- shell: bash
run: |
./build.sh --python --skip-install --no-auto-install
./test.sh --python --skip-install --no-auto-install

# One binary per RID, each built on a runner of its own OS — the Ruby job's
# matrix, without its libclang step: the parser is Rust, and only psm (its
# stack growth) compiles a little C, with the runner's own compiler. Each
# binary then re-extracts the fixture and must reproduce the committed
# snapshot byte for byte: the cross-OS proof of principle 3 (PLAN.md §23).
# No Windows build, as for Ruby and the metrics pass.
python-native:
name: python native ${{ matrix.rid }}
needs: python-test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, rid: linux-x64 }
- { os: ubuntu-24.04-arm, rid: linux-arm64 }
- { os: macos-latest, rid: osx-arm64 }
- { os: macos-15-intel, rid: osx-x64 }
steps:
- uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal && rustup default stable
- shell: bash
run: ./build.sh --python --skip-install --no-auto-install
- shell: bash
run: |
bin=extractors/python/target/release/codegraph-python
"$bin" --version
"$bin" --licenses > /dev/null # the embedded notice (no pipe: pipefail and SIGPIPE)
# The relative --src on purpose: the path as typed is the header's `root`.
"$bin" --src fixtures/python/src --out out.jsonl --progress plain
cmp out.jsonl fixtures/python/expected/model.jsonl
echo "the binary reproduces the snapshot on ${{ matrix.os }}"
- uses: actions/upload-artifact@v4
with:
name: codegraph-python-${{ matrix.rid }}
path: extractors/python/target/release/codegraph-python
if-no-files-found: error
retention-days: 14

csharp-test:
name: csharp extractor
runs-on: ubuntu-latest
Expand Down Expand Up @@ -649,7 +723,7 @@ jobs:
release:
name: github release
if: startsWith(github.ref, 'refs/tags/v')
needs: [verify, java, java-native, metrics-native, ruby-native, csharp-smoke, typescript-smoke, elixir-smoke, elixir-native, sea, desktop, desktop-bundle, npm-publish]
needs: [verify, java, java-native, metrics-native, ruby-native, python-native, csharp-smoke, typescript-smoke, elixir-smoke, elixir-native, sea, desktop, desktop-bundle, npm-publish]
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -666,7 +740,7 @@ jobs:
set -euo pipefail
mkdir -p release
# The metrics pass rides the same loop: `codegraph-metrics-<rid>`.
for extractor in csharp java metrics ruby; do
for extractor in csharp java metrics python ruby; do
for dir in artifacts/codegraph-$extractor-*; do
rid="${dir#artifacts/codegraph-$extractor-}"
for f in "$dir"/codegraph-$extractor*; do
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ extractors/metrics/target/
extractors/ruby/target/
extractors/ruby/tools/core-table/target/

# Python extractor (Cargo): build output, its own and the stdlib-table tool's.
# Both Cargo.lock files ARE committed.
extractors/python/target/
extractors/python/tools/stdlib-table/target/

# The model writer the Rust extractors share (Cargo): build output of its own
# tests. Its Cargo.lock IS committed, so `--locked` holds there too.
extractors/model-rs/target/

.DS_Store
.idea/
.vscode/
Expand Down
37 changes: 35 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,26 @@ extractors/ruby/ Cargo package `codegraph-ruby` (Prism, CRuby's own parser,
`trace/codegraph_trace.rb` (one Ruby file, run by the USER
inside a booting project) writes the trace `--trace` merges:
`generated` mixins, `dynamic-candidate` calls, never a key.
extractors/python/ Cargo package `codegraph-python` (Ruff's parser as a LIBRARY,
pinned to one tag + a lexical scope and import resolver + a
table of the standard library distilled from typeshed and
committed; nothing is run, no virtual environment or
site-packages read, Python 2 files recovered) → emits
model.jsonl. ONE binary: no Python to build it or to run it.
The module is the FILE, keyed by its path. Only
`declarations.rs` may name a `ruff_*` type (a boundary test).
`trace/codegraph_trace.py` (one Python file, run by the USER
around a program that still imports) writes the trace
`--trace` merges: `generated` bases, `dynamic-candidate`
calls, never a key.
extractors/model-rs/ Rust crate `codegraph-model`: the model.jsonl WRITER the Rust
extractors (ruby, python) share — canonical order, surrogates,
the file table, JSON byte for byte as core's encoder. It
holds no language and no vocabulary: kinds, traits and the id
scheme stay in each extractor. A change here changes every
Rust extractor's output: run each one's suite.
extractors/metrics/ Rust crate `codegraph-metrics` (big-code-analysis 2.2.0 as a
LIBRARY, five tree-sitter grammars). Not an extractor: a PASS
LIBRARY, six tree-sitter grammars). Not an extractor: a PASS
over any extractor's model.jsonl that joins bca's function and
class spaces to measured entities on their anchors and adds its
own `metrics` keys (METAMODEL §3.8), never the extractor's.
Expand Down Expand Up @@ -225,10 +243,25 @@ node scripts/homebrew/render.mjs --version X.Y.Z --sums SHA256SUMS [--npm-sha256
# binary must reproduce fixtures/ruby. CODEGRAPH_UPDATE_SNAPSHOTS=1 cargo test --manifest-path
# extractors/ruby/Cargo.toml rewrites the snapshot; the core table: extractors/ruby/README.md

./build.sh --python # cargo build --release → extractors/python/target/release/codegraph-python
./bin/codegraph-python --src <dir> --out model.jsonl # needs nothing installed — no Python
./bin/codegraph-python --src <dir> --out model.jsonl --explain-dropped # + stderr: dropped <reason>: <file>:<line> <what>
./bin/codegraph-python --src <dir> --import-root <dir>/lib --out model.jsonl # a root the layout does not betray (PYTHONPATH)
./bin/codegraph-python --src <dir> --trace <dir>/codegraph-trace.jsonl --out model.jsonl
# the trace, inside a project that still imports (it RUNS the project's code — the extractor never does):
# [CODEGRAPH_TRACE_CALLS=1] python <repo>/extractors/python/trace/codegraph_trace.py -m pytest
# docs/python-extractor.md: the import order, the provenance tiers, the dropped-site reasons, the audit, the oracles
# Rust ≥ 1.98 (the pinned Ruff tag's floor) and a C compiler to BUILD; `test.sh --python` = cargo test (the
# shared writer's, the extractor's, the stdlib-table generator's) + the release binary must reproduce
# fixtures/python. CODEGRAPH_UPDATE_SNAPSHOTS=1 cargo test --manifest-path extractors/python/Cargo.toml
# rewrites the snapshot; a change to extractors/model-rs also needs `test.sh --ruby`
./bin/codegraph-python --licenses # the embedded notice (every linked crate, typeshed's Apache-2.0/MIT);
# after a dependency change: node extractors/python/scripts/licenses.mjs > extractors/python/THIRD-PARTY-LICENSES.txt

./build.sh --metrics # cargo build --release → extractors/metrics/target/release/codegraph-metrics
./bin/codegraph-metrics model.jsonl [--src DIR] [--out FILE] [--audit] # after ANY extractor; in place by default
# Rust ≥ 1.94 to build, nothing to run; docs/metrics.md. `test.sh --metrics` = cargo test: the join's unit
# tests + the five fixtures/<lang>/expected/model.metrics.jsonl byte for byte (and a re-run is the identity);
# tests + the six fixtures/<lang>/expected/model.metrics.jsonl byte for byte (and a re-run is the identity);
# CODEGRAPH_UPDATE_SNAPSHOTS=1 cargo test --manifest-path extractors/metrics/Cargo.toml rewrites them
./bin/codegraph-metrics model.jsonl --history [--ref REV] # + model.history-metrics.jsonl: git history per
# file and per entity at the model's commit — a SIDE-CAR, never the model (PLAN §18.2); then
Expand Down
2 changes: 1 addition & 1 deletion METAMODEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Enum qualifying *how we know* an edge exists. Never mix facts and inferences.
| `declared` | written literally in the source | explicit `extends`, direct call |
| `derived` | computed by analysis | Go implicit interface satisfaction, TS structural conformance, Python protocols, Rust blanket impls, a Ruby receiver typed by its one assignment (`x = Foo.new; x.bar`) |
| `dynamic-candidate` | dispatch not statically resolvable; targets are guesses | multimethods, PHP `__call`, duck typing, `dyn Trait`, a Ruby call on an untyped receiver bound to what a trace saw it reach (`candidates`: every target observed) |
| `generated` | produced by macro/annotation expansion | Rust `#[derive]`, Lombok, Python decorators, Clojure macros, Ruby `Struct.new` / `Data.define` (the class they produce inherits `Struct` / `Data`; no `class` writes it), a Ruby mixin the VM holds and no line writes (from a trace) |
| `generated` | produced by macro/annotation expansion | Rust `#[derive]`, Lombok, Clojure macros, a Python class whose base is a `namedtuple(…)` call (it inherits `tuple`; no `class` writes it), Ruby `Struct.new` / `Data.define` (the class they produce inherits `Struct` / `Data`; no `class` writes it), a Ruby mixin the VM holds and no line writes (from a trace) |

**Relations:** mandatory attribute of every Edge. Analyses wanting facts only
filter on `declared`.
Expand Down
Loading
Loading