Skip to content

Fix relationship validation to track endpoints for duplicate detection#27

Merged
akollegger merged 3 commits into018-pattern-path-semanticsfrom
copilot/sub-pr-24
Nov 29, 2025
Merged

Fix relationship validation to track endpoints for duplicate detection#27
akollegger merged 3 commits into018-pattern-path-semanticsfrom
copilot/sub-pr-24

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 29, 2025

Relationship identifiers were incorrectly flagged as duplicates on any reuse. Per spec, relationships can repeat in a path as long as they connect the same nodes.

Valid: (a)-[r]->(b), (a)-[r]->(b)-[r2]->(c)r connects same endpoints
Invalid: (a)-[r]->(b), (a)-[r]->(c)r connects different targets

Changes

  • Extended PatternSignature with sigEndpoints :: Maybe (Maybe Identifier, Maybe Identifier) to track source/target nodes for relationships
  • Updated registerRelationship to compare endpoints when identifier already exists — error only if endpoints differ
  • Added registerPathSegments helper to pass node context during path traversal

Tests Added

it "accepts relationship reuse with same endpoints" $
  validateSource "(a)-[r]->(b), (a)-[r]->(b)-[r2]->(c)" `shouldSatisfy` isRight

it "rejects relationship reuse with different endpoints" $
  validateSource "(a)-[r]->(b), (a)-[r]->(c)-[r2]->(b)" `shouldSatisfy` isLeft

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 29, 2025 14:28
… same source/target nodes

Co-authored-by: akollegger <53756+akollegger@users.noreply.github.com>
Co-authored-by: akollegger <53756+akollegger@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issues in pattern path semantics logic review Fix relationship validation to track endpoints for duplicate detection Nov 29, 2025
Copilot AI requested a review from akollegger November 29, 2025 14:31
@akollegger akollegger marked this pull request as ready for review November 29, 2025 14:33
@akollegger akollegger merged commit b1d6e18 into 018-pattern-path-semantics Nov 29, 2025
@akollegger akollegger deleted the copilot/sub-pr-24 branch November 29, 2025 14:33
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.

2 participants