Skip to content

feat: add the Python extractor (M22) - #51

Merged
jgrodziski merged 70 commits into
mainfrom
worktree-python-extractor
Nov 23, 2026
Merged

jgrodziski merged 70 commits into
mainfrom
worktree-python-extractor

Conversation

@jgrodziski

@jgrodziski jgrodziski commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What this does

Adds codegraph-python, the sixth extractor: Python source → model.jsonl, with no Python needed to build it or to run it.

./build.sh --python
./bin/codegraph-python --src <dir> --out model.jsonl                    # nothing installed, nothing run
./bin/codegraph-python --src <dir> --out model.jsonl --explain-dropped  # + stderr: dropped <reason>: <file>:<line> <what>
./bin/codegraph-python --src <dir> --trace codegraph-trace.jsonl --out model.jsonl
  • One Rust binary on Ruff's parser used as a library (pinned to tag 0.17.6, its commit in Cargo.lock), plus a lexical scope and import resolver and a table of the standard library distilled from typeshed at a pinned commit and committed. No virtual environment or site-packages is read. Python 2 files are read from the recovered tree.
  • The module is the file, keyed by its path. External names live under three reserved roots: <builtins>, <stdlib>, <site>.
  • Provenance is counted by tier. declared for what the scoping rules bind; derived for flow-typed and annotation-typed receivers and for attribution to a sole library ancestor; generated and dynamic-candidate only from --trace. An untyped receiver is dropped and counted, never guessed.
  • trace/codegraph_trace.py (one stdlib-only 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 (codegraph-model): the model.jsonl writer lifted out of the Ruby extractor so both Rust extractors share it. Ruby's snapshot is unchanged, byte for byte.

Plan: PLAN.md §23 (Phase 20, M22a–M22c). The plan text is not in this PR.

The stages

Stage What
M22a The shared writer crate; python profile v2 in core (decorator and lambda no longer kinds, annotationUse and throws added); the walking skeleton: classes, functions, methods, parameters, absolute and relative imports, bases, stub roots; bin/codegraph-python, build.sh --python, test.sh --python, python-test in CI.
M22b Attributes and variables, scopes, every receiver shape with its provenance, star imports, annotationUse, access, reference, throws, synthetic classes, declaredType, comments, sloc and cyclomatic; .pyi and shebang files; python in the metrics pass with a sixth model.metrics.jsonl; the fixture in every per-fixture suite (core, analyzer, city, navigator).
M22c --trace; the five-corpus audit and four oracles; --licenses; the python-native job on four Unix runners; the Homebrew row; the desktop catalogue row; docs/python-extractor.md, the website pages, README, CLAUDE.md.
After the audit One key per third-party class (keyed at the dotted module, a stated guess on class evidence only); one key per standard-library class (keyed where typeshed declares it); a declared reference to a corpus class written as a receiver (Message.objects), whether the member lands on a library ancestor, on a corpus ancestor, or is dropped. The reference is evidence about the class, not a resolution of the member: no rate and no drop counter moves.

Measured

Release binary, each model codegraph validate-clean:

Corpus Files Sites Resolved Entities (stubs) Edges Time Peak RSS
requests 37 5 768 81.6 % 2 529 (158) 3 593 0.06 s 20 MB
Django 2 922 278 073 73.4 % 111 593 (585) 229 360 2.9 s 433 MB
Zulip 2 125 228 523 81.9 % 54 725 (1 063) 174 640 2.0 s 307 MB
CPython 3.14.10 Lib/ 1 876 623 485 77.0 % 206 234 (663) 420 124 5.1 s 822 MB
CPython 2.7.18 Lib/ 1 613 303 632 78.7 % 141 281 (511) 217 345 2.8 s 478 MB

Oracles, each run in a container with no network:

  • CPython's ast (declarations): equal on requests, Django and Zulip; 83 413 of 83 415 on CPython 3.14, 43 112 of 43 117 on 2.7 (lib2to3).
  • grimp on Django (import graph): 3 209 edges in common, of 3 214 and 3 211.
  • pyright through scip-python, per provenance tier, on requests / Zulip: declared 98.6 % of 1 345 / 98.3 % of 112 881, annotation-typed 99.1 % / 98.9 %, flow-typed 100 % / 96.3 %, ancestor-attributed 100 % / 100 %. On Django the declared tier agrees at 98.8 % of 152 717.
  • requests' own test suite: 262 of the 282 imports it executes match the model's.

Verified locally

./build.sh --python, ./test.sh --python, ./test.sh --metrics, clippy with -D warnings, cargo fmt --check, typecheck, the workspace suite, the Homebrew render tests and cargo test -p codegraph-discovery. The five corpora were extracted twice, independently, with byte-identical results.

Not verified before this PR

  • The python-native job had never run. Its first run, on this PR, passed on linux-x64, linux-arm64, osx-arm64 and osx-x64. The release loop has still never run with a Python asset.
  • The Homebrew formula has not been rendered against real release assets. The next release must carry the four codegraph-python assets, or the render fails.
  • The docs say "from the release after v0.3.0" in 17 places (git grep -n 'release after'); the release commit must replace them.

Known limits (documented in docs/python-extractor.md §8)

  • A star-imported name read from another file is dropped unbound-name.
  • Imports under if TYPE_CHECKING: are counted but not marked on the edge, so a cycle they close is drawn.
  • A base written under an alias comes back from the trace under its real name and is added again as generated.
  • A receiver reference is anchored at its site's first line: 2 of 23 135 over the five corpora are one line early.
  • Memory grows with the corpus (822 MB peak on CPython 3.14's Lib/).
  • The dotted-module guess for a third-party class keys 66 classes across the five corpora; one is known to be wrong (a nested class taken for a module).

🤖 Generated with Claude Code

https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT

jgrodziski and others added 30 commits November 21, 2026 18:27
The language-neutral half of the Ruby extractor — natural keys and the
in-memory model, canonical order by UTF-16 code unit, the JSON encoder,
surrogates, sections and the header dictionaries — moves out of
extractors/ruby/src (model.rs, writer.rs, json.rs) into a standalone
path crate, extractors/model-rs (`codegraph-model`), so the Python
extractor (PLAN §23) writes the same bytes from the same code.

The crate holds no language: `Model` gains `lang`, the header writes it,
and `Key::render` takes it for messages and tests. The Ruby id scheme,
its `rb` tag (now `ids::LANG`), the header's prism/rbs fields and the
stats stay in extractors/ruby. The writer's and the model's unit tests
move with them, on neutral keys, plus one pinning that the header and
every error message name the model's own language.

A pure refactor: the release binary reproduces
fixtures/ruby/expected/model.jsonl byte for byte, and its stderr under
--explain-dropped is the pre-refactor binary's. test.sh --ruby runs the
new crate's tests before Ruby's; CI caches its target and hashes its
lockfile. The crate is 0.0.0 and printed nowhere, so the release bump
does not touch it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The Python profile predates M10, M12 and M13; the Ruff-parser
extractor (PLAN §23) is written against this one, so the data comes
first (invariant 8). The corrections of §23.2:

- no `decorator` kind: an application is an `annotationUse` edge
  with its written arguments, the TypeScript rule; no `lambda` kind:
  a lambda contributes to the invocable that writes it
- `variable` is a module-level binding; `TWithLocalVariables` leaves
  `function` and `method` (a local is flow), which now require
  `TWithChildren` (parameters and nested defs)
- `module` loses `TChildOf`: a package's `__init__` is no parent (a
  namespace package has none); its body may invoke and access
- `TMetrics` on module, class, function and method; `TWithValue` on
  variable, attribute and parameter; a `throws` edge for `raise`;
  `interfaceImplementation` kept for the analyzer's Protocol
  conformance, never written by the extractor
- lexicon: the module is the file, named by its path —
  `fileKinds: ["module"]`, `qualified: { module: "/" }`

The notes are rewritten to state what the plan decides: the module
keyed and named by its path, key escaping, the `<builtins>` /
`<stdlib>` / `<site>` stub roots, import roots, star imports bound
and attributed, `if TYPE_CHECKING:` imports emitted and counted, MRO
order not represented, the `declared` / `derived` tiers (the
annotation tier `derived`, counted `annotation-typed`), an untyped
receiver dropped and counted — never a `dynamic-candidate` from the
extractor — Python 2 read from the recovered tree, synthesized
members not extracted.

The generated profile reference is regenerated; the `codegraph
profiles` listings, the vocabulary lexicon table and the provenance
tables that cited "Python decorators" as `generated` follow.
schemas/ does not change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The Python extractor's ct.sym (PLAN §23.1): every module of typeshed's
stdlib/ and the names each binds at its top level, so `<stdlib>` versus
`<site>` and `from a import b` (a name or a submodule) are decided on a
machine with no Python. The table is data, committed and embedded; the
generator is a separate package the extractor never links.

tools/stdlib-table reads stdlib/**/*.pyi with Ruff's parser at the
extractor's own tag (0.17.6), so no second grammar is involved, and
fails on any syntax error (there are none). Per module: its VERSIONS
range, removed modules included; per name: class, function, value or
module, through `X = Y` aliases, re-exports in the stub convention
(`import x as x`, `from m import n as n`), star imports and `__all__`,
every `if sys.version_info` / `sys.platform` branch united. Not names:
`@type_check_only` declarations, private TypeVars and TypeAliases, and
plain imports — except as what an alias reads (`os.path = _path`).
`_typeshed` (the stubs' helpers) and `typing_extensions` (a PyPI
distribution) are not the standard library and are left out.

Pinned commit 2e4d4dcf657f, the one Ruff 0.17.6 vendors (its copy is
patched by ty, so the input is a clean typeshed checkout at that sha):
746 modules, 15 330 names, 557 KB. The header line names the commit;
regenerating with the generator reproduces the file byte for byte.

  codegraph-python-stdlib-table <typeshed>/stdlib <commit> \
    > extractors/python/data/typeshed-stdlib-<commit>.tsv

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
extractors/python, the sixth extractor (PLAN §23, M22a): Ruff's parser
as a library — a git dependency, the three crates at ONE tag (0.17.6),
the commit in Cargo.lock, every build --locked; `RUFF_TAG` restated in
lib.rs and pinned to Cargo.toml by a test — over the typeshed table, no
Python anywhere. The parser's API is internal: declarations.rs is the
only file that names it (a boundary test), and turns each tree into the
extractor's own records — scopes and their bindings, classes and their
bases, defs and their parameters, imports wherever written — which M22b
extends with sites.

- corpus.rs: *.py / *.pyw in ordinal order; a directory holding
  pyvenv.cfg, site-packages, __pycache__, node_modules and dot-dirs not
  walked. Bytes decoded as Python decodes them: a BOM, the PEP 263
  cookie of line 1 or (after a comment) line 2, names normalized as
  `codecs` does; UTF-8, Latin-1, cp1252 and ASCII exactly, anything else
  lossily and counted. Lines end at \n, \r\n AND a lone \r. Package
  roots: climb while __init__.py.
- resolve.rs: relative imports by path arithmetic; absolute ones in the
  roots, the nearest winning and a tie dropped (`ambiguous-root`), then
  a missing file below a corpus package, then the table, then Python
  2's implicit relative import, then `<site>` as written. `from a import
  b` names a's file when a binds b, else the submodule — never by the
  binding the statement itself makes. Names followed through re-export
  chains, cycle-guarded; a name bound twice keeps the first binding that
  names a declaration (`rebound-name`).
- scopes.rs: the scope a class header reads — itself, enclosing
  functions (never a class body), the module, then builtins; `global`
  and `nonlocal` heard; parameters bind in their function.
- extraction.rs: module (the file), class, function, method, parameter
  at every nesting, keyed per §23.3 (`Order.total#setter`,
  `make.Local`, `#param:x`); a def written twice is one entity anchored
  at the first; `import` and `inheritance` edges, all `declared`; stubs
  `<builtins>/X`, `<stdlib>%2Fm/X`, `<site>%2Fm/X` and missing files,
  made only because an edge points at them.
