Skip to main content

Overview

Apply confirmed decisions from the review process to the knowledge graph. Merges approved duplicate entities and removes rejected relations, then updates the graph file.

Usage

sift apply-merges [OPTIONS]

Options

--output
string
Output directory containing graph and review files. Use -o as shorthand.
--verbose
boolean
default:"false"
Enable verbose logging. Use -v as shorthand.

Behavior

Application Process

  1. Load Graph - Reads graph_data.json
  2. Apply Entity Merges - Processes confirmed proposals from merge_proposals.yaml
    • Merges entity attributes
    • Redirects all relations to canonical entity
    • Removes duplicate entities
  3. Apply Relation Rejections - Removes rejected relations from relation_review.yaml
  4. Save Graph - Updates graph_data.json with changes

Entity Merge Logic

When merging entities:
  • Canonical Name - Uses name from merge proposal
  • Attributes - Combines attributes from all merged entities
  • Relations - Redirects all incoming/outgoing relations to canonical entity
  • Source Documents - Preserves references from all merged entities

Relation Rejection

Removes relations marked as status: rejected in relation_review.yaml.

Input Files

merge_proposals.yaml

Reads the confirmed section:
proposals:
  confirmed:
    - cluster_id: "cluster_001"
      members: ["entity_1", "entity_2"]
      canonical_name: "Merged Entity"

relation_review.yaml

Reads relations with status: rejected:
relations:
  - source_id: "entity_123"
    target_id: "entity_456"
    relation_type: "WORKS_WITH"
    status: rejected

Output

Updates graph_data.json with:
  • Merged entities
  • Removed duplicate entities
  • Removed rejected relations
  • Updated entity and relation counts

Examples

Apply all confirmed decisions

sift apply-merges
Applies all confirmed merges and rejections from review files.

Apply from custom directory

sift apply-merges --output ./project/output
Applies decisions from specified output directory.

With verbose logging

sift apply-merges -v
Shows detailed merge operations.

Output Summary

Displays:
  • Number of entity merges applied
  • Number of relations rejected
  • Final entity count
  • Final relation count
  • Graph file location

No Changes

If no confirmed merges or rejections exist:
No changes to apply.
Edit merge_proposals.yaml or relation_review.yaml first.

Next Steps

After applying merges:
sift narrate
To generate a narrative summary of the updated knowledge graph.

Iterative Workflow

The review-apply cycle can be repeated:
  1. sift resolve - Find more duplicates
  2. sift review - Review new proposals
  3. sift apply-merges - Apply decisions
  4. Repeat as needed

Error Handling

Exits with error if:
  • No graph_data.json found (run sift build first)
  • Review files are malformed

Rollback

To undo applied merges:
  • Restore graph_data.json from backup
  • Or rebuild graph from extractions: sift build

See Also

  • review - Review merge proposals
  • resolve - Find duplicate entities
  • narrate - Generate narrative summary

Build docs developers (and LLMs) love