cordon-emit (Python)
The Python reference emitter for Cordon. Where the bash toolchain declares
a surface in a DSL, a Python CLI already has an argparse parser — so you don't
declare anything twice: this introspects that parser and projects it to the
one Cordon v4 contract. --describe becomes a
machine-readable view of the exact parser that produces --help, so the two
can't drift.
Pure stdlib, zero dependencies, published to PyPI as cordon-emit on the same
version as cordon. Add it as a dependency; never copy it, since a copy drifts
from the schema it targets.
So easy — one line
Add the parser you already build, then one line. That's the whole integration:
import argparse
from cordon_emit import describe_main, set_effect
def build_parser():
p = argparse.ArgumentParser(prog="hq", description="Operate the deploy.")
sub = p.add_subparsers(dest="command")
logs = sub.add_parser("logs", help="Show app container logs")
logs.add_argument("-f", "--follow", action="store_true", help="Stream live output")
set_effect(logs, "read", network=True)
set_effect(sub.add_parser("restart", help="Restart the app"), "deploy", network=True)
return p
def main():
parser = build_parser()
describe_main(parser, group="Integrations", order=130) # ← handles --describe / --pretty, exits
args = parser.parse_args()
...
Now hq --describe emits a valid contract and hq --help reads from the same
parser. The only thing you add by hand is the one fact a parser can't tell you:
each command's blast radius, via set_effect() on the
effect ladder
(read < local_write < vault_write < remote_write < deploy, plus network /
interactive). Unannotated commands default to read, and the emitter warns
on stderr for each one so a forgotten blast radius isn't a silent fail-open. Pass
--effect-required (or effect_required=True) to make an undeclared command a
hard error instead — the strict, multi-tenant posture.
So powerful — zero-touch on any parser
Don't even need to edit the tool. Point the module at any importable factory that
returns an ArgumentParser (module:attribute) and pipe it straight into
cordon's validator:
python -m cordon_emit myapp.cli:build_parser -g Integrations -o 130
python -m cordon_emit myapp.cli:build_parser -g X -o 1 \
| npx --yes --package cordon-spec@2 cordon-validate - # exit 0 = conformant
That's a contract — and a conformance check — for an existing Python CLI with no code change.
API
| symbol | does |
|---|---|
describe_main(parser, *, group, order, **kw) |
drop-in --describe handler: emit + SystemExit(0) when requested, else return. Honors --effect-required in argv. The one-liner. |
describe_parser(parser, *, group, order, effect=None, paras=None, examples=None) -> dict |
the pure projection — returns the full {ok, schema_version, …} document. |
set_effect(parser, effect, *, network=False, interactive=False) |
annotate a (sub)parser's blast radius; returns it so it nests in add_parser(...). |
undeclared_effects(parser, *, tool_effect_override=None) -> list[str] |
the surfaces whose blast radius defaulted instead of being declared (command names, or the tool itself for a leaf). Empty means every effect was an explicit choice. |
emit(parser, *, pretty=False, effect_required=False, **kw) |
print(json.dumps(describe_parser(...))); compact by default, --pretty indents. Warns on any command whose effect defaulted; effect_required=True makes that a hard error. |
describe_parser returns the canonical, byte-deterministic document (no
timestamps, stable order) — a guard can diff it.
Install
uv add cordon-emit
Verify
python3 emitters/python/selftest.py # structural + byte-parity with the bash leaf fixture
python3 emitters/python/selftest.py --emit | node ../../conformance/validate.ts -
The selftest also proves convergence: introspecting an encrypt-shaped parser
yields a contract byte-identical to the bash-DSL-emitted
fixtures/valid/leaf-tool.json — same
schema, two emitters, one output.
Metadata
Release files for cordon-emit 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cordon_emit-2.0.1.tar.gz | 11.0 kB | With provenance | Details for cordon_emit-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cordon_emit-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for cordon_emit-2.0.1-py3-none-any.whl |
Total release size: 20.5 kB
Release files / cordon_emit-2.0.1.tar.gz
| Download URL | cordon_emit-2.0.1.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f01a2d49142ba821424eb084179a2418ec82af22cb3e4e5d97e76002357f384
|
|
BLAKE2b-256 checksum How to use checksums |
a74a9be9bcdefe27a28d307c0f68ad4e0deb3109819cc92381ec8927c536abd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / cordon_emit-2.0.1-py3-none-any.whl
| Download URL | cordon_emit-2.0.1-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e697cd708ffdddee37096b9dbd7d846f8074aed78e46baebbfc79678ed976cf9
|
|
BLAKE2b-256 checksum How to use checksums |
7d18136dd55715e81292d3639f605cad58d417c0c581ee1a0cbffe8a243374c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logSecurity for cordon-emit 2.0.1
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for cordon_emit-2.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logA 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.