Skip to main content

Source code to structural graph facts — Python bindings

Project description

code2graph Python bindings

code2graph-rs exposes the Rust extractor and resolver as Python values. It returns neutral symbols, references, and edges; it performs no storage or policy work.

Identity wire format

Facts and graphs encode SymbolId losslessly. Global identities use an object with version: 1, scip, and lang; local identities use version: 1, scip, and file. The scip value stays compatible with SCIP tooling, but SCIP has no language or local-file coordinate, so applications must retain the whole object when persisting or forwarding facts. Deserialization also accepts the legacy plain SCIP string for compatibility, though it cannot preserve those identity coordinates. GraphIndex deliberately rejects that lossy form for identity lookup and traversal.

GraphIndex queries

GraphIndex accepts a resolved CodeGraph dictionary whose symbol and edge IDs are lossless structural-ID dictionaries. Python method names and serde payload fields use snake_case:

index = GraphIndex(graph)
index.symbol(symbol_id)  # a locally defined symbol or None
index.symbols_named("run")
index.ids_with_scip(symbol_id["scip"])  # plural: SCIP display strings can collide
index.incoming(symbol_id, 50, "Call", "Scoped", "ScopeGraph")
index.outgoing(symbol_id, 50)
index.impact(symbol_id, 3, 100, "Call", "Scoped", "ScopeGraph")

Global IDs are { "version": 1, "scip": ..., "lang": ... }; local IDs are { "version": 1, "scip": ..., "file": ... }. ids_with_scip is plural because globals with different lang coordinates and locals with different file coordinates can have identical SCIP display strings. Edges may also contain endpoint-only IDs: they are traversable, but symbol returns None for them.

incoming, outgoing, and impact accept optional role, min_confidence, and provenance filters. Valid role values are Call, IsImplementation, Import, ModuleRef, TypeRef, Read, and Write; confidence values are Heuristic, NameOnly, Scoped, and Exact; provenance values are SymbolTable, ScopeGraph, FfiBridge, Conformance, NormalizedName, and External. All provided filters are conjoined. Omitted filters allow every role/provenance and use Heuristic as the confidence floor. limit must be a positive u32; output order is deterministic. impact follows incoming edges, excludes the seed, terminates cycles, and returns { "steps": ..., "truncated": ... }. truncated is true only if a depth or node bound omitted a matching reachable ID; no visited field is returned.

After maturin develop, or after installing the wheel produced by maturin build, run python -m unittest bindings/python/tests/test_query.py from the repository root to exercise this surface.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code2graph_rs-0.0.0b17.tar.gz (579.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

code2graph_rs-0.0.0b17-cp39-abi3-win_amd64.whl (5.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

code2graph_rs-0.0.0b17-cp39-abi3-musllinux_1_2_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

code2graph_rs-0.0.0b17-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

code2graph_rs-0.0.0b17-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

code2graph_rs-0.0.0b17-cp39-abi3-macosx_11_0_arm64.whl (5.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

code2graph_rs-0.0.0b17-cp39-abi3-macosx_10_12_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file code2graph_rs-0.0.0b17.tar.gz.

File metadata

  • Download URL: code2graph_rs-0.0.0b17.tar.gz
  • Upload date:
  • Size: 579.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for code2graph_rs-0.0.0b17.tar.gz
Algorithm Hash digest
SHA256 06528e894e77b750ecbd56bb3942716b5c56e3aa49bc615f5a83f592664dfd09
MD5 7d8edc6f14991112aa6aac35cfcfe519
BLAKE2b-256 1479e63ddefe22ebd441b36d890335168cbc03e860e45d481e539fdc4cae4bc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b17.tar.gz:

Publisher: release.yml on NodeDB-Lab/code2graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file code2graph_rs-0.0.0b17-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b17-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dd88456ec532623e754bde164d21bab93ab03f1a322fbdf7b38ad637eac6b2ed
MD5 c45212c63b81bb8ebf4418a8f387292c
BLAKE2b-256 dc229f9b6e4624793b5068758fa8844ef27b8e88d7d821dccb1ac7efef8921f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b17-cp39-abi3-win_amd64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file code2graph_rs-0.0.0b17-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b17-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 52065826af439c5a05450f35363c5a8d4063bb097b0f061b17e178b66de8b08e
MD5 4a08a82113aaad091edabbe1317d45aa
BLAKE2b-256 f66b08589cde0882cc4de64600645590d7d4dbae3d63400e24d30253995bb422

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b17-cp39-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file code2graph_rs-0.0.0b17-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b17-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80fad0a746c08665fe9496edac6185e1244c36383d962a64cf107e79b51046b7
MD5 3534c25dfb3a073b1d583c072604c277
BLAKE2b-256 aa70c04cd57cf621d8cb5339d3e7ea196f49fe4b817beed55ee265e3a65caa79

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b17-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file code2graph_rs-0.0.0b17-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b17-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dc7b04b4590bef4385a7f63eddf3d8e7f34238f1444b65f14330704e5613f742
MD5 fab239fbec4957a6d301fe94fad5566d
BLAKE2b-256 c119896215841fb8ae182eee413f2a7f1c92b0298a71a59890d2d5547833a82f

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b17-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file code2graph_rs-0.0.0b17-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b17-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 43041018b489a6e39e230c0d1e9441de0b1a5b3f3f1cd964fc9cd04d2e89eb3e
MD5 13f4173a012263173de1d1f868c703fd
BLAKE2b-256 4e819550fc55ef3e5f6769c0b8a37d58f47fceff80d4d04e31df1287c1b6c4ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b17-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file code2graph_rs-0.0.0b17-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for code2graph_rs-0.0.0b17-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4cb183e4be58f115759d5d505c2c32b51d3e9971f4172dd8151893211635e4c8
MD5 340afb7bebd5809004fcb75b2b825451
BLAKE2b-256 471a7b206c91831b0cdcea3810b2d76fc2b56e5b1aadf15e4df44807f18a2959

See more details on using hashes here.

Provenance

The following attestation bundles were made for code2graph_rs-0.0.0b17-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on NodeDB-Lab/code2graph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page