Skip to content

fix: two-pass re-import for catalog entities with x-cortex-relationships - #216

Merged
jeff-schnitter merged 2 commits into
mainfrom
jeff/entity-relationship-reprocess
Jul 6, 2026
Merged

fix: two-pass re-import for catalog entities with x-cortex-relationships#216
jeff-schnitter merged 2 commits into
mainfrom
jeff/entity-relationship-reprocess

Conversation

@jeff-schnitter

Copy link
Copy Markdown
Collaborator

Summary

  • Adds two-pass relationship reprocessing to backup import
  • Pass 1 imports all catalog entities alphabetically; entities with x-cortex-relationships referencing not-yet-created entities get stale/missing relationship links
  • Pass 2 detects all entities with x-cortex-relationships and re-creates them after all entities exist in the DB
  • Wave 2 handles multi-tier hierarchies: if an entity's relationship destination was itself re-created in wave 1, re-create the dependent entity again in wave 2

Test plan

  • test_backup_import_triggers_pass2_for_relationship_entities — confirms pass 2 runs when relationship entities are present
  • test_backup_import_no_pass2_when_no_relationships — confirms pass 2 is skipped when no entities have relationships
  • test_backup_import_triggers_wave2_for_dependent_relationships — confirms wave 2 handles multi-tier dependency chains

🤖 Generated with Claude Code

…ips #patch

Entities are imported in alphabetical order. An entity early in the alphabet
may reference a relationship destination that hasn't been created yet, causing
the relationship processor to cache a failed state that subsequent updates
won't clear.

Pass 2 detects all catalog entities with x-cortex-relationships, deletes and
re-creates them after all entities exist in the DB. A second wave handles
multi-tier hierarchies where a relationship entity's own destination was also
recreated in wave 1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jeff-schnitter
jeff-schnitter requested a review from Cantaley as a code owner July 6, 2026 17:42
@jeff-schnitter
jeff-schnitter merged commit 6fdb081 into main Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant