Chunk deletion
Backend-specific chunk-deletion strategies for the regulation graph indexer.
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.
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]
|
tuple[int, int]: nodes_deleted & edges_deleted, the counts of deleted graph elements. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always raised by the base implementation. |
Neo4jChunkSubgraphDeleter(capability)
Bases: BaseChunkSubgraphDeleter
Neo4j implementation of :class:BaseChunkSubgraphDeleter.
Borrows (does not own) a :class:Neo4jGraphCapability and issues Cypher
through its read-write :meth:~Neo4jGraphCapability.query path. Holding the
capability rather than subclassing it keeps the deletion strategy decoupled
from how the capability is constructed (Neo4jDataStore.with_graph()).
Attributes:
| Name | Type | Description |
|---|---|---|
capability |
Neo4jGraphCapability
|
Capability used to execute Cypher. |
Initialize the deleter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
Neo4jGraphCapability
|
Neo4j capability used to run Cypher. |
required |
delete_chunk_subgraph(chunk_id, index_name)
Delete all nodes and edges owned by chunk_id in a single Cypher query.
Runs three operations atomically in one round-trip:
- Delete content nodes exclusively
MENTIONS-ed by this chunk (shared nodes are preserved). Ownership is scoped toindex_nameto avoid cross-index interference. - Delete edges whose
chunk_idproperty matches. By design only reference edges (CITES,MENTIONS_CONCEPT,CONTAINS_OBLIGATION) carrychunk_id(seeOWNED_EDGE_TYPESin the generator), so this step removes exactly the chunk's reference edges whose endpoints may outlive it. Containment edges (HAS_*,AMENDS,MENTIONS) carry nochunk_idand are left toDETACH DELETEof their endpoint node — this avoids over-deleting containment edges still shared by other chunks. - Delete the
Chunknode itself (DETACH DELETEremoves remainingMENTIONSedges).
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]
|
tuple[int, int]: nodes_deleted & edges_deleted, the counts of deleted graph elements. |
get_chunk_deleter(capability)
Get a chunk deleter strategy for a given graph capability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
BaseGraphCapability
|
The indexer's graph capability. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseChunkSubgraphDeleter |
BaseChunkSubgraphDeleter
|
A deletion strategy bound to |
Raises:
| Type | Description |
|---|---|
TypeError
|
If no deletion strategy is registered for the capability's backend. |