OpenRemap Docs

health — API

This page is for developers. If you just want to check a file, the plain-English introduction is the better place to start.

health is one method registered with openremap.api. Everything the CLI can do, the API can do too — same checks, same input rules, same result.

The method is a composite: it runs several built-in sub-checks (identity, checksums, map tables, layout, VINs) and combines them into one verdict. To you it looks like a single call — the composition happens inside.

Input schema

{
    "path": {"type": "str", "required": True, "description": "Path to the binary."},
}

Defaults and validation live in the schema, in the registry — not in the CLI or any client. Every consumer reads the same contract via list_methods.

Calling it in-process (Python)

import openremap.api as api

result = api.call("health", {"path": "stock.bin"})
# result is a plain JSON-serialisable dict — the same report as `openremap health --json`

print(result["healthy"])        # True or False
print(result["family"])         # "EDC17" (or None when unidentified)
for check in result["checks"]:
    print(check["name"], check["status"], check["message"])

Calling it over JSON-RPC

The same call over the stdio server — usable from any language:

echo '{"id": 1, "method": "health", "params": {"path": "stock.bin"}}' \
  | python -m openremap.api.transport.stdio

Response (one JSON object per line):

{"id": 1, "result": {"healthy": true, "file_size": 2097152, "family": "EDC17", "checks": [{"name": "checksums", "status": "ok", "...": "..."}]}}

Errors come back as JSON-RPC error objects — clients branch on code:

{"id": 1, "error": {"code": -32602, "message": "health: missing required param 'path'"}}

Error handling

Code Meaning Example message
-32602 Invalid params (schema validation) health: missing required param 'path'
-32601 Method not registered Unknown method: 'healthx'
-32000 Guard rejection (business rule, not a bug) Binary file 'stock.bin' is empty.
-32603 Unexpected internal failure

A missing or empty file, or an image that fails to decode, raises a guard error (-32000) — a clean client-facing rejection, never a traceback.

Discovery — list_methods

Ask the registry what health expects and what it is composed of:

import openremap.api as api

catalogue = api.call("list_methods", {})
meta = next(m for m in catalogue["methods"] if m["name"] == "health")
print(meta["kind"])   # "composite"
print(meta["steps"])  # ["identify", "checksums", "scan_map_tables", "segment", "scan_vins"]
print(meta["input_schema"])

Quick smoke test

echo '{"id": 1, "method": "ping", "params": {}}' | python -m openremap.api.transport.stdio
# → {"id": 1, "result": {"ok": true}}

See also