Skip to content

fix(recompute): refresh a reader's derived values when its read peer is deleted#9845

Draft
gmazoyer wants to merge 1 commit into
developfrom
recompute-deleted-peer-readers-ifc-2852
Draft

fix(recompute): refresh a reader's derived values when its read peer is deleted#9845
gmazoyer wants to merge 1 commit into
developfrom
recompute-deleted-peer-readers-ifc-2852

Conversation

@gmazoyer

@gmazoyer gmazoyer commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Why

Deleting a node that other nodes read across a relationship left the readers with derived values (display label, human-friendly id, computed attribute) that still named the deleted peer after a merge or rebase. Tracked in IFC-2852.

Root cause

The reader does appear in the merge/rebase change set, but as an update whose changed field is the relationship to the deleted peer. The coalesced deriver treated updates as needing no self recompute, on the assumption the node refreshed its own derived values inline on the save that recorded the change. A peer deletion never triggers that inline recompute (the reader is not saved, its edge is closed from the peer side). The only submission was a reverse lookup from the deleted peer, which finds no readers once its edges are closed, so the reader kept its stale value.

Fix

An update whose changed fields include a relationship now also recomputes the node's own derived values that read across it, keyed by the node's own id. This works because the reader still exists. It covers both merge and rebase through the shared build_coalesced_recompute. Attribute-only updates are unchanged, so the coalescing behavior for the common case is preserved.

Tests

  • Un-marked and broadened the former strict xfail test_deleting_read_peer_refreshes_reader_after_merge to assert the computed attribute and display label stop naming the deleted peer and the human-friendly id (local name only) is unchanged, using the full cross-relationship display label.
  • Added test_merge_submits_delete_peer.py: a component test asserting the reader is recomputed by its own id for the computed attribute and display label.
  • Full coalescing component suite green locally (17 passed). Local integration_docker was blocked by a slow-boot healthcheck timeout on the dev machine (the server boots cleanly, just slower than the stack wait window), so the end-to-end integration test is verified here in CI.

Notes


Summary by cubic

Refreshes a reader’s computed attribute, display label, and HFID when its relationship changes during merge/rebase—including when the peer is deleted—so values stop naming the deleted node (IFC-2852). Adds a safe fallback for unscoped updates that also recomputes the node’s own derived values.

  • Bug Fixes
    • UPDATED with relationship fields also recomputes the reader’s own derived values, keyed by its id; attribute-only updates unchanged.
    • Unscoped UPDATED imprecisely recomputes cross-node readers and the node’s own derived values.
    • Coalesces affected readers into one submission per family; component test asserts own-id coalescing and integration verifies summary refresh with HFID unchanged.

Written for commit 694204d. Summary will update on new commits.

Review in cubic

@github-actions github-actions Bot added the group/backend Issue related to the backend (API Server, Git Agent) label Jul 8, 2026
@gmazoyer
gmazoyer force-pushed the recompute-deleted-peer-readers-ifc-2852 branch from d890bf0 to b2c86e4 Compare July 8, 2026 09:54
@codspeed-hq

codspeed-hq Bot commented Jul 8, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing recompute-deleted-peer-readers-ifc-2852 (694204d) with develop (049b821)

Open in CodSpeed

@gmazoyer
gmazoyer force-pushed the recompute-deleted-peer-readers-ifc-2852 branch from b2c86e4 to 7885f27 Compare July 8, 2026 10:06

@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.

1 issue found and verified against the latest diff

Confidence score: 3/5

  • In backend/infrahub/core/merge/recompute_coalescing.py, unscoped UPDATED changes can skip the reader-by-own-id recompute when the unrecorded change is relationship-only, because _changed_relationship_fields() may return None when changed_fields is empty; merging as-is risks stale or incorrect read results after merges. Ensure relationship-only updates are treated as relationship changes (instead of None) and add a regression test for the unscoped UPDATED path before merging.

Shadow auto-approve: would not auto-approve because issues were found.

Re-trigger cubic

Comment thread backend/infrahub/core/merge/recompute_coalescing.py Outdated
@gmazoyer
gmazoyer force-pushed the recompute-deleted-peer-readers-ifc-2852 branch from 7885f27 to 6f9c427 Compare July 8, 2026 10:33
@gmazoyer
gmazoyer force-pushed the coalesce-merge-recompute-ifc-2761 branch 2 times, most recently from d0c528c to 870a3b7 Compare July 12, 2026 11:27
@gmazoyer
gmazoyer force-pushed the recompute-deleted-peer-readers-ifc-2852 branch from 6f9c427 to e574a26 Compare July 12, 2026 11:38
Base automatically changed from coalesce-merge-recompute-ifc-2761 to develop July 12, 2026 14:10
@gmazoyer
gmazoyer force-pushed the recompute-deleted-peer-readers-ifc-2852 branch 4 times, most recently from 4e842db to d7ab2f3 Compare July 17, 2026 09:48
…is deleted

Deleting a node that others read across a relationship left the readers with
derived values that still named the deleted peer after a merge or rebase. The
reader appears in the change set as an update whose changed field is the
relationship, but the coalesced deriver treated updates as needing no self
recompute (the node is assumed to have refreshed its own values inline on save),
which a peer deletion never triggers; the only submission was a reverse lookup
from the deleted peer, which finds no readers once its edges are closed.

An update whose changed fields include a relationship now also recomputes the
node's own derived values that read across it, keyed by the node's own id. This
covers merge and rebase through the shared deriver. Attribute-only updates are
unchanged, so the coalescing behavior for the common case is preserved.
@gmazoyer
gmazoyer force-pushed the recompute-deleted-peer-readers-ifc-2852 branch from d7ab2f3 to 6a127f1 Compare July 17, 2026 12:30
@gmazoyer
gmazoyer force-pushed the recompute-deleted-peer-readers-ifc-2852 branch from 6a127f1 to 694204d Compare July 17, 2026 12:59
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.

1 participant