Skip to content

Run governance rules to a fixed point in the reasoner worker (RULES step) - #5

Merged
harshach merged 3 commits into
release/6.2.0from
openmetadata/governance-rules-step
Nov 10, 2026
Merged

harshach merged 3 commits into
release/6.2.0from
openmetadata/governance-rules-step

Conversation

@harshach

@harshach harshach commented Oct 15, 2026 •

Copy link
Copy Markdown

Phase 5 of OpenMetadata's reasoning inside the Fuseki image design, worker side: a RULES step that runs OpenMetadata's governance CONSTRUCT bundles to a fixed point over a working TDB2 dataset. No job plan runs it yet; the REFRESH slice (capture → LOAD → CLASSIFY → RULES → COMPACT) wires it in. It runs today through bin/reasoner run with a step file.

Included

  • Validation (RuleCompiler) on Jena algebra, independent of OpenMetadata: the same monotonic, finite subset as OpenMetadata's FixedPointRuleCheck (no OPTIONAL, MINUS, NOT EXISTS, BOUND, EXISTS outside a top-level FILTER conjunct, nondeterministic functions, subqueries, aggregates, SERVICE, blank nodes in templates, template variables bound only by BIND). Stricter at this trust boundary: GRAPH/FROM/FROM NAMED refused (rules read the selected union), only SPARQL built-ins, fn: and XSD casts callable (extension and property functions off, since java:/apf: run code), and size bounds. One bad rule rejects the bundle as INVALID_RULES with every problem listed.
  • Semi-naive evaluation. Pass 1 evaluates every rule; each later pass builds, per triple-pattern atom whose predicate is a variable or in the previous delta, a variant where that atom ranges over the delta graph and is evaluated first, dropping UNION branches without it. Rules whose property paths or EXISTS read a delta predicate are evaluated in full for that pass. SemiNaiveAgreementTest checks the result against naive iteration on random graphs.
  • Execution. Each pass evaluates in one read transaction and spools solutions to a bounded file, then applies them in write transactions of up to 500k; TDB2 deduplicates and genuinely new facts form the next delta. No in-memory candidate set, no read-to-write upgrades. Every run first empties its output, provenance and delta graphs, so it recomputes from assertions and never seeds from earlier conclusions.
  • Witnesses. One supporting witness per derived fact (rule, pass, one quad per bound variable) in a provenance graph; a converged run records the graphs read and each rule's body and digest. Explanations.explain returns a fact as ASSERTED, DERIVED or ABSENT, with premises explained recursively, property-path premises rebuilt as a shortest chain, EXISTS answered with one match, and every cut marked truncated.
  • Limits: maxRules 256, maxRulePatterns 64, maxPasses 64, maxNewFacts 10,000,000, maxSpoolBytes 4 GiB — fixed, since heap does not grow with facts (276k triples → 158k facts at 27 MiB peak after GC; 552k → 317k at 43 MiB).
  • Budget outcomes: new exit status 6 for INCOMPLETE budgets (PASS_BUDGET, FACT_BUDGET, SPOOL_BUDGET); the launcher and WorkerStage map it to LIMIT_EXCEEDED with the limit as subject. A step that does not converge writes no run record.

Tests

  • Reasoner mvn -B -ntp verify: 173 unit + 7 integration tests. RulesStepTest ports OpenMetadata's starter rules (unchanged copies in reasoner/src/test/resources/rules/): schema tag → table → column, table domain → columns, two-hop PII through lineage from an inherited tag; a three-rule chain gives the same facts and pass count in all 6 orders; symmetric and mutually deriving rules terminate; deleting a premise and recomputing retracts a lineage cycle while a column with a second support keeps its tag; each budget ends INCOMPLETE and cleans up. WorkerProcessIT runs the starter bundle through the real launcher, plus a 275,893-triple lineage catalog at 512m heap (157,805 facts, 8 passes, ~25 s locally; asserts < 120 s and < 256 MiB).
  • Extension mvn -B -ntp verify: 240 unit + 11 integration tests.

Not yet

The REFRESH job plan and the module's admission check with RuleCompiler; an EXPLAIN step for governance facts; a RULES case in the image smoke test. After an INCOMPLETE run the output graphs are partial; only the missing run record marks the dataset as unpublishable, which the snapshot slice enforces.

Seen while testing: TimeBudgetTest.anExplanationEndsIncompleteAtItsDeadline hung once under heavy machine load in HermiT Reasoner.isEntailed, which ignored the interrupt (pre-existing; passed on rerun and on the base commit). A follow-up should give HermiT an individualTaskTimeout from the remaining budget or call Reasoner.interrupt() from the watchdog.

Semi-naive evaluation over selected graphs of the working dataset, with solutions spooled to a bounded file, conclusions applied in large write transactions, one witness per derived fact in a provenance graph, an explanation API with path reconstruction, and admission limits for rules, passes, new facts and spool. OpenMetadata's starter rules are test fixtures.
@harshach
harshach merged commit 5dfc54f into release/6.2.0 Nov 10, 2026
3 checks passed
harshach added a commit that referenced this pull request Nov 10, 2026
Brings in the RULES step (#5), protocol gaps (#4), the Guava bump (#14) and
the image fixes (#9-#12). Conflicts kept both sides: the direct-buffer cap
beside the core-dump flag in the entrypoint, the measured CLASSIFY envelope
beside the RULES limits in the README, and both import sets in Limits.
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