C API

Errors

Interpret stable C status values and public diagnostics fail-closed.

Declarations from <maelys/datalog.h> and its optional C11 builders <maelys/datalog_builders.h>. For explanations and complete examples, see the Errors guide.

The examples use failed_diagnostic and check_status supplied by the page reference context.

Enum: status_t

C · enumSince ≤ v0.1.0-alpha.2
status_t

#include <maelys/datalog.h>

Machine-readable outcome of a public call. OK is success; other values must never be treated as a negative membership answer.
Members
STATUS_OK0
Operation succeeded.
STATUS_INVALID_ARGUMENT-1
Malformed argument.
STATUS_INVALID_FIELD-2
Invalid field or typed value.
STATUS_NOT_FOUND-3
Requested item or explanation symbol not found.
STATUS_NOT_IMPLEMENTED-4
Operation not implemented.
STATUS_UNSUPPORTED-5
Unsupported capability or operation.
STATUS_TIMEOUT-6
Operation timed out.
STATUS_IO-7
Input/output failure.
STATUS_INTERNAL-8
Internal operation failure.
STATUS_UNAUTHORIZED-9
Authentication required.
STATUS_FORBIDDEN-10
Permission or manifest policy rejects the operation.
STATUS_RATE_LIMITED-11
Rate limit reached.
STATUS_PAYLOAD_TOO_LARGE-12
Content exceeds an engine bound.
STATUS_INVALID_STATE-13
Resource is closed or its current lease prevents the operation.
STATUS_STORAGE_TOO_SMALL-14Since v0.5.0
Supplied storage is insufficient.
Typedef
typedef enum {
    MAELYS_DATALOG_STATUS_OK = 0,
    MAELYS_DATALOG_STATUS_INVALID_ARGUMENT = -1,
    MAELYS_DATALOG_STATUS_INVALID_FIELD = -2,
    MAELYS_DATALOG_STATUS_NOT_FOUND = -3,
    MAELYS_DATALOG_STATUS_NOT_IMPLEMENTED = -4,
    MAELYS_DATALOG_STATUS_UNSUPPORTED = -5,
    MAELYS_DATALOG_STATUS_TIMEOUT = -6,
    MAELYS_DATALOG_STATUS_IO = -7,
    MAELYS_DATALOG_STATUS_INTERNAL = -8,
    MAELYS_DATALOG_STATUS_UNAUTHORIZED = -9,
    MAELYS_DATALOG_STATUS_FORBIDDEN = -10,
    MAELYS_DATALOG_STATUS_RATE_LIMITED = -11,
    MAELYS_DATALOG_STATUS_PAYLOAD_TOO_LARGE = -12,
    MAELYS_DATALOG_STATUS_INVALID_STATE = -13,
    MAELYS_DATALOG_STATUS_STORAGE_TOO_SMALL = -14
} maelys_datalog_status_t;

Functions

status_name()

C · functionSince ≤ v0.1.0-alpha.2
status_name()

#include <maelys/datalog.h>

const char *
maelys_datalog_status_name(
maelys_datalog_status_t status
);
Converts a public status code into a readable name for logs and error messages.
Arguments
Status returned by a public API call.
Return value

const char *

Returns a readable status name for diagnostics; do not infer success from the text alone.

Example
maelys_datalog_status_t status = maelys_datalog_limit_get(
    MAELYS_DATALOG_LIMIT_MAX_ARITY, NULL);
if (status != MAELYS_DATALOG_STATUS_INVALID_ARGUMENT) return EXIT_FAILURE;
printf("status: %s\n", maelys_datalog_status_name(status));
status: invalid_argument

Struct: diagnostic_t

C · structSince v0.10.0
diagnostic_t

#include <maelys/datalog.h>