- stats.rs, cli.rs: the drops ARE the list the counts come from
  (`--explain-dropped` lists exactly what the summary counts); the
  schemas/README §8 contract plus `--import-root`; `--trace` answers
  exit 3 until M22c. The passes run on a 64 MiB thread: a 100 000-term
  expression overflows a default one when its tree is dropped.

fixtures/python/src is the acme_order corpus (src/ layout, 36 files,
README listing what each pins); expected/model.jsonl: 185 entities,
66 edges. Three files whose bytes are the hazard are -text.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The M22a acceptance gate, the other half of principle 2 (PLAN §23):
fixtures/python/expected/model.jsonl parses as core's Model, is byte-
identical to what core's own encoder writes — two independent
encoders, one in Rust — validates against the Python profile with ZERO
issues, is closed, has no self-edge, and writes only `declared` import
and inheritance edges.

What only the profile's side can state is pinned by id: the module is
the file (keyed and named by its path, parent of none, `#` escaped);
classes, functions, methods and accessors keyed by nesting
(`make.Local.describe.label`, `Order.total#setter`); every parameter
shape in order; a def written twice and an NFKC twin one entity each;
Python 2, a broken file, Latin-1, a BOM and lone \r read; the stub
discipline — `<builtins>`, `<stdlib>` and `<site>` stubs parented and
anchorless, no reserved `<stdlib>` / `<site>` entity, a corpus module
shadowing the standard library, a missing relative module; imports
module to module as Python finds them; a re-export chain followed to
the class, and the bases no line can resolve left without an edge.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The Python extractor joins the two entry points and CI, the Ruby shape
without libclang (PLAN §23.1, §23.9):

