You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
assert_root_only_membership and its _in_tx twin have silently diverged on the collection-type exemption #2977
No current user-facing or functional impact exists (two independent DB triggers make the divergent branch unreachable today), but it is a real, git-history-confirmed maintenance hazard: the last person to touch this code already believed — incorrectly, per their own commit message — that they'd fixed both twins.
Root cause
assert_root_only_membership (packages/core/src/db/sqlite_store/relationships.rs:478) reads has_parent != 0 && node_type != "person"; assert_root_only_membership_in_tx (line 528) reads has_parent != 0 && node_type != "collection" && node_type != "person" — an extra clause the non-tx sibling lacks. Commit be5a7d270 ("Enforce that a collection is always a root") deliberately removed the collection exemption from the non-tx function, with a commit message stating explicitly "the collection exemption in both root-only membership guards is gone" — but the diff never touched the _in_tx twin, which still has it. Two DB triggers (collection_is_root_edge, collection_is_root_type) currently make has_parent structurally always 0 for a collection, so the divergence is inert today — but it's a proven authoring hazard, not a hypothetical one.
Suggested fix
Remove the leftover node_type != "collection" clause from assert_root_only_membership_in_tx to match the non-tx twin, and add a shared macro/helper so this pair (and other _in_tx twins in this codebase) can't silently diverge again.
Found via the 2026-09-25 full-repo code sweep (finding #31 of 84 in CODE_SWEEP_FINDINGS_2026-09-25.md). Severity: medium. Category: duplicate.
Activity
malibio commentedon Sep 26, 2026
Frontend: 277 files / 5392 tests passed