Versioned diagnostic record: owned text plus independent typed detail sections. Initialize before every producer call.
Fields
struct_sizesize_t
Size of the caller-provided object in bytes; required by diagnostic ABI 1.
abi_versionuint32_t
Set to MAELYS_DATALOG_DIAGNOSTIC_ABI_VERSION (1).
LOAD, SOLVE or NONE; NONE means no detail was supplied.
Status associated with this populated diagnostic.
Typed reason; use maelys_datalog_diag_code_name() for its stable name.
presentuint64_t
Bitmask selecting the independent detail sections that are valid.
linesize_t
Source line when LOCATION is present.
columnsize_t
Source column when LOCATION is present.
phasechar[32]
Bounded producer phase text.
messagechar[256]
Bounded human-readable message, not a machine-readable code.
hintchar[256]
Bounded optional corrective guidance.
filechar[256]
Bounded source path when LOCATION is present.
predicatechar[96]
Predicate name when PREDICATE is present.
aritysize_t
Predicate arity when PREDICATE is present.
observed_countsize_t
Attempted count for a CAPACITY failure.
limitsize_t
Capacity bound, or inclusive numeric aggregate bound when AGGREGATE is present.
depthsize_t
Observed depth when DEPTH is present.
depth_limitsize_t
Allowed depth when DEPTH is present.
rule_idsize_t
Rule identifier when RULE is present.
comparison_resultunsigned int
Comparison outcome when COMPARISON is present.
expected_kindunsigned int
Expected comparison kind when COMPARISON is present.
lhs_kindunsigned int
Left-hand IR kind; also the offending aggregate value kind.
rhs_kindunsigned int
Right-hand IR kind when COMPARISON is present.
comparison_opunsigned int
IR comparison operator when COMPARISON is present.
Public capacity identifier; zero when no budget identity is available.
term_indexsize_t
Zero-based term or aggregate projection index when its section is present.
expected_aritysize_t
Required arity when ARITY is present.
observed_aritysize_t
Supplied arity when ARITY is present.
tokenchar[96]
Bounded offending token or aggregate value text.
fieldchar[96]
Bounded field name; min, max or sum for aggregate rejection.
domainchar[96]
Bounded domain name when CONTEXT is present.
Typedef
typedef struct {
    size_t struct_size;
    uint32_t abi_version;
    maelys_datalog_diagnostic_source_t source;
    maelys_datalog_status_t status;
    maelys_datalog_diag_code_t code;
    uint64_t present;
    size_t line, column;
    char phase[32], message[256], hint[256];
    char file[256], predicate[96];
    size_t arity, observed_count, limit, depth, depth_limit, rule_id;
    unsigned comparison_result, expected_kind, lhs_kind, rhs_kind, comparison_op;
    /* limit is the effective bound (possibly a smaller session reservation),
     * while limit_get reports the library ceiling, or UNSUPPORTED for a
     * dimension whose bound is session-specific. */
    maelys_datalog_limit_t limit_kind; /* 0 when the producer cannot identify the budget. */
    size_t term_index, expected_arity, observed_arity;
    char token[96], field[96], domain[96];
} maelys_datalog_diagnostic_t;

Creation

diagnostic_init()

C · functionSince v0.10.0
diagnostic_init()

#include <maelys/datalog.h>

maelys_datalog_status_t
maelys_datalog_diagnostic_init(
void *storage,
size_t storage_bytes
);
Initializes diagnostic storage supplied by the application, with the metadata required before passing it to an API call.
Arguments
storage_bytessize_tin
Available bytes; at least sizeof(maelys_datalog_diagnostic_t) for ABI 1.
Outputs

Written on success.

storagevoid *out
Naturally aligned caller-owned storage.
Return status

maelys_datalog_status_t — OK on success.

Initializes the known ABI 1 object. Rejects storage that is too small before writing a diagnostic payload.

Example
maelys_datalog_diagnostic_t diagnostic;
maelys_datalog_status_t status = maelys_datalog_diagnostic_init(
    &diagnostic, sizeof(diagnostic));
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("diagnostic.status: %s\n", maelys_datalog_status_name(diagnostic.status));
printf("ABI version: %u\n", diagnostic.abi_version);
status: ok
diagnostic.status: ok
ABI version: 1

DIAGNOSTIC_INIT

C · macroSince v0.10.0
DIAGNOSTIC_INIT

#include <maelys/datalog.h>

MAELYS_DATALOG_DIAGNOSTIC_INIT

Constructs an initialized diagnostic value.

Effect

Calls maelys_datalog_diagnostic_initializer(). Returns an initialized maelys_datalog_diagnostic_t value.

