scope uniqueness constraints to specific objects

Merged
AJ
4mo ago
+3090-379

combines two previous reviewed PRs

Only these commits (the final 3) are unreviewed

Each of these is self-contained and can be reviewed on its own:

  • 671b39c — reject a non-positive chunked() size
    chunked() let size=0 surface range()'s own opaque ValueError and silently yielded nothing for a negative size. Adds an explicit guard and replaces the single test with rejection cases for zero/negative plus round-trip cases (empty, exact multiple, trailing partial, oversized size, tuple-in/tuple-out). Defensive only — every current caller passes a positive size.

  • dbbcad4 — move get_query_arrows() from RelationshipSchema to Query
    Mapping a relationship direction to Cypher arrows is a database concern, not a schema one. QueryArrow/QueryArrows and the mapping now live in infrahub.core.query as Query.get_query_arrows(direction); all nine call sites were already inside Query subclasses, and QueryArrow* had no consumers outside relationship_schema.py. Pure refactor — the arrows rendered per direction are unchanged.

  • abcd7e7 — traverse the relationship in its own direction when resolving dependents
    AffectedUniquenessDependentsQuery matched IS_RELATED undirected, so for a kind whose relationship peer is its own kind (parent/children sharing one identifier) resolving the dependents of a changed peer returned nodes on both sides, over-scoping validation. Threads RelationshipDirection through the scoper and resolver so the path is traversed node→Relationship→peer, matching how the edges are created and how the sibling uniqueness queries already read them. Currently latent — a peer-attribute constraint element still falls back to full-population validation — but it matters as soon as targeted validation covers those paths. Adds self-referential coverage that fails against the undirected query.