Edge resolution: a self-referential base edge is always read in reverse

entity.parent_id -> entity matches every type pair in both directions, and the
discovery loop kept forward whenever reverse also matched — so an array
include compiled as `parent.parent_id = child.id` and every nested list read
back empty. Includes always start from the parent and list what hangs under
it; nothing reads the edge from a child up to its parent object. So the edge
is reverse, full stop. 1286 library tests pass. Pinned by api's accounting
suites on branch activity-task-assignment-lines.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AvkGU4kQ4wsqxHFpXtZKZM
This commit is contained in:
2026-09-02 11:41:34 -04:00
parent b699061f2f
commit 0778624560

View File

@ -500,6 +500,13 @@ impl Database {
let is_reverse = p_def.hierarchy.contains(&rel.destination_type)
&& c_def.hierarchy.contains(&rel.source_type);
// A self-referential edge on a shared ancestor table (entity.parent_id -> entity) matches
// both ways for every type pair. Includes always start from the parent and list what hangs
// under it, so the edge is read in reverse — never from a child up to its parent object.
if is_forward && is_reverse {
is_forward = false;
}
// Structural Cardinality Filtration:
// If the schema requires a collection (Array), it is mathematically impossible for a pure
// Forward scalar edge (where the parent holds exactly one UUID pointer) to fulfill a One-to-Many request.