Skip to content

AB#1922 Fix: Validate resulting cardinality for to-one associations#201

Merged
mmgerald merged 1 commit into
mainfrom
gerald/AB#1922_multiple-parents-cardinality
Jun 29, 2026
Merged

AB#1922 Fix: Validate resulting cardinality for to-one associations#201
mmgerald merged 1 commit into
mainfrom
gerald/AB#1922_multiple-parents-cardinality

Conversation

@mmgerald

@mmgerald mmgerald commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bug 1922: it was possible to set multiple parents on a to-one association (e.g. ParentChild outbound Parent, multiplicity One).
  • Root cause: the cardinality guard in GraphRuleEngine checked only the current DB state (currentMultiplicity == One) instead of the resulting cardinality after applying the batch. A single mutation creating ≥2 targets from an empty state (Zero) slipped through.
  • Fix in both ValidateOrigin and ValidateTarget: report a violation when a to-one role net-adds while already One/Many, or creates two or more from Zero.

Azure DevOps Work Item

AB#1922

Test Plan

  • Build passes (DebugL)
  • Unit tests pass (Runtime.Engine.Tests 584/584)
  • New tests cover 0→2 (single mutation) and 1→+1 scenarios
  • Positive cases (single parent, replace via delete+create) still allowed

🤖 Generated with Claude Code

The association cardinality guard in GraphRuleEngine only checked the
current DB state (currentMultiplicity == One), so a single mutation could
add multiple targets to a to-one role (e.g. multiple parents on a
TreeNode) when starting from an empty or already-corrupt state.

ValidateOrigin and ValidateTarget now validate the resulting cardinality
after applying the batch: a violation is reported when a to-one role
net-adds while already One/Many, or creates two or more from Zero.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mmgerald mmgerald merged commit fb5d884 into main Jun 29, 2026
1 check passed
@mmgerald mmgerald deleted the gerald/AB#1922_multiple-parents-cardinality branch June 29, 2026 07:33
mmgerald added a commit that referenced this pull request Jun 30, 2026
…ts-cardinality

AB#1922 Fix: Validate resulting cardinality for to-one associations
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