Graph Namespace Utils
Graph node ID namespacing utilities.
build_cypher_chunk_id_match(chunk_id, index_name, use_namespaced_id=True)
Build the Cypher Chunk-id match clause and its bind parameters for one chunk id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk_id
|
str
|
Raw (un-namespaced) chunk identifier. |
required |
index_name
|
str
|
Namespace scoping the lookup. |
required |
use_namespaced_id
|
bool
|
Whether the predicate also matches the
namespaced ( |
True
|
Returns:
| Type | Description |
|---|---|
tuple[str, dict[str, Any]]
|
tuple[str, dict[str, Any]]: The parenthesized Cypher predicate matching the chunk's
|
build_namespaced_edge_dict(edge_dict, index_name)
Return a copy of a generator edge dict with its endpoints namespaced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_dict
|
dict[str, Any]
|
Raw edge dict from generator output, with |
required |
index_name
|
str | None
|
Namespace prefix to apply, or |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A copy of |
build_namespaced_id(raw_id, index_name)
Return a namespaced node identifier.
When index_name is provided, the returned id takes the form
"{index_name}:{raw_id}", scoping the node to a single pipeline's
namespace. When index_name is None the raw id is returned
unchanged, preserving backwards compatibility with deployments that
predate namespacing. Idempotent when raw_id already carries the
current index_name prefix (e.g. an in-flight element produced by a
generator version that namespaced ids itself), so callers can't
double-prefix an id into "{index_name}:{index_name}:...".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_id
|
str
|
Raw, un-namespaced node identifier. |
required |
index_name
|
str | None
|
Namespace prefix to prepend, or |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The namespaced id |
build_namespaced_node_dict(node_dict, index_name)
Return a copy of a generator node dict with its id (and id references) namespaced.
Prefixes the top-level id and, when present, every property in
_ID_REFERENCE_PROPERTIES — the mirrored properties["id"] copy several node
builders carry (Chapter, Part, Paragraph, Article, ArticleVersion, Clause, Concept,
Obligation, Explanation, Chunk), and properties["article_id"] (ArticleVersion's
reference to its parent Article's id). Never touches properties["chunk_id"], which
the deleter/reader match on in its raw (un-namespaced) form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_dict
|
dict[str, Any]
|
Raw node dict from generator output, with |
required |
index_name
|
str | None
|
Namespace prefix to apply, or |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A copy of |