Skip to content

Execute Cypher with a caller-supplied DERIVE rule set evaluated for this query only

POST
/api/v1/admin/kg/derive
curl --request POST \
--url http://localhost:11044/api/v1/admin/kg/derive \
--header 'Content-Type: application/json' \
--header 'X-Embabel-Api-Key: <X-Embabel-Api-Key>' \
--data '{ "cypher": "example", "derives": "example", "description": "example", "name": "example", "paramSpecs": { "additionalProperty": { "choices": [ "example" ], "default": "example", "description": "example", "required": true, "type": "string" } }, "params": { "additionalProperty": "example" }, "requires": [ { "description": "example", "materialize": "example" } ], "rules": [ { "derive": "example", "from": "example" } ] }'

The rule set’s derived label is visible to the query as an ordinary label; nothing persists. Invalid rule sets are refused with the validator’s messages.

username
string

Optional, and never needed: the call always acts as the signed-in principal. Naming the principal changes nothing; naming anyone else is refused with 403.

The rule set to evaluate for this one query, and the query that reads it: cypher (sees the derived label as an ordinary label), derives (the label the rules conclude), rules (each a derive head pattern and a RETURN-less Cypher from body), and optionally name (default adhoc/<derives>), description, paramSpecs (declared bind variables, referenced as $name in rule bodies), params (values for them; the whole map also binds the outer query) and requires (materialization demands run before the rules). Rule bodies are scoped to the acting user and nothing persists. An invalid rule set, a body label the world does not know, or a param that does not resolve answers 400

Media typeapplication/json

Body of POST /admin/kg/derive: a DERIVE rule set to evaluate for this one query, and the Cypher that reads what it derives. Nothing persists; the world’s installed rule sets are evaluated alongside it.

object
cypher
required

The Cypher query to run with the derived label or relationship type visible like any other

string
derives
required

The label the rules derive, or the relationship type when the heads are relationship patterns: letters, digits and _, starting with a letter

string
description
required

One-line description of the rule set; empty when omitted

string
name

Qualified name for the rule set, realm/ruleset style; validator messages and traces name it. Defaults to adhoc/ followed by derives. An installed rule set of the same name is shadowed for this query

string
paramSpecs
required

Bind variables the rule set declares, by name, in the view-param vocabulary (type, default, description); referenced as $name in rule bodies and demands. A param with no default must be given in params

object
key
additional properties

A declared bind variable of a saved view, referenced as $name in its Cypher and supplied per invocation, keyed by that name wherever a view’s params are declared or listed

object
choices

The fixed set of values this param accepts — rendered as a select, enforced at invocation. Absent = any value of the declared type.

Array
default

Used when an invocation omits this param. Absent = required on invocation, unless required: false.

description

What the argument means — rendered verbatim as the field’s hint.

string
required

False lets an invocation omit a param that has no default; it is then bound to null.

boolean
type

The coercion applied to supplied values, and the form control a UI renders (int/number a number field, boolean a checkbox, date a date picker). float and double are aliases of number.

string
default: string
Allowed values: string int number float double boolean date
params
required

Invocation values: keys declared in paramSpecs bind the rule bodies, coerced to their declared types; the whole map also binds the query as ordinary params

object
key
additional properties
requires
required

Materialization demands run before the rules; an unsatisfiable one does not fail the query. Empty when omitted

Array<object>

A materialization demand in an ad-hoc rule set: facts fetched into the query before the rules run, as an installed rule set’s requires: entry

object
description
required

Why the rule set needs these facts; empty when omitted

string
materialize
required

Read-only Cypher, MATCH clauses and one RETURN (RETURN 1 is enough), run after the query has materialized its anchors to deepen what it fetched, e.g. MATCH (r:NpmRelease)-[:HAS_DEPENDENCY*1..3]->(:NpmDependency) RETURN 1. May reference the rule set’s declared params

string
rules
required

The rules: unordered clauses of one definition, at least one, all concluding derives and all of the same kind

Array<object>

One DERIVE rule in an ad-hoc rule set sent to POST /admin/kg/derive: what it concludes (the head) and when (the body)

object
derive
required

The head: a Cypher node pattern, or a relationship pattern for a rule set deriving a relationship, whose variable names the body binding that becomes a member, whose label or type is the rule set’s derives, and whose property map defines derived properties from body-bound expressions, e.g. (e:Blocked {blockedStake: stake})

string
from
required

The body: read-only Cypher that binds the head’s variables and has no RETURN. It may match the derived label itself

string

The query result over the derived overlay

Media typeapplication/json

Answer of POST /admin/kg/derive: the query result, plus every rule set evaluated for it with its derivations

object
derived
required

Each rule set evaluated for the query, the ad-hoc one and any installed ones it reached, with members, rounds and why traces

