Skip to main content

Versioned ABI schema validation, parsing, and registry

Project description

nodus-schema

Versioned ABI schema validation, parsing, and registry for Nodus AI systems.

Validates payloads against simple-form or JSON Schema object definitions, parses versioned surface names (sys.v1.domain.action), and maintains a thread-safe SchemaRegistry of versioned schemas with stability tracking. No required external dependencies — pure stdlib.

Note on naming: This is the standalone nodus-schema package (C:\dev\nodus-schema). The nodus-lang runtime also ships an in-tree nodus_schema package (src/nodus_schema/) with SyscallSpec, HandlerContract, and VALID_EFFECTS. The two are distinct; check python -c "import nodus_schema; print(nodus_schema.__file__)" to confirm which is active.

Status: v0.1.0 — prepared, not yet published.


Install

pip install nodus-schema

What it provides

Component Purpose
validate_payload Validate a dict against a schema; returns list of error strings
validate_input / validate_output Aliases for validate_payload
parse_versioned_name Parse "sys.v1.domain.action"(version, action)
resolve_version Find best compatible version from available set
is_stable_version True for "v1", "v2", etc. (not alpha/beta)
SchemaEntry One versioned schema with stability and deprecation state
SchemaRegistry Thread-safe registry of SchemaEntry objects

Schema validation

from nodus_schema import validate_payload

schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age":  {"type": "integer"},
    },
    "required": ["name"],
}

errors = validate_payload(schema, {"name": "Alice", "age": 30})
# [] — valid

errors = validate_payload(schema, {"age": 30})
# ["Missing required field: 'name'"]

errors = validate_payload(schema, {"name": "Alice", "age": "thirty"})
# ["Field 'age': expected type 'integer', got 'str'"]

Simple-form schema

A flat {field: type_string} dict is also accepted:

errors = validate_payload({"key": "str", "value": "any"}, {"key": "hello"})
# [] — "any" allows any type

Supported type strings: string/str, integer/int, number/float, boolean/bool, object/map/dict, array/list, null/nil, any.


Versioned name parsing

from nodus_schema import parse_versioned_name, resolve_version, is_stable_version

version, action = parse_versioned_name("sys.v1.memory.write")
# ("v1", "memory.write")

best = resolve_version("v1", available={"v1", "v2"}, fallback=True)
# "v1"

is_stable_version("v1")      # True
is_stable_version("v1alpha1") # False
is_stable_version("v1beta2")  # False

SchemaRegistry

from nodus_schema import SchemaRegistry, SchemaEntry

registry = SchemaRegistry()
registry.register(SchemaEntry(
    name="memory.write",
    version="v1",
    input_schema={"key": "str", "value": "any"},
    output_schema={"stored": "bool"},
    stable=True,
    deprecated=False,
))

entry = registry.get("memory.write", version="v1")  # SchemaEntry | None
versions = registry.versions("memory.write")         # ["v1"]
all_entries = registry.list()                        # list[SchemaEntry]

Design

  • No required dependencies. Pure stdlib (json, threading, dataclasses).
  • Simple-form schemas. Flat {field: type} dicts are normalized to JSON Schema objects automatically.
  • Thread-safe. SchemaRegistry uses threading.Lock.

Development

pip install -e ".[dev]"
pytest tests/ -q

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nodus_schema-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nodus_schema-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file nodus_schema-0.1.0.tar.gz.

File metadata

  • Download URL: nodus_schema-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for nodus_schema-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5b8578455cb011e40eb1badcc81fcfe46da35806e32adcb42fc19b2a4e49decc
MD5 9de17f4a3cd015fc2d695ecb9c4f0eea
BLAKE2b-256 278f88c42d1cafe91b0a4b655a2222afac082b6472e1012529bd06225667d3d2

See more details on using hashes here.

File details

Details for the file nodus_schema-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nodus_schema-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for nodus_schema-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0959124dec91b762fbcfcbf5dc9791ec842be0ffb8fc73e7f6460eaae15e18ef
MD5 1f9b413e65c0d074ea3180164f7039bc
BLAKE2b-256 2107685c5cb0fa20181a60a2183fd0e24c81636a7f96798807a06c5910574fd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page