Oxilite already had a Datalog of its own — recursive rules that read RDF triples and can write their conclusions back as triples. Version 0.9 adds a second rule language beside it: Synalog, a Rust rewrite of Google’s Logica, built for AI agents. Same store, same quads, two very different jobs. Here’s how they differ, what Logica brings to the table, and a worked example of an agent that uses both to build itself a semantic layer over a knowledge graph.

oxilite 0.9.0 · Synalog dialect · github.com/Volland/oxilite · oxilitedb.com · MIT or Apache-2.0

The gap between “query the graph” and “reason about it”

SPARQL is good at asking a graph what it contains. It is bad at teaching a graph new concepts.

The only recursion SPARQL 1.1 offers is a property path: one predicate, a fixed regular expression, no way to join in another relation or filter partway through. “Everyone who reports, directly or indirectly, to Alice” is a property path. “Everyone who reports to Alice, through a chain that never crosses into a sanctioned subsidiary, weighted by how much budget they control” is not expressible — SPARQL has nowhere to put that rule.

Oxilite is Oxigraph‘s data model and SPARQL semantics, reimplemented on nothing but portable SQL on stock SQLite — so the same graph runs on a laptop, inside a mobile app, or on Cloudflare D1 at the edge. That part of the story is about where your graph runs. This article is about what happens once you want it to reason: to hold named, reusable concepts — “active customer,” “indirect supplier,” “over-budget” — instead of re-deriving them in every query, and to let something other than a human write those rules.

That something, increasingly, is an agent. And an agent has opinions a human query author doesn’t: it wants results in pages, it wants named arguments instead of positional ones it might get wrong, and when it does get something wrong it wants an error message it can read and act on, not a database exception. That last requirement turns out to be the interesting one.

Oxilite already answers half of this: Datalog

oxilite has shipped its own Datalog since 0.3 (oxilite-datalog). It reads and writes triples natively:

@prefix ex: <http://example.org/> .

ancestor(?x, ?y) :- ex:parent(?x, ?y).
ancestor(?x, ?z) :- ex:parent(?x, ?y), ancestor(?y, ?z).

?- ancestor(ex:ada, ?who).

ex:parent(?x, ?y) is the triple pattern ?x ex:parent ?y; ex:Person(?x) is ?x rdf:type ex:Person. Every relation, stored or derived, is a set of rows of the same tagged 64-bit term ids the rest of oxilite uses, so a derived predicate composes with a triple pattern with no conversion step. The compiler turns a non-recursive rule into a plain CTE, a linear recursive rule into one WITH RECURSIVE member, and the whole program into one SQL statement — one round trip, even against Cloudflare D1. Rules that can’t collapse to one statement (non-linear recursion) get iterated to a fixpoint instead, one request per round, so they still run on a backend that can’t hold a transaction open.

The part that matters for what comes next: what Datalog derives can be materialized — written into quads_inf, the same table OWL 2 RL reasoning already uses — so a rule’s conclusions become triples that SPARQL and Cypher see under include_inferred. Rules extend the reasoner; they don’t run beside it.

Datalog is about the graph. Its atoms are triple patterns, its answers are sets of RDF terms, and its natural home is inside the store, permanently, as more facts.

Synalog is a guest, and that’s the point

Synalog is a different animal: a Rust rewrite of Google’s Logica, built by Synalinks around one idea — give an agent a semantic layer it can write to. Instead of re-deriving “who is an active customer” in every query, the agent defines it once as a named concept, builds more concepts on top of it, and gets every rule checked by a verifier whose errors are written to be read by a model, not a human staring at a stack trace.

Credit where it’s due, because Synalog is upfront about it too: it’s maintained by Yoan Sallami and the Synalinks team, and it stands on Logica, the language Evgeny Skvortsov and Google’s Logica team designed and open-sourced first. The Rust parser, verifier and compiler are Synalinks’ own work; the language’s shape — named arguments, the compile-to-SQL model, the whole idea of a semantic layer an agent writes to — is Logica’s. Synalog’s own README says it plainly: it wouldn’t exist without it.

# @table parent <http://example.org/parent>
# @table age <http://example.org/age>

@Recursive(Ancestor, 10);
Ancestor(x:, y:) distinct :- parent(subject: x, object: y);
Ancestor(x:, y:) distinct :- Ancestor(x:, y: m), parent(subject: m, object: y);

AdultAncestor(x:, y:) distinct :- Ancestor(x:, y:), age(subject: x, object: a), a >= 18;

Notice what’s not here: no ?x sigil, no triple-pattern syntax. Arguments are named (x:, y:), tables are declared once up front, and recursion is bounded explicitly (@Recursive(Ancestor, 10)) rather than inferred from the rule shape. That’s Logica’s relational heritage showing through — it was built to compile to BigQuery, DuckDB, Postgres and friends, not to read triples.

oxilite runs it unchanged. oxilite-synalog takes Synalog’s own parser, verifier and compiler — untouched, default features off — and makes the triple store look like tables in front of them: # @table NAME <IRI> declares a table of one predicate’s triples, # @class NAME <IRI> declares one of a class’s instances, and a plain triples(subject, predicate, object, kind, datatype, lang, graph) table sits underneath for anything not declared. Those tables get injected as NOT MATERIALIZED CTEs in front of Synalog’s own SQL. Nothing is forked, nothing is schema — an upgrade to a newer Synalog is a version bump, not a merge conflict.

Why keep Logica’s shape instead of translating it

The design decision behind this (D42 in the project’s architecture notes) is worth spelling out, because it’s the reason Synalog is a second dialect rather than a rewrite of the first one:

  • Forking the compiler to emit term-id SQL directly would make Synalog a third dialect to maintain by hand, and cut it off from every upstream fix and from the agent skill Synalog ships with.

  • Lowering Synalog’s AST into oxilite’s own Datalog would silently change its semantics — Synalog’s recursion is unrolled to a bound with multiset results unless a rule says distinct, oxilite’s Datalog is fixpoint iteration with set semantics — and would chase an unstable internal format.

  • Persisted views were rejected outright: a view is a schema change (a migration, on D1), can’t follow a per-call choice of graph, inferred triples or as_of time-travel, and shows up in dumps of data nobody asked to store.

CTEs cost nothing when a program doesn’t reference them, decoding terms to real SQL values is what makes Synalog’s comparisons and arithmetic mean what they say (a >= 18 is a number, not a term id), and the price of that is honestly stated: results are SQL values, not RDF terms. Synalog queries the graph; it doesn’t add to it. Datalog remains the tool for conclusions that should become triples.

The portability tax also gets paid up front rather than at query time. Synalog’s SQLite output leans on runtime helper functions Logica registers — things D1 simply cannot install. oxilite scans the compiled SQL, rewrites the ones with a plain-SQL equivalent (JOIN_STRINGS and friends become JSON_GROUP_ARRAY/JSON_EACH subqueries, negation’s anti-hoisting trick collapses to a no-op), and rejects the rest before running anything, naming the exact construct: ArgMax=, ArgMin=, file/solver/model calls, and any @Recursive bound above 20. An agent gets that rejection as an error message about its program, not a runtime crash three requests later.

Datalog (oxilite-datalog)Synalog (oxilite-synalog)Lineageoxilite’s own, RDF-nativeRust rewrite of Google’s LogicaAtomsTriple patterns (ex:parent(?x, ?y))Declared tables, named arguments (parent(subject: x, object: y))RecursionInferred; WITH RECURSIVE or iterated to a fixpointExplicit bound, @Recursive(Name, n), unrolledNegationStratified, checked before compilingLogica’s own construct, rewritten for portable SQLResultsRDF termsSQL values (integers, strings, booleans)Can write back to the graphYes — datalog_materialize() into quads_infNo — queried, not materializedBuilt forRules over a graphA semantic layer an agent authors

A cool example: an agent that builds its own semantic layer

Here’s where the two dialects stop being alternatives and start being a pipeline. The scenario: a procurement agent sitting on top of a supply-chain knowledge graph, asked “who are our riskiest indirect suppliers, and should I be worried about the sanctioned one three hops away?”

The graph starts small and RDF-native:

@prefix sc: <http://example.org/supplychain#> .

sc:acme     sc:suppliedBy sc:globex .
sc:acme     sc:suppliedBy sc:hooli .
sc:globex   sc:suppliedBy sc:initech .
sc:initech  sc:suppliedBy sc:umbrella .

sc:umbrella a sc:Sanctioned .

sc:hooli    sc:riskScore 30 .
sc:globex   sc:riskScore 55 .
sc:initech  sc:riskScore 20 .
sc:umbrella sc:riskScore 95 .

sc:suppliedBy is a chain of unknown depth — exactly what a SPARQL property path can traverse but not filter mid-chain. This is where Datalog goes first.

Step 1 — recursive closure, filtered, written back as facts

