Skip to content

Visual DMN & FEEL Engine ​

LatticeDX decouples volatile business rules from workflow DAG topology through a zero-eval Decision Model and Notation (DMN) engine in @latticedx/plugin-dxos-studio. Analysts and platform engineers author decision tables in Control Studio or via dxosDmn, simulate draft rules without database writes, and feed deterministic outputs into logic.dmn nodes inside LatticeFlow v2.

Visual DMN Decision Table & FEEL Evaluation
CALLER INPUTDMN ENGINE (DMN-ENGINE.JS · FORCE RLS)FLOW / API OUTPUTloadrulesmatchemitInput Factslogic.dmn orPOST :evaluate(dry-run simulated)VersionedDecision TablePG16 DecisionTablesRLS · <=500 rulessaveTable -> LedgerZero-Eval FEELMatchereq · neq · gt..ltebetween · in · not_incontains · * (safe)Hit PolicySelectorFIRST · COLLECTUNIQUE (409 on >1)PRIORITY (rank desc)DeterministicOutput{ matched, result,results[] } ->{{dmnResult}}
InspectorZero-Eval FEEL MatcherClick any component to inspect bindings & boundaries
Role
Safe AST condition parser & matcher without eval()
Package / Port
@latticedx/plugin-dxos-studio · dmn-engine.js
Protocol
Zero-Eval AST Matcher · Object.hasOwn
Payload / Schema
ALLOWED_OPERATORS (11 operators · prototype-safe)
Responsibilities
Compiles string or JSON predicates to { op, value }, reads inputs via Object.hasOwn, and collects candidate rows matching all when columns.
5-stage deterministic DMN evaluation without eval(); publishing via dxosDmn:saveTable auto-increments version and logs dmn.table_saved to the Ed25519 ledger (latticeCryptoLedger).

Data Model & Validation Caps ​

Each decision table is stored in latticeDecisionTables under PostgreSQL 16 FORCE ROW LEVEL SECURITY scoped by organizationId. Records are uniquely indexed per tenant on (organizationId, tableKey) via uidx_lattice_dmn_org_key.

latticeDecisionTables Field Schema
ParameterTypeDefaultDescription
organizationIdrequired
string—Tenant identifier owning the decision table; must match the active RLS session context.
tableKeyrequired
string—Unique key within the tenant matching /^[a-zA-Z0-9_-]{2,80}$/.
namerequired
string—Human-readable table title (capped at 160 characters).
description
string—Operational rule scope description (capped at 500 characters).
hitPolicy
stringFIRSTMatch aggregation policy: FIRST, UNIQUE, COLLECT, or PRIORITY.
inputsJsonrequired
jsonb—Array of 1 to 50 input declarations { name, type?, label? }.
outputsJsonrequired
jsonb—Array of 1 to 50 output declarations { name, type?, label? }.
rulesJsonrequired
jsonb—Array of up to 500 rules { when, then, priority?, description? }.
version
integer1Monotonically incremented revision number managed by dxosDmn:saveTable.
published
booleantruePublication state flag for studio lifecycle tracking.
active
booleantrueOnly tables with active = true can be evaluated by tableKey.

Validation guards execute before persistence or draft simulation:

ConstraintCap / PatternError Code
tableKey syntax^[a-zA-Z0-9_-]{2,80}$400 DMN_TABLE_KEY_INVALID
Field identifier syntax (inputsJson, outputsJson, when, then)^[a-zA-Z0-9_.-]{1,64}$400 DMN_SCHEMA_INVALID / DMN_RULE_INVALID
inputsJson and outputsJson cardinality1 to 50 fields per array400 DMN_SCHEMA_INVALID
rulesJson cardinalityMaximum 500 rules per table400 DMN_RULE_INVALID
Blocked prototype keys (FORBIDDEN_KEYS)__proto__, constructor, prototype400 DMN_SCHEMA_INVALID / DMN_RULE_INVALID
Rule-level description lengthTruncated at 255 charactersNormalized on save

