Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Consiliency_treesitter-chunker /chunker /boundary /identity.py
| """Boundary IR identity helpers.""" | |
| from __future__ import annotations | |
| from typing import TYPE_CHECKING, Any | |
| if TYPE_CHECKING: | |
| from chunker.types import CodeChunk | |
| def _metadata_text(metadata: dict[str, Any], key: str) -> str | None: | |
| value = metadata.get(key) | |
| if isinstance(value, str) and value: | |
| return value | |
| return None | |
| def select_node_identity( | |
| chunk: CodeChunk, module_name: str | None = None | |
| ) -> dict[str, str]: | |
| """Select the canonical Boundary IR node identity for a chunk. | |
| Prefers ``definition_id`` (a name-based, position-independent identity) so the | |
| Boundary IR node id stays STABLE across edits/moves — its purpose for diffing | |
| and impact analysis. Same-name overloads whose ``definition_id`` collides are | |
| disambiguated at the adapter level (``_dedupe_node_identities``) using the | |
| collision-free ``node_id``, so distinct definitions never share a Boundary id | |
| without making every node id position-sensitive. | |
| """ | |
| if chunk.definition_id: | |
| return {"source": "definition_id", "value": chunk.definition_id} | |
| metadata = chunk.metadata or {} | |
| module = module_name or _metadata_text(metadata, "module") | |
| qualified_name = _metadata_text(metadata, "qualified_name") | |
| if module and qualified_name: | |
| return { | |
| "source": "module + qualified_name", | |
| "value": f"{module}:{qualified_name}", | |
| } | |
| return {"source": "node_id", "value": chunk.node_id} | |
Xet Storage Details
- Size:
- 1.48 kB
- Xet hash:
- fe73068938b39152d6895d1cac13de4e406aad1aa1a2e93f347d99ed7f3056d8
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.