Persist registry and revision state
Wanaku keeps the registry and the evaluator and action-policy revision histories in files, so that they survive a restart. WANAKU_PERSIST_BACKEND and WANAKU_PERSIST_PATH control all of these files.
Registry Persistence
File persistence is enabled by default. Wanaku reads and writes $HOME/.wanaku/server/registry.json. Set a different directory when the default location is not suitable:
export WANAKU_PERSIST_BACKEND=file
export WANAKU_PERSIST_PATH=/data/registryOn startup, the server loads registry.json from WANAKU_PERSIST_PATH. Each registry change sends a full snapshot to one background writer. The writer keeps only the newest pending snapshot. On an orderly Pingora shutdown, Wanaku waits for pending persistence for up to 10 seconds.
Format:
{
"tools": [],
"resources": [],
"prompts": [],
"namespaces": [],
"forwards": []
}Limitation: File persistence has one in-process writer. It does not coordinate separate Wanaku processes. Do not run multiple replicas against the same persistence directory. If the process stops because of SIGKILL, an out-of-memory error, or a panic, changes since the latest completed snapshot are lost. Use a shared external persistence implementation before you run multiple replicas.
To disable persistence:
export WANAKU_PERSIST_BACKEND=noneWith none, the registry stays in memory. Wanaku loses all registry changes at restart.
Registry data at startup
The registry gets data from three sources: wanaku.yaml, the management API (also used by the CLI and the Admin UI), and the discovery of forwards. This section tells which data Wanaku persists and which source wins when two sources define the same entry.
Static and dynamic data
- Static data is the data that you write in
wanaku.yamlbefore startup: forwards, namespaces, credential bindings, and feature settings. A forward fromwanaku.yamlis a static forward. The management API and the Admin UI show it with"static": true. - Runtime data is the data that you add, change, or remove through the management API after startup.
- Discovered data is the tools, resources, resource templates, and prompts that Wanaku gets from an upstream MCP server when it discovers a forward. Each discovered entry has a
forwardIdthat identifies its forward.
What Wanaku persists
| Data | Persisted |
|---|---|
| Static forwards | No. Wanaku registers them from wanaku.yaml at each startup. |
| Forwards from the management API | Yes |
| Discovered entries | No. Wanaku discovers them again at each startup. |
| A disabled discovered entry | Yes, so that it stays disabled after the next discovery |
| Tools, resources, and prompts that you register directly | Yes |
| Agents, namespaces, and credential bindings | Yes |
The management API always creates a forward with "static": false. The API ignores a static value in the request body.
Startup order
- Wanaku loads the registry snapshot from the persistence backend. Each restored forward is unavailable until its discovery succeeds.
- Wanaku registers the
namespacesfromwanaku.yaml. - Wanaku registers the
forwardsfromwanaku.yamlas static forwards and marks each one unavailable. - Wanaku registers the
bindingsfromwanaku.yaml. - Wanaku removes the restored disabled entries of forwards that are not registered, and the entries that are not in the current namespace of their forward.
- Wanaku discovers each registered forward, static or restored. If the discovery succeeds, Wanaku publishes the entries of the forward and marks the forward available. An entry that was disabled stays disabled.
- The features load their sections of
wanaku.yaml.
Startup discovers the forwards at the same time. Startup waits for the slowest upstream. An unreachable upstream adds its connection timeout to the startup time. If a discovery fails, the forward stays unavailable. It keeps only its restored disabled entries. MCP clients do not see disabled entries. The background reconnect loop tries the discovery again. See WANAKU_FORWARD_HEALTHCHECK_INTERVAL in Wanaku environment variables.
Precedence
- An entry in
wanaku.yamlreplaces a persisted entry with the same name. This rule applies to forwards, namespaces, and credential bindings.wanaku.yamlwins at each startup. - You can delete a static forward through the management API or the Admin UI. Wanaku removes it until the next startup. To remove it permanently, also remove it from
wanaku.yaml. The Admin UI shows a warning before it deletes a static forward. - A change that you make through the management API to a static forward stays until the next startup. The forward stays static, so Wanaku does not persist the change. At the next startup, the
wanaku.yamlentry replaces it. - If you remove a forward from
wanaku.yaml, Wanaku does not register it at the next startup. - In one namespace, a discovered name belongs to one forward. Discovery does not replace an entry that a different forward owns. See Name Conflicts in a Namespace.
- Evaluator and action-policy revisions and WASM tool handlers have their own rules. See Evaluator Revision Persistence, Action Policy Revision Persistence, and WASM tool handler persistence.
Snapshots from earlier versions
A snapshot from an earlier version can contain forwards from wanaku.yaml and all discovered entries. At startup, Wanaku ignores the discovered entries that are enabled. Wanaku restores the persisted forwards as runtime forwards. A forward that is still in wanaku.yaml becomes static again, and Wanaku removes it from the next snapshot. A forward that you removed from wanaku.yaml before the upgrade stays in the registry. Delete it through the management API.
An earlier version can read a snapshot from this version, but it does not discover the restored forwards at startup. After a downgrade, refresh each forward to get its entries back.
Embedded redb Persistence
Wanaku can keep the registry and the audit trail in an embedded redb database instead of registry.json. redb runs inside the Wanaku process. It needs no external database or storage service.
export WANAKU_PERSIST_BACKEND=redb
export WANAKU_PERSIST_PATH=/data/registryOn startup, Wanaku opens wanaku.redb in WANAKU_PERSIST_PATH. If the file does not exist, Wanaku creates it. The default backend stays file.
The redb backend stores the registry (agents, tools, resources, prompts, forwards, namespaces, and credential bindings) and the audit events. Evaluator revisions, action-policy revisions, WASM tool handlers, and plugin configuration stay in their JSON files in the same directory.
Storage layout
Each registry record kind has its own table. Each row holds one record. The row key is the record name, scoped by namespace where the registry scopes it. The row value is the JSON form of the record. Audit events have their own table. The row key is the event sequence number. The database also stores a schema version.
Writes and durability
- Each registry change sends a snapshot to the same background writer as the
filebackend. The writer keeps only the newest pending snapshot. - The writer runs on a dedicated thread, not on an async runtime worker.
- The writer applies each snapshot in one redb write transaction. The transaction writes only the rows that changed and removes the rows that are gone. It does not replace the whole registry.
- The transaction commits with immediate durability. A commit returns after the data is on disk.
- If a commit fails, the database keeps the previous committed state. The registry persistence status or the audit health reports the error.
- A management API call returns before the background writer commits its change. A process stop before the commit loses that change.
- Audit events use a separate background writer and separate transactions. The writer collects the events recorded since its last commit and writes them in one transaction.
- An audit commit inserts only new events. It does not write stored events again. A retried commit writes each event to the same row, so a retry does not duplicate events.
WANAKU_AUDIT_MAX_RECORDSsets the audit retention. An audit commit removes the events that are no longer in the audit store.- Audit queries read the events in memory, not the database. The database holds the same events.
Recovery and failures
- After an unclean shutdown, redb repairs the database when Wanaku opens it. The database contains the last committed transaction.
- If Wanaku cannot open
wanaku.redb, startup stops. Causes include a corrupt file, a file with a newer schema version, and a file that another process holds open. - After a storage I/O error, redb refuses all later writes, for the registry and for audit events. Restart the server to write again.
- If a stored record or audit event is not valid, startup stops. A record is not valid when it is not valid JSON, when an agent fails validation, or when the namespace graph is not valid. Wanaku does not write to the database in this case, so the stored records stay unchanged. Fix or move the database file, then start the server again.
Limits
- redb locks the database file. Only one Wanaku process can use a database file at a time.
- redb does not replicate data to other hosts. Do not put the file on a shared file system for multiple replicas.
- Wanaku does not import
registry.jsonoraudit-events.jsonintowanaku.redb. When you change the backend, the registry and the audit trail start empty, and Wanaku keeps the JSON files unchanged.
WASM tool handler persistence
When file persistence is enabled, the server reads and writes tool-handlers.json in WANAKU_PERSIST_PATH. This file contains handler definitions, component paths, capability grants, and execution limits. It does not contain compiled native code or component bytes.
Deploy each referenced component file before you restart the server. Startup recompiles and validates the components. An invalid or missing component stops startup. An explicit tool_handlers configuration replaces the restored handler configuration. An absent key retains the restored configuration. An empty list removes all handlers.
Runtime activation validates and compiles the candidate before publication. A failed activation retains the active configuration. See WASM tool handlers for the host API and lifecycle procedures.
Evaluator Revision Persistence
Evaluator revision history uses the same persistence configuration as the registry. When WANAKU_PERSIST_BACKEND=file, the server reads and writes evaluator-revisions.json in WANAKU_PERSIST_PATH. When persistence is disabled, revision history stays in memory and is lost on restart.
The server writes the file after every revision change, not only at shutdown. A revision created or activated through the management API therefore survives an abrupt stop.
On startup the server loads the persisted history. The wanaku.yaml configuration is the source of truth for the live runtime. If the startup configuration matches the persisted active revision, the server re-validates and recompiles that revision and installs it, without recording a new revision. If the startup configuration differs, the server activates it as a new revision.
When the server re-applies an existing active revision, it re-validates the evaluator names, triggers, and LLM connection references and recompiles the WASM processors and result schemas. If the revision no longer validates or compiles on the current host, the server marks the evaluator runtime invalid and logs the error. Startup stops by default. The top-level evaluator_startup_failure: deny option permits startup with an invalid runtime. Governed actions are then blocked in enforce mode. The server does not append a revision in this case.
The server keeps a bounded history of the most recent 50 revisions. Older revisions are dropped. Rejected revisions are also persisted, so a failed activation stays visible in the history.
If the startup wanaku.yaml evaluator configuration is identical to the persisted active revision, the server keeps that revision active and creates no new revision. A restart with an unchanged configuration does not grow the history.
Format:
{
"revisions": [],
"active_id": null,
"next_id": 1
}Limitation: File persistence supports one writer. Use a shared external persistence implementation before you run multiple replicas.
Update an earlier pre-release configuration
This section applies to the 0.3.0 pre-release builds. Evaluator configuration changed between these builds. The 0.3.0 release removes on_error without an automatic migration. The field is rejected in YAML, API requests, and all persisted evaluator revisions, including inactive revisions.
Before you start the updated build:
- Stop the server.
- Back up the configuration and
evaluator-revisions.jsoninWANAKU_PERSIST_PATH. The default directory is$HOME/.wanaku/server. - Remove
on_errorfrom each evaluator in the startup YAML and each definition in the persisted revision history. - Set
governance.default.on_failureor a namespace override in the startup YAML. Useallowfor the formercontinuebehavior. Usedenyfor the formerblockbehavior. The setting applies to shared namespace governance, not to one evaluator. Evaluators in the same namespace must use the same failure behavior. - Start the server with the updated configuration.
To discard pre-release evaluator history instead, move the backed-up evaluator-revisions.json out of the persistence directory while the server is stopped. Restore the required evaluator definitions in the startup YAML before restart. This resets evaluator revision history. Keep registry.json and other persistence files in place.
The server stops at startup if legacy fields remain in the revision file. evaluator_startup_failure: deny does not migrate this file or restore evaluator readiness.
Action Policy Revision Persistence
Action-policy revision history uses the same persistence settings. Wanaku writes action-policy-revisions.json in WANAKU_PERSIST_PATH. The action-policy stream is independent from the evaluator stream.
Wanaku writes the file after each revision change. Wanaku validates and installs the persisted active policy during startup. See Action Policies for the policy schema and lifecycle.
Next steps
- Wanaku environment variables: find the defaults of the persistence variables.
- Deploy Wanaku on Kubernetes and OpenShift: mount a persistent volume for the persistence directory.
- FAQ and Troubleshooting: find out why registry data is lost on restart.