Skip to content

Expose explicit write transactions across all supported language bindings #824

Closed

Description

@adityamukho

Request

Expose explicit write transactions across all supported Minigraf language bindings, with behavior matching the Rust API: begin a transaction, run multiple reads and writes against its staged state, then commit or roll back.

The immediate consumer is ldbc-benchmarks. FinBench conditional read-write operations need tentative writes, reads that see those writes, and a conditional commit or abort within one operation. Separate auto-committed execute() calls cannot preserve that boundary. The benchmark will continue with a narrow JNI bridge to complete Rust operations for now; the official bindings should eventually make that workaround unnecessary.

Verified current state

Source inspection on 2026-11-03, using the immutable development revisions below. This is a binding API gap, not a claim that Minigraf lacks transactions or that every single-statement write is non-atomic.

Binding Revision / source Observation
Python ade0eead exported API Ordinary execute/query and other handles, but no exposed begin / transaction-local execute / commit / rollback handle.
Java/JVM 68de43c6 exported API Ordinary execute/query and other handles, but no exposed begin / transaction-local execute / commit / rollback handle.
Android (Kotlin/Java) 110a9dc5 exported API Ordinary execute/query and other handles, but no exposed begin / transaction-local execute / commit / rollback handle.
Swift (iOS/macOS) 4f2b296d exported API Ordinary execute/query and other handles, but no exposed begin / transaction-local execute / commit / rollback handle.
Node.js 823cf3a8 exported API Ordinary execute/query and other handles, but no exposed begin / transaction-local execute / commit / rollback handle.
C / FFI 22e4a852 exported API Ordinary execute/query and other handles, but no exposed begin / transaction-local execute / commit / rollback handle.
Browser WASM Core BrowserDb at d1d006b2 Exposes individual asynchronous execute() writes and query/prepared cursors, but no explicit multi-call transaction API.

WASI is currently packaged as the REPL, not an embeddable database library. Include an explicit design decision for transaction control on that supported target instead of treating it as the same API as browser WASM or claiming it already has a library transaction handle.

The Java v3 branch is still 68de43c6, and its Cargo.toml pins core 02243f1656eedd987611a9babdfee4a8c6e22b6b. Core and binding revisions must be tracked separately. The benchmark's compatibility analysis records why transaction-local execution is needed.

Expected contract

  • Begin an explicit write transaction through each binding's normal public API.
  • Execute multiple transact/retract/query statements within that transaction. Queries must see tentative writes; ordinary database or prepared-query calls must not silently be mistaken for transaction-local calls.
  • Commit all staged fact changes atomically, or explicitly roll them back.
  • Make cleanup safe when callers abandon a transaction, throw an exception, close the database, or try to use a completed handle. Document ownership, thread affinity, concurrent access, and nested-transaction behavior.
  • Preserve core error codes and durability semantics. Document browser persistence differences rather than promising native WAL behavior there.
  • Keep scope aligned with the core's existing behavior. For example, Rust currently registers rules immediately in the shared registry; do not imply that rule registration is rolled back with staged facts.

Exact language-specific API shape can follow each binding's conventions (handle, context manager, scoped callback, or equivalent), provided callers can make a decision after reading tentative state. A batch of independent auto-committed statements is not sufficient.

Completion criteria

  • Cover Python, Java/JVM, Android, Swift, Node.js, C, and browser WASM; record and implement the chosen transaction-control contract for WASI.
  • Add binding-level tests for multi-statement commit, read-your-own-writes, explicit rollback, exception/abandonment cleanup, errors, and invalid/reused transaction handles.
  • Test concurrent access and handle lifetimes so the binding cannot bypass the core's locking rules or leave locks held.
  • For persistent targets, verify committed changes survive close/reopen and rolled-back changes do not.
  • Publish usage examples and update API/support documentation, package declarations, and release artifacts.
  • Record binding and embedded-core versions so downstream consumers can select and validate a transaction-capable build.

Related cross-binding API work: #462 (query cursors), #465 (open options), #467 (log writer).

Activity

  1. added this to the v3.0.0 milestone on Nov 3, 2026
  2. added a commit that references this issue on Nov 11, 2026
  3. adityamukho commented on Nov 11, 2026

    @adityamukho
    CollaboratorAuthor

    Done on v3. Explicit write transactions in every binding, built on core's new OwnedWriteTransaction (Send + 'static) and, in the browser, BrowserDb.beginWrite(). WASI stays auto-commit per REPL command.

    PR Merged as Core pinned First version with transactions
    minigraf#885 (core) 32d71ce0 — v3.0.0
    minigraf-binding-template#13 52b9312a 32d71ce0 (template)
    minigraf-python#21 4678be9b 32d71ce0 release built on core v3.0.0
    minigraf-java#26 6db20787 32d71ce0 release built on core v3.0.0
    minigraf-android#19 eae34ff6 32d71ce0 release built on core v3.0.0
    minigraf-swift#20 13131572 32d71ce0 release built on core v3.0.0
    minigraf-node#25 971d4a11 32d71ce0 release built on core v3.0.0
    minigraf-c#18 9e072383 32d71ce0 release built on core v3.0.0
    minigraf-wasm#25 7a382315 32d71ce0 release built on core v3.0.0
    minigraf-docs#96 (squash, main) — docs @since v3.0.0

    Design: docs/superpowers/specs/2026-11-10-824-binding-transactions-design.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions