The Gluthag TOML contract — schema types, parser, and validator. Shared source of truth between Erzgrimm (emitter) and Gluthag (consumer).
Project description
gluthag-schema
The Gluthag TOML contract — parser, schema types, and validator.
This package is the single source of truth for the gluthag.toml file
shape (contract version 1.0). It is shared by:
- Erzgrimm — the build platform that emits Gluthag bundles.
- Gluthag — the local test-server / runner that consumes them.
- Third parties who want to author or verify bundles by hand.
Install
pip install gluthag-schema
Requires Python >=3.11 (uses the stdlib tomllib). Zero runtime
dependencies.
Quick example
from gluthag_schema import (
parse_gluthag_toml,
validate_gluthag_toml,
cross_check_env,
SUPPORTED_CONTRACT_VERSIONS,
)
toml_text = '''
contract_version = "1.0"
[app]
name = "smiths-anvil"
primary_service = "backend"
[run]
target_default = "local"
mode_default = "ephemeral"
[env]
required = ["DATABASE_URL", "JWT_SECRET"]
generated = ["JWT_SECRET"]
[network]
policy = "allow"
allow = ["api.stripe.com"]
'''
# Parse — raises ValueError if TOML is malformed
manifest = parse_gluthag_toml(toml_text)
assert manifest["contract_version"] in SUPPORTED_CONTRACT_VERSIONS
# Validate — never raises; returns ALL findings so you get a
# complete error picture in one pass.
result = validate_gluthag_toml(toml_text)
if not result.ok:
for f in result.findings:
print(f"{f.severity} {f.path}: {f.message}")
# Cross-check env against a companion .env.example
env_example = "DATABASE_URL=postgres://...\nJWT_SECRET=change-me\n"
cross = cross_check_env(manifest, env_example)
assert cross.ok, cross.findings
Public API
Everything the package exports is stable at 1.0.x:
| Name | Kind | Purpose |
|---|---|---|
parse_gluthag_toml(text) |
function | Parse TOML text → typed GluthagManifest. Raises ValueError on malformed TOML. |
validate_gluthag_toml(text) |
function | Parse + validate; returns ValidationResult (never raises). |
cross_check_env(manifest, env_example_text) |
function | Cross-check [env].required vs .env.example and [env].generated ⊆ required. |
SUPPORTED_CONTRACT_VERSIONS |
constant | Tuple of contract versions this release understands. ("1.0",) at v1.0.0. |
GluthagManifest |
type | TypedDict describing the parsed shape. |
ValidationResult |
dataclass | .ok: bool, .findings: list[Finding]. |
Finding |
dataclass | .severity: Literal["error"], .path: str, .message: str. |
Design notes
- Content-based API. All functions take TOML text. The library never touches the filesystem. This lets Erzgrimm (which builds the document in memory) and Gluthag (which reads it from disk) call identical code paths.
- Findings, not exceptions. Validation returns every problem in one pass. Consumers iterate for a full error picture rather than discover-fix-repeat cycles.
- No dependencies.
tomllibis stdlib; that is the only import. - Typed. Full type hints +
py.typedmarker for downstream mypy / pyright users.
Contract reference
The v1.0 shape is documented in the Erzgrimm spec, Section 13.
Required tables: [app], [run], [env], [network]. Optional:
[services.*], [seed]. See the tests directory for the canonical
example.
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gluthag_schema-1.0.0.tar.gz.
File metadata
- Download URL: gluthag_schema-1.0.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f93b8398690b9f64678734b2610b9c63311fcd85dc11a93d30bbc7e450af54a1
|
|
| MD5 |
2b66051ac8939825dd768d91cec75d66
|
|
| BLAKE2b-256 |
b50c33f552ce6ed48ba457b75621b44315327eeb560acda2f5c42060d310ebc8
|
File details
Details for the file gluthag_schema-1.0.0-py3-none-any.whl.
File metadata
- Download URL: gluthag_schema-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
278e44ac6ff6bb8f69fd694d624c1e89ef43bdeeb423a5c9594eb98d0de403d7
|
|
| MD5 |
c62bf9ab85192c3cea142f04bba87c3a
|
|
| BLAKE2b-256 |
01dee302012a0dcca1f96a285fc9a92561badb28ec3ea29ded347290aee65509
|