Initial values
FieldInitial valueMeaning
struct_sizesizeof(d)Size of the caller-provided object in bytes; required by diagnostic ABI 1.set automatically
abi_versionMAELYS_DATALOG_DIAGNOSTIC_ABI_VERSIONSet to MAELYS_DATALOG_DIAGNOSTIC_ABI_VERSION (1).set automatically
source0LOAD, SOLVE or NONE; NONE means no detail was supplied.
status0Status associated with this populated diagnostic.
code0Typed reason; use maelys_datalog_diag_code_name() for its stable name.
present0Bitmask selecting the independent detail sections that are valid.
line0Source line when LOCATION is present.
column0Source column when LOCATION is present.
phase{0}Bounded producer phase text.
message{0}Bounded human-readable message, not a machine-readable code.
hint{0}Bounded optional corrective guidance.
file{0}Bounded source path when LOCATION is present.
predicate{0}Predicate name when PREDICATE is present.
arity0Predicate arity when PREDICATE is present.
observed_count0Attempted count for a CAPACITY failure.
limit0Capacity bound, or inclusive numeric aggregate bound when AGGREGATE is present.
depth0Observed depth when DEPTH is present.
depth_limit0Allowed depth when DEPTH is present.
rule_id0Rule identifier when RULE is present.
comparison_result0Comparison outcome when COMPARISON is present.
expected_kind0Expected comparison kind when COMPARISON is present.
lhs_kind0Left-hand IR kind; also the offending aggregate value kind.
rhs_kind0Right-hand IR kind when COMPARISON is present.
comparison_op0IR comparison operator when COMPARISON is present.
limit_kind0Public capacity identifier; zero when no budget identity is available.
term_index0Zero-based term or aggregate projection index when its section is present.
expected_arity0Required arity when ARITY is present.
observed_arity0Supplied arity when ARITY is present.
token{0}Bounded offending token or aggregate value text.
field{0}Bounded field name; min, max or sum for aggregate rejection.
domain{0}Bounded domain name when CONTEXT is present.
Expansion
maelys_datalog_diagnostic_initializer()
Example
maelys_datalog_diagnostic_t diagnostic = MAELYS_DATALOG_DIAGNOSTIC_INIT;
printf("diagnostic.status: %s\n", maelys_datalog_status_name(diagnostic.status));
printf("present: 0x%llx\n", (unsigned long long)diagnostic.present);
diagnostic.status: ok
present: 0x0

diagnostic_initializer()

C · functionSince v0.10.0
diagnostic_initializer()

#include <maelys/datalog.h>

static inline maelys_datalog_diagnostic_t
maelys_datalog_diagnostic_initializer(
void
);
Constructs an initialized diagnostic value, including its size and ABI metadata, ready to receive details from an API call.
Return value

maelys_datalog_diagnostic_t

Returns a zeroed diagnostic with struct_size and abi_version set for diagnostic ABI 1. MAELYS_DATALOG_DIAGNOSTIC_INIT is the equivalent initializer macro.

Example
maelys_datalog_diagnostic_t diagnostic = maelys_datalog_diagnostic_initializer();
printf("diagnostic.status: %s\n", maelys_datalog_status_name(diagnostic.status));
printf("present: 0x%llx\n", (unsigned long long)diagnostic.present);
diagnostic.status: ok
present: 0x0

Functions

diagnostic_clear()

C · functionSince v0.10.0
diagnostic_clear()

#include <maelys/datalog.h>

maelys_datalog_status_t
maelys_datalog_diagnostic_clear(
maelys_datalog_diagnostic_t *diagnostic
);
Clears details from a previous diagnostic while keeping the object ready for reuse by another API call.
Arguments
diagnosticmaelys_datalog_diagnostic_t *in/out
Previously initialized diagnostic to reuse.
Return status

maelys_datalog_status_t — OK on success.

Resets the known fields while preserving struct_size and abi_version. This is not secure erasure.

Example
maelys_datalog_diagnostic_t diagnostic = failed_diagnostic();
printf("diagnostic.status before: %s\n", maelys_datalog_status_name(diagnostic.status));
printf("diagnostic.code before: %s\n", maelys_datalog_diag_code_name(diagnostic.code));
maelys_datalog_status_t status = maelys_datalog_diagnostic_clear(&diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("diagnostic.status after: %s\n", maelys_datalog_status_name(diagnostic.status));
printf("diagnostic.code after: %s\n", maelys_datalog_diag_code_name(diagnostic.code));
printf("diagnostic.present after: 0x%llx\n", (unsigned long long)diagnostic.present);
diagnostic.status before: unsupported
diagnostic.code before: manifest_unknown_domain
status: ok
diagnostic.status after: ok
diagnostic.code after: none
diagnostic.present after: 0x0

Constants

Diagnostic detail sections
NameValueMeaning
DIAGNOSTIC_AGGREGATE
Since v0.10.0
0x100Aggregate field, offending value text and kind, projection index and inclusive numeric bound are populated.
DIAGNOSTIC_ARITY
Since v0.10.0
0x20Expected and observed arity are populated.
DIAGNOSTIC_CAPACITY
Since v0.10.0
0x4Attempted count, capacity bound and budget identity are populated.
DIAGNOSTIC_COMPARISON
Since v0.10.0
0x10Comparison outcome, operand kinds and operator are populated.
DIAGNOSTIC_CONTEXT
Since v0.10.0
0x80Domain and producer context are populated.
DIAGNOSTIC_DEPTH
Since v0.10.0
0x8Observed and permitted depth are populated.
DIAGNOSTIC_LOCATION
Since v0.10.0
0x1Source file, line and column are populated.
DIAGNOSTIC_PREDICATE
Since v0.10.0
0x2Predicate name and arity are populated.
DIAGNOSTIC_RULE
Since v0.10.0
0x40Rule identifier is populated.
Versioning

Initialize with the DIAGNOSTIC_INIT macro; these values identify the structure version and are not set by hand.

Diagnostic ABI
NameValueMeaning
DIAGNOSTIC_ABI_VERSION
Since v0.10.0
1ABI version required when initializing this diagnostic record.

Enum: diag_code_t

C · enumSince v0.1.0-alpha.4
diag_code_t

#include <maelys/datalog.h>

Typed diagnostic reason reported alongside the public status; use diag_code_name() for its stable name.
Members
DIAG_NONE0
No diagnostic reason was supplied.
DIAG_MANIFEST_INVALID_JSON1
The manifest is not valid JSON.
DIAG_MANIFEST_INVALID_FIELD2
A manifest field has an invalid value or type.
DIAG_MANIFEST_UNKNOWN_FIELD3
A policy entry contains an unknown field.
DIAG_MANIFEST_UNKNOWN_DOMAIN4
The manifest names an unknown policy domain.
DIAG_MANIFEST_SHA_MISMATCH5
The policy content does not match its declared SHA-256.
DIAG_MANIFEST_POLICY_NOT_FOUND6
A required manifest or policy file could not be found.
DIAG_MANIFEST_TEST_ONLY_REJECTED7
Production loading rejects a test-only policy.
DIAG_LEXER_INVALID_TOKEN8
The policy text contains an invalid, unexpected or unterminated token.
DIAG_LEXER_UNSUPPORTED_CONSTRUCT9
The policy text uses an unsupported construct.
DIAG_LEXER_INVALID_UTF810
The policy text contains invalid UTF-8.
DIAG_LEXER_STRING_TOO_LONG11
A string literal exceeds the supported length.
DIAG_PARSER_EXPECTED_PREDICATE12
A predicate was expected at this position.
DIAG_PARSER_UNKNOWN_PREDICATE13
A predicate name is unknown or exceeds the supported length.
DIAG_PARSER_ARITY_MISMATCH14
A predicate is used with the wrong number of terms, or exceeds the maximum arity.
DIAG_PARSER_UNKNOWN_ATOM15
A policy atom has not been declared.
DIAG_PARSER_RULE_HEAD_EDB_FORBIDDEN16
An input predicate cannot appear in a rule head.
DIAG_PARSER_RULE_BODY_LITERAL_OVERFLOW17
A rule body exceeds the supported number of literals.
DIAG_PARSER_UNSAFE_VARIABLE18
A variable is not bound by a positive body atom.
DIAG_PARSER_INVALID_COMPARISON19
A comparison or arithmetic expression is invalid or exceeds the expression limits.
DIAG_PARSER_INVALID_FILTER20
A filter expression is invalid or exceeds a filter capacity.
DIAG_PARSER_EXPECTED_DOT21
A clause terminator was expected.
DIAG_PARSER_EXPECTED_NECK22
A rule neck was expected.
DIAG_PARSER_FACT_USES_NON_BASE_PREDICATE23
A direct policy fact uses a predicate not permitted for policy facts.
DIAG_PARSER_ANONYMOUS_VARIABLE_IN_HEAD24
An anonymous variable cannot appear in a rule head.
DIAG_PARSER_ANONYMOUS_VARIABLE_IN_COMPARISON25
An anonymous variable cannot appear in a comparison, arithmetic expression or not() call.
DIAG_PARSER_ANONYMOUS_VARIABLE_IN_FACT26
A policy fact cannot contain a variable.
DIAG_PARSER_TOO_MANY_VARIABLES27
A rule exceeds the supported number of variables.
DIAG_POLICY_NOT_STRATIFIABLE28
The policy cannot be stratified within the supported limits.
DIAG_RUNTIME_INVALID_COMPARISON29
A comparison encounters incompatible operand types during evaluation. The Stable API reports the corresponding SOLVE_COMPARISON_TYPE_ERROR code.
DIAG_RUNTIME_INVALID_FILTER30
Filter evaluation encounters an invalid state or exceeds its budget. The Stable API reports the corresponding SOLVE_FILTER_ERROR code.
DIAG_REGISTRY_CONFLICT31
The query whitelist or domain predicate registry could not be installed.
DIAG_REGISTRY_MUTATION_AFTER_FREEZE32
The predicate registry must be frozen before parsing policy text.
DIAG_MALFORMED_PROGRAM33
The compiled program is malformed.
DIAG_OPERATION_REJECTED256Since v0.10.0
The requested operation was rejected.
DIAG_SOLVE_MAX_DEPTH513Since v0.10.0
Evaluation exceeds the maximum permitted depth.
DIAG_SOLVE_IDB_OVERFLOW514Since v0.10.0
Derived facts exceed the available storage capacity.
DIAG_SOLVE_COMPARISON_TYPE_ERROR515Since v0.10.0
The solve encounters incompatible operand types in a comparison or arithmetic expression.
DIAG_SOLVE_FILTER_ERROR516Since v0.10.0
A filter program, runtime value or execution budget is invalid.
DIAG_SOLVE_MALFORMED_FACT517Since v0.10.0
A fact is structurally invalid for the active registry.
DIAG_SOLVE_MALFORMED_EDB518Since v0.10.0
The input fact buffer is not finalized, not sorted, or otherwise invalid.
DIAG_SOLVE_INVALID_STATE519Since v0.10.0
The ruleset or result is not in the required state.
DIAG_SOLVE_INVALID_ARGUMENT520Since v0.10.0
A required solve argument is invalid.
DIAG_SOLVE_INTERNAL_ERROR521Since v0.10.0
An internal allocation or solver failure occurred.
DIAG_SOLVE_AGGREGATE_DOMAIN_ERROR522Since v0.10.0
An aggregate projection is not an integer in the accepted range 0–2147483647.
DIAG_SOLVE_SUM_OVERFLOW523Since v0.10.0
The first partial sum exceeds 2147483647.
Typedef
typedef enum {
    MAELYS_DATALOG_DIAG_NONE = 0,
    MAELYS_DATALOG_DIAG_MANIFEST_INVALID_JSON,
    MAELYS_DATALOG_DIAG_MANIFEST_INVALID_FIELD,
    MAELYS_DATALOG_DIAG_MANIFEST_UNKNOWN_FIELD,
    MAELYS_DATALOG_DIAG_MANIFEST_UNKNOWN_DOMAIN,
    MAELYS_DATALOG_DIAG_MANIFEST_SHA_MISMATCH,
    MAELYS_DATALOG_DIAG_MANIFEST_POLICY_NOT_FOUND,
    MAELYS_DATALOG_DIAG_MANIFEST_TEST_ONLY_REJECTED,
    MAELYS_DATALOG_DIAG_LEXER_INVALID_TOKEN,
    MAELYS_DATALOG_DIAG_LEXER_UNSUPPORTED_CONSTRUCT,
    MAELYS_DATALOG_DIAG_LEXER_INVALID_UTF8,
    MAELYS_DATALOG_DIAG_LEXER_STRING_TOO_LONG,
    MAELYS_DATALOG_DIAG_PARSER_EXPECTED_PREDICATE,
    MAELYS_DATALOG_DIAG_PARSER_UNKNOWN_PREDICATE,
    MAELYS_DATALOG_DIAG_PARSER_ARITY_MISMATCH,
    MAELYS_DATALOG_DIAG_PARSER_UNKNOWN_ATOM,
    MAELYS_DATALOG_DIAG_PARSER_RULE_HEAD_EDB_FORBIDDEN,
    MAELYS_DATALOG_DIAG_PARSER_RULE_BODY_LITERAL_OVERFLOW,
    MAELYS_DATALOG_DIAG_PARSER_UNSAFE_VARIABLE,
    MAELYS_DATALOG_DIAG_PARSER_INVALID_COMPARISON,
    MAELYS_DATALOG_DIAG_PARSER_INVALID_FILTER,
    MAELYS_DATALOG_DIAG_PARSER_EXPECTED_DOT,
    MAELYS_DATALOG_DIAG_PARSER_EXPECTED_NECK,
    MAELYS_DATALOG_DIAG_PARSER_FACT_USES_NON_BASE_PREDICATE,
    MAELYS_DATALOG_DIAG_PARSER_ANONYMOUS_VARIABLE_IN_HEAD,
    /* Historical code name: also covers arithmetic expressions and not().
     * The message identifies the rejected use of the anonymous variable. */
    MAELYS_DATALOG_DIAG_PARSER_ANONYMOUS_VARIABLE_IN_COMPARISON,
    MAELYS_DATALOG_DIAG_PARSER_ANONYMOUS_VARIABLE_IN_FACT,
    MAELYS_DATALOG_DIAG_PARSER_TOO_MANY_VARIABLES,
    /* Cycle, or finite stratum exhaustion (CAPACITY MAX_STRATA + DEPTH). */
    MAELYS_DATALOG_DIAG_POLICY_NOT_STRATIFIABLE,
    MAELYS_DATALOG_DIAG_RUNTIME_INVALID_COMPARISON,
    MAELYS_DATALOG_DIAG_RUNTIME_INVALID_FILTER,
    MAELYS_DATALOG_DIAG_REGISTRY_CONFLICT,
    MAELYS_DATALOG_DIAG_REGISTRY_MUTATION_AFTER_FREEZE,
    MAELYS_DATALOG_DIAG_MALFORMED_PROGRAM,
    MAELYS_DATALOG_DIAG_OPERATION_REJECTED = 256,
    MAELYS_DATALOG_DIAG_SOLVE_MAX_DEPTH = 513,
    MAELYS_DATALOG_DIAG_SOLVE_IDB_OVERFLOW,
    /* Includes arithmetic overflow; COMPARISON identifies operator/kinds.
     * Arithmetic overflow is not CAPACITY exhaustion. */
    MAELYS_DATALOG_DIAG_SOLVE_COMPARISON_TYPE_ERROR,
    MAELYS_DATALOG_DIAG_SOLVE_FILTER_ERROR,
    MAELYS_DATALOG_DIAG_SOLVE_MALFORMED_FACT,
    MAELYS_DATALOG_DIAG_SOLVE_MALFORMED_EDB,
    MAELYS_DATALOG_DIAG_SOLVE_INVALID_STATE,
    MAELYS_DATALOG_DIAG_SOLVE_INVALID_ARGUMENT,
    MAELYS_DATALOG_DIAG_SOLVE_INTERNAL_ERROR,
    MAELYS_DATALOG_DIAG_SOLVE_AGGREGATE_DOMAIN_ERROR,
    MAELYS_DATALOG_DIAG_SOLVE_SUM_OVERFLOW
} maelys_datalog_diag_code_t;

Functions

diag_code_name()

C · functionSince v0.10.0
diag_code_name()

#include <maelys/datalog.h>

const char *
maelys_datalog_diag_code_name(
maelys_datalog_diag_code_t code
);
Converts a diagnostic reason code into a readable name, complementing the broader public status.
Arguments
Typed reason from an initialized diagnostic.
Return value

const char *

Returns a stable reason name suitable for diagnostics; the status remains the call outcome.

Example
maelys_datalog_diagnostic_t diagnostic = failed_diagnostic();
printf("code name: %s\n", maelys_datalog_diag_code_name(diagnostic.code));
code name: manifest_unknown_domain

Enum: diagnostic_source_t

C · enumSince ≤ v0.1.0-alpha.2
diagnostic_source_t

#include <maelys/datalog.h>

Identifies the producer of diagnostic details: NONE, policy loading, or solving.
Members
DIAGNOSTIC_NONE0
No diagnostic detail was supplied.
DIAGNOSTIC_LOAD1
Diagnostic details came from policy loading.
DIAGNOSTIC_SOLVE2
Diagnostic details came from solving.
Typedef
typedef enum {
    MAELYS_DATALOG_DIAGNOSTIC_NONE = 0,
    MAELYS_DATALOG_DIAGNOSTIC_LOAD = 1,
    MAELYS_DATALOG_DIAGNOSTIC_SOLVE = 2
} maelys_datalog_diagnostic_source_t;

Enum: limit_t

C · enumSince v0.4.0
limit_t

#include <maelys/datalog.h>

Identifies a budget dimension rather than its current occupancy. limit_get() reports library-wide ceilings; session-specific dimensions have no global value. Capacity diagnostics report the effective bound at the failure site, including session quotas.
Members
LIMIT_MAX_SYMBOLS1
Maximum distinct symbols in the engine symbol table.
LIMIT_STRING_POOL_BYTES2
Byte capacity of the engine symbol-text pool.
LIMIT_MAX_PREDICATES3
Maximum declared predicates.
LIMIT_MAX_RULES4
Maximum compiled rules.
LIMIT_MAX_ARITY5
Maximum number of terms in a predicate.
LIMIT_MAX_BODY_LITERALS6
Maximum body literals per rule.
LIMIT_MAX_DEPTH7
Maximum configured derivation depth.
LIMIT_MAX_EDB_FACTS8
Maximum input entries; counted before deduplication.
LIMIT_MAX_IDB_FACTS9
Maximum derived facts.
LIMIT_MAX_FACTS_PER_PRED10
Maximum facts retained for one predicate.
LIMIT_MAX_STRING_BYTES11
Maximum UTF-8 bytes in one input string.
LIMIT_INPUT_EDB_TEXT_BYTES12
Default and maximum byte capacity for owned input EDB text.
LIMIT_MAX_POLICY_ATOMS13Since v0.16.0
Maximum declared policy-source atoms.
LIMIT_MAX_POLICY_ATOM_BYTES14Since v0.16.0
Maximum UTF-8 bytes across policy atoms, excluding NUL terminators.
LIMIT_MAX_RULE_VARIABLES15Since v0.23.0
Maximum variables in one rule.
LIMIT_MAX_ARITH_EXPR_NODES16Since v0.23.0
Maximum arithmetic-expression nodes in one rule.
LIMIT_MAX_ARITH_EXPR_DEPTH17Since v0.23.0
Maximum arithmetic-expression depth.
LIMIT_MAX_FILTER_PATTERN_BYTES18Since v0.23.0
Maximum bytes in one filter pattern.
LIMIT_MAX_FILTER_PROGRAMS19Since v0.23.0
Maximum compiled filter programs.
LIMIT_FILTER_PATTERN_POOL_BYTES20Since v0.23.0
Byte capacity of the compiled filter-pattern pool.
LIMIT_MAX_FILTER_EVALUATIONS21Since v0.23.0
Maximum filter evaluations.
LIMIT_MAX_FILTER_COST_UNITS22Since v0.23.0
Maximum filter cost units.
LIMIT_SESSION_ARENA_BYTES23Since v0.23.0
Session-specific arena byte budget; no global limit_get() value.
LIMIT_EXECUTION_BYTES24Since v0.23.0
Session-specific execution byte budget; no global limit_get() value.
LIMIT_MAX_RULE_FACTS25Since v0.23.1
Maximum number of static policy facts in a compiled program.
LIMIT_MAX_STRATA26Since v0.25.0
Maximum number of strata in a compiled program.
Typedef
typedef enum {
    MAELYS_DATALOG_LIMIT_MAX_SYMBOLS = 1,
    MAELYS_DATALOG_LIMIT_STRING_POOL_BYTES,
    MAELYS_DATALOG_LIMIT_MAX_PREDICATES,
    MAELYS_DATALOG_LIMIT_MAX_RULES,
    MAELYS_DATALOG_LIMIT_MAX_ARITY,
    MAELYS_DATALOG_LIMIT_MAX_BODY_LITERALS,
    MAELYS_DATALOG_LIMIT_MAX_DEPTH,
    MAELYS_DATALOG_LIMIT_MAX_EDB_FACTS,
    MAELYS_DATALOG_LIMIT_MAX_IDB_FACTS,
    MAELYS_DATALOG_LIMIT_MAX_FACTS_PER_PRED,
    MAELYS_DATALOG_LIMIT_MAX_STRING_BYTES,
    MAELYS_DATALOG_LIMIT_INPUT_EDB_TEXT_BYTES,
    MAELYS_DATALOG_LIMIT_MAX_POLICY_ATOMS,
    MAELYS_DATALOG_LIMIT_MAX_POLICY_ATOM_BYTES,
    MAELYS_DATALOG_LIMIT_MAX_RULE_VARIABLES,
    MAELYS_DATALOG_LIMIT_MAX_ARITH_EXPR_NODES,
    MAELYS_DATALOG_LIMIT_MAX_ARITH_EXPR_DEPTH,
    MAELYS_DATALOG_LIMIT_MAX_FILTER_PATTERN_BYTES,
    MAELYS_DATALOG_LIMIT_MAX_FILTER_PROGRAMS,
    MAELYS_DATALOG_LIMIT_FILTER_PATTERN_POOL_BYTES,
    MAELYS_DATALOG_LIMIT_MAX_FILTER_EVALUATIONS,
    MAELYS_DATALOG_LIMIT_MAX_FILTER_COST_UNITS,
    MAELYS_DATALOG_LIMIT_SESSION_ARENA_BYTES,
    MAELYS_DATALOG_LIMIT_EXECUTION_BYTES,
    MAELYS_DATALOG_LIMIT_MAX_RULE_FACTS,
    MAELYS_DATALOG_LIMIT_MAX_STRATA
} maelys_datalog_limit_t;

Functions

limit_get()

C · functionSince v0.4.0
limit_get()

#include <maelys/datalog.h>

maelys_datalog_status_t
maelys_datalog_limit_get(
maelys_datalog_limit_t limit,
size_t *out_value
);
Reads a selected build capacity from the loaded library so callers can size bounded inputs.
Arguments
Installed-library capacity selector.
Outputs

Written on success.

out_valuesize_t *out
Receives the selected capacity on success.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with a library-wide capacity. Session-specific dimensions return UNSUPPORTED. Unknown identifiers and a null output return INVALID_ARGUMENT. Failure leaves the output unchanged.

Example
size_t max_arity = 0;
maelys_datalog_status_t status = maelys_datalog_limit_get(
    MAELYS_DATALOG_LIMIT_MAX_ARITY, &max_arity);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("maximum arity: %zu\n", max_arity);
status: ok
maximum arity: 4

limit_name()

C · functionSince v0.23.0
limit_name()

#include <maelys/datalog.h>

const char *
maelys_datalog_limit_name(
maelys_datalog_limit_t limit
);
Returns the stable name of a public budget identifier.
Arguments
Budget identifier to name.
Return value

const char *

Returns the stable budget name, such as MAX_RULES, or NULL for an unknown identifier.

Example
const char *name = maelys_datalog_limit_name(MAELYS_DATALOG_LIMIT_MAX_RULES);
printf("limit name: %s\n", name ? name : "unknown");

Usage guides