Skip to content

Write-path transaction-layering seam (graphdb_mgr:transaction/1)#41

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

Write-path transaction-layering seam (graphdb_mgr:transaction/1)#41
david-w-t merged 3 commits into
davidwt-com:mainfrom
david-w-t:develop

Conversation

@david-w-t

Copy link
Copy Markdown
Contributor

Write-path transaction-layering seam

First piece of the write-path completion track. Adds the shared Mnesia
transaction boundary that the upcoming node/relationship mutation work
(delete_node, remove_relationship, a future batch mutate/1) all build
on, so those operations compose into one atomic transaction without nesting.

What's here

  • graphdb_mgr:transaction/1 — a plain exported helper that runs a fun
    inside one mnesia:transaction/1 and normalises the result:
    {atomic, R}{ok, R}, {aborted, Reason}{error, Reason}. It is a
    plain function (not a gen_server:call) because mnesia:transaction/1
    runs in the calling process — routing writes through the server would
    needlessly serialise them and risk deadlock.
  • The three-tier convention it anchors: tier-1 in-transaction primitives
    (signal failure via mnesia:abort/1, never open a transaction → compose);
    tier-2 single-op public wrappers (own one transaction); tier-3
    batch/composite (wrap one transaction, call tier-1 primitives directly →
    no nesting).
  • 4 CT cases proving the contract: commit + result passthrough, abort
    rollback, composition rollback (the property tier-3 relies on), and
    uncaught-crash passthrough.

This slice is the minimal seam only — no consumers, no retrofit of the
existing inline {atomic}/{aborted} mapping sites, no batch mutate/1.
Those are tracked follow-ups in TASKS.md. No existing behaviour changes.

Why now

graphdb_mgr already carries the tier-1 pattern in embryo
(expected_parents/1, expected_classes/1, verify_one/1,
rebuild_one/1 are documented "must run inside an active mnesia
transaction") and hand-rolls the {atomic}/{aborted} mapping inline in
do_get_relationships/2, verify_caches/0, and rebuild_caches/0. This
names the convention and factors that mapping into one helper.

Docs

  • Design: docs/designs/write-path-transaction-seam-design.md
  • Plan: docs/superpowers/plans/2026-06-17-write-path-transaction-seam.md
  • TASKS.md write-path section restructured into slices A–E.

Testing

graphdb_mgr_SUITE: 32/32 green (28 pre-existing + 4 new). Full tree
compiles clean, zero warnings. Suite totals: 419 CT + 105 EUnit = 524.

🤖 Generated with Claude Code

david-w-t and others added 3 commits June 17, 2026 08:03
Decompose write-path completion into 5 slices (A-E) in TASKS.md; split
slice A so a transaction-layering seam ships before delete_node. Add the
seam design and its single-task implementation plan.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds the shared Mnesia transaction-runner that normalises
{atomic,R}->{ok,R} / {aborted,R}->{error,R} and anchors the tier-1
primitive / tier-2 wrapper / tier-3 batch convention. First consumers
(delete_node, remove_relationship) land in later slices.

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

Adds transaction_crash_passes_through, closing the design doc section 4
contract row (uncaught crash -> {error, {Reason, Stack}}, rolled back) that
the three original cases left untested. Documents the scratch-nref band.
Final-review Minor follow-up.

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 81b2962 into davidwt-com:main Jun 17, 2026
1 check passed
david-w-t added a commit to david-w-t/SeerStoneGraphDb that referenced this pull request Jun 18, 2026
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
david-w-t added a commit that referenced this pull request Jun 20, 2026
… transaction/1 (#43)

* docs: mark transaction-layering seam IMPLEMENTED in TASKS.md

The seam shipped in PR #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

* docs: add transaction-seam retrofit design (seam follow-up 1)

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>

* docs: track atomic add_relationship follow-up; link retrofit design in 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>

* docs: add transaction-seam retrofit implementation plan

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>

* refactor(graphdb_mgr,bootstrap): route txn sites through transaction/1

* refactor(graphdb_attr): route txn sites through transaction/1

* refactor(graphdb_class): route txn sites through transaction/1

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWukKCbrN8GybaScJGU2kF

* refactor(graphdb_language): route txn sites through transaction/1

* refactor(graphdb_rules): route txn sites through transaction/1

* test(graphdb_instance): cover add_relationship missing char/reciprocal arms

* refactor(graphdb_instance): route txn sites through transaction/1

* docs: mark transaction-seam retrofit follow-up IMPLEMENTED in TASKS.md

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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