Single-store text_key / index_doc_id
CompletionIn this exercise, you will implement the deterministic node ID and collection naming pattern used by the LlamaIndex + Qdrant integration to ensure idempotent re‑runs — the same corpus always creates or upserts the same Qdrant points, never appending duplicates.
You are given a partial scaffold with two functions and a comment placeholder. Your tasks:
-
Implement
_stable_node_ids– assign eachTextNodea deterministic UUID5 (based onuuid.NAMESPACE_DNSand a string combiningnamespaceand the node’s originalnode_id). Overwrite the node’snode_idwith the string form of that UUID. -
Implement
_collection_name– return a string"kg-<sanitized_namespace>-<12_hex_fp>"where the fingerprint is the first 12 hex characters of the SHA‑256 hash of the sorted stable node IDs (use'\x1f'as separator between IDs). Sanitize the namespace by replacing any non‑alphanumeric (except_and-) character with_, defaulting to"content"if empty. -
Explain – provide a short comment (or print) that explains why the in‑memory docstore is left empty by design on this Qdrant path (refer to the real source’s use of
text_keyandindex_doc_id).
Fill in the three # TODO: blanks in the starter code below.
- roadmap-kg/kg/memory_common.py:920-928
- roadmap-kg/kg/memory_common.py:931-972
- roadmap-kg/kg/ground_content.py:519-546