# Build with MoolBase

MoolBase is an embedded C++ database with an evidence reasoning runtime. You supply observations and their relationships. The runtime compares explanations and returns a result with a receipt.

Embedded means the database runs inside your application process.

Use it when your application must explain why an answer changed. You still choose relevant evidence and check its sources.

## Start with the memory correction example

[Install the DB and examples](INSTALL.html). Run the memory example, then inspect its receipt. This path shows correction and retirement through the native adapter.

After that, choose C++ for the full native lifecycle. Choose HTTP for the smaller server example below.

## What you get

| Problem | Runtime behavior to inspect | Application responsibility |
| --- | --- | --- |
| Several reports copy one source | Supporting source-group counts | Assign a common group to those copies |
| Sources support different explanations | Alternatives, opposition and result status | Supply support and opposition relationships |
| Evidence is corrected or withdrawn | A revised result and preserved history | Use the native correction flow and retire affected copies |
| Someone asks why the answer changed | The result, uncertainty and receipt | Save the receipt with the answer |

A **source group** identifies observations with a common origin. Copies share one group. Your application establishes whether different groups are independent. Native fields call this an evidence family.

A **receipt** records the runtime result. The browser adapter and HTTP server export different response shapes. Use the example for the interface you choose.

[Browse the HTTP API](api.html) · [Download OpenAPI JSON](api/openapi.json) · [Inspect a recorded HTTP response](api/runtime-response-example.json)

## Choose an integration

| Need | Use | Important limit |
| --- | --- | --- |
| Store, correct and retire evidence; carry prior reasoning state | Embedded C++ `GrapheneDB` and `CompleteHypoKoshRuntime` | Your application must save and restore prior reasoning state and receipts |
| Ingest typed evidence and request a reasoning result | Pilot HTTP server | HTTP does not expose the complete correction and retirement lifecycle |
| Learn the flow in a browser | Evidence Lab and tutorial | Files last for this page session; this is not a hosted database API |

`GrapheneDB`, `graphene` and `GRAPHENEDB_*` are existing implementation names. They refer to MoolBase components. The current downloadable build is **0.6.0-audit.3**. The server may report its older internal version string; use the package manifest and source pin to identify the build.

## Make your first HTTP request

This example stores typed evidence and requests a result. It does not replay the Lab’s complete correction flow.

These commands run the server from the Linux x86_64 DB package. First follow [Install](INSTALL.html) to verify and extract that package. Keep these commands in one Bash terminal so the API key remains available. No model API key is required.

```bash
export MOOLBASE_PREFIX="$PWD/moolbase-0.6.0-audit.3-linux-x86_64"
export GRAPHENEDB_API_KEY="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')"
mkdir -p moolbase-api-data
"$MOOLBASE_PREFIX/bin/graphenedb_server" "$PWD/moolbase-api-data" 16 8080 \
  --bind-address 127.0.0.1 >moolbase-api-server.log 2>&1 &
MOOLBASE_SERVER_PID=$!
curl --fail --retry 10 --retry-connrefused --retry-delay 1 http://127.0.0.1:8080/v1/ready
```

Wait for `status: ready` before sending evidence. If the probe fails, inspect `moolbase-api-server.log`. Use a new data directory for this example if you want the exact recorded response.

### 1. Describe the evidence

The extraction endpoint accepts nodes and typed relationships. Your application supplies this structure. The server does not extract it from a pasted paragraph.

[Download this request](api/extraction-example.json) into your working directory, then send it:

```bash
curl --fail http://127.0.0.1:8080/v1/extractions \
  -H "X-API-Key: $GRAPHENEDB_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary @extraction-example.json
```

```json
{
  "schema_version": 1,
  "source_id": "onboarding-incident",
  "signature": 33,
  "nodes": [
    {"external_id": "release", "content": "release changed pool timeout", "role": "root"},
    {"external_id": "pool", "content": "connection pool exhausted", "role": "node"},
    {"external_id": "checkout", "content": "checkout failures increased", "role": "symptom"}
  ],
  "relations": [
    {"from_external_id": "release", "to_external_id": "pool", "origin": "observed", "role": "mechanistic", "confidence": 0.97, "evidence_id": "config-diff"},
    {"from_external_id": "pool", "to_external_id": "checkout", "origin": "discovered", "role": "causal", "confidence": 0.96, "evidence_id": "pool-trace"}
  ]
}
```

A new extraction returns HTTP `201`. Sending the identical extraction again returns `200` without new writes. Changing a replay with the same source and external IDs can return `409`. This example's confidence and origin values are supplied labels, not judgments made by MoolBase.

### 2. Request a result

```bash
curl --fail http://127.0.0.1:8080/v1/reason/runtime \
  -H "X-API-Key: $GRAPHENEDB_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"query":"checkout failures increased","signature":33,"mode":"empirical","minimum_confidence":0.3,"max_hops":5,"max_paths":32}'
```

