Deprecated
Bindings overview
Choose between native C, Python, and JavaScript/TypeScript integration surfaces.The Python and JavaScript bindings use the same public C SDK and reference solver. Their host-language interfaces differ; neither exposes native solver structures as application objects. Both accept a declaration before loading a policy, preserve typed values and return native explanation documents.
In 0.10.0, there is one Python package, maelys_datalog: the former
Python-next implementation became the current Python binding.
The old C-shim binding is no longer shipped; its
Python V1 documentation remains under Deprecated.
Window support through 0.16.0
The single-fact and group windows are native C adapters. Their static context and explicit expiration additions in 0.13.0 are not exposed by the released Python or JavaScript/TypeScript bindings. Release 0.16.0 adds an opt-in retained-input contract for C sessions; the existing window adapters use snapshot replacement for each bank. It does not add Python or JavaScript window-adapter methods.
Choosing a binding
| Contract | JavaScript / TypeScript (0.16.0) | Native Python |
|---|---|---|
| Runtime | Native Node-API addon, or an independent WASM module | An installed native SDK and CFFI |
| Input | string, bigint or safe integer number, boolean | str, int, bool |
| Integer output | Always bigint | Python int |
| Domain scope | Module-local in WASM; shared per native profile addon | Process-wide native registry |
| Session | Explicit Engine, Ruleset, Edb, Session and SolveResult; one live result per session | Explicit Engine, Ruleset, Edb, prepared Session and Result handles |
| Ground query | containsFact(predicate, terms) | contains_fact(predicate, terms) |
| Resolved IDB enumeration | enumeratePredicateFacts(predicate, arity) | enumerate_predicate_facts(predicate, arity) |
| Explanation | explainTrue / explainFalse | explain_true / explain_false |
| Failure | MaelysDatalogError with status and diagnostic snapshot | MaelysDatalogError with status and diagnostic fields |
| Lifetime | Explicit close() | Explicit close() or context managers |
The common JS/TS API was published in 0.15.0
and retires the old WASM package and MaelysPlayground. The site serves its
0.27.0 WASM implementation; Node applications use the package's native addon.
Both JavaScript and Python expose copied resolved values and explicit raw terms.
Raw symbol IDs belong to a live result and cannot be reused across results.
Neither binding silently interns unknown query strings.
Predicate declarations across Python and C
The Python shortcuts and optional C builder macros express the same origin-plus-query roles. Python creates immutable Predicate values; the C macros initialize public predicate declarations. Neither form registers a domain by itself. For the full vocabulary rules, see Python registries and C registries.
| General Python declaration | Python shortcut | C builder macro |
|---|---|---|
Predicate(name, arity, PRED_EDB) | Predicate.edb(name, arity) | MAELYS_DATALOG_EDB(name, arity) |
| `Predicate(name, arity, PRED_EDB | PRED_QUERY)` | Predicate.edb_query(name, arity) |
Predicate(name, arity, PRED_IDB) | Predicate.idb(name, arity) | MAELYS_DATALOG_IDB(name, arity) |
| `Predicate(name, arity, PRED_IDB | PRED_QUERY)` | Predicate.idb_query(name, arity) |
Predicate(name, arity, PRED_POLICY_FACT) | Predicate.policy_fact(name, arity) | MAELYS_DATALOG_POLICY_FACT(name, arity) |
| `Predicate(name, arity, PRED_POLICY_FACT | PRED_QUERY)` | Predicate.policy_fact_query(name, arity) |
Session model
The common JS API uses the same ownership model in native Node and WASM.
Engine.create() is asynchronous; operations after initialization are synchronous.
Each prepared session admits one live result. Convenience solves create separate
sessions, so results can remain independent. Closing an engine closes its full
resource tree. WASM engines use independent modules by default; native calls are
serialized between workers loading the same profile addon, so workers do not
imply parallel solves. Python Engine objects and handles stay on their creating
thread; each worker creates its own Engine.
A failed solve publishes no partial result. Bounded input append and native resolution are separate admissions: an input may fit the public buffer yet exceed a solver limit when materialized.
Shared semantics
- Predicate origins and QUERY permission come from explicit domain declarations.
- Quoted constants written in policy source need declared atoms; runtime input strings do not. Policy facts also need POLICY_FACT permission.
- Ground queries can find authorized EDB, policy and derived facts. Enumeration returns derived IDB facts only.
- Missing symbols produce false queries but NOT_FOUND explanations. A known fact without an IDB witness produces a not-derived Why-true document.
- Truncated Why-false is an incomplete search, not a complete proof.
- SMALL/LARGE capacities and aggregate arithmetic limits remain engine limits. Host-language integers do not extend the policy language.
Memory and packaging
Neither binding is zero-malloc: JS/Python objects, conversions and text buffers allocate. Prepared engine workspaces have their own explicit storage contract. Wasm memory growth does not make an engine profile elastic.
Consume one coherent SDK version. JavaScript modules, declaration, factory and WASM travel together; Python builds against one installed SDK prefix. The 0.10.0 migration removes the historical native-object interfaces and aliases.
See the TypeScript / JavaScript reference for both JavaScript runtimes and the Python reference for the native binding. The Python V1 reference describes the deprecated pre-0.10.0 interface and is retained solely for migration.