Elixir bindings for the Taskweft C++20 HTN planner NIF.
Provides planning, replanning, temporal consistency checking, HRR (Holographic Reduced Representation) encoding for semantic memory, and ReBAC (relationship-based access control) checks.
Used by multiplayer-fabric-artifacts-mmog and
multiplayer-fabric-zone-console. Breaking API changes require
coordinated updates in both consumers.
Domain JSON format
All JSON strings use the taskweft JSON-LD domain format. Domains are
JSON-LD documents; the "op" field syntax ("add", "get") must match
what domain.ex emits — do not revert to the old "type": "math/add"
form. See standalone/tw_domain.hpp and priv/plans/ for examples.
Nested transactions via savepoints
SQLite does not support BEGIN inside an open transaction. The adapter
uses txn_depth in GenServer state to track nesting:
- Depth 0 → 1:
BEGIN - Depth N → N+1:
SAVEPOINT sp{N} - Depth 1 → 0 commit:
COMMIT, then rebuild dirty bundles - Depth N → N-1 commit:
RELEASE sp{N-1} - Depth 1 → 0 rollback:
ROLLBACK - Depth N → N-1 rollback:
ROLLBACK TO sp{N-1}
Ecto.Repo.transaction/2 calls nest: an inner Repo.transaction
inside an outer one promotes to a savepoint.
Deferred bundle rebuild inside transactions
hrr_bundles holds the superposition of all record_vectors for a
source. Rebuilding on every insert/delete inside a transaction is wrong;
partial-commit state would corrupt the bundle:
- Inserts and deletes inside a transaction mark the source in a
dirtyMapSetbut skiprebuild_bundle. - At outermost
COMMIT, the dirty set is drained and each source is rebuilt after the SQLiteCOMMITreturns. - Nested savepoint
ROLLBACK TOdoes not clear the dirty set — the outer transaction may still commit.
Ecto adapter
All four adapter behaviours (Ecto.Adapter, Ecto.Adapter.Schema,
Ecto.Adapter.Queryable, Ecto.Adapter.Transaction) are guarded by
Code.ensure_loaded? at compile time. Projects without Ecto pay no
compile-time cost and the NIF tests still pass.