Skip to content

Transaction-seam retrofit: route all mnesia:transaction sites through transaction/1#43

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

Transaction-seam retrofit: route all mnesia:transaction sites through transaction/1#43
david-w-t merged 12 commits into
davidwt-com:mainfrom
david-w-t:develop

Conversation

@david-w-t

Copy link
Copy Markdown
Contributor

What

First tracked follow-up of the transaction-layering seam (PR #41): retrofit every hand-rolled mnesia:transaction call site in the graphdb app onto the seam convention, making graphdb_mgr:transaction/1 the single place that pattern-matches {atomic,_}/{aborted,_}.

Full sweep — 40 sites across the six workers + the bootstrap loader:
graphdb_mgr (4) · graphdb_bootstrap (2) · graphdb_attr (9) · graphdb_class (8) · graphdb_language (7) · graphdb_rules (3) · graphdb_instance (7).

How

Each site's transaction fun is a tier-1 primitive (bare mnesia ops; rollback-worthy failures via mnesia:abort(ExactReason)); the wrapper calls transaction/1 and projects {ok,Value} to the site's existing public shape, reproducing its existing failure contract. Because transaction/1's {aborted,Reason} -> {error,Reason} mapping is byte-identical to the inline mapping, fun-internal aborts/throws are preserved automatically.

Four behaviour-preservation traps handled explicitly:

  1. Non-uniform failure propagation — return {error,R}, throw({error,R}), and {reply,{error,R},State} all preserved at their sites.
  2. {atomic,{error,_}=E} -> E (graphdb_class) kept as a returned, committed value — NOT converted to an abort (preserves no-rollback semantics).
  3. Abort-swallow → not_found (graphdb_class:do_find_template_by_name, graphdb_instance:resolve_from_connected) preserved.
  4. Abort-relocation (graphdb_instance:validate_arc_endpoints) uses byte-identical Reason terms for every arm.

Scope

Behaviour-preserving refactor only. Out of scope (tracked separately in TASKS.md):

  • Atomic add_relationship — needs graphdb_class tier-1 in-txn read primitives (its reads are gen_server:call today).
  • Batch mutate([Mutation]) — the tier-3 entry point.

Testing

  • Single mapping point verified: grep -rn "mnesia:transaction" apps/graphdb/src/ returns only transaction/1's own definition.
  • Clean compile, zero warnings.
  • 434 CT + 105 EUnit = 539 green (537 prior + 2 new graphdb_instance CT cases covering the previously-untested characterization_not_found / reciprocal_not_found arms). Existing tests unchanged — the only test-file change is additions.

Design: docs/designs/transaction-seam-retrofit-design.md
Plan: docs/superpowers/plans/2026-06-20-transaction-seam-retrofit.md

🤖 Generated with Claude Code

david-w-t and others added 12 commits June 18, 2026 06:18
The seam shipped in PR davidwt-com#41 (81b2962); the heading still read "IN DESIGN".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWukKCbrN8GybaScJGU2kF
Brainstormed spec for the first tracked Transaction-layering seam
follow-up: route every hand-rolled mnesia:transaction site (40 across
the six graphdb workers + bootstrap) through graphdb_mgr:transaction/1.
Behaviour-preserving; documents the conversion taxonomy, four
behaviour-preservation traps, the full per-site inventory, and the
two-part testing standard (existing 537 are the oracle; new/reshaped
paths get new tests). Atomic add_relationship and batch mutate/1
remain separate slices.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…n TASKS.md

Inserts the out-of-scope Atomic add_relationship item between the
retrofit and batch-mutate follow-ups under the Transaction-layering seam
section, and links the retrofit design doc on the retrofit bullet.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Task-by-task plan (7 tasks, one per worker module + final verification)
to route all 40 mnesia:transaction sites through graphdb_mgr:transaction/1.
Per-site before/after code, the four behaviour-preservation traps flagged
at their sites, and the only 2 new tests (instance abort-relocation arms:
characterization_not_found / reciprocal_not_found). Behaviour-preserving:
existing 537 are the oracle, zero expectation edits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@david-w-t david-w-t left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@david-w-t david-w-t merged commit 6d48d80 into davidwt-com:main Jun 20, 2026
1 check 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