Tier-1 class-read primitives (atomic add_relationship PR 1/2)#44
Merged
Conversation
…p PR 1/2) Primitives-only slice: add default_template_in_txn/get_template_in_txn/ class_in_ancestry_in_txn to graphdb_class as exported, in-transaction, bare-mnesia reads. Uniform add-don't-rewrap (gen_server reads stay dirty for B5 conflict-resolver deadlock-safety); purely additive. The add_relationship collapse is deferred to PR 2. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EWukKCbrN8GybaScJGU2kF
4-task TDD plan: get_template_in_txn/1, class_in_ancestry_in_txn/2, default_template_in_txn/1 added to graphdb_class as in-transaction bare-mnesia twins, +10 CT cases; docs + full-suite verify. Purely additive (gen_server reads untouched). Implements docs/designs/atomic-add-relationship-primitives-design.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EWukKCbrN8GybaScJGU2kF
This was referenced Jun 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 1 of 2 of the atomic
add_relationshipseam follow-up. Adds threetier-1, in-transaction, bare-mnesia read primitives to
graphdb_classso that
add_relationship(PR 2) and a futuremutate/1can compose alltheir class reads into a single enclosing Mnesia transaction:
get_template_in_txn/1{ok, #node{}} | {error, not_a_template | not_found}class_in_ancestry_in_txn/2boolean()default_template_in_txn/1{ok, Nref} | not_foundEach returns results identical to its existing gen_server twin
(
do_get_template/1,do_class_in_ancestry/2,default_template/1) but usesbare
mnesia:readand assumes it already runs inside an Mnesia activity.The honest framing
add_relationshipis read-read-read-read-write today — only the lastphase writes — so there is no partial-write bug. Collapsing it (PR 2)
buys TOCTOU isolation and unblocks
mutate/1; the real deliverable shared byboth follow-ups is this primitive library.
Key design decision — add, don't rewrap
The gen_server reads stay untouched.
get_template/class_in_ancestrykeep their
dirty_reads, which are load-bearing forgraphdb_rules:default_conflict_resolver/0deadlock-safety (it runs outsideany transaction during
plan_composition_firing). The new primitives areseparate functions; the resulting near-verbatim duplication of the ancestry
walk is the intended, explicitly-chosen design.
This PR is purely additive: no existing function body,
handle_callclause, or existing test changed.
Tests
+10 CT cases in
graphdb_class_SUITE(3 + 4 + 3), each invoked inside agraphdb_mgr:transaction/1, mirroring the existing gen_server-twin assertions.Full suite: 444 CT + 105 EUnit = 549, all green, zero warnings.
Docs
docs/designs/atomic-add-relationship-primitives-design.mddocs/superpowers/plans/2026-06-20-tier1-class-read-primitives.mdapps/graphdb/CLAUDE.mdgraphdb_class API +TASKS.mdfollow-up updated.🤖 Generated with Claude Code