During fact evaluation, evaluateDecisionTable reads input keys exclusively via Object.hasOwn(ctxObj, inputKey), preventing prototype-chain lookup leaks.

Four Hit Policies (HIT_POLICIES) ​

evaluateDecisionTable in dmn-engine.js supports four deterministic hit policies when evaluating rulesJson:

Hit PolicyEvaluation SemanticsOutput ShapeConflict & Edge Behavior
FIRSTEvaluates rules top-to-bottom and stops on the first matchSingle result and outputs object plus matchedRuleIndexReturns matched: false, matchedRuleIndex: -1, result: null when nothing matches
UNIQUEEvaluates every rule to verify mutual exclusivitySingle result, outputs, results: [only.outputs], matchedRuleIndexThrows HTTP 409 DMN_UNIQUE_POLICY_VIOLATION if more than one rule matches
COLLECTEvaluates every rule and aggregates all matching rule outputs in declaration orderresults: [...] array of then objects plus matchedRulesReturns matched: false, results: [] when no rule matches
PRIORITYEvaluates every rule and sorts matches descending by numeric priority (or rank)Top rule result / outputs, results: [top.outputs], sorted matchedRulesTies break by ascending ruleIndex; omitted priority defaults to 0

Complete FEEL Expression Reference ​

Every when condition is normalized into { op, value } via normalizeConditionSpec and parseStringConditionSpec. No eval() or new Function() is ever invoked. Rules accept both shorthand FEEL strings and structured JSON condition objects.

Canonical OperatorAccepted AliasesFEEL Shorthand StringStructured JSONEvaluation Semantics
eq==, ===, ="critical", "= 100", "== true"{ "op": "eq", "value": "critical" }Scalar equality; finite numeric strings and numbers normalize before comparison via parseFinite
neq!=, !=="!= closed", "!== 0"{ "op": "neq", "value": "closed" }Logical negation of valuesEqual
gt>"> 8"{ "op": "gt", "value": 8 }Strictly greater than a finite numeric operand
gte>=">= 75"{ "op": "gte", "value": 75 }Greater than or equal to a finite numeric operand
lt<"< 2"{ "op": "lt", "value": 2 }Strictly less than a finite numeric operand
lte<="<= -12"{ "op": "lte", "value": -12 }Less than or equal to a finite numeric operand
between—"[2..8]"{ "op": "between", "value": [2, 8] }Closed numeric interval check min <= actual <= max
in—"in [high, critical]"{ "op": "in", "value": ["high", "critical"] }Matches if actual equals any element in the array
not_innot in"not in [draft, cancelled]"{ "op": "not_in", "value": ["draft", "cancelled"] }Matches if actual equals no element in the array
contains—"contains COLD-"{ "op": "contains", "value": "COLD-" }Case-insensitive substring check against String(actual)
any*, -"*", "-", "any", ""{ "op": "any", "value": null } or nullWildcard match; always evaluates to true

When parsing shorthand strings, parseScalarValue coerces "true" / "false" to booleans, "null" to null, finite numeric literals matching /^-?\d+(?:\.\d+)?$/ to numbers, and strips balanced outer quotes ('...' or "..."). For string [a..b] ranges, parseStringConditionSpec normalizes bounds automatically via Math.min(a, b) and Math.max(a, b).

Production Decision Tables & logic.dmn Binding ​

The lattice-templates/dmn-tables/ repository directory ships three reference decision tables (cold_chain_approval_v1, cmms_priority_routing_v1, coldchain_settlement_policy_v1) alongside a 12-case sample-evaluations.json verification suite.