@prefix sc: <http://example.org/supplychain#> .

indirectSupplier(?x, ?y)      :- sc:suppliedBy(?x, ?y).
indirectSupplier(?x, ?z)      :- sc:suppliedBy(?x, ?y), indirectSupplier(?y, ?z).

safeIndirectSupplier(?x, ?y)  :- indirectSupplier(?x, ?y), not sc:Sanctioned(?y).

One recursive rule walks the chain to any depth; one stratified-negation rule splits it into “reachable” and “reachable and not currently sanctioned.” Run with datalog_materialize(), the conclusions land in quads_inf as real sc:indirectSupplier and sc:safeIndirectSupplier triples — the graph now knows its multi-hop supply chain, permanently, and any SPARQL query with include_inferred sees it with no idea a rule was ever involved.

Step 2 — a named, paged view, written by the agent

This is the part a human wouldn’t bother writing as a SPARQL query, and an agent shouldn’t have to re-derive by hand every time: “give me the top 5 risk exposures for Acme, by score, five at a time.”

# @table indirectSupplier <http://example.org/supplychain#safeIndirectSupplier>
# @table riskScore        <http://example.org/supplychain#riskScore>

Exposure(root:, supplier:, score:) :-
  indirectSupplier(subject: root, object: supplier),
  riskScore(subject: supplier, object: score);

@OrderBy(Exposure, score desc);
@Limit(Exposure, 5);

store.synalog(program, "Exposure") runs this as one read request, no term resolution needed since decoding already happened in SQL, and the agent gets back exactly the columns it named — root, supplier, score — pageable with Options { limit, offset } for “show me the next five.” Nothing here got written to the graph; Exposure is disposable, defined in the same request that answers the question, gone the moment the agent moves on. Tomorrow’s question gets a different named concept, with no migration and no cleanup.

Step 3 — the part that actually makes this agent-shaped

The interesting failure mode for an agent isn’t “the query is slow,” it’s “the agent wrote a program that doesn’t compile, and now what.” This is where Logica’s verifier — kept intact because oxilite runs Synalog unmodified — pays for itself. Get a table name wrong, forget a distinct on a recursive predicate, reference a column Exposure never defined, and the verifier’s response is a sentence about that mistake, meant to be read by a model:

agent  → writes an Exposure program, gets a column name wrong
oxilite → check(program) fails: "column `scroe` is not bound in Exposure(...)"
agent  → reads the message, fixes the typo, resubmits
oxilite → check(program) passes → compile → run → paged rows back

No retraining, no few-shot examples of correct syntax baked into a prompt — the loop closes because the error text was written for exactly this reader. Combine that with @Recursive‘s explicit bound (an agent-authored recursive rule can’t accidentally spin forever) and @Limit/@OrderBy (every result set an agent asks for is naturally page-sized), and Synalog ends up matching the shape of a tool call an LLM is good at making: named arguments in, a bounded page of rows out, a plain-English reason when it’s wrong.

When to reach for which

  • Something the graph should know forever — a derived class, a transitive relation other queries will rely on, a fact that should show up under include_inferred next week too — is a Datalog rule, materialized.

  • Something one agent needs answered right now, shaped exactly for how it’s going to consume it — named, aggregated, ordered, paged, thrown away after — is a Synalog program against the tables Datalog (or plain data) already populated.

  • Either way, it’s the same quads, the same backends (SQLite, Turso, a system SQLite library, Cloudflare D1), and the same time-travel: both dialects respect as_of, so an agent can ask “what would Exposure have looked like last quarter” without a different code path.

Synalog is an off-by-default feature (synalog) in every binding — Rust, the CLI, Node.js, Python, and an opt-in ~2 MB in the WebAssembly core, so a Worker that never uses it doesn’t carry the weight.

oxilite = { version = "0.9", features = ["synalog"] }
oxilite synalog Exposure -l data.sqlite -f exposure.l          # run it, tab-separated rows
oxilite synalog Exposure -l data.sqlite -f exposure.l --sql    # the SQL it actually runs

Try it

  • crates/oxilite-synalog — the crate, README and tests this article’s examples are drawn from

  • crates/oxilite-datalog — the native dialect that materializes back into the graph

  • Synalog — Yoan Sallami and the Synalinks team’s Rust rewrite, which oxilite runs unmodified

  • Logica — Evgeny Skvortsov and Google’s Logica team, the project Synalog is built on

Originally published on Sovereign Agentic AI on Substack.