Skip to main content

agrag.ingestion.merge.apply_merge

apply_merge(plan:MergePlan, *, graph_store:GraphStore, schema:GraphSchema, pending_job_id:str | None = None) -> None

Write a computed MergePlan to storage.

Every call runs inside one GraphStore transaction. It upserts the survivor and records a merge-key alias for its current name. A failure partway through leaves no half-written state. No survivor without its alias remains.

Parameters:

  • plan (MergePlan) – The merge to write.
  • graph_store (GraphStore) – Where the merge is written.
  • schema (GraphSchema) – The schema the survivor's label belongs to.
  • pending_job_id (str | None) – The in-flight Cutover Job's id, tagging the survivor node and its aliases until that job commits. None writes untagged, for callers outside a job.

Raises:

  • GraphStoreAliasConflictError – An accepted merge_key is already owned by a live entity outside this merge's own survivor id -- a concurrent writer accepted that name as an alias of, or created it as the canonical name of, a different entity.