Array<object>

One rule set evaluated for the query: what it derived, how many rounds the fixpoint took, and each member’s why trace

object
derivations
required

Derived members with their traces, in the order concluded, at most 500

Array<object>

One member of a derived label or relationship type, with the firing chain that concluded it

object
elementId
required

The member node’s element id, the key to join query rows to traces (RETURN elementId(x)). For a derived relationship, the two endpoints’ element ids joined by a NUL character and ->

string
props
required

Derived property values as they settled at the fixpoint, by property name (the last write wins)

object
key
additional properties
round
required

Fixpoint round, counting from 1, in which this member was first concluded

integer format: int32
rule
required

Position, counting from 1, of the rule that first concluded this member

integer format: int32
trace
required

Firings oldest first: each rule’s first conclusion of this member, and every later firing that changed its values

Array<object>

One firing in a derived member’s why trace: which rule concluded it, in which fixpoint round, with what property values

object
props
required

Derived property values this firing concluded, by property name; empty when the head declares none

object
key
additional properties
round
required

Fixpoint round the rule fired in, counting from 1

integer format: int32
rule
required

Position of the rule that fired in the rule set’s rules, counting from 1

integer format: int32
label
required

The label, or relationship type, the rule set derives

string
members
required

Number of members derived, counted in full even when derivations is truncated

integer format: int32
rounds
required

Fixpoint rounds run, including the final round that changed nothing

integer format: int32
ruleSet
required

Qualified name of the rule set evaluated

string
truncated
required

True when derivations was capped at 500; members and rounds still cover everything

boolean
result
required

The Cypher query’s result, run over the derived overlay

object
answerBoundary

The rows are supporting context only, not a match for the original question.

object
kind
required

What the rows are instead of an answer. Only SUPPORTING_CONTEXT_ONLY exists.

string
Allowed values: SUPPORTING_CONTEXT_ONLY
unresolvedQuestion

The question the rows do not answer: the asked question on /ask, view:<name> on a view run. Null on /execute, which has no question.

string
apiCallLog
required

The actual calls as producer(keys), in order — fan-out is visible here.

Array<string>
apiCalls
required

External fetches the executor made. 0 means everything was cached or local.

integer format: int32
capturedScope

The scope this result set froze into — present only on a capturing execute.

object
capturedAt
required

When the membership froze, ISO-8601.

string
expiresAt

When the scope lapses, ISO-8601 — null means PINNED (kept until deleted).

string
members
required

How many members the capture froze. Membership is frozen; values stay live.

integer format: int64
name
required

The name the scope was captured under, unique per user; a later query binds it as (x:$name).

string
outputLabel
required

The node label later references bind with.

string
statement
required

The statement that produced the capture — the scope’s provenance.

string
columnSources

Each column -> the expression that computed it, traced back through WITH and UNWIND, e.g. {“total”: “sum(b.amount)”}; an unwound column reads “UNWIND ”. Where the origin cannot be traced with certainty, the column’s own RETURN expression is given unchanged. A column name is the query’s label for a value, not evidence of what it is.

object
key
additional properties
string
cypher
required

The cypher that actually ran, after scope rewriting.

string
dataContract

The pinned ODCS identity and invocation verdict, for a contracted named view only.

object
apiVersion
required

The ODCS apiVersion the contract declares, such as v3.1.0; v3.1.0 when the view was refused before it ran

string
available
required

False when the view could not run under its contract: the pinned contract or its object is missing, or its status forbids it. Then no rows are returned, whatever the mode

boolean
blocksRows
required
boolean
checkedAt
required

ISO-8601 instant the result was checked

string
checks
required

Each check made, in the order it was made

Array<object>

One check made when a view’s result was evaluated against its data contract

object
kind
required

schema, quality, freshness, status, binding or execution

string
message

What it found, in words, naming rows and fields but never their values; null when there is nothing to say

string
ruleId
required

The contract’s own id for a quality or freshness rule, or an embabel: id for a check the runtime makes itself, such as embabel:schema, embabel:binding or embabel:status

string
scope

invocation for the schema check, which covers this one result; null for every other check

string
verdict
required

PASS, WARN, FAIL, or UNKNOWN when the check could not be made

string
Allowed values: PASS WARN FAIL UNKNOWN
id
required

Id of the governing contract, as the view’s binding pins it

string
mode
required

observe or enforce, from the view’s binding

string
Allowed values: observe enforce
object
required

The contract object the rows were checked against, as the binding names it

string
status
required

The contract’s ODCS status, such as active, deprecated or retired; unavailable when the pinned contract is not in the world

string
verdict
required

The worst of the checks: FAIL if any failed, else UNKNOWN if any could not be made, else WARN if any warned, else PASS

string
Allowed values: PASS WARN FAIL UNKNOWN
version
required

