8000 GitHub - project-minigraf/minigraf-java: JVM binding for Minigraf — bi-temporal graph database · GitHub
[go: up one dir, main page]

Skip to content

About

JVM binding for Minigraf — bi-temporal graph database

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

73 Commits

Folders and files

Repository files navigation

minigraf-java

Java and Kotlin bindings for Minigraf. Run bi-temporal Datalog queries in an embedded, single-file graph database.

Installation

This guide uses the 3.x API. For a working 2.x install and imports, follow the stable guide.

The 3.x examples require the exact version shown below in Maven Central. If it is not published yet, use the stable guide instead.

Gradle (Kotlin DSL)

dependencies {
    implementation("io.github.project-minigraf:minigraf-jvm:3.0.0-alpha")
}

Maven

<dependency>
    <groupId>io.github.project-minigraf</groupId>
    <artifactId>minigraf-jvm</artifactId>
    <version>3.0.0-alpha</version>
</dependency>

Quick start

import io.github.project_minigraf.minigraf.MiniGrafDb

val db = MiniGrafDb.openInMemory()
val result = db.execute("""(transact [[:alice :name "Alice"]])""")
println(result)  // {"transacted":<tx id>}

From Java, use io.github.project_minigraf.minigraf.Minigraf.openInMemory() / Minigraf.open(path). See java/README.md for supported platforms and Java usage.

Incoming references (v3)

Inside a write transaction, incomingRefs(target, maxLinks, maxRecords) returns a typed IncomingRefs.Complete or IncomingRefs.Exhausted:

db.beginWrite().use { tx ->
    when (val result = tx.incomingRefs("82958a33-8334-5ef8-ae38-de39ce3fab69", 100, 10_000)) {
        is IncomingRefs.Complete -> {
            for (link in result.links) println("${link.source} ${link.attribute}
7C0E
")
            // Discovery is complete; stage any deletes here, then commit.
        }
        is IncomingRefs.Exhausted -> {
            println("Budget ${result.budget} exhausted after ${result.recordsExamined} records")
            // Retry with larger budgets or abandon the delete.
        }
    }
}

Import io.github.project_minigraf.minigraf.IncomingRefs for this example. maxLinks limits the number of distinct (source, attribute) pairs. maxRecords limits how many stored fact versions the lookup examines across storage layers, including superseded and retracted versions. Both take nonnegative Long counts, and zero is a valid limit. Each outcome reports recordsExamined. Require Complete before deleting. A Complete result can contain no links; Exhausted never returns a partial list.

The lookup sees earlier writes in this transaction without changing them. It returns only stored scalar Ref values, excluding Keywords, Strings, set members and rule-derived facts. Valid time is ignored, so future-dated and expired assertions are included; the newest assertion or retraction decides whether a link is live. Source UUID strings are canonical, attributes are strings, and result order is unspecified. See Java usage and errors.

Building from source

Requires Rust stable toolchain and JDK 17.

cargo build --release
cd java
./gradlew generateKotlinBindings copyLocalNative test

Cascade release

The core cascade sends core-release with client_payload.version set to a full tag such as v3.0.0-alpha or v2.0.13. After the branch move, the default-branch workflow selects main for 3.x and the existing v2.x for 2.x, and updates only that branch. If the branch is missing or the version is unsupported, the workflow stops. Run production retries from the default branch so they use its workflow definition.

The workflow pins the exact crates.io version, keeps the dependency's features, and checks the locked dependency graph before building. It tests the source branch, seven native libraries, reproducible JAR and six consumer environments (including Alpine) before creating the immutable tag. Maven keeps the full SemVer spelling: io.github.project-minigraf:minigraf-jvm:3.0.0-alpha, with JNA 5.14.0 unchanged. The 3.x generated bindings use io.github.project_minigraf.minigraf; 2.x uses uniffi.minigraf_ffi. The workflow sets the install versions in both READMEs for the selected release line. Each consumer verifies that it resolved the selected Maven version, then runs that line's contract tests.

Retry with gh workflow run release.yml --ref main -f version=<full-tag>. Never delete or move a release tag. The retry verifies the original tested artifacts and the records of that run, which are kept for 90 days. It compares public Maven files and checksums. If every public file matches exactly, it skips the Portal, rebuild, and upload. If public files are missing or incomplete, the retry recognizes a matching pending or published Central deployment and does not submit it again.

Java and Android share a Portal namespace. The retry rechecks unindexed deployments up to 20 times, 15 seconds apart plus request time. It ignores a deployment only after identifying it as a different Maven coordinate. If a deployment is still unidentified after those checks, the retry stops and prints its ID, even if it vanished from later responses. Check Central Portal and retry later. A Portal API error stops the retry immediately; it does not mean a deployment is missing.

Missing run records or conflicting bytes also stop the retry. Any rebuild must match the original checksums, including for the unsigned files in the final signed bundle. Every successful retry ends with a consumer test of the exact version from Maven Central. Failures are still reported as release-broken.

When public files are missing or incomplete, a matching FAILED deployment stops recovery with its ID before downloading deployment files. Inspect that deployment's validation errors in Central Portal and preserve its files if requesting Sonatype support. Automation never drops it or resubmits it. An operator may remove only the confirmed failed, unpublished deployment after resolving its cause, following Sonatype's recovery guidance, then retry the same tag using the retained tested artifacts. Never remove public artifacts or change the tested unsigned bytes to force recovery; a required byte change needs a separately tested release. An identified FAILED deployment for the other artifact is ignored. A user-managed VALIDATED deployment may still need its original manual publish action.

Run rehearsals from main with rehearsal=true. For 3.x, use version=v3.0.0-alpha and candidate=<full-core-SHA>. For 2.x, use version=v2.0.12 without a candidate. Leave source_alias unset on both lines; it was for rehearsals before the branch move.

Each rehearsal prepares a new source commit, saves it in a Git bundle, and records the workflow and source commits, the dependency, artifact checksums, and consumer test results. It does not push refs, tag, publish, or file issues. For 3.x, the record identifies the candidate as a Git dependency and gives its actual crate version. It does not claim to use a published alpha crate.

License

MIT OR Apache-2.0

About

JVM binding for Minigraf — bi-temporal graph database

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0