Skip to content

Register keygen, sign and issue-approval as cohaera subcommands - #54

Merged
404SecNotFound merged 1 commit into
mainfrom
claude/compassionate-meitner-nzp6tq
Oct 8, 2026
Merged

404SecNotFound merged 1 commit into
mainfrom
claude/compassionate-meitner-nzp6tq

Conversation

@404SecNotFound

Copy link
Copy Markdown
Owner

What this changes, and why

The producer commands from cohaera.emit are now subcommands of cohaera: cohaera keygen, cohaera sign and cohaera issue-approval. A collector host needs one command rather than a module path, and python -m cohaera.emit still runs the same parser.

The emitter was built on one boundary: a host that only scores never loads signing code. That boundary is kept, and is now checked as a runtime fact rather than inferred from the module layout. cohaera.cli checks the first argument and hands a producer command to its own parser before the scoring parser runs. That hand-off contains the only import of signing code in any verifier module, and the import is deferred. cohaera --help lists all four commands. cohaera sign --help prints usage: cohaera sign.

src/cohaera/emit/__main__.py moved to emit/command.py, which also exports a COMMANDS table. __main__.py is now a two-line shim.

Evidence

  • The defect was reproduced first, and the test that reproduces it is in this change. n/a as a defect, because this is a feature. The new tests are in tests/test_emit.py:
    • a syntax-tree check that no verifier module imports cohaera.emit, except one deferred import inside cli._producer;
    • a fresh-interpreter check that a full cohaera score run leaves no cohaera.emit module loaded;
    • the CLI's command table equals the emitter's;
    • cohaera --help lists all four commands;
    • a keygen → sign --close → score --require-closed-streams round trip through cohaera.cli.main, ending in verified_complete.
  • I mutated the fix and the test failed. A module-level from .emit import command added to cli.py fails 3 boundary tests.
  • python -m pytest tests/ -q passes: 1553 passed, 18 skipped.
  • python tests/test_evasion.py passes. Counts are unchanged: 29 constructed evasions (14 working, 13 half closed, 2 closed).
  • ruff check src tests eval tools lab demo passes. mypy passes.
  • python tools/readme_facts.py --check passes.

The command sequence in docs/EMITTING.md section 4 was re-run with the new cohaera subcommands and printed verified_complete. Both lab --checks pass and the release gate passes.

If this changes detection

  • python eval/run_eval.py re-run. The card is byte-identical.
  • Recall and false-positive rate, before → after: unchanged.
  • The CH06 coverage remedy text now names cohaera sign --close instead of "the emit command's --close". The local lab was regenerated for that. The changed fields are the remedy text and the verdict_id values that hash it; nothing else changed.

If this changes an evasion

n/a. Only E30's wording changes, to name cohaera sign --close.

Anything a reviewer should push back on

  • The old test refused the string cohaera.emit anywhere in verifier sources. Its replacement is a syntax-tree check that allows exactly one deferred import and nothing at module level. It is paired with a runtime check on the scoring path. A help string or comment that mentions the package is no longer flagged; an actual import still is.
  • The three command names and their help lines are listed in both cli.py and emit/command.py, because cli.py must not import the emitter just to print help. A test holds the two tables equal.
  • cohaera --help shows the producer commands but does not show their flags; each command's own --help does. That is the cost of not loading the emitter on the scoring path.

🤖 Generated with Claude Code

https://claude.ai/code/session_01As5wcUhETPg1K3ceCVrWew


Generated by Claude Code

A collector host now needs one command rather than a module path;
`python -m cohaera.emit` still runs the same parser.

The boundary the emitter was built around stays a runtime fact: cohaera.cli
hands a producer command to its own parser before the scoring parser runs,
through the only import of signing code in any verifier module, and that
import is deferred. A full `cohaera score` in a fresh interpreter loads
nothing from cohaera.emit. The test that forbade the string "cohaera.emit" in
verifier sources is replaced by a syntax-tree check permitting exactly that
one deferred import, plus a runtime check on the scoring path.

The CH06 remedy now names `cohaera sign --close`; the local lab is
regenerated for that text and nothing else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01As5wcUhETPg1K3ceCVrWew
@404SecNotFound
404SecNotFound merged commit 0f04ade into main Oct 8, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants