Skip to content

L5 + Task 7: rel_id_server for arc IDs; wire dictionary gen_servers#22

Merged
david-w-t merged 10 commits into
davidwt-com:mainfrom
david-w-t:develop
May 20, 2026
Merged

L5 + Task 7: rel_id_server for arc IDs; wire dictionary gen_servers#22
david-w-t merged 10 commits into
davidwt-com:mainfrom
david-w-t:develop

Conversation

@david-w-t
Copy link
Copy Markdown
Contributor

Summary

  • L5 — Relationship row ID namespace pollution fixed: rel_id_server, a new DETS-backed gen_server, now owns all #relationship{id} primary key allocation. Previously, arc row PKs were allocated from the global nref_server, consuming integers that could otherwise identify graph nodes. rel_id_server is wired as the first child of graphdb_sup (before graphdb_mgr) so bootstrap can call get_id/0 during startup. All 23 call sites across 5 files migrated from nref_server:get_nref/0 to rel_id_server:get_id/0. All 6 CT suites updated to start/stop rel_id_server in their test lifecycle. Bootstrap test assertions updated: nref floor is now >= 100002 (was 100078 — 76 arc IDs no longer consume nref slots); relationship IDs are now unique positive integers starting at 1.

  • Task 7 — Dictionary gen_servers wired: dictionary_server and term_server were gen_server stubs. Both now delegate to dictionary_imp via start_dictionary/stop_dictionary in init/terminate and forward all CRUD calls (create, read, update, delete, all, size). Also fixed a pre-existing bug in dictionary_imp:delete/2 — it passed {list_to_binary(Key)} (a 1-element tuple) instead of list_to_binary(Key) (a binary) as the ETS delete key, causing delete to silently no-op.

Test counts: 212 CT + 103 EUnit = 315, all green (was 297 in PR #21).

Test plan

  • ./rebar3 ct --dir apps/graphdb/test — 198 CT pass
  • ./rebar3 ct --dir apps/dictionary/test — 14 CT pass (7 per server)
  • ./rebar3 eunit --app=graphdb — 103 EUnit pass
  • ./rebar3 compile — zero warnings

🤖 Generated with Claude Code

david-w-t and others added 9 commits May 19, 2026 21:18
Separate allocator prevents arc PKs from consuming graph-visible nref
integers.  4 CT cases cover counter basics and DETS persistence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Must start before graphdb_mgr because bootstrap calls expand_relationship
which calls rel_id_server:get_id/0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Test suites that call graphdb_bootstrap:load(), graphdb_mgr:start_link(),
or other initialization that allocates relationship row IDs must start
rel_id_server first. Updated init_per_testcase/end_per_testcase in:
- graphdb_attr_SUITE
- graphdb_bootstrap_SUITE
- graphdb_class_SUITE
- graphdb_instance_SUITE
- graphdb_language_SUITE
- graphdb_mgr_SUITE

Also updated two test assertions in graphdb_bootstrap_SUITE that relied on
the old architecture where relationship IDs came from nref_server and had
to be >= 100000. With separate rel_id_server, IDs now start at 1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…elete bug

Both gen_servers init/terminate via start_dictionary/stop_dictionary and
forward CRUD calls to dictionary_imp.  Also fixed a pre-existing bug in
dictionary_imp:delete/2 (passed {BinKey} tuple instead of BinKey binary
to ets:delete, causing delete to silently no-op).  14 CT tests added.
L5 and Task 7 marked RESOLVED in TASKS.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread apps/graphdb/src/rel_id_server.erl
Relationship arcs are always written in directed pairs. A single
get_id_pair/0 call now allocates both IDs atomically, replacing two
sequential get_id/0 calls at every arc-write site across bootstrap,
attr, class, instance, and language modules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@david-w-t
Copy link
Copy Markdown
Contributor Author

Addressed: added get_id_pair/0 which allocates both IDs for a reciprocal arc pair in one atomic call. All 15 pair allocation sites across 5 modules migrated. 3 new CT tests added (returns integers, consecutive, no overlap with get_id/0). 304 tests green.

@david-w-t david-w-t merged commit 7629d41 into davidwt-com:main May 20, 2026
2 checks passed
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.

1 participant