Skip to main content

victor-codegraph

Shared code → Code-Property-Graph chunker: tree-sitter symbol + relation extraction, size-capped embeddable chunks, and a ProximaRecord projection. One chunker, three consumers — Victor (owner), the ProximaDB SDK ([codegraph] extra), and AnvaiOps (SaaS code-graph vertical).

Design: ProximaDB ADR-029 (authoritative) · Victor ADR-014 (owner/donor) · AnvaiOps ADR-0018 (consumer). This package is the TD-CG1 scaffold.

Why

The same tree-sitter code→symbol+relation chunker existed twice (ProximaDB SDK code.py and Victor victor-coding) and was about to be written a third time in AnvaiOps. This package is the single neutral home. It merges the best of both donors and fixes their two gaps:

  • Size-capping — ProximaDB's code.py emitted one chunk per symbol with no size bound (a huge function became a huge chunk). Here, oversized symbols are body-split with overlap (LlamaIndex CodeSplitter discipline). See sizing.py.
  • Real JS/TS — the donor JS/TS parser was a stub returning no symbols. Here JS/TS get a real tree-sitter extractor (functions, classes, methods, const … = () =>, imports).

Install

Published on PyPI as victor-codegraph (current release 0.1.2). Consumers pin the PyPI release — the ProximaDB SDK's proximadb[codegraph] extra and AnvaiOps both require victor-codegraph>=0.1.2.

# from PyPI
pip install victor-codegraph                 # Python-only (stdlib ast) path, zero native deps
pip install "victor-codegraph[treesitter]"   # + multi-language tree-sitter grammars

# dev (monorepo): editable, with tree-sitter grammars + test tooling
make -C victor-codegraph dev          # = pip install -e ../victor-contracts && pip install -e ".[dev]"
pip install -e ./victor-codegraph     # minimal editable install

Releasing

CI: .github/workflows/ci-codegraph.yml runs the suite (editable install, grammars on) for every PR touching victor-codegraph/**. Publishing: push a tag victor-codegraph-v0.1.0 to trigger .github/workflows/release-codegraph.yml, which builds and publishes via PyPI Trusted Publishing (OIDC — no API token). Configure the publisher once on PyPI (owner vjsingh1984, repo victor, workflow release-codegraph.yml, environments pypi / testpypi); see the header of that workflow.

Use

from victor_codegraph import chunk, parse, to_proxima_records, ChunkConfig

# Size-capped, embeddable chunks:
chunks = chunk(source, file_path="app/service.py", config=ChunkConfig(max_chunk_tokens=512))

# Symbols + relations:
parsed = parse(source, file_path="app/service.py")

# Project to the ProximaDB substrate-keystone record shape (one symbol = row+node+vector):
records = to_proxima_records(parsed, repo_graph_id="myrepo", branch_id="main",
                             embedder=my_embed_fn)  # embedder optional

Design principles (the "best posture" this encodes)

  1. Chunk at symbol granularity (not statement, not fixed-size).
  2. AST-aligned and size-capped — never split mid-statement, never exceed the budget.
  3. Extract relations (CALLS/EXTENDS/CONTAINS/…) and project to a CPG.
  4. Deterministic IDs + content hash → idempotent incremental re-index.
  5. Graceful fallback chain: python-ast → tree-sitter → sliding-window.
  6. Token budget matched to the embedding model (BGE-small 384-d ≈ 512 tokens).

Status

0.1.2 (PyPI). Python (stdlib ast) is the primary, fully-offline path. Multi-language extraction is best-effort via tree-sitter; deeper per-language relation extraction (the donor parsers' Rust/Go/Java specifics) lands incrementally.

Download files

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

Source Distribution

victor_codegraph-0.8.1.tar.gz (41.1 kB view details)

Uploaded Source

Built Distribution

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

victor_codegraph-0.8.1-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file victor_codegraph-0.8.1.tar.gz.

File metadata

  • Download URL: victor_codegraph-0.8.1.tar.gz
  • Upload date:
  • Size: 41.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for victor_codegraph-0.8.1.tar.gz
Algorithm Hash digest
SHA256 b3414738c4524f1007a00bca02ced6ca881f2f4f16aabaf1220fdf0273ec68a0
MD5 a0f07d568cb9a67df23a3befbbc7cf4f
BLAKE2b-256 d102b5bb982939cf8e25139444b4670363ced62053c3ba434775d9dffa68317c

See more details on using hashes here.

Provenance

The following attestation bundles were made for victor_codegraph-0.8.1.tar.gz:

Publisher: release-codegraph.yml on anvai-labs/victor

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

File details

Details for the file victor_codegraph-0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for victor_codegraph-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31ac725b3984b80a0b09fc3f7aa5624b52347cb1ebff4afaf3c40c9108bf861f
MD5 ef4c9f84e72330f5730fd2cac5c3d32a
BLAKE2b-256 92ba300fe32542c8f577d9f375c2b6e73d4fda12664bfd8da6e82bf830534543

See more details on using hashes here.

Provenance

The following attestation bundles were made for victor_codegraph-0.8.1-py3-none-any.whl:

Publisher: release-codegraph.yml on anvai-labs/victor

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 Sentry Error logging StatusPage Status page