Skip to content

IFC-2025: Fix artifact diff migrated kind#9273

Merged
solababs merged 2 commits into
stablefrom
fix-artifact-diff-migrated-kind-ifc-2025
May 20, 2026
Merged

IFC-2025: Fix artifact diff migrated kind#9273
solababs merged 2 commits into
stablefrom
fix-artifact-diff-migrated-kind-ifc-2025

Conversation

@solababs

@solababs solababs commented May 18, 2026

Copy link
Copy Markdown
Contributor

Why

ArtifactDiffQuery anchors its target-branch artifact lookup on the Neo4j node identity of target_node. After NodeKindUpdateMigration runs, two physical Neo4j nodes share the same UUID — the original (soft-deleted on the migration branch) and the new-kind duplicate (active). The query starts from the new-kind node, which has no IS_RELATED edges on the target branch, so the OPTIONAL MATCH returns NULL and the artifact appears as ADDED.

Closes #7490

How to test

uv run pytest backend/tests/component/core/diff/test_calculate_artifact_diff.py -v

Impact & rollout

  • Backward compatibility: no breaking changes; the fix only suppresses false positives. Operators who were working around the bug by ignoring ADDED entries in schema-rename scenarios will now see correct empty diffs.
  • Performance: the UUID-based OPTIONAL MATCH (WHERE tn_target.uuid = target_node.uuid) relies on the existing uuid index on :Node; no regression expected.

Checklist

  • Tests added/updated
  • Changelog entry added (backend/changelog/7490.fixed.md)
  • External docs updated (if user-facing or ops-facing change)
  • Internal .md docs updated (internal knowledge and AI code tools knowledge)
  • I have reviewed AI generated content

Summary by cubic

Fixes artifact diffs for nodes re-keyed by a kind migration so we don’t show false ADDED/UPDATED entries. Aligns with IFC-2025 by matching migrated targets by UUID and only reporting real content changes.

  • Bug Fixes
    • Cypher now matches the target by UUID (tn_target.uuid = target_node.uuid) to find the correct artifact across migrated nodes.
    • Diff calculator skips entries when the artifact storage is unchanged (same storage_id and checksum).
    • Tests cover branch-side migration, main-side migration, and a genuine content change after migration.

Written for commit 5d1b2ec. Summary will update on new commits. Review in cubic

@solababs solababs requested a review from a team as a code owner May 18, 2026 11:09
@github-actions github-actions Bot added the group/backend Issue related to the backend (API Server, Git Agent) label May 18, 2026
@codspeed-hq

codspeed-hq Bot commented May 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing fix-artifact-diff-migrated-kind-ifc-2025 (5d1b2ec) with stable (eaef5c4)

Open in CodSpeed

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Shadow auto-approve: would require human review. This PR modifies the core artifact diff engine and a Cypher query to handle node migrations by using UUID matching, which warrants human review to ensure no unintended side effects on global diffing behavior.

Re-trigger cubic

Comment thread backend/changelog/7490.fixed.md Outdated
@@ -0,0 +1 @@
ArtifactDiffCalculator no longer produces false-positive diff entries for artifacts whose target node was re-keyed by a node kind migration (schema name or namespace change).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

users aren't going to know what ArtifactDiffCalculator is

}


async def test_calculate_artifact_diff_migrated_kind(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you combine this test with the one below into a class or single test case, then the migration only has to run one time instead of two

(target_artifact:%(artifact_kind)s)-[drel1:IS_RELATED]-(drel_node:Relationship)-[drel2:IS_RELATED]-(definition_node)
WHERE trel_node.name = $target_rel_identifier
WHERE tn_target.uuid = target_node.uuid
AND trel_node.name = $target_rel_identifier

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much smaller change than I would have expected this to be. very cool

assert artifact_diffs[0].item_previous.checksum == "aabbccdd11223344556677889900aabb"


async def test_calculate_artifact_diff_main_side_migration(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be worth checking the with_genuine_change case for the main branch like the tests above too

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Shadow auto-approve: would auto-approve. This PR fixes a targeted bug in artifact diff calculation after a kind migration by updating the Cypher query to match target nodes by UUID and adding a guard to skip diffs when storage is unchanged; the changes are minimal, well-tested, and do not affect critical infrastructure or production data.

Re-trigger cubic

@solababs solababs requested a review from ajtmccarty May 19, 2026 10:03
@solababs solababs merged commit 0caf6fa into stable May 20, 2026
64 checks passed
@solababs solababs deleted the fix-artifact-diff-migrated-kind-ifc-2025 branch May 20, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/backend Issue related to the backend (API Server, Git Agent)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: artifact diff needs update for migrated kind nodes

2 participants