cli: exit-code contract for zero-answer runs + close pooled httpx client#32
Merged
Conversation
closes #17: establish a documented exit-code contract on `conclave ask`. A run that produces zero *usable* member answers now exits non-zero (1) on both the human and `--json` paths. Under `--json` the full JSON result is still emitted to stdout first, so a script can parse the payload and detect failure via the exit code. Usage/config errors keep their distinct code 2. The check is computed once (`result.successful_answers`) and applied to both paths, so an all-members-failed run is also treated as a failure (previously the human path keyed off `result.answers` non-emptiness and the JSON path always exited 0). closes #20: wire the pooled httpx client lifecycle. The sync wrappers (`ask_sync`/`debate_sync`/`adversarial_sync`) now close the shared client in a `finally` inside the same event loop that used it, so the CLI never leaks the pool and no "unclosed client" warning fires. Added `Council.aclose()` / `Council.close_sync()` and re-exported `conclave.aclose` so long-lived library/server consumers can release the pool on shutdown. tests: new tests/test_cli.py (Typer CliRunner) pins the exit-code contract (zero members, all-failed, success, bad mode, empty council) and verifies `transport.aclose()` is actually invoked on sync run completion (no leaked client). cli.py coverage 0% -> 43%; total 82.7% (floor 75%).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the CLI / lifecycle cluster of the Wave 2 backlog.
closes #17
closes #20
#17 — exit-code contract on
conclave askPreviously
--jsonreturned to its early-return before the no-members guard, so akeyless run exited 0 with an empty payload while the human path exited 1 — a
CI/script consumer couldn't tell "no keys" from "ran fine".
New contract (documented in the
askcommand help):--jsonthe full JSON is still written to stdout first, then exit 1The failure signal is computed once as
not result.successful_answersand applied toboth the JSON and human paths, so an all-members-failed run is now also a non-zero exit
(previously the human path only checked
result.answersnon-emptiness).successful_answersis consistent across all four modes (synthesize/raw/debate/adversarial all populate
result.answers).#20 — pooled httpx client lifecycle
transport.aclose()had no callers, leaking the process-wideAsyncClient.ask_sync/debate_sync/adversarial_sync) now close the client in afinallyinside the sameasyncio.runloop that used it, so the CLI never leaks thepool and no "unclosed client" warning fires under strict asyncio.
Council.aclose()(async) andCouncil.close_sync()so long-lived library/serverconsumers can release the pool on shutdown;
close_syncpassesclose_client=Falsetoavoid a redundant double-close.
conclave.acloseand documented the shutdown contract in the package docstring.Tests
New
tests/test_cli.py(TyperCliRunner, offline):--json(JSON still emitted)transport.aclose()is actually invoked on sync run completion (no leaked client)close_sync()fires aclose exactly once; real_get_client()→aclose()closes the clientcli.pycoverage 0% → 43%; total 82.7% (floor 75%).ruff check+ruff format --checkclean. 77 passed (was 68).
Do not merge — leaving checks to run.