The pinned contract version

string
durationMs
required

Total: bridge-resolve plus materialize plus read.

integer format: int64
error

Why the query failed, or null when it did not.

string
exposure

What the models behind an /ask answer were shown: resolved schema groups and prompt sizes.

object
generationPromptChars

Characters in the Cypher-generation prompt. Absent when no query was generated.

integer format: int32
groups
required

The schema groups rendered in full for generation, and whose views view selection was offered.

Array<string>
indexed
required

Groups named to the generator by one index line only — no labels, properties or examples.

Array<string>
matched

Each named group -> the words that named it, tier first: name:, label:, weak: or keyword:.

object
key
additional properties
Array<string>
resolvedBy
required

How the groups were chosen: WHOLE (nothing to narrow), SCOPE, QUESTION, UNRESOLVED or SELECTOR.

string
spineOnly
required

True when the always-on core was cut to the spine anchors (the user, Person, Organization).

boolean
viewSelectPromptChars

Characters in the view-selection prompt. Absent when no view selection ran.

integer format: int32
viewsInWorld

Saved views in the world.

integer format: int32
viewsOffered

Saved views offered to view selection, of viewsInWorld.

integer format: int32
fetchedRecords

Source records fetched before query-side filtering, cache-served included. Absent when none.

integer format: int32
hint

What to try instead. Accompanies an empty result only.

string
llmCallLog
required

The actual LLM calls (kg-ask and agg-*), in order.

Array<string>
llmCalls
required

LLM calls: the generation plus any aggregate reductions. Reasoning only — a semantic anchor’s embedding is on semanticCalls.

integer format: int32
materializedNodes

Graph nodes materialized from fetched records in this execution. Absent when none.

integer format: int32
question

The question asked, echoed back. Present only for /ask.

string
reason

Typed outcome when this was not a clean answer — UNBOUNDED, NOT_IN_GRAPH, MISSING_ATTRIBUTE, FETCHED_NOT_MATCHED, PARTIAL_NOT_MATCHED, UNPUSHED_FILTER, DISCONNECTED or INTERNAL_ERROR. May accompany rows when a source failed, a read was refused, or a filter was not applied; absent on a clean answer, including a genuine zero.

string
rowCount
required

How many rows rows holds.

integer format: int32
rows
required

One map per row, keyed by RETURN column. Empty and meaningless while run is present — the run has not finished, which is not the same as no data. From a synchronous /execute, a node is its properties plus __type, __labels and __elementId; a relationship its properties plus __type (the relationship type), __elementId, __startElementId and __endElementId (the __elementIds of the nodes it joins); a path its nodes and relationships in traversal order. Elsewhere a node carries __type and __labels and a relationship its properties alone.

Array<object>
object
key
additional properties
run

Present only when /execute with waitSeconds gave up waiting: the run is still going (or parked), and this is how to follow it. Absent on every answer that finished in the call.

object
answer

Where to send the owner’s pick for a parked run. Absent while running.

string
choices

The {kind, question, options, context} payload when parked.

object
key
additional properties
kill

Where to stop the run. Absent when parked — nothing is executing to kill.

string
poll
required

Where to poll for state and, once settled, the result.

string
runId
required

The run’s id, for /runs/{runId}, /kill/{runId} and /runs/{runId}/answer.

string
state
required

RUNNING (materializing now) or WAITING_INPUT (parked on choices).

string
semanticCallLog
required

The actual searches as producer: mode search on index (k=…), in order.

Array<string>
semanticCalls
required

Relevance searches behind a semantic anchor: one embedding plus one similarity scan per anchor. The third call axis — a search of an index is neither a producer fetch nor a reduction, and a semantic query spends here and nowhere else.

integer format: int32
warnings
required

Caveats on this result that do not make it an error — a producer that failed, rows that are partial or supporting context, an aggregate over mixed units. Absent when there are none.

Array<string>

Example

{
"result": {
"answerBoundary": {
"kind": "SUPPORTING_CONTEXT_ONLY"
},
"dataContract": {
"checks": [
{
"verdict": "PASS"
}
],
"mode": "observe",
"verdict": "PASS"
}
}
}

The rule set failed validation; error carries every violation

Media typeapplication/json

A refusal carrying only a human-readable reason.

object
error
required

What went wrong, in the terms the caller can act on.

string

Example generated

{
"error": "example"
}

No authenticated principal

Media typeapplication/json

A refusal carrying only a human-readable reason.

object
error
required

What went wrong, in the terms the caller can act on.

string

Example generated

{
"error": "example"
}

username names someone other than the signed-in principal

Media typeapplication/json

A refusal carrying only a human-readable reason.

object
error
required

What went wrong, in the terms the caller can act on.

string

Example generated

{
"error": "example"
}