Repository navigation
Add the reasoner worker, launcher and memory budget to the Fuseki image - #1
Merged
Merged
Conversation
A standalone Maven project, openmetadata/fuseki/reasoner, for the batch program that the Fuseki extension will launch as a separate JVM, one step at a time. It never runs inside the Fuseki JVM, opens only its job's private TDB2 dataset, has no network listener and fetches nothing. Each step is a JSON step file in a job directory; every path it names must stay inside that directory. The worker writes a result manifest atomically next to it and exits with an explicit status: 0 completed, 1 internal error, 2 invalid step, 3 out of memory (reserved for -XX:+ExitOnOutOfMemoryError), 4 input rejected, 5 time budget. Steps: - LOAD bulk-loads N-Quads or TriG into a fresh dataset with the phased loader. - CLASSIFY exports one import closure in a read transaction, resolves owl:imports only against the closure's own graphs, parses it with OWL API, rejects anything outside OWL 2 DL or the admission limits, routes it, and writes the finite named entailments into an output graph: direct subclasses, equivalences, unsatisfiable classes, direct types and, with HermiT, property values and equalities. It also answers entailment checks: ENTAILED, NOT_ENTAILED (never a proven negation), INCONSISTENT or INVALID. - EXPLAIN computes one justification with OWL API's black-box explanation over HermiT. - COMPACT compacts the dataset before publication. Routing sends a closure to ELK only when it is in OWL 2 EL and uses nothing ELK 0.6.0 reports as incomplete, and falls back to HermiT if ELK still reports incompleteness. HermiT runs with an explicit configuration, with disjunction learning off. Jena is provided by fuseki-server.jar, and libraries it already bundles at newer versions are excluded rather than shadowed, as are Woodstox, the StAX API, commons-logging and the OWL API's RDF4J, JSON-LD and HTTP modules.
Fifty fixtures, each a TriG input, a CLASSIFY step file, optional entailment checks in OWL functional syntax, and an expected canonical report derived by hand from the OWL 2 Direct Semantics. They cover every construct in the design's coverage table, combinations, local imports (including import by version IRI, a missing import and two contexts that share IRIs without leaking conclusions), inconsistency, open-world counterexamples where a statement and its negation are both NOT_ENTAILED, and closures outside OWL 2 DL that must be rejected rather than classified. routing.expected names the engine production routing must pick. Every fixture routed to ELK runs through both ELK and HermiT with identical reports, and every OWL 2 EL fixture that ELK would answer incompletely is refused when ELK is forced.
The extension now holds the launcher the Fuseki module will use to run worker steps, with JDK and Jena classes only. Readiness reads the container limit from cgroup v2 memory.max, else cgroup v1, else physical memory, and requires limit >= (H_f + O_f + H_w + O_w + C_min) / 0.9. Before every step it also reads the container's anonymous memory, and refuses to launch when Fuseki's has outgrown H_f + O_f. When the budget does not fit it reports NOT_READY with the required and available bytes and admits nothing. The launcher runs the worker with its own flags, never the server's: choom -n 1000, nice and ionice, a fixed heap, capped metaspace, code cache and direct memory, -XX:+ExitOnOutOfMemoryError, a processor count and fuseki-server.jar first on the classpath. It holds a file lock so one worker runs per container, terminates a worker that outlives its own deadline (SIGTERM, then SIGKILL) and maps exit statuses to SUCCEEDED, FAILED, INCOMPLETE or INTERRUPTED in a status file next to the step. A second Fuseki module logs readiness at startup when reasoning is enabled and does nothing otherwise. ReasonerCli exposes readiness and step runs to operators and the image tests.
A new builder stage, run on the build platform like the extension's, builds HermiT from open-metadata/hermit-reasoner at a pinned commit and then the worker. The build fails unless the fuseki-server.jar Maven compiled against is byte for byte the one the image ships, and unless every third-party jar matches dependencies.sha256. The worker and its 32 dependency jars go to /jena-fuseki/reasoner, in the image and never on the volume, with the HermiT source jar, NOTICE, THIRD-PARTY.md, the licence texts and bin/reasoner, the launcher's command line. The image grows by about 15 MB.
OPENMETADATA_REASONING_ENABLED, OPENMETADATA_REASONER_HEAP, _OFF_HEAP, _PAGE_CACHE_FLOOR and _CPUS are checked whenever they are set, and an invalid value stops the container with an ERROR naming the variable. Reasoning needs the extension, whose module launches the worker. With the variables unset nothing changes.
OWL API's black-box explanation expands from the signature of the class it explains, and owl:Thing has none, so it returned an empty justification for an inconsistent closure. EXPLAIN now finds a minimal inconsistent subset with QuickXplain over HermiT consistency checks, each interruptible by the step's deadline; entailments keep the black-box generator. An import smuggled into a checks file or an explanation target surfaced as an unchecked OWL API exception, reported as an internal error. It is now rejected as IMPORT_NOT_ALLOWED, still without any fetch.
- StepContractTest: invalid step files, paths that leave the job directory (including through a symbolic link), loads that need a fresh dataset and quads, admission limits that reject rather than truncate, and checks about unknown entities answered INVALID. - NoNetworkTest: an HTTP server on localhost serves every IRI the inputs name and must receive no request, whether an import is missing, resolvable inside the closure, or smuggled into checks or an explanation target. - TimeBudgetTest: a generated closure HermiT cannot classify in minutes ends INCOMPLETE at its deadline, with the interrupt latency recorded. - ExplainStepTest and EntailmentGraphTest: one justification per target, and the persisted hierarchy answering the design's discovery query after compaction. - WorkerProcessIT, in the integration-test phase: the packaged worker on fuseki-server.jar plus target/reasoner/* with the launcher's JVM flags, exit status 3 on heap exhaustion and 5 at its deadline, and the shipped jars exactly the pinned ones, each listed in THIRD-PARTY.md.
A job directory the server's uid cannot write made the command line fail with a stack trace and print nothing. The launcher now logs the failed write and still returns the outcome.
The smoke test now covers the reasoner through the image's real launcher, command line and classpath: - Settings: reasoning is off by default and every OPENMETADATA_REASONER_* variable fails fast on an invalid value; reasoning without the extension is refused. - Readiness: a 1 GiB container logs and reports NOT_READY with required and available bytes, refuses a step and starts no worker, and Fuseki serves as usual. - Conformance: in a container whose --memory is exactly the budget's minimum, every conformance fixture's report matches, each answered fixture is routed to its expected engine, and every ELK-routed fixture gives the identical report through HermiT. - Containment: with 1,000 serving triples seeded, a worker exhausting a 48m heap ends INCOMPLETE with exit status 3, a classification past its 5 s budget ends INCOMPLETE, a stopped worker is killed after its deadline, and a worker killed with SIGKILL during a bulk load ends INTERRUPTED without a result manifest. Fuseki answers queries throughout, and after each case it is the same process, was never OOM killed, keeps its heap, serves the same data and still commits writes. hard-ontology.awk generates the 58 KB closure HermiT cannot classify in minutes, byte for byte the same as the reasoner tests' generator. The smoke test now needs jq.
Before the image build, install OpenMetadata's HermiT build from the commit the Dockerfile pins, then run mvn -B -ntp verify for the reasoner: its unit and conformance tests and the integration tests of the packaged worker. Publishing is unchanged.
A Reasoner section in the README: what runs where, the engines and the routing between them, HermiT's configuration and the measurements behind turning disjunction learning off, the step contract and outcomes, the memory-budget formula with a worked example, what readiness reports and where, the launch command, licences and the HermiT source, and how to build and test the reasoner. The environment variable table and the layout list the new variables and directories.
harshach
marked this pull request as ready for review
October 10, 2026 15:28
Classification asked HermiT for the values of every object property of every named individual, and routed every closure with an object property assertion to HermiT. Most catalog properties only ever have their asserted values. PropertyValues now finds the properties that can gain values (sub-, equivalent and inverse properties, chains, symmetry and transitivity, reflexivity, has-value and has-self) and the constructs that defeat a per-property analysis, which fall back to asking about every property. Asserted values are read from the closure and moved across equal individuals; a closure in OWL 2 EL whose values are all asserted stays with ELK. The output is unchanged: every conformance report and routing is the same, and a differential test compares the values with HermiT's for every property on every answered fixture and on closures that reach named individuals through anonymous ones. On a catalog-shaped closure of 20,000 individuals and 30 properties, classification takes 16 s instead of 44 s.
A classification held its facts in a TreeSet, then copied them into report lines, a sorted report, an immutable copy, a list of triples and a StringBuilder, and counted each kind by streaming the set again. Facts now go to the output graph as the classifier finds them, inside one write transaction that commits only when the step completes, so a failed step still leaves the graph's previous contents. Each pair is recorded once, from its first member in IRI order, so nothing needs deduplicating; counts are kept as facts arrive. The opt-in report, which repeats the output graph, keeps only its first 100,000 lines in order and says how many it left out, and is written to disk as a stream. Sorting it is all that determinism requires; the output graph is a set.
The default limits (2M closure triples, 500k axioms, 5M output triples) were far beyond what the 2 GiB default worker heap holds. The limits that bound the heap now default to a size per GiB of it, measured on a catalog-shaped closure: 300k triples, 200k axioms, 50k individuals and 1M output triples with a 2 GiB heap. The manifest records the limits a step ran with. Limits accepted fractions and silently truncated them. Every integer in a step file is now parsed exactly; fractions and values outside a long are invalid. EXPLAIN ran one fresh HermiT per consistency check with only the step's deadline to stop it. maxExplainChecks (default 1,000) bounds the checks of both the black-box explanation and QuickXplain, and is reported as LIMIT_EXCEEDED. QuickXplain reuses one ontology manager instead of one per check, and returns an empty subset for a closure without logical axioms instead of recursing without end.
ClosureDocument kept the exported file's path and exposed it and the triple count through accessors nothing called. Engine.workerVersion() was never used; the manifest's worker section now carries it, next to the Java version and heap figures.
- cancel() set a flag that was never cleared, so every later step on the same launcher ended CANCELLED. A cancellation now belongs to the step running when it is made, gets SIGTERM at once and SIGKILL after the grace period, as its javadoc said, and the termination latency is measured from it instead of being reported as 0. - An interrupted caller killed the worker and released the worker lock without waiting for it to exit; it now waits, uninterruptibly and for a bounded time, so two workers never overlap. - The worker inherited the server's whole environment, ADMIN_PASSWORD included. It now gets only PATH, the locale, TZ and HOME. - The lock is taken before the memory budget is checked, so a step requested while a worker runs is BUSY, not NOT_READY because of the running worker's memory. BUSY writes no status file, since the running step may be the same file, and nothing is written next to a step file outside the reasoning root. - A step that does not succeed has its exported closure and *.tmp files removed; a stale status file is removed before the worker starts. - Exit statuses come from WorkerExitCodes, which mirrors the worker's ExitCodes (this module cannot see them). A SIGKILL the launcher did not send is reported INCOMPLETE MEMORY_BUDGET, the cgroup OOM killer. - The step log keeps the first and last 512 KiB of the worker's output. - timeoutMillis is read with the worker's rules: the 1 MiB step file cap and exact integers, so 1000.5 is refused rather than truncated.
…extension The entrypoint treated an empty variable as unset, but ReasoningSettings used containsKey and then failed to parse the empty string, so a container started fine and docker exec bin/reasoner refused to run. The two also disagreed on digit limits (CPUs unbounded in the shell, six digits in Java; sizes 13 and 16 digits), and a 13-digit size with a t suffix overflowed bash arithmetic into a negative number. Java now treats an empty value as unset; both cap sizes at 13 digits and a byte count that fits a signed 64-bit integer, and CPU counts at six digits. The entrypoint's validation is a function, and sourcing the script defines its functions without running it. test/reasoning-settings.cases lists values and verdicts that ReasoningSettingsParityTest runs through both the entrypoint (with bash 4 or later, as in the image) and ReasoningSettings.
WorkerProcessIT copied the launcher's JVM flags, so a change to the launch command could break the image without failing a test. The reasoner's test build now compiles the extension's launcher sources (build-helper add-test-source; nothing changes in either jar), and the integration tests lay out the image's directories and start the packaged worker with WorkerLauncher itself: its command, environment allowlist, priority commands where the platform has them, and outcome mapping. They also check that a worker out of heap or past its deadline leaves no exported closure, and that the manifest carries the worker's version. LauncherContractTest compiles WorkerExitCodes next to the worker's ExitCodes and requires them equal, and runs step ids, deadlines and an oversized file through both StepFile and the launcher's StepHeader, which must agree. A scale test classifies a catalog-shaped closure (20,000 individuals, 30 object properties, a transitive hierarchy and its inverse, routed to HermiT) in the default 2 GiB heap under the default limits, and bounds its time and heap. It took 44 s and peaked at 0.28 GiB after collection before this branch's classifier changes; it now takes about 16 s and 0.27 GiB. At 40,000 individuals: 90 s before, 34 s after.
ELK 0.6.0 reports a property range together with assertions as possibly incomplete. Before this branch every closure with an assertion went to HermiT, so the README's claim that such closures never reach ELK held without a check; now that asserted values stay on ELK, the router lists the combination as an ELK gap. A new fixture covers it, and forcing ELK on it is refused like the other gaps. ClassifierFallbackTest forces ELK on that closure and checks that the run-time incompleteness report makes HermiT classify it, and that only HermiT's facts are recorded.
The reasoner builder stage used the floating maven:3.9-eclipse-temurin-21 tag; it is pinned to the digest that tag resolves to today (3.9.16-eclipse-temurin-21). The HermiT comment named a branch and pull request that are now merged into master (0e2dbb2f); the pinned commit is unchanged and reachable from it. The smoke test now expects a worker SIGKILLed during a load to report INCOMPLETE MEMORY_BUDGET, and checks in the image that the worker's environment has no ADMIN_PASSWORD and that a step requested while a worker runs is BUSY.
This was referenced Oct 11, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 of OpenMetadata's reasoning inside the Fuseki image design: a reasoner worker that the Fuseki extension launches as a separate JVM inside the existing image, the launcher and its memory-budget check, and the image packaging. No new service, port or container. HTTP job operations come in a later PR; until then reasoning runs only through
/jena-fuseki/reasoner/bin/reasoner, and nothing launches a worker unlessOPENMETADATA_REASONING_ENABLED=trueand the extension is enabled.Included
openmetadata/fuseki/reasoner/: worker (org.openmetadata.reasoner.Main <step-file>) on OWL API 5.5.1, OpenMetadata's HermiT build (LGPL-3.0, built from pinned commitbb78447aof open-metadata/hermit-reasoner) and ELK 0.6.0; Jena is provided byfuseki-server.jar.WorkerLaunchertakes a per-container lock and then checks the memory budget (a concurrent step gets BUSY), passes only an allowlisted environment (noADMIN_PASSWORD), cancels only the running step (SIGTERM, then SIGKILL after the grace period), kills and waits for the worker if the caller is interrupted, removes leftovers after a failed step, keeps a bounded log, and reports a SIGKILL it did not send asINCOMPLETE MEMORY_BUDGET(probable cgroup OOM). PlusReadiness,ReasoningSettings,ReasoningModuleandbin/reasoner./jena-fuseki/reasoner/with NOTICE, THIRD-PARTY.md, licence texts and the HermiT sources; the build fails on any jar checksum drift.OPENMETADATA_REASONING_ENABLEDandOPENMETADATA_REASONER_{HEAP,OFF_HEAP,PAGE_CACHE_FLOOR,CPUS}with the same rules as the extension (one shared case table runs through both). Nothing changes when they are unset; an invalid value stops the container at startup.Test evidence
mvn verify: 127 unit + 7 integration tests.mvn verify: 152 unit + 5 integration tests, including 53 hand-derived conformance fixtures (ELK-routed fixtures cross-checked against HermiT), a differential test of property values against HermiT asked about every property, integration tests through the launcher's real command, and a catalog-shaped scale test.ADMIN_PASSWORDin the worker, and BUSY while a worker runs.Open decisions
:6.2.0tag: merging publishesopenmetadata/fuseki:6.2.0and:6.2.0-<sha>from a multi-arch build that is smoke-tested on amd64 only. Proposed follow-up workflow change: publish only6.2.0-<sha>, smoke-test the pushed digest on amd64 and arm64, then retag that digest as:6.2.0.