- bin/codegraph-python runs extractors/python/target/release beside
  itself; the binary needs nothing installed.
- build.sh --python: cargo build --release --locked, after checking the
  crate's rust-version (the Ruff tag's floor) and a C compiler (psm,
  the parser's stack growth) — scripts/lib.sh's new ensure_c_compiler.
- test.sh --python: the extractor's suite (the snapshot byte for byte
  under CRLF and a reversed creation order, the CLI contract), the
  stdlib-table generator's, then the release binary must reproduce
  fixtures/python/expected/model.jsonl (cmp). The shared writer's tests
  now run once for whichever Rust extractor is in scope, not inside
  Ruby's section; ./test.sh --ruby is unchanged in what it runs.
- ci.yml: a python-test job — stable Rust, the cargo git checkouts and
  both targets cached on the two lockfiles and model-rs's, then the two
  scripts. Binaries per runner, the registry entry and the formula are
  M22c's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
What the Python extractor's model needs and the shared writer could not
yet write, each in core's key order (packages/core/src/jsonl.ts):

- Entity `declared_type`, the TTypedEntity key `declaredType`, written
  between `signature` and `isStub` as a surrogate, closed like every
  reference.
- Edge `arguments`, an annotationUse's written arguments as
  `[{name, value}]`, between `candidates` and `isRead`; an empty list is
  not written, as core omits it (the edge kind vouches for the key).
- `NamedArgument` and `Literal::Enum { ty, name }` — core's
  `{k:"enum", type, name}`, the member of an enumeration by its type's
  key; Literal now hashes, since edges carrying one are deduplicated.

The Ruby and Python extractors set the new edge field to None. Ruby's
snapshot is unchanged byte for byte: its contract suite and the rebuilt
release binary both reproduce fixtures/ruby/expected/model.jsonl.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
What M22b's lookups need from the standard library: the MRO and the
members of a class nothing in the corpus declares (PLAN §23.4), and
what a star import of a standard module binds.

The generator now records, from the same typeshed commit:

- where a class is declared — `name unittest TestCase class
  unittest.case.TestCase` — so a re-export and its original are one
  class; a class declared in its own module needs no target;
- each top-level class's bases, in order, resolved in its stub
  (`base collections.OrderedDict 0 builtins.dict`; a subscripted base
  is its subscripted name, `Generic[T]` names no class);
- what each class body binds, in every branch — method, property (a
  `@property` with its accessors, `cached_property`), attribute, or a
  nested class (`member unittest.case.TestCase assertEqual method`);
- `__all__` where a stub writes one (`all string Formatter …`).

The table grows to 36 396 lines (746 modules, 15 328 names, 2 716
bases, 17 332 members, 273 `__all__` lists), 1.6 MB; lines are now
sorted as a whole. stdlib_table.rs reads them: `class`, `bases`,
`member`, `exports` (`__all__`, else the public names). The model is
unchanged: nothing reads them yet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
A Python 2 file named its standard library `<site>` (`import
ConfigParser`) and its builtins unbound (`class E(StandardError)`):
typeshed knows Python 3 only. Two data files close that (PLAN §23.1,
`data/stdlib-py2.txt`), each with its source URL and committed, so no
Python is needed:

- data/stdlib-py2.txt: the 432 modules of the Python 2.7 Library
  Reference's index (docs.python.org/2.7/py-modindex.html). A module
  Python 3 dropped (ConfigParser, urllib2, cPickle) is now `<stdlib>`
  as written; keys do not move.
- data/builtins-py2.txt: the 17 builtins of Python 2.7 that Python 3's
  lack (functions.html, exceptions.html), each class with its base:
  `StandardError(Exception)`, `unicode(basestring)`, `long`, `file`,
  `xrange`… The docs file basestring, buffer, file, unicode and xrange
  as functions; each is a type in CPython 2.7, so a class here. Python
  3's names answer first; True / False / None are keywords there.

The fixture's `report.py` now inherits `<builtins>/StandardError` and
imports `<stdlib>%2FConfigParser`. The profile's stub-roots note says
so, the website's generated profiles page follows, and profiles.test.ts
pins both mentions. A resolver test that pinned StandardError unbound
is restated: Python 2's builtin, while a name neither binds stays
unbound.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
declarations.rs, still the only file naming the parser's types, now
walks every body with the parser's visitor and records what M22b
resolves (PLAN §23.4): no edge or entity changes yet.

- Scopes: a lambda's and a comprehension's, whose code their nearest
  module / class / function owns; a walrus binds outside the
  comprehension; a `def`'s parameters, PEP 695 type parameters.
- Bindings: an assignment now binds `Assigned(i)` — its record keeps
  the target (a name, or `receiver.name` as in `self.x = …`), the
  value as written, the call that built it, the annotation.
- Sites: every name read, attribute and call as a chain from its head
  (`self.repo.find()`, `make().total`, `"x".upper()`, `super().save()`),
  the outermost call's arguments, attribute and `global` writes,
  `raise` (with the `except … as` types a raised name has) and each
  `except` type.
- Values: literals, dotted names, arrays, dict displays; constant-shaped
  expressions unevaluated, code not a value (the TypeScript rule).
- Decorators with their arguments (keyword, spread), how a method is
  bound (static, class), `@property`, `@overload`; bases now keep a
  call's callee and arguments; `metaclass=`.
- Annotations as type expressions, string ones parsed in place.
- Docstrings (cleaned as `inspect.cleandoc`), `#` blocks keyed by their
  last line with the shebang, the cookie and tool directives left out,
  code lines, and each `def`'s 1 + decision points.

