GitNexus/gitnexus/test/unit/scope-resolution/python
vijaygali aa7c273093
fix(ingestion): index Python repos with empty __init__.py and >32 KB files (#1163)
* fix(ingestion): index Python repos with empty __init__.py and >32 KB files

Two defensive fixes that let `gitnexus analyze` complete on Python
codebases that previously failed.

scope-extractor: synthesize an empty Module scope when the provider
emits zero captures. Previously threw "no Module scope found", which
fired for any 0-byte `__init__.py` package marker if the bridge's
empty-source guard was bypassed.

python/captures: wrap the parser.parse() and getPythonScopeQuery()
.matches() calls in try/catch. node-tree-sitter throws "Invalid
argument" for sources that overrun internal buffers (observed at the
~32 KB threshold on Windows). Degrade gracefully with a clear
"skipping scope extraction for this file" warning instead of the
opaque "Invalid argument" surfacing through the bridge.

Verified by indexing whittlem/pycryptobot (which has 7 empty
__init__.py and 11 Python files between 34 KB and 158 KB):
2,367 nodes / 4,973 edges, no segfault, queries resolve symbols
inside the 158 KB controllers/PyCryptoBot.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(ingestion): harden Python scope extraction fallbacks

Keep failed Python scope extraction on the bridge skip path and build synthetic module scopes before extractor indexes are derived.

Made-with: Cursor

---------

Co-authored-by: Vijay Gali <vgali@vexcelco.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Gergo Magyar <gergomagyar@icloud.com>
2026-04-30 19:24:04 +01:00
..
cached-tree-parity.test.ts feat(python): scope-based call resolution + registry-primary flip + perf + generalization (RFC #909 Ring 3) (#980) 2026-04-21 15:50:00 +01:00
python-fixtures.test.ts fix(ingestion): index Python repos with empty __init__.py and >32 KB files (#1163) 2026-04-30 19:24:04 +01:00
python-hooks.test.ts feat(csharp): migrate C# to registry-primary scope-resolution (Closes #934) (#1019) 2026-04-23 12:38:13 +01:00