Skip to main content

algovoi-substrate-guard (lite)

Deterministic input-bounds / DoS hardening gate for the AlgoVoi JCS substrate. It runs before canonicalization and fails closed on well-formed but resource-hostile payloads, with a named reject code. Apache-2.0.

The substrate already fails closed on malformed input. A payload can be perfectly valid JSON and still be hostile by resource: megabytes of data, nested ten thousand deep, millions of keys, an 8 MB string, numbers outside the safe-integer range. Those sail past "is it well-formed?" and into your canonicalizer and hasher, which is exactly where a cheap denial-of-service lives. This guard is the front door that stops them, so the expensive work never touches a hostile payload.

pip install algovoi-substrate-guard
from algovoi_substrate_guard import guard, profile_ref, GuardError, Profile

# Accept or reject BEFORE canonicalization. Never truncates, never repairs.
try:
    guard(value)                 # uses the default profile guard-receipt-v1
    ref = ...                    # ...then action_ref(...) / decision_ref(...) / a receipt
except GuardError as e:
    print("rejected:", e.code)   # e.g. REJECT_OVER_DEPTH, REJECT_TOO_MANY_KEYS

# The limits in force are content-addressed, so a record can prove which bounds admitted it.
profile_ref()                    # "sha256:a4791b13...c3d5524a6"  (guard-receipt-v1)
profile_ref(Profile(max_depth=8, max_object_keys=16))   # your own pinnable profile

What it adds

  • A pre-canonicalization gate. Runs before JCS + SHA-256, so the expensive work never touches a hostile payload. Accept, or reject with a named code (REJECT_OVER_DEPTH, REJECT_TOO_MANY_KEYS, …). Never truncates or repairs: no silent mangling, no ambiguous half-processing.
  • Resource fail-closed, to match the malformed fail-closed. Together the substrate fails closed on both axes: bad shape and bad size.
  • Pinnable, provable limits. profile_ref = "sha256:" + SHA-256(JCS(profile)), the same discipline as policy_binding. An adopter pins guard-receipt-v1 (or their own profile); a record can carry the profile_ref it was admitted under, so an auditor can prove which limits were enforced.
  • Cross-implementation by construction. Every bound is a pure structural property of the parsed value (depth, count, length), so independent implementations enforce it identically: "N independent implementations reject the same hostile inputs with the same code."
  • Additive, zero blast radius. Changes no hash, adds no crypto primitive. Composes in one line: guard(value) then your existing action_ref(...). Everything built on the canonicalization substrate gets the protection for free, with no format change.

Default profile guard-receipt-v1

limit default reject code
max_bytes (UTF-8 of canonical form) 65536 REJECT_OVER_SIZE
max_depth (nesting, root = 1) 32 REJECT_OVER_DEPTH
max_object_keys (per object) 256 REJECT_TOO_MANY_KEYS
max_array_length 1024 REJECT_OVER_ARRAY
max_string_length (per string / key) 8192 REJECT_OVER_STRING
max_total_nodes 4096 REJECT_OVER_NODES
number_safety on REJECT_UNSAFE_NUMBER (outside JSON safe-int range / non-finite)

guard-receipt-v1 addresses to sha256:a4791b13c67a16109b85ef67fc65700ea902b6ad40dad44d8556632c3d5524a6.

Honest scope

A deterministic structural validator plus a content-addressed profile: not cryptography, and not rate-limiting or replay windows (those stay in the runtime verifier layer, never claimed as a substrate property). This is the open, lite tier of the AlgoVoi hardening layer.

Conformance

conformance/substrate_guard_v1/ carries the canonical vectors plus an independent verifier (verify.py). The same vectors and a Node verifier ship in the @algovoi/substrate-guard package, so the two implementations are checked to reject the same hostile inputs with the same code and compute the same profile_ref. Vectors are also published in the AlgoVoi JCS conformance corpus.

pip install rfc8785 algovoi-substrate
python conformance/substrate_guard_v1/verify.py

Metadata

Release files for algovoi-substrate-guard 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for algovoi-substrate-guard 0.5.0
File Size Uploaded Provenance Actions
algovoi_substrate_guard-0.5.0.tar.gz 11.6 kB Without provenance Details for algovoi_substrate_guard-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for algovoi-substrate-guard 0.5.0
File Interpreter ABI Platform Actions
algovoi_substrate_guard-0.5.0-py3-none-any.whl Python 3 none any Details for algovoi_substrate_guard-0.5.0-py3-none-any.whl

Total release size: 23.7 kB

Release files / algovoi_substrate_guard-0.5.0.tar.gz

Download URL algovoi_substrate_guard-0.5.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8d79cf249df675c6ef00591766253da4db9eb13824a2f4ebcba58534d89ac9ea
BLAKE2b-256 checksum
How to use checksums
653722b874f42c7705796dc85fd1f6b82fe8eac3a6c64ee9480ad333b6a4bf67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / algovoi_substrate_guard-0.5.0-py3-none-any.whl

Download URL algovoi_substrate_guard-0.5.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8563119035c9ada39036947114b46307367e7f034ad659809862ac97fa282fc
BLAKE2b-256 checksum
How to use checksums
baa2cf07a12dc6a29496a789633af3649b2b82ab225f1e62f9e463806675c81f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for algovoi-substrate-guard 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page