Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
{"result":{"answer":"Synthesis is unavailable (no-llm-provider), but symbol_bodies contains live source for the named code. Use that evidence directly.","citations":["django/db/models/query.py"],"confidence":"medium","retrieval_quality":"high","degraded":"no-llm-provider","note":"Synthesis is unavailable; local retrieval and source evidence remain usable. code_rationale carries rationale comments mined from the candidate source — they may already answer the question. symbol_bodies carries the live body of the symbol(s) you named, so answer from that rather than re-reading the file.","best_guesses":[{"file":"django/db/models/query.py","why_relevant":"Implements class PreventQuerySetCloning.","score":5,"excerpt":"# django/db/models/query.py\n\n## Overview\n\nThe main QuerySet implementation. This provides the public API for the ORM.\n\nIt exposes 106 public symbols and depends on 20 other files.\n\n## History\n\n500 commits in its history, 7 in the last 90 days. The last landed on 2026-06-25. **Author One** is its primary maintainer, at 7% of commits. It is one of the repository's change hotspots.\n\n## Changes together with\n\nFiles that change in the same commits as this one without importing it or being imported by it.\n\n- `django/db/models/sql/compiler.py` — 7 shared commits (last together on 2026-06-10)\n\n## Public API\n\n| Symbol | Kind | Signature |\n| --- | --- | --- |\n| `MAX_GET_RESULTS` | constant | MAX_GET_RESULTS = 21 |\n| `REPR_OUTPUT_SIZE` | constant | REPR_OUTPUT_SIZE = 20 |\n| `DEFAULT_FETCH_MODE` | constant | DEFAULT_FETCH_MODE = FETCH_ONE |\n| `BaseIterable` | class | class BaseIterable |\n| `ModelIterable` | class | class ModelIterable |\n| `RawModelIterable` | class | class RawModelIterable |\n| `ValuesIterable` | class | class ValuesIterable |\n| `ValuesListIterable` | class | class ValuesListIterable |\n| `NamedValuesListIterable` | class | class NamedValuesListIterable |\n| `FlatValuesListIterable` | class | class FlatValuesListIterable |\n| `PreventQuerySetCloning` | class | class PreventQuerySetCloning |\n| `QuerySet` | class | class QuerySet |\n| `query` | method | def query(self) |\n| `query` | method | def query(self, value) |\n| `as_manager` | method | def as_manager(cls) |\n| `iterato"},{"file":"django/db/models/sql/query.py","why_relevant":"Create SQL statements for QuerySets..","score":3.5,"excerpt":"# django/db/models/sql/query.py\n\n## Overview\n\nCreate SQL statements for QuerySets.\n\nThe code in here encapsulates all of the SQL construction so that QuerySets\nthemselves do not have to (and could be backed by things other than SQL\ndatabases). The abstraction barrier only works one way: this module has to know\nall about the internals of models in order to get the information it needs.\n\nIt exposes 102 public symbols and depends on 18 other files.\n\n## History\n\n500 commits in its history, 5 in the last 90 days. The last landed on 2026-06-10. **Anssi Kääriäinen** is its primary maintainer, at 18% of commits. It is one of the repository's change hotspots.\n\n## Changes together with\n\nFiles that change in the same commits as this one without importing it or being imported by it.\n\n- `tests/aggregation_regress/tests.py` — 4 shared commits (last together on 2026-04-19)\n- `tests/queries/test_qs_combinators.py` — 2 shared commits (last together on 2026-05-18)\n- `tests/composite_pk/test_filter.py` — 6 shared commits (last together on 2026-04-02)\n- `tests/filtered_relation/tests.py` — 4 shared commits (last together on 2026-02-03)\n- `tests/queries/tests.py` — 4 shared commits (last together on 2026-04-02)\n\n## Public API\n\n| Symbol | Kind | Signature |\n| --- | --- | --- |\n| `FORBIDDEN_ALIAS_PATTERN` | constant | FORBIDDEN_ALIAS_PATTERN = _lazy_re_compile(…) |\n| `EXPLAIN_OPTIONS_PATTERN` | constant | EXPLAIN_OPTIONS_PATTERN = _lazy_re_compile(r\"[\\w-]+\") |\n| `get_field_names_from_opts` | functi"},{"file":"django/db/models/query.py","why_relevant":"Represent a lazy database lookup for a set of objects..","score":3,"excerpt":"# QuerySet\n\n**Kind:** class | **Defined in:** `django/db/models/query.py` | **Estimated complexity:** 1\n\n```\nclass QuerySet\n```\n\n## Overview\n\nRepresent a lazy database lookup for a set of objects.\n\n## Where it is used\n\n12 files import the module that defines it. These are import-level references, not confirmed call sites.\n\n- `django/contrib/contenttypes/fields.py`\n- `django/contrib/contenttypes/prefetch.py`\n- `django/db/models/__init__.py`\n- `django/db/models/base.py`\n- `django/db/models/manager.py`\n- `django/db/models/fields/related_descriptors.py`\n- `django/db/models/sql/query.py`\n- `tests/basic/tests.py`\n- `tests/model_forms/tests.py`\n- `tests/prefetch_related/models.py`\n- `tests/prefetch_related/tests.py`\n- `tests/raw_query/tests.py`\n\n## Implementation\n\n```\nclass QuerySet(AltersData):\n \"\"\"Represent a lazy database lookup for a set of objects.\"\"\"\n\n def __init__(self, model=None, query=None, using=None, hints=None):\n self.model = model\n self._db = using\n self._hints = hints or {}\n self._query = query or sql.Query(self.model)\n self._result_cache = None\n self._sticky_filter = False\n self._for_write = False\n self._prefetch_related_lookups = ()\n self._prefetch_done = False\n self._known_related_objects = {} # {rel_field: {pk: rel_obj}}\n self._iterable_class = ModelIterable\n self._fetch_mode = DEFAULT_FETCH_MODE\n self._fields = None\n self._defer_next_filter = False\n sel"}],"code_rationale":[{"path":"django/db/models/query.py","lines":[309,316],"comment":"Temporarily prevent the given QuerySet from creating new QuerySet instances on each mutating operation (e.g: filter(), exclude() etc), instead modifying the QuerySet in-place. @contextlib.contextmanager is intentionally not used for performance reasons.","matched_terms":["queryset"]},{"path":"django/db/models/query.py","lines":[566,570],"comment":"An iterator over the results from applying this QuerySet to the database. chunk_size must be provided for QuerySets that prefetch related objects. Otherwise, a default chunk_size of 2000 is supplied.","matched_terms":["queryset"]}],"symbol_bodies":[{"path":"django/db/models/query.py","name":"QuerySet","lines":[330,450],"source":"class QuerySet(AltersData):\n \"\"\"Represent a lazy database lookup for a set of objects.\"\"\"\n\n def __init__(self, model=None, query=None, using=None, hints=None):\n self.model = model\n self._db = using\n self._hints = hints or {}\n self._query = query or sql.Query(self.model)\n self._result_cache = None\n self._sticky_filter = False\n self._for_write = False\n self._prefetch_related_lookups = ()\n self._prefetch_done = False\n self._known_related_objects = {} # {rel_field: {pk: rel_obj}}\n self._iterable_class = ModelIterable\n self._fetch_mode = DEFAULT_FETCH_MODE\n self._fields = None\n self._defer_next_filter = False\n self._deferred_filter = None\n self._cloning_enabled = True\n\n @property\n def query(self):\n if self._deferred_filter:\n negate, args, kwargs = self._deferred_filter\n self._filter_or_exclude_inplace(negate, args, kwargs)\n self._deferred_filter = None\n return self._query\n\n @query.setter\n def query(self, value):\n if value.values_select:\n self._iterable_class = ValuesIterable\n self._query = value\n\n def as_manager(cls):\n # Address the circular dependency between `Queryset` and `Manager`.\n from django.db.models.manager import Manager\n\n manager = Manager.from_queryset(cls)()\n manager._built_with_as_manager = True\n return manager\n\n as_manager.queryset_only = True\n as_manager = classmethod(as_manager)\n\n ########################\n # PYTHON MAGIC METHODS #\n ########################\n\n def __deepcopy__(self, memo):\n \"\"\"Don't populate the QuerySet's cache.\"\"\"\n obj = self.__class__()\n for k, v in self.__dict__.items():\n if k == \"_result_cache\":\n obj.__dict__[k] = None\n else:\n obj.__dict__[k] = copy.deepcopy(v, memo)\n return obj\n\n def __getstate__(self):\n # Force the cache to be fully populated.\n self._fetch_all()\n return {**self.__dict__, DJANGO_VERSION_PICKLE_KEY: django.__version__}\n\n def __setstate__(self, state):\n pickled_version = state.get(DJANGO_VERSION_PICKLE_KEY)\n if pickled_version:\n if pickled_version != django.__version__:\n warnings.warn(\n \"Pickled queryset instance's Django version %s does not \"\n \"match the current version %s.\"\n % (pickled_version, django.__version__),\n RuntimeWarning,\n stacklevel=2,\n )\n else:\n warnings.warn(\n \"Pickled queryset instance's Django version is not specified.\",\n RuntimeWarning,\n stacklevel=2,\n )\n self.__dict__.update(state)\n\n def __repr__(self):\n data = list(self[: REPR_OUTPUT_SIZE + 1])\n if len(data) > REPR_OUTPUT_SIZE:\n data[-1] = \"...(remaining elements truncated)...\"\n return \"<%s %r>\" % (self.__class__.__name__, data)\n\n def __len__(self):\n self._fetch_all()\n return len(self._result_cache)\n\n def __iter__(self):\n \"\"\"\n The queryset iterator protocol uses three nested iterators in the\n default case:\n 1. sql.compiler.execute_sql()\n - Returns 100 rows at time (constants.GET_ITERATOR_CHUNK_SIZE)\n using cursor.fetchmany(). This part is responsible for\n doing some column masking, and returning the rows in chunks.\n 2. sql.compiler.results_iter()\n - Returns one row at time. At this point the rows are still just\n tuples. In some cases the return values are converted to\n Python values at this location.\n 3. self.iterator()\n - Responsible for turning the rows into model objects.\n \"\"\"\n self._fetch_all()\n return iter(self._result_cache)\n\n def __aiter__(self):\n # Remember, __aiter__ itself is synchronous, it's the thing it returns\n # that is async!\n async def generator():\n await sync_to_async(self._fetch_all)()\n for item in self._result_cache:\n yield item\n\n return generator()","verified":true,"truncated":true,"continuation":"django/db/models/query.py:451-2367","withheld_symbols":[{"name":"QuerySet","kind":"class","line":330,"symbol_id":"django/db/models/query.py::QuerySet","signature":"class QuerySet(AltersData):","body_continues":true},{"name":"__bool__","kind":"def","line":452,"symbol_id":"django/db/models/query.py::__bool__","signature":"def __bool__(self):"},{"name":"__getitem__","kind":"def","line":456,"symbol_id":"django/db/models/query.py::__getitem__","signature":"def __getitem__(self, k):"},{"name":"__class_getitem__","kind":"def","line":493,"symbol_id":"django/db/models/query.py::__class_getitem__","signature":"def __class_getitem__(cls, *args, **kwargs):"},{"name":"__and__","kind":"def","line":496,"symbol_id":"django/db/models/query.py::__and__","signature":"def __and__(self, other):"},{"name":"__or__","kind":"def","line":508,"symbol_id":"django/db/models/query.py::__or__","signature":"def __or__(self, other):"},{"name":"__xor__","kind":"def","line":527,"symbol_id":"django/db/models/query.py::__xor__","signature":"def __xor__(self, other):"},{"name":"_iterator","kind":"def","line":550,"symbol_id":"django/db/models/query.py::_iterator","signature":"def _iterator(self, use_chunked_fetch, chunk_size):"}]}],"grounding":"symbol_body","next_action_hint":"QuerySet was served through line 450; call get_symbol id='django/db/models/query.py::__bool__' for the withheld body.","_meta":{"contract_version":2,"timing_ms":2087,"hint":"Synthesis is what is missing here, not retrieval. Answer from symbol_bodies; retrieval_quality rates what was served.","index_scope":{"version":1,"projection":"compact","run_mode":"standard","content_provenance":"template","git_tier":"full","status":"upgrading","fingerprint":"99c42a358f89","full":"get_overview()","degraded_analyses":["Graph build can take several minutes on a first run. Safe to Ctrl-C — re-run 'repowise init --resume' to continue where it stopped."]},"embedder":"mock","embedder_degraded":false,"semantic_search":false,"degraded":"no-llm-provider","projection":{"recovery":{"tool":"get_answer","arguments":{"question":"why is QuerySet lazy?","include":["evidence"]}}},"index_age_days":0,"indexed_commit":"e78991410b78","live_head":"e78991410b78","index_behind":false,"scope_hint":"Unrelated to what was served: Application (472 files), Config (205), Service (80).","state":{"degraded":true,"degraded_reasons":{"degraded":"no-llm-provider"}},"response_budget":{"limit_chars":24000,"tier":"default","serialized_chars":14042},"completeness":{"capped":true,"shown":2,"total":21,"reason":"confidence_projection_and_deduplication"}},"retrieval_total":5,"retrieval_emitted":0,"retrieval_reduced_reason":"confidence_projection_and_deduplication","code_rationale_total":6,"code_rationale_emitted":2,"code_rationale_reduced_reason":"confidence_projection_and_deduplication","candidates_total":5,"candidates_emitted":0,"candidates_reduced_reason":"confidence_projection_and_deduplication","fallback_targets_total":5,"fallback_targets_emitted":0,"fallback_targets_reduced_reason":"confidence_projection_and_deduplication"}}