json
{
  "tableKey": "cold_chain_approval_v1",
  "name": "Cold-Chain & MKT Excursion Approval Matrix",
  "hitPolicy": "FIRST",
  "inputsJson": [
    { "name": "totalAmountM", "type": "number" },
    { "name": "maxTempC", "type": "number" }
  ],
  "outputsJson": [
    { "name": "approvalTier", "type": "string" },
    { "name": "slaMinutes", "type": "number" }
  ],
  "rulesJson": [
    {
      "when": { "maxTempC": { "op": "gt", "value": 8 } },
      "then": { "approvalTier": "quality_hold_director", "slaMinutes": 15 }
    },
    {
      "when": { "totalAmountM": "> 500" },
      "then": { "approvalTier": "director_approval", "slaMinutes": 45 }
    },
    {
      "when": { "totalAmountM": "*", "maxTempC": "*" },
      "then": { "approvalTier": "manager_approval", "slaMinutes": 120 }
    }
  ]
}

Inside a LatticeFlow v2 DAG, logic.dmn merges { ...evalCtx.data, ...input, ...facts, organizationId } and invokes evaluateDecisionTable. Downstream nodes (control.if, control.approval, notify.send) read the decision outputs via {{dmn.approvalTier}} and {{dmnResult.outputs}}:

  • For FIRST, UNIQUE, and PRIORITY: context.dmn holds the matched outputs object directly (such as {{dmn.approvalTier}}), and context.dmnResult holds { tableKey, matched, hitPolicy, outputs }.
  • For COLLECT: context.dmn holds { results: [...] } containing every matched rule's then payload in rulesJson order.
  • To inspect every matched rule index and priority score downstream, read the node output directly via {{steps.dmn_gate.matchedRules}}.

If the target tableKey does not exist or has active: false in the organization, logic.dmn throws 404 DMN_TABLE_NOT_FOUND and routes execution along the node's error output edge when connected.

Evaluation & Authoring API (dxosDmn) ​

The dxosDmn resource exposes three actions protected by tenant FORCE ROW LEVEL SECURITY and scoped Personal Access Tokens (read, write, dmn).

GET/api/dxosDmn:listTables
Bearer JWT | ldx_pat_*read | write | dmn
Lists DMN tables scoped to the caller organization; supports tableKey, activeOnly, and limit (1..200) filters.
POST/api/dxosDmn:saveTable
Bearer JWT | ldx_pat_*write | dmn
Validates schemas and rules, increments version, persists to latticeDecisionTables, and writes a dmn.table_saved entry to the Ed25519 latticeCryptoLedger.
POST/api/dxosDmn:evaluate
Bearer JWT | ldx_pat_*read | write | dmn
Evaluates a persisted active tableKey or simulates an unsaved draft via params.table (returning simulated: true with zero database writes).

Inline draft simulation (params.table) requires view or update ACL on latticeDecisionTables (or org-admin privileges) so analysts can test rule edits before publishing a new version.

bash
curl -sS -X POST "https://app.latticedx.example.com/api/dxosDmn:evaluate" \
  -H "Authorization: Bearer ldx_pat_your_token" \
  -H "Content-Type: application/json" \
  -d '{
    "tableKey": "cold_chain_approval_v1",
    "context": { "totalAmountM": 320, "maxTempC": 11.4 }
  }'

Security Boundaries & Error Codes ​

Every dxosDmn:saveTable call verifies organization admin status (isOrgAdmin) or explicit create/update collection permissions on latticeDecisionTables, and appends an immutable dmn.table_saved audit record under scope dxos:dmn to latticeCryptoLedger containing { tableKey, hitPolicy, version, ruleCount }.

Error CodeHTTPTrigger Condition
DMN_OPERATOR_INVALID400Condition specifies an operator outside ALLOWED_OPERATORS
DMN_RULE_INVALID400Numeric comparison receives non-finite value, invalid [min, max] range, or > 500 rules
DMN_CONTEXT_INVALID400String context argument is not valid JSON
DXOS_ACL_DENIED403Caller lacks org-admin role or latticeDecisionTables collection permission
DMN_TABLE_NOT_FOUND404No active (active: true) table matches tableKey inside the caller organization
DMN_UNIQUE_POLICY_VIOLATION409Table uses hitPolicy: "UNIQUE" and matched two or more rules

Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)