The walk grows its stack as the parser does: `stacker`, the parser's
own dependency at the version the lock already holds, becomes a direct
one (=0.1.25) — the 100 000-term contract test overflowed the 64 MiB
worker without it. Records are pinned by unit tables in
src/declarations/tests.rs, moved out of declarations.rs; three M22a
tests are restated (a call base keeps its callee, an assignment binds
`Assigned`).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The walk now takes what the profile's walk note always listed
(PLAN §23.6): `*.pyi`, and an extensionless file whose first line is a
`python` shebang — `bin/acme-report` is a module, `bin/setup` (`#!/bin/sh`)
is not.

A stub is a module of its own, keyed by its path. Beside its source no
import names it: the program imports the `.py`, so the lookup tries a
package's `__init__.py`, then `.py`, `.pyw`, and a `.pyi` last. Alone,
it answers the import — a compiled extension's (`from ._speedups import
checksum` → `_speedups.pyi`); an `__init__.pyi` alone makes a package.
The walk note says so.

The fixture gains `pricing/discounts.pyi` beside `discounts.py`,
`_speedups.pyi` alone, and the two scripts; the core gate pins each.
The M22a walk tests that kept `.pyi` out are restated.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
`from m import *` now binds what the profile's re-export note says it
does: `__all__` where `m` assigns it a literal list of strings, else
every public name its module scope binds (star imports it makes
included, cycle-guarded) — for a corpus module and for a table module.

A name no binding and no known star answers is, unless it is a
builtin, attributed to the ONE star-imported module nothing answers
(`<site>`, a missing module, a Python 2 module the table only names):
`derived`, counted `star-attributed`. With two such modules it is
dropped `ambiguous-star`, the drop naming both. A builtin stays the
builtin — an unknown module is not presumed to shadow it; the note
says so.

`pkg.Name` reads a star binding of `pkg` too, and `from pkg import Name`
is satisfied by one before a submodule is tried.

The resolver also stops folding assignments and parameters into
`Opaque`: `Value::Assigned` and `Value::Parameter` (a parameter binding
now names its function) are what the receiver will type.

Fixture: `shapes.py` + `packing.py` (a base through `__all__`, a base
attributed to `pallets.lib`), `two_stars.py` (the refusal), and
`pricing/__init__.py` reading `discounts.Discount` through its own
`from . import discounts`. The core gate's "declared only" assertion is
restated as the durable property: no `dynamic-candidate`, no
`interfaceImplementation`, every edge kind the profile's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
A name read in a lambda or a comprehension now finds the scopes that
enclose it as the compiler does: its own, then every enclosing function,
lambda or comprehension (never a class body), then the module. Before,
only a `def` enclosed, so a comprehension inside a lambda could not see
the lambda's parameter. A walrus inside a comprehension binds in the
scope that contains it (PEP 572) — a lambda's, when it is in one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
Modules, classes and invocables now carry what the comments-and-measures
note promised (METAMODEL §3.8):

- TComment: the docstring, else the `#` block directly above the
  declaration (above its decorators), directives left out; a module,
  its docstring.
- TMetrics: `sloc` over the entity's span — from the line of its name,
  so decorators are outside, as they are outside the anchor — and
  `cyclomatic` on invocables.

The note now lists the decision points the reader counts, and says a
lambda's branches are its writer's: a lambda is no entity (the Ruby
block rule), where METAMODEL's lambda rule assumes it is one.

The core gate pins the property — every corpus module, class and
invocable measured, `cyclomatic` on invocables only, nothing on a stub —
and the fixture gains a `#` block over a `# noqa`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The class model and the bindings other code reads:

- `classes.rs`: each corpus class's MRO by C3 over corpus classes,
  the table's (members known) and library classes no table describes
  (members unknown), `object` last; an inconsistent order keeps the
  bases' orders as written, a base cycle is cut. A class decides its
  members at run time when one of its order writes `__getattr__` /
  `__getattribute__`, has a `metaclass=`, or a base nothing resolves to
  a class. `find` gives the tier the notes prescribe: the first corpus
  member, else the library classes that could answer (a table class
  that declares the name ends the list), the language, dynamic, none.
- `variable`: every module-level binding but a def, a class or an
  import, and every `global` write from a function, at its first.
- `attribute`: a class body's binding or `self.x =` / `cls.x =` in a
  method, ONE per name, owned by the root-most corpus class of the
  order that has it. Where a def, a nested class or (for a module) an
  import holds the name, the binding is counted
  `rebinding-of-a-declaration` with its line.
- `value` (TWithValue) on both and on parameter defaults: literals,
  a class as a type literal, an enum member as an enum literal, a
  constant's or a dict's source text; a parameter, a local or a call
  is no value.

The ownership note names the counter, the import rule and the value
rules; the core gate pins one of each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
Every name, attribute, call, write, `raise` and `except` a body holds
is now an edge, a count or a drop (`extraction/sites.rs`), from the
module, class or invocable that RUNS it — an initializer's calls are
its body's, never the binding's.

A chain is ONE site, its outcome its last step; an attribute or a
variable read on the way is an `access`. The receiver table:

- declared: a name the scoping rules bind; a module's attribute; a
  class named at the site (`Order(…)` is its `__init__` where the MRO
  writes one); `self` / `cls` along written bases; `super()` along C3.
- derived: a local or an attribute assigned one class (`flow-typed`);
  an annotation, `Optional` / `| None` unwrapped (`annotation-typed`);
  the one library class of the MRO that could answer
  (`ancestor-attributed`) — a class the table describes answers only
  for what it declares; a star-imported name (`star-attributed`).
- dropped and counted: `untyped-receiver`, `ambiguous-ancestor`,
  `unbound-self-call`, `unbound-attribute` (any other receiver),
  `unbound-dynamic`, `raise-of-a-value`, `unbound-name`.

A property is an `access` of its getter, written of its setter; a
`def` anywhere in the MRO holds its name over a subclass's attribute.
A library's class or module takes every step below it; a `<site>`
name is a class only on evidence (a base, a raise, an except, an
annotation), gathered before any site. `len`, `print`, a literal's
methods and the module dunders are the language. A module or a class
that calls or reads carries TWithInvocations / TWithAccesses.

