Skip to content

Base chunk subgraph deleter

Contract shared by all chunk-deletion strategies.

BaseChunkSubgraphDeleter

Bases: ABC

Deletes a chunk and its exclusively-owned subgraph from one backend.

Implementations encapsulate the backend-specific queries that enforce the regulation indexer's ownership rule: content a chunk exclusively owns is removed, while content shared with other chunks is preserved.

check_chunk_exists(chunk_id, index_name) abstractmethod

Return True if a chunk node for chunk_id exists in this index.

Performs a read-only lookup; does not modify the graph.

Parameters:

Name Type Description Default
chunk_id str

Raw (un-namespaced) chunk identifier.

required
index_name str

Namespace to scope the lookup.

required

Returns:

Name Type Description
bool bool

True when at least one chunk node matches; False otherwise.

Raises:

Type Description
NotImplementedError

Always raised by the base implementation.

delete_chunk_subgraph(chunk_id, index_name) abstractmethod

Delete the subgraph owned exclusively by chunk_id.

Parameters:

Name Type Description Default
chunk_id str

Identifier of the chunk to delete.

required
index_name str

Namespace scoping the deletion to one pipeline.

required

Returns:

Type Description
tuple[int, int, int]

tuple[int, int, int]: nodes_deleted, edges_deleted, and chunks_deleted — the counts of deleted graph elements. chunks_deleted is the number of Chunk nodes removed (0 when the chunk did not exist), letting callers distinguish a real deletion from a no-op on a missing chunk.

Raises:

Type Description
NotImplementedError

Always raised by the base implementation.

delete_chunks_subgraph(chunk_ids, index_name) abstractmethod

Delete the subgraphs owned exclusively by each chunk in chunk_ids.

Equivalent to calling delete_chunk_subgraph once per chunk id and summing the results, but implemented as a batched operation where the backend supports it, trading many round-trips for a few.

Parameters:

Name Type Description Default
chunk_ids list[str]

Identifiers of the chunks to delete. An empty list is a no-op.

required
index_name str

Namespace scoping the deletion to one pipeline.

required

Returns:

Type Description
tuple[int, int, int]

tuple[int, int, int]: Total nodes_deleted, edges_deleted, and chunks_deleted across every chunk in chunk_ids.

Raises:

Type Description
NotImplementedError

Always raised by the base implementation.