7. Python API Reference (fleetmesh_schema)
The fleetmesh_schema Python package carries the canonical schema documents and provides standard helper functions for resolving schema paths and loading JSON data with in-memory caching.
7.1. Package API
fleetmesh_schema: the published schema files as an installable package.
The files are the ones at the root of the schema repo - schema/ (the digest set: constants, kinds, messages, DIGEST, PROTOCOLS, conformance) and schemas/ (the JSON Schema documents). This package carries them, nothing more: a path for anything that opens files itself, and one cached loader for the JSON. Standard library only, no I/O at import time.
In a checkout the two directories are reached through the symlinks beside this file; installed, they are package data at the same relative place, so files() is the same path arithmetic either way.
- fleetmesh_schema.path(name)[source]
Absolute path of a file under schema/ (constants.json, kinds.json, DIGEST …).
- fleetmesh_schema.schema_path(*parts)[source]
Absolute path of a JSON Schema document under schemas/ (plane, …, file).
- fleetmesh_schema.load_json(name)[source]
Parse one file under schema/, once; every importer sees the same object. The path is in any error so a broken install names itself.
7.2. Functions & Constants Reference
``SCHEMA_DIR``: Absolute filesystem path to the directory containing
constants.json,kinds.json,messages.json, andDIGEST.``SCHEMAS_DIR``: Absolute filesystem path to the directory containing JSON Schema Draft 2020-12 files (
common/,events/, etc.).``path(name: str) -> str``: Computes the absolute path to a file under
SCHEMA_DIR.``schema_path(*parts: str) -> str``: Computes the absolute path to a JSON Schema file under
SCHEMAS_DIR.``load_json(name: str) -> Any``: Parses a JSON file from
SCHEMA_DIRwith automatic LRU memoization. Guarantees that every caller in the process receives the identical in-memory object without redundant disk I/O.``text(name: str) -> str``: Reads and returns a text file from
SCHEMA_DIR(e.g.,DIGEST,PROTOCOLS) as a stripped string.``digest() -> str``: Convenience accessor returning the active protocol version digest string from
schema/DIGEST.
7.3. Usage Example
import fleetmesh_schema
# Inspect active protocol digest
print("Active Digest:", fleetmesh_schema.digest())
# Load canonical event kinds dictionary
kinds_data = fleetmesh_schema.load_json('kinds.json')
print("Descriptor Kind:", kinds_data['kinds']['11801']['name'])
# Locate a JSON Schema Draft 2020-12 file
descriptor_schema = fleetmesh_schema.schema_path('events', 'kind-11801.json')