Skip to main content

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, newest-first. ("1.0",) at v1.0.1.
DEFAULT_EMIT_VERSION constant The contract version an emitter SHOULD write when producing a fresh bundle. "1.0" at v1.0.1. Introduced in v1.0.1 as an explicit escape hatch from SUPPORTED_CONTRACT_VERSIONS[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. tomllib is stdlib; that is the only import.
  • Typed. Full type hints + py.typed marker 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


Download files

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

Source Distribution

gluthag_schema-1.0.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

gluthag_schema-1.0.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file gluthag_schema-1.0.1.tar.gz.

File metadata

  • Download URL: gluthag_schema-1.0.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for gluthag_schema-1.0.1.tar.gz
Algorithm Hash digest
SHA256 727eed3654aa93cdfa226d46b1678c3f721eee48882e7edecc6d29c0fbb7b633
MD5 82c40c2f85c3bd2a90632d88b3a23206
BLAKE2b-256 4d9824062edbfce2d688055d4eb80cb88aa08129bcfd7e125e5031e2ce77ac94

See more details on using hashes here.

File details

Details for the file gluthag_schema-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: gluthag_schema-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for gluthag_schema-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2fd337fda5cd7ae78c553d06cc5fb9159514dd1690a3c46b066ae8895c5e2862
MD5 c3cfb28286796fe088fcbd06a6a0e786
BLAKE2b-256 cd9a20417cbce50941c10e596fc135f5084129c5495cab944960fb3d36da11c8

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