Also: an argument or a chain head that is a comprehension is read in
its own scope (the reader walked it in the caller's).

Notes 17-19 state the chain, property and `could answer` rules and
`unbound-attribute`; the core gate pins the from-the-body property.
Smoke: requests 77.2 % of 4 464 sites, CPython 2.7 Lib 77.7 % of
301 824, both exit 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
An annotation now sets `declaredType` where it names ONE class —
`Optional`, `ClassVar`, `Final`, `Annotated` and a union with `None`
unwrapped — on the parameter, the invocable (its return), the variable
or the attribute; and it is a `reference` to every class it names
(`Order` in `list[Order]` included), from the body that holds it. A
builtin, a `typing` form, a `TypeVar` name nothing.

A decorator is an `annotationUse` from the decorated class or
invocable to what it names, its written arguments named the
TypeScript way: a keyword keeps it; a positional argument takes the
parameter it lands on in a corpus function (or a corpus class's
`__init__`, `self` aside), else `arg<i>`; code is its source text; a
spread is counted `spread-argument`, not written. `@property`, its
accessors, `@staticmethod`, `@classmethod`, `@overload` shape the
entity and are the language. Both are sites of the summary.

A local or a variable assigned a library name's call with no class
evidence (`app = Flask(__name__)`) is now its module's by flow, so
`app.run()` and `@app.route(…)` land on `<site>%2Fflask`, `derived`.

Notes 15 and 22 state the naming, the counter and the unwrapping; the
gate pins that a declared type is a class and a use leaves what it
decorates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
- A `namedtuple` / `NamedTuple` / `TypedDict` / `Enum` call bound to a
  module-level name, recognised by the form's name and a literal class
  name, is a `class` named by the binding (the reader makes it one, so
  the MRO, the members and the resolver see a class), its literal
  fields `attribute`s. It inherits what the interpreter gives it —
  `<builtins>/tuple`, `<builtins>/dict`, the `Enum` called — as a
  `generated` edge, once the resolver finds the callee is the standard
  library's; otherwise no base, counted `computed-base`.
  `class A(namedtuple(…))` inherits `tuple` the same way, its fields
  the class's; it is no longer a class whose members are unknown.
- `importlib.import_module("a.b")` and `__import__("a.b")` with a
  literal are `import` edges, counted like a statement's; a computed
  name is counted `computed-import`.
- The summary counts `dotted-site-class`: `<site>` stub classes named
  through an imported name (`models.Model`), the lead's ruling on
  decision 7.

The stub, import and provenance notes name each; the subscripted-base
note now says a type variable argument is an `access`, as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
Three profile notes now say what the extractor does where they said
less or otherwise:

- the order an absolute import is answered in (decision 3, accepted):
  the corpus roots nearest first, a file missing below a corpus
  package, the standard library's table, a sibling inside a package
  (Python 2's implicit relative import), then `<site>` — so a sibling
  `queue.py` in a package never shadows the standard `queue`;
- the file is never rejected however deep its nesting: the parser
  grows its stack, and the extraction runs on a 64 MiB worker thread
  whose recursive walks grow theirs;
- body recovery on Python 2 is measured, no longer owed: on CPython
  2.7.18's `Lib/`, in the 586 files the parser recovered from, the
  reader keeps as many calls as `lib2to3` counts (106 148 against
  106 072, 555 files exact), as in the 1 015 clean ones; a `print`
  statement is a read of the builtin `print` with its operands read
  as expressions; what recovery loses is local, an `unbound-name`.

The measurement is a scratch probe (the library's reader, per file)
against a `lib2to3` script; nothing committed runs Python.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The acme_order corpus now holds what a body says, one hazard per row
of its README:

- `services.py` (+ `repository.py`, `retry.py`, `settings.py`): the
  receiver table — every declared shape (`cls(…)`, `super()`, a class
  named at the site, a stub module's function), every derived one
  (an annotation, an attribute and a local assigned one class), and
  every drop (`untyped-receiver`, `unbound-self-call`,
  `unbound-attribute`, `raise-of-a-value`, `computed-import`,
  `spread-argument`); a corpus decorator with positional and keyword
  arguments; `raise error` under `except KeyError as error`.
- `money.py`: classes a call makes, with `generated` bases.
- `shipping.py` (appended, no anchor moves): `Tracked.objects`
  (`ancestor-attributed`), two library ancestors
  (`ambiguous-ancestor`), a `__getattr__` class (`unbound-dynamic`).
- `settings.py`: variables, a value, a comment, a `global` write.

The core gate pins the durable properties: the three tiers the
extractor writes (no `dynamic-candidate`), every edge kind of the
profile but `interfaceImplementation`, and one witness per receiver
shape; the contract test pins one `--explain-dropped` line per drop
reason. 47 files, 303 entities, 178 edges, 83.3 % of 162 sites.

The gate found one reader bug, fixed here: `global x` then `x += 1`
wrote an access that did not read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The measures assertion added with the comments-and-measures commit read
`pythonProfile.notes` as if it were always present; `notes` is optional
in `Profile`, so `pnpm -r typecheck` refused it. Read as the file's
other note assertions do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The smoke run on CPython 2.7.18's `Lib/` wrote 333 entities whose
value was an `unevaluated` literal with an empty source, which core
refuses (`codegraph validate`: not a model). A Python 2 octal or long
literal (`0660`, `0777L`) is invalid Python 3; the parser recovers with
an empty expression, and its source text was taken as the value.

An expression with an empty range is now no value, like code; no
literal is written with an empty source; a decorator argument that has
no text is not written. The fixture's Python 2 module gains
`MODE = 0660` (appended): a variable with no value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The extractor kept a copy of every edge it wrote in a set, to refuse
a repeat: one more model's worth of keys and anchors. It now keeps,
by the edge's hash, the indices of the written edges that share it
(almost always one), and compares the candidate with those.

No output byte changes: the requests and CPython 2.7.18 `Lib/` models
are `cmp`-identical to bbe9057's. Peak RSS on 2.7 `Lib/`: 756 -> 675 MB;
wall 3.43 -> 3.18 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The reader recorded, for every call site, every argument with its
value and the source text of each one that is code; for every
assignment, the source text of a value that is code and the arguments
of a call it makes. Nothing reads them: a site's call is read only
for the first positional string literal (`import_module("a.b")`), an
assignment's call only for its callee, and code text only where a
decorator's argument is written.

A site now keeps `literal`, an assignment `constructed: Option<Chain>`,
and code text is built for arguments alone. No output byte changes
(requests and 2.7 `Lib/` `cmp`-identical to bbe9057's); peak RSS on
2.7 `Lib/` 675 -> 625 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
A `Key` owned three strings and an `Anchor` one, so every entity and
edge held its own copy of its module's path and its file's, and every
map keyed by a key copied them again. They are now `Arc<str>`: a key
cloned from another, or made below it (`member`, `disambiguated`),
shares its module text; the empty symbol is one allocation.

The Python extractor hands out one key per stub module and stub type
(interned in `Stubs`, entities still in the same order) and one path
per file to its anchors. The Ruby extractor only converts where it
builds a key or an anchor; its snapshot is byte-identical
(`./test.sh --ruby`).

No output byte changes: requests and CPython 2.7.18 `Lib/` are
`cmp`-identical to bbe9057's. Peak RSS on 2.7 `Lib/`: 625 -> 488 MB;
wall 3.05 -> 2.65 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
An `Entity` was 480 bytes, 152 of them three fields most entities
never set: `declaredType`, `attachedTo` and `value`. They are now
boxed, so an entity without them holds three pointers; one is held
per declaration, so its size is the model's.

No output byte changes: requests and CPython 2.7.18 `Lib/` are
`cmp`-identical to bbe9057's, the Ruby snapshot too. Peak RSS on 2.7
`Lib/`: 488 -> 469 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The ruling on alias bases: a base that reads a module- or class-level
name bound EXACTLY ONCE to a class (`TestCase = unittest.TestCase`,
`Base = models.Model`, a chain of such aliases followed, cycle-guarded)
is an `inheritance` to that class, `derived` (the flow tier applied to
a base), counted `alias-base`. The class keeps its key, the alias stays
its `variable`. A name bound to a call or to anything but a class, or
bound more than once, stays `computed-base`.

The class model takes such a base into the MRO (the class is no longer
one whose members are unknown) and remembers which ancestors only an
alias brought in: what one of them answers — a method, `__init__`, a
property write — is `derived` too, counted `alias-base`. A decision of
mine: the alternative, keeping the base out of the MRO, would leave the
class dynamic.

On CPython 2.7.18 `Lib/`: 26 of the 281 bases "bound to a value" are
recovered; alias-base counts 516 (the 26 and 490 members through them);
unbound-dynamic 2 387 -> 1 840. The fixture gains `aliases.py`; the
note on bases says it, the gate pins it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The names a literal `__slots__` lists — a string, a list, tuple or set
of strings, a dict's string keys — are now attributes of the class,
each anchored at its string with no value, so `self._x` on one
resolves (the reader records them, the class model makes them
members). A computed `__slots__` names nothing.

On CPython 2.7.18 `Lib/` (after the alias bases): unbound-self-call
6 076 -> 5 755, unbound-attribute 955 -> 910. The fixture's
`repository.py` gains `Cursor`; the attribute note says it, the gate
pins it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
A name bound once to `importlib.import_module("a.b")` or
`__import__("a.b")` with a literal is now that module by flow: what is
read through it is `derived`, counted `flow-typed`. `__import__("a.b")`
is `a`, as the interpreter returns it. Bound to a computed name, it
types nothing — it was folded onto the `importlib` stub, which named a
call's callee as its result.

The reader keeps the first positional string literal of the call an
assignment makes; a module value carries the inference that made it.

On CPython 2.7.18 `Lib/`: flow-typed 11 881 -> 11 892, untyped-receiver
46 805 -> 46 822 (the computed ones); requests unchanged. The fixture's
`services.py` gains `shipping = importlib.import_module(…)`; the import
note says it, the gate pins it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The final gate's smoke run on CPython 2.7.18 `Lib/` wrote an attribute
with an empty name, which core refuses: `test_descr.py` writes
`__slots__ = [""]` to see the interpreter refuse it. A string that is
no identifier now names no slot, and no field of a synthetic class
(that filter let an empty string through too).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
jgrodziski and others added 23 commits November 22, 2026 04:25
An annotation's subscript arguments were all read as types, and a
string there as a forward reference (PEP 563): `Literal["add",
"remove"]` read the names `add` and `remove`, each dropped as unbound,
and `Literal["Op"]` would have referenced the class `Op`. `Literal[…]`
now holds values, and `Annotated[T, …]` one type and its metadata.

The `typing` forms were recognised in `typing_extensions` only as a
standard-library module, which the table deliberately is not (a PyPI
distribution): `typing_extensions.Literal` and its `NotRequired` /
`Required` wrappers went unrecognised. They are `typing`'s now.

Zulip: unbound names 398 -> 65; 25 TypedDict fields lose a
`declaredType` that named the `NotRequired`/`Required` stub (`int` is
what they wrap: none). Django, requests, CPython 3.14 and 2.7, the
fixture: unchanged. The annotation note says it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The Python extractor drops, and counts, a class that redefines a name
its scope first wrote as a `def` (or the converse), with what it
declares — the key is the first one's. The drop reason was tested but
the profile never said it; the CPython ast oracle found it: 1 in
CPython 3.14.10's `Lib/`, 2 in 2.7.18's (`binhex.openrsrc`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The pyright oracle (scip-python over requests) found derived edges the
profile says cannot exist:

- `parsed = urlparse(u)` typed `parsed` as the module `urllib.parse`,
  so `parsed.scheme` was a derived edge to the module. What a function
  (or a value) of the table returns is a call's result: untyped, as
  the note's ceiling says. A library name no table describes keeps
  its fold (it may be a class).
- `x: Any` typed `x` as the stub class `typing.Any` (typeshed declares
  `class Any`), and `x: Callable[…]`, `TypeAlias`, `Unpack`… likewise.
  An annotation types a receiver only with a class: `Any`, a `typing`
  form, a function or a value types nothing.
- `r: Annotated[Repo, …]` typed `r` as `typing.Annotated`. The
  wrappers `declaredType` unwraps (`Annotated`, `Final`, `ClassVar`,
  the `TypedDict` qualifiers) now type a receiver with what they wrap.

Derived edges removed, by target (each site now `untyped-receiver`):
requests 96 (stub modules 50, `typing.Any` 41, `Unpack` 4, `Final`
1); Django 436 (modules 434, `Callable` 2); Zulip 985 (modules 626,
`Any` 174, `Callable` 164, `Annotated` 15, `TypeAlias` 6), 3 added
through `Annotated`; CPython 3.14.10 1534 and 2.7.18 637 (modules).
The fixture is unchanged. The derived-tier notes say it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
An annotation that reads a variable — a `TypeVar`, a type alias
(`VerifyType: TypeAlias = …`) — writes no edge: the site lands as the
language. The pyright oracle reads it as a reference to the alias (37
of requests' 341 references with no edge and no drop on the line); the
profile now says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The profile states what M22c measured: the five corpora (requests,
Django, Zulip, CPython 3.14.10 and 2.7.18 `Lib/`) with files,
entities, edges, wall time, peak RSS and resolution, the largest
remainders, the CPython-3 import property, and the four oracles —
CPython's `ast` (lib2to3 for 2.7), grimp 3.20 on Django, pyright
through scip-python 0.6.8 on requests and Zulip per provenance tier,
and the imports requests' own tests execute — each difference named
by the rule it comes from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The help named *.py and *.pyw; the walk also takes *.pyi (a stub file,
which answers an import alone). It listed exit code 3 (a pass not
written yet), which no pass returns since the trace landed. The contract
test checks both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The binary prints the third-party notice it embeds, as
codegraph-metrics does: every crate the lockfile resolves (75), its
declared license and the license texts it ships, each text once — a
crate of a git checkout without its own, the checkout's, so Ruff's
parser crates carry Ruff's MIT LICENSE — then the data: the
standard-library table distilled from typeshed at the pinned commit,
with typeshed's LICENSE (Apache-2.0, parts MIT) reproduced in full
(data/typeshed-LICENSE, copied from that commit), and the two Python 2
name lists, credited to the 2.7 documentation (names only, no text).

scripts/licenses.mjs regenerates THIRD-PARTY-LICENSES.txt; the contract
test fails while a locked crate is missing from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The Python extractor's binary is built on each of the four Unix
runners Ruby's is (linux-x64/arm64, osx-arm64/x64), prints its version
and notice, and must re-extract fixtures/python byte for byte before it
is uploaded as codegraph-python-<rid>. The release job needs it and its
loop attaches codegraph-python-<rid> beside the other extractors. No
libclang step: the parser is Rust; psm compiles its bit of C with the
runner's compiler. Not run here: the workflow parses (js-yaml) and the
step's commands reproduce the snapshot locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The tap renders Formula/codegraph-python.rb from the release's sums:
one Rust binary per Unix platform (the python-native job's four RIDs),
depending on the metrics pass like every extractor and on no Python;
its test extracts a one-class hello.py. node --test covers the formula,
the metrics dependency and the rendered file lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The desktop app's extractor catalogue gains the Python row: it claims a
tree by the three extensions the extractor walks (.py, .pyw, .pyi — as
extractors/python/src/corpus.rs reads them), runs codegraph-python and
suggests `brew install defsquare/tap/codegraph-python` when the binary
is missing. The discovery crate's test pins the row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
docs/python-extractor.md, modelled on the Ruby guide: getting it (the
formula and the assets from the release after v0.3.0, the build from a
clone), what it reads and how it resolves without running anything,
the options, the summary with every counter and dropped-site reason,
the trace tool, the audit table, the four oracles with their stated
folds, the limits as measured today (the six open questions and the
honest remainders), and the byte-identity and --licenses. Every number
is the profile's or the M22c audit's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The install line, the python-native row of the release table, the
formula among the rendered ones, its --licenses notice beside the
metrics pass's, and the job + loop + row that land together — each
worded "from the release after v0.3.0": Python is built, not released.
The metrics row says six fixtures; the tap paragraph no longer counts
formulae or install lines it had stopped matching.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The join's summary line, quoted on the website and in docs/metrics.md,
is now what today's binary prints, from real runs: the `trailing`
count (Ruby and Java fixtures, BroadleafCommerce) and the `entities
rewritten` tail Broadleaf's quote lacked. The website gains the
`trailing` outcome, Python's row in what each language leaves
unmeasured, six grammars and six languages where it said five, and
the catalogue's Python rows for ABC, exits and npm/npa — read from
big-code-analysis 2.2.0's own Python implementations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The how-to's report table had no `trailing` row and its rule of thumb
left trailing joins out of "measured"; a Python class a call makes is
among the unjoined, and a Python docstring among the witness's known
exceptions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
reference/python-extractor.md, modelled on the Ruby page: install (the
formula and assets from the release after v0.3.0, the build from a
clone), the synopsis and every option with --import-root and
--licenses, how it resolves without running anything, the fixture's
summary with every dropped-site reason and derived tier, the trace
tool with requests' merge, the profile's kinds and keys, the measures,
the audit and its four oracles, the limits as measured today, the
reference corpus. The profile's notes stay on the generated profiles
page, which now lists Python among the languages with an extractor.
The page takes weight 14; the metrics pages and exit codes move down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
Every page that lists the languages or the extractors names Python:
the docs index (six languages, the platforms), Discover's prerequisites
and its structure step (now every extractor's page, not three), the
architecture (six extractors, the extractors/python and extractors/
model-rs rows), the decision log (a Python module row, the link), and
Install: the brew line, the asset row, Windows, the build line and its
toolchain (Rust 1.98+ and a C compiler; no Python), the references.
Release-dependent lines read "from the release after v0.3.0".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The install line and the no-runtime sentence (released from the
release after v0.3.0), the build line, a Python section beside Ruby's
(what it reads, --explain-dropped, the trace), the platforms, the
pipeline's parser list, the extractors/python and extractors/model-rs
rows, the docs link, and the status row — built, not released.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The shared writer's README named Ruby as its only user: test.sh
--python runs it too, and fixtures/python's snapshot holds it to
core's bytes as fixtures/ruby's does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The architecture block gains extractors/python and extractors/model-rs,
the commands block the Python extractor's build, run, trace, snapshot
and notice lines; the metrics pass reads six grammars and six fixture
snapshots.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
Decision (a). A <site> class reached through an imported name —
`from django.db import models` … `class S(models.Model)` — was keyed
as written, `<site>%2Fdjango.db/models.Model`, beside the
`<site>%2Fdjango.db.models/Model` that `from django.db.models import
Model` and `import django.db.models` give: two keys for one class. It
is now keyed at the dotted module, every segment before the last taken
for module path. Class evidence only (a base, a raise, an except, an
annotation, an MRO member): a library function or value still folds to
the module the import names, and the import edge still names the module
written; no tier moves, no corpus key moves.

It is a guess — `models` could be a class or a value of `django.db`,
not its submodule — so `dotted-site-class` now counts the classes keyed
on it, and the note says so. One place keys a library class
(`stub_class`): the MRO fold, the written fold and a base.

Fixture: `<site>/django.db/models.Model` becomes
`<site>/django.db.models/Model` (and its module); 2 edges retargeted;
entities 372 -> 373 (stubs 43 -> 44). Snapshots regenerated (metrics
too; vocabulary.json unchanged); the four TS assertions naming the old
key restated, the city's as the property it guards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
Decision (b). A standard-library class was keyed under the module the
import writes (D17), so `unittest.TestCase` and `unittest.case.TestCase`
were two keys for one class. It is now keyed where TYPESHED declares
it: the committed table already carries each re-export's source
(`name unittest TestCase class unittest.case.TestCase`), so the data
is followed, nothing special-cased — `<stdlib>%2Funittest.case/TestCase`,
`json.decoder`'s `JSONDecodeError`, `typing`'s `Mapping`, `_io`'s
`StringIO`. Every way a library class is keyed goes through one place
(a written base, a table class of an MRO, a type literal, a trace
base); the written-spelling map that served D17 is gone. The import
still names the module written; no tier moves; no corpus key moves; no
new typeshed pin — the generator is unchanged. A Python 2 module's names
(its list carries no re-export data) stay as written.

A contract property: every <stdlib> stub class of the fixture is keyed
where the table declares it (it fails on the previous snapshot). The
note says where the key comes from and that it may be a private module
and differ from the run-time __module__.

Fixture: unittest/TestCase -> unittest.case/TestCase (4 edges, and the
module), collections.abc/Mapping -> typing/Mapping (1 edge); entities
373 -> 374 (stubs 44 -> 45). Snapshots regenerated (vocabulary.json
unchanged); two TS assertions naming the old keys restated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
Decision (d). `UserProfile.objects.all()`: no corpus class declares
`objects`, the one library ancestor could answer, so the edge names the
library (`derived`, ancestor-attributed) — and no edge named the corpus
class, though the site writes it. It now also yields a `reference` to
the class, provenance `declared` (the class IS written there), anchored
at its name, from the same entity as the member edge. Only that case:
not `self`/`cls` (no class is written), not a member a corpus ancestor
declares (that member is already the edge), not a dropped member. No
tier moves; no key moves; an edge is added.

Fixture: one row, `Tracked.recent` -> `Tracked` at shipping.py:50
(edges 222 -> 223); a core gate assertion pins it, the receiver-tier
unit test gains `M.go`'s row, the note says the rule. Snapshots
regenerated (vocabulary.json unchanged); navigator and analyzer suites
read the fixture unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The five corpora re-extracted after (a), (b) and (d), every model
validate-clean before and after the metrics pass; every number that
moved is refreshed — the profile's audit note (its test pins the new
facts), docs/python-extractor.md (the fixture summary, the audit table,
the pyright table) and the website reference (summary, table, keys).

What moved: entities and stubs (Django 111 593 / 585, Zulip 54 725 /
1 063, CPython 3.14 206 234 / 663, 2.7 141 281 / 511), edges with the
receiver references (Zulip 173 638, 2.7 216 890, 3.14 418 812, Django
215 023); no standard-library class has two keys in any model; the
dotted guess keys 66 site classes, one with a Capitalized segment
(pika.spec's Basic.Deliver). pyright's "as the site imports it" fold
is down to site re-exports and typeshed skew (requests 86 -> 30,
Zulip 1 935 -> 1 399); its percentages hold. ast, grimp and the import
oracle read the new models unchanged.

The limits: (a), (b), (d) leave them and are stated as rules; the
star-import read, TYPE_CHECKING imports and the trace alias stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
codegraph 02f65dc Commit Preview URL

Branch Preview URL
Nov 23 2026, 08:09 AM

jgrodziski and others added 2 commits November 23, 2026 07:47
Rule (d) extended, as the user approved: a corpus class written as a
receiver is a `declared` `reference` to the class, at its name, from
the same entity, whatever its member does — a library ancestor answers
it (as before), a corpus ancestor declares it (`Sub.method`, the edge
naming `Base.method`), or nothing does and the site is DROPPED: the
reference is evidence about the class, not a resolution of the member,
so the drop and its reason stand, and the summary is unchanged. One
rule, one emission point; no reference for the class's own member (its
edge names the class), for the language (`Order.__name__`), or through
`self`/`cls`, which write no class. No tier, key, rate or stdlib table
moves.

The fixture gains `Express(Tracked)` and `audit()`: `Express.recent()`
(a corpus ancestor's) and `Ledger.flush()` (dropped
`ambiguous-ancestor`), two new references. Run with the previous rule
on that same tree, the summary is identical but for +2 edges. Snapshots
regenerated (vocabulary.json: the two new names); the metrics gate's
pinned join count 190 -> 192 (the two new entities), the note and its
pins, the fixture README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
The five corpora re-extracted after the written-class rule took every
member outcome: sites, rates, every drop counter and the metrics joins
are identical; only edges move — requests 3 593, Django 229 360, Zulip
174 640, CPython 3.14 420 124, 2.7 217 345 — all declared references
to a written corpus class (23 135 in all with the library-ancestor
case). The profile's audit note (a new pin), docs/python-extractor.md
and the website reference say the rule whole and carry the numbers;
wall times are the previous run's, the re-run having shared the host.

pyright, re-measured on the declared tier: requests 98.6 % (1 345),
Zulip 98.2 -> 98.3 % (112 881), and Django, indexed for this, 98.6 ->
98.8 % (152 717): of its 14 337 new references pyright names the same
class for 14 326, is silent for 7 and names 4 otherwise (classes in
nested functions, which scip-python names without the inner function).
A new limit, measured: a reference is anchored at its site's first
line, a line early for 2 of the 23 135 (a receiver after an opening
parenthesis).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
@jgrodziski
jgrodziski marked this pull request as ready for review November 23, 2026 08:09
@jgrodziski
jgrodziski merged commit ae97e4c into main Nov 23, 2026
57 checks passed
jgrodziski added a commit that referenced this pull request Nov 23, 2026
§23 gains "Ruled after the audit": the six questions the five corpora
raised and the memory figure, each with the answer it was preferred to.
Two of the rulings reverse a sentence of §23.3 (a class stub is no
longer keyed by the name as written at the site), so the table says
which holds.

The three M22 milestone rows carry their status (built on the worktree
`python-extractor`, PR #51; the release loop has not run with a Python
asset), and the decisions table gains the row for class stub keys.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2FzSpDnFBcv5iXAjT
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