Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Errors and recovery

Treat an error as a result with a defined recovery path. Do not convert it to a neutral probability or silently drop a question from evaluation.

CodeTypical causeAppropriate response
invalid_jsonSyntax, unknown fields, wrong types, invalid probability during decodingCorrect the request; no command executed
validationImpossible evidence, incoherent probabilities, bad timeline, stale predecessorReconsider inputs or read current state; do not fabricate a substitute number
not_foundMissing question/version keyCheck target identity; create the intended question if appropriate
conflictReused request ID with different content, duplicate persisted key, SQL constraintReconcile intended mutation with existing state
busySQLite could not obtain a required lock within five secondsBack off and retry the identical mutation/ID
storageOther SQLite or journal failurePreserve the database, inspect the fault, and restore only through a verified procedure
request_too_largeLine exceeds 1 MiBReduce/split the operation where semantics permit; restart the process

Core validation errors are mapped to validation after a request is decoded. A numeric probability rejected by transport decoding instead appears as invalid_json. Error messages explain a specific failure but are not a stable machine enum; branch on the code and your operation context.

Failed writes are atomic

A mutation validates under the database transaction and commits its event and receipt together. Failure in either insert rolls back both. The test suite injects a receipt-write failure after the event insert to verify that no partial event survives.

A failed mutation does not consume the request ID. You can fix a previously uncommitted request and submit it under that ID, although recording a distinct attempt ID can be useful at the application layer. After a successful mutation, the ID is bound to its decoded content.

Stale revisions

If another worker appends after you read the ledger, your predecessor becomes stale. Reading the newest revision and blindly substituting its ID is unsafe: the evidence may already be incorporated or the assumptions may have changed. Recompute the intended update against the new history.

Impossible evidence

When a supplied observation has zero probability under the entire current model, Bayesian updating cannot produce a valid posterior. This is a model error. Inspect the event definition, prior, likelihoods, and observation claim. Returning 0.5 would hide the failure.

Startup and output failure

An invalid database, unsupported schema version, unavailable filesystem path, or failed output write can stop the process with exit code 2. These failures may not have a JSON response. If a response was lost, use idempotent replay to determine whether the intended mutation committed.

The library does not automatically repair an unknown schema or delete damaged history. Keep backups and the release version that created them. See storage and operations for the supported local workflow.