The response contains `status`, `primary_node`, `residual_uncertainty`, opposition details and a receipt. [Inspect the full recorded HTTP response](api/runtime-response-example.json). This exact example returns `provisionally_resolved`. It does not produce the same receipt shape as the browser showcase adapter.

`/v1/reason/hypokosh` returns hypothetical proposals. `/v1/reason/dialectic` returns reasoning with configured search limits. `/v1/reason/runtime` runs the combined runtime and returns its result. Use the last endpoint for this example.

### 3. Read the status before using the answer

| Status | Meaning |
| --- | --- |
| `resolved` | The configured evidence rules were met |
| `provisionally_resolved` | A result was selected, but the resolution rules were not fully met |
| `contested` | The result is disputed; inspect the opposition and uncertainty |
| `open` | No conclusion is committed |
| `evidence_required` | More usable evidence is needed |
| `abstain` | The runtime declines to select an answer |
| `speculative` | The result remains speculative; do not treat it as established |

Keep uncertainty and the receipt beside the selected result. Scores such as `confidence`, support and belief are not calibrated probabilities. A resolved result is not proof of objective truth.

### 4. Stop the example server

```bash
kill -TERM "$MOOLBASE_SERVER_PID"
wait "$MOOLBASE_SERVER_PID"
unset GRAPHENEDB_API_KEY
```

## Authentication and errors

Send the configured key in `X-API-Key`, or use `Authorization: Bearer <key>`. Liveness, readiness and version probes are public. The same configured key protects the other routes, including maintenance routes; this preview does not provide separate administrator roles.

Use `Content-Type: application/json` and a known content length for JSON requests. Curl handles the length when you use `--data` or `--data-binary`. For access beyond loopback, follow the repository's [TLS reverse-proxy deployment guide](https://github.com/rastogivaibhav/MoolBase/tree/dab6772e6493bd4301761e2bdd1726c4b337a745/deploy).

| Response | What to do |
| --- | --- |
| `400` | Check the fields and limits; read `error` and any `detail` |
| `401` / `403` | Check the key or the configured proxy policy |
| `409` | Inspect a conflicting replay; do not blindly retry changed data |
| `411` / `413` / `415` | Supply a content length, reduce the request size, or set the JSON content type |
| `429` / `503` | Respect `Retry-After` when present; the server may be rate-limited, busy or not ready |
| `500` / `507` | Inspect the server error; storage or capacity may need attention |

Use `Idempotency-Key` for `/v1/nodes` and `/v1/facts`. Extraction replay uses its own source and external identities. Other writes have different retry rules; read their endpoint details before retrying.

## When to run

Your application decides when to reason: after a relevant observation, after a batch, or when a user asks a question. An HTTP reasoning request reads available evidence and returns a result. It does not run continuously when new logs arrive.

The result reflects the evidence retrieved for that request and the configured limits. Include an `as_of` value when the supported temporal view is needed. Check the receipt and uncertainty; do not assume that a returned result covers every stored record or automatically remains current after later writes.

A 1 TB log collection needs an ingestion and evidence-selection plan first. This preview has not established reasoning latency, throughput or server capacity at that scale. Measure those properties with your workload before a production decision.

## Persistence and evidence lifecycle

Native database files persist on disk. Each HTTP runtime request starts with fresh reasoning state. It does not restore the history of earlier decisions. Your application must save receipts and versioned prior reasoning state separately when it needs them.

Use C++ for the complete correction and retirement flow shown in the Lab. HTTP extraction ingestion is atomic and replay-safe, but it is not a replacement for the Lab's `revoke` and `supersede` event contract. [Read the native input and persistence guide](AGENT_INTEGRATION.html).

## Full API reference

[Browse every versioned HTTP route](api.html). The OpenAPI document combines the shipped pilot contract and runtime supplement into one file. It includes request schemas, authentication, responses and schema definitions. Some existing response contracts remain open JSON objects; those are identified in the reference rather than presented as fully typed responses.

Learning and policy endpoints exist as experimental surfaces. Recording outcomes or an approved retrieval policy does not make the proposed autonomous action layer a shipped capability. [See the capability matrix](CAPABILITIES.html).

The C++ API is in the [public headers at the package source pin](https://github.com/rastogivaibhav/MoolBase/tree/dab6772e6493bd4301761e2bdd1726c4b337a745/include/graphene). Python examples call a native adapter or the pilot HTTP API; there is no published MCP server or hosted MoolBase database service on this website.

## Check the evidence

[Current validation and its limits](VALIDATION.html) · [audit.3 build notes](RELEASE_v0.6.0-audit.3.html) · [Public-incident replay](REAL_INCIDENT.html) · [Repository](https://github.com/rastogivaibhav/MoolBase)

## Explore and automate

[Visual investigation](explore.html) · [Agent entry point](agents.md) · [Discovery manifest](.well-known/moolbase-agent.json)
