Skip to content

REST API

The neuro-symbolic feature exposes a rule CRUD surface, an LLM-free reasoning endpoint, and the verifiable query endpoint. All paths are relative to the HyperMesh API server (default http://localhost:8000).

Method & pathAuthPurpose
GET /v1/rulesreadList rules
POST /v1/ruleswriteCreate/update a rule (re-validates the whole set)
POST /v1/rules/validatereadDry-run validate a rule (no write)
GET /v1/rules/{id}readFetch one rule
DELETE /v1/rules/{id}writeDelete a rule
POST /v1/reasonreadRetrieve + reason (LLM-free) → derived facts + proofs
POST /v1/rag/queryreadFull pipeline; mode, require_proof, mock, rules
Terminal window
curl -s localhost:8000/v1/rules
{ "rules": [ {"id": "...", "name": "...", "enabled": true, "priority": 10,
"version": 1, "head": "coordinated_threat", "body_size": 4} ] }

Body is a rule object (see Rules). Re-validates and re-stratifies the entire set; returns the stored rule plus its stratum. 422 with a precise message if the rule is malformed, unsafe, or makes the set non-stratifiable.

Terminal window
curl -sX POST localhost:8000/v1/rules \
-H 'content-type: application/json' -d @rule.json
{ "id": "rule:coordinated_threat", "name": "...", "enabled": true,
"if": [...], "then": {"pred": "coordinated_threat", "args": ["?E"], "confidence": 0.9},
"stratum": 1 }

Dry-run; never writes. Safe to call from an editor on every change.

Terminal window
curl -sX POST localhost:8000/v1/rules/validate \
-H 'content-type: application/json' -d @rule.json
{ "ok": true, "errors": [], "stratum": 1 }

GET /v1/rules/{id} · DELETE /v1/rules/{id}

Section titled “GET /v1/rules/{id} · DELETE /v1/rules/{id}”
Terminal window
curl -s localhost:8000/v1/rules/rule:coordinated_threat
curl -sX DELETE localhost:8000/v1/rules/rule:coordinated_threat

404 if the id doesn’t exist. Delete returns {"id": "...", "deleted": true}.

Retrieves hyperedges for the query and runs the symbolic reasoner. No model is called. Use it for audits, CI, and air-gapped checks.

Request

FieldTypeDefaultMeaning
querystrNatural-language query (drives retrieval).
tablestrHyperedge table.
top_kint40Max edges retrieved.
require_proofboolfalseAbstain unless something is proved.
ruleslist | nullnullAd-hoc rules; else the durable rule store.
Terminal window
curl -sX POST localhost:8000/v1/reason -H 'content-type: application/json' -d '{
"query": "which edges are coordinated threats?",
"table": "DRONES",
"require_proof": true
}'

Response

{
"query": "...", "table": "DRONES",
"answer": "coordinated_threat(42) is established by rule ... [RULE-0][STEP-1][HEDGE-42] (confidence 0.90). Sources: [STEP-1]",
"abstained": false,
"derived_facts": [ {"step_tag": "STEP-1", "fact": "coordinated_threat(42)",
"predicate": "coordinated_threat", "args": [42],
"confidence": 0.9, "rule_id": "rule:coordinated_threat",
"rule_tag": "RULE-0", "hedge_tags": ["HEDGE-42"]} ],
"proofs": [ { "proof_id": "proof-1", "status": "proved", "nodes": [...], "edges": [...] } ],
"rules_fired": ["rule:coordinated_threat"],
"reasoning_ms": 1.2
}

422 for a bad table, bad mode, or invalid ad-hoc rule.

POST /v1/rag/query — full verifiable query

Section titled “POST /v1/rag/query — full verifiable query”

The complete pipeline: retrieve → reason → prove → generate → firewall.

Request

FieldTypeDefaultMeaning
querystrNL query.
tablestrHyperedge table.
modestr"hybrid"neuro | symbolic | hybrid.
require_proofboolfalseAbstain unless proved.
mockboolfalseUse the deterministic mock LLM (no network).
ruleslist | nullnullAd-hoc rules; else the rule store.
modelstrgpt-4o-miniLLM model (ignored if mock).
base_urlstrOpenAIAPI base URL.
openai_api_keystrenvKey (or OPENAI_API_KEY).
top_kint40Max edges retrieved (1–200).
token_budgetint3000Context token budget (500–12000).
time_start / time_endint | nullnullOverride the parsed time window.
Terminal window
curl -sX POST localhost:8000/v1/rag/query -H 'content-type: application/json' -d '{
"query": "summarize the coordinated threats",
"table": "DRONES",
"mode": "hybrid",
"require_proof": true,
"mock": true
}'

Response — the full RAGResult.as_dict():

{
"query": "...", "answer": "...", "table": "DRONES",
"mode": "hybrid", "abstained": false,
"cited_edges": [...], "all_edges": [...],
"derived_facts": [...], "proofs": [...],
"firewall": {"outcome": "supported", "abstained": false, "coverage": 1.0,
"supported_count": 1, "stripped_count": 0, "stripped": []},
"rules_fired": ["rule:coordinated_threat"],
"confidence": 0.9, "low_confidence": false,
"model": "mock", "prompt_tokens": 0, "completion_tokens": 64,
"retrieval_ms": 3.1, "reasoning_ms": 1.2, "generation_ms": 0.4, "total_ms": 5.0,
"context_tokens": 240, "interaction_id": "..."
}

422 for an invalid mode or bad ad-hoc rule; 404 if the table isn’t found.

Rule writes (POST /v1/rules, DELETE /v1/rules/{id}) require a write-scoped key; the rest require a read key. See Authentication & Keys.