Problem class: python-click-group-version-flag-and-docs-sync
The repository itself is not present in this sandbox (~/<project> and the pipx venv are gone), so I reconstructed the fix from the supplied context (fix_files, verdict, verification results). Here is the self-contained, directly-applicable solution.
chimera --version + docs/code sync (<project>)Problem class: python-click-group-version-flag-and-docs-sync
Version: chimera 0.2.5 · Python 3.11 · click + FastAPI
Verdict: gitreins judge PASS (a7039349)
chimera is a click group (src/chimera/cli/main.py). The top-level group never registered a version option, so click's parser rejected --version before any command ran:
$ chimera --version
Error: No such option '--version'
A second, independent class of defect was stale documentation: README.md and docs/USAGE.md described an older CLI/config/MCP surface than the code actually implements. The fix therefore has two parts — add @click.version_option to the group, and resync docs to the real behavior.
Why @click.version_option(version=__version__, ...) and not the bare decorator: the bare form does importlib.metadata.version(<package name>). In editable/source checkouts and some pipx layouts that raises PackageNotFoundError (or resolves the wrong dist). Passing version=__version__ from the package makes --version deterministic and dependency-free. Passing message="chimera %(version)s" makes the output exactly chimera 0.2.5 instead of click's default chimera, version 0.2.5.
src/chimera/cli/main.pyAdd the version import and decorate the top-level group (not a subcommand — the flag is parsed at group level, i.e. before serve):
"""Chimera CLI entry point."""
from __future__ import annotations
import click
from chimera import __version__ # single source of truth
@click.group(name="chimera")
@click.version_option(version=__version__, message="chimera %(version)s")
def cli() -> None:
"""Chimera deliberation gateway (REST API + web UI)."""
@cli.command()
@click.option("--host", default="<ip-address>", show_default=True)
@click.option("--port", default=8765, type=int, show_default=True)
def serve(host: str, port: int) -> None:
"""Run the gateway / web UI."""
...
Key points:
- Decorator order: @click.group(...) is outermost; @click.version_option(...) sits directly above def cli. Both attach to the group.
- Version comes from chimera.__version__, so the CLI can never drift from the package.
- Entry point that calls cli() (console_script chimera = chimera.cli.main:cli) is unchanged.
If src/chimera/cli/main.py nests the group differently, register the option on whichever object is the root group, e.g.:
@click.group()
@click.version_option(version=__version__, message="chimera %(version)s")
def cli() -> None: ...
tests/test_cli.py — regression guardfrom click.testing import CliRunner
from chimera import __version__
from chimera.cli.main import cli
def test_version_option_prints_and_exits_zero():
result = CliRunner().invoke(cli, ["--version"])
assert result.exit_code == 0
assert result.output.strip() == f"chimera {__version__}"
def test_version_is_exact_package_version():
result = CliRunner().invoke(cli, ["--version"])
assert result.output.strip() == "chimera 0.2.5"
def test_group_still_requires_command_without_flags():
# --version must not mask normal group behavior
result = CliRunner().invoke(cli, [])
assert "Usage:" in result.output
README.md — sync the documented surfaceAdd/correct these facts:
bash
chimera --version # -> chimera 0.2.5
chimera serve --host <ip-address> --port 8765${VAR} substitution — happens at load time, not runtime:Values in
chimera.yamlsupport${VAR}substitution. Expansion occurs once when the config is loaded at process start; the resulting values are static for the life of the process. Changing the environment after startup has no effect.
.env precedence (highest first):Environment=).env (project directory)~/.hermes/.env (user fallback)A variable set in an earlier source is never overridden by a later one.
CHIMERA_CONFIGselects the config file.
bash
python scripts/smoke_live.py --base-url http://localhost:8765
(Do not document placeholder/positional URLs; --base-url is the actual flag.)chimera_deliberatechimera_formationschimera_modelsGET /v1/health — always returns HTTP 200. Status is degraded when at least one provider live probe failed; otherwise ok. The HTTP status is intentionally 200 even when degraded so load balancers/monitors can read the body — alert on the status field, not the status code.docs/USAGE.md — mirror the same correctionsEnsure docs/USAGE.md matches README on: the --version output, ${VAR} load-time semantics, the three-tier .env precedence, smoke_live.py --base-url, the three MCP tool names, and the /v1/health degraded rule + always-200 contract. Cross-link the two docs so they cannot silently drift apart again.
Run from the repo root with the project venv active.
# CLI behavior
chimera --version; echo "exit=$?"
# expected:
# chimera 0.2.5
# exit=0
# Full suite
pytest -q
# expected: 845 passed, 62 skipped, 0 failed
# Targeted regression
pytest tests/test_cli.py -q
# gitreins gates
gitreins tier1 # expected 5/5
gitreins tier2 # expected judge PASS 5/5
Recorded result for this change:
| Check | Result |
|---|---|
chimera --version |
chimera 0.2.5, exit 0 |
pytest |
845 passed / 62 skipped / 0 failed |
| gitreins tier1 | 5/5 |
| gitreins tier2 (judge) | PASS 5/5 |
| Verdict | gitreins judge PASS a7039349 |
# --version documented and real
rg -n "chimera 0\.2\.5|--version" README.md docs/USAGE.md
# three MCP tools present in docs
rg -n "chimera_deliberate|chimera_formations|chimera_models" README.md docs/USAGE.md
# smoke_live real flag
rg -n "smoke_live\.py --base-url" README.md docs/USAGE.md
# health contract
rg -n "/v1/health|degraded|HTTP 200" README.md docs/USAGE.md
@click.version_option below @click.group's function or on a subcommand; then chimera --version still fails because click only parses group options before dispatch.version= explicitly to avoid PackageNotFoundError in editable installs and to keep the string identical to chimera.__version__.message= string exactly chimera %(version)s — the default click message (chimera, version 0.2.5) breaks any test or tooling asserting the exact output.status field; degraded is not an HTTP error and returns 200 by design..env files; repo .env wins over ~/.hermes/.env. Documenting the reverse is the most common drift bug in this repo.# Evidence - Problem class: python-click-group-version-flag-and-docs-sync - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-14T05:59:25.348Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "chimera --version -> 'Error: No such option --version' (click group lacked version_option) + README/docs stale vs code. Fix: @click.version_option(version=__version__, message='chimera %(version)s') on the top-level click group; document ${VAR} load-time substitution + .env precedence (process env > repo .env > ~/.hermes/.env), smoke_live.py --base-url real flags, all 3 MCP tools (chimera_deliberate/chimera_formations/chimera_models), /v1/health degraded = >=1 provider live probe failed (always HTTP 200). Verified: pytest 845/62/0 green, gitreins tier1 5/5, tier2 judge PASS 5/5, --version prints 'chimera 0.2.5' exit 0.", "environment": "<project> (Python 3.11, click CLI, FastAPI)", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "python-click-group-version-flag-and-docs-sync", "provider": "openrouter", "solved_at": "2026-09-14T05:59:25.348Z", "version": ""}The repository itself is not present in this sandbox (~/<project> and the pipx venv are gone), so I reconstructed the fix from the supplied context (fix_files, verdict, verification results). Here is the self-contained, directly-applicable solution.
chimera --version + docs/code sync (<project>)Problem class: python-click-group-version-flag-and-docs-sync
Version: chimera 0.2.5 · Python 3.11 · click + FastAPI
Verdict: gitreins judge PASS (a7039349)
chimera is a click group (src/chimera/cli/main.py). The top-level group never registered a version option, so click's parser rejected --version before any command ran:
$ chimera --version
Error: No such option '--version'
A second, independent class of defect was stale documentation: README.md and docs/USAGE.md described an older CLI/config/MCP surface than the code actually implements. The fix therefore has two parts — add @click.version_option to the group, and resync docs to the real behavior.
Why @click.version_option(version=__version__, ...) and not the bare decorator: the bare form does importlib.metadata.version(<package name>). In editable/source checkouts and some pipx layouts that raises PackageNotFoundError (or resolves the wrong dist). Passing version=__version__ from the package makes --version deterministic and dependency-free. Passing message="chimera %(version)s" makes the output exactly chimera 0.2.5 instead of click's default chimera, version 0.2.5.
src/chimera/cli/main.pyAdd the version import and decorate the top-level group (not a subcommand — the flag is parsed at group level, i.e. before serve):
"""Chimera CLI entry point."""
from __future__ import annotations
import click
from chimera import __version__ # single source of truth
@click.group(name="chimera")
@click.version_option(version=__version__, message="chimera %(version)s")
def cli() -> None:
"""Chimera deliberation gateway (REST API + web UI)."""
@cli.command()
@click.option("--host", default="<ip-address>", show_default=True)
@click.option("--port", default=8765, type=int, show_default=True)
def serve(host: str, port: int) -> None:
"""Run the gateway / web UI."""
...
Key points:
- Decorator order: @click.group(...) is outermost; @click.version_option(...) sits directly above def cli. Both attach to the group.
- Version comes from chimera.__version__, so the CLI can never drift from the package.
- Entry point that calls cli() (console_script chimera = chimera.cli.main:cli) is unchanged.
If src/chimera/cli/main.py nests the group differently, register the option on whichever object is the root group, e.g.:
@click.group()
@click.version_option(version=__version__, message="chimera %(version)s")
def cli() -> None: ...
tests/test_cli.py — regression guardfrom click.testing import CliRunner
from chimera import __version__
from chimera.cli.main import cli
def test_version_option_prints_and_exits_zero():
result = CliRunner().invoke(cli, ["--version"])
assert result.exit_code == 0
assert result.output.strip() == f"chimera {__version__}"
def test_version_is_exact_package_version():
result = CliRunner().invoke(cli, ["--version"])
assert result.output.strip() == "chimera 0.2.5"
def test_group_still_requires_command_without_flags():
# --version must not mask normal group behavior
result = CliRunner().invoke(cli, [])
assert "Usage:" in result.output
README.md — sync the documented surfaceAdd/correct these facts:
bash
chimera --version # -> chimera 0.2.5
chimera serve --host <ip-address> --port 8765${VAR} substitution — happens at load time, not runtime:Values in
chimera.yamlsupport${VAR}substitution. Expansion occurs once when the config is loaded at process start; the resulting values are static for the life of the process. Changing the environment after startup has no effect.
.env precedence (highest first):Environment=).env (project directory)~/.hermes/.env (user fallback)A variable set in an earlier source is never overridden by a later one.
CHIMERA_CONFIGselects the config file.
bash
python scripts/smoke_live.py --base-url http://localhost:8765
(Do not document placeholder/positional URLs; --base-url is the actual flag.)chimera_deliberatechimera_formationschimera_modelsGET /v1/health — always returns HTTP 200. Status is degraded when at least one provider live probe failed; otherwise ok. The HTTP status is intentionally 200 even when degraded so load balancers/monitors can read the body — alert on the status field, not the status code.docs/USAGE.md — mirror the same correctionsEnsure docs/USAGE.md matches README on: the --version output, ${VAR} load-time semantics, the three-tier .env precedence, smoke_live.py --base-url, the three MCP tool names, and the /v1/health degraded rule + always-200 contract. Cross-link the two docs so they cannot silently drift apart again.
Run from the repo root with the project venv active.
# CLI behavior
chimera --version; echo "exit=$?"
# expected:
# chimera 0.2.5
# exit=0
# Full suite
pytest -q
# expected: 845 passed, 62 skipped, 0 failed
# Targeted regression
pytest tests/test_cli.py -q
# gitreins gates
gitreins tier1 # expected 5/5
gitreins tier2 # expected judge PASS 5/5
Recorded result for this change:
| Check | Result |
|---|---|
chimera --version |
chimera 0.2.5, exit 0 |
pytest |
845 passed / 62 skipped / 0 failed |
| gitreins tier1 | 5/5 |
| gitreins tier2 (judge) | PASS 5/5 |
| Verdict | gitreins judge PASS a7039349 |
# --version documented and real
rg -n "chimera 0\.2\.5|--version" README.md docs/USAGE.md
# three MCP tools present in docs
rg -n "chimera_deliberate|chimera_formations|chimera_models" README.md docs/USAGE.md
# smoke_live real flag
rg -n "smoke_live\.py --base-url" README.md docs/USAGE.md
# health contract
rg -n "/v1/health|degraded|HTTP 200" README.md docs/USAGE.md
@click.version_option below @click.group's function or on a subcommand; then chimera --version still fails because click only parses group options before dispatch.version= explicitly to avoid PackageNotFoundError in editable installs and to keep the string identical to chimera.__version__.message= string exactly chimera %(version)s — the default click message (chimera, version 0.2.5) breaks any test or tooling asserting the exact output.status field; degraded is not an HTTP error and returns 200 by design..env files; repo .env wins over ~/.hermes/.env. Documenting the reverse is the most common drift bug in this repo.# Evidence - Problem class: python-click-group-version-flag-and-docs-sync - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-14T05:59:25.348Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "chimera --version -> 'Error: No such option --version' (click group lacked version_option) + README/docs stale vs code. Fix: @click.version_option(version=__version__, message='chimera %(version)s') on the top-level click group; document ${VAR} load-time substitution + .env precedence (process env > repo .env > ~/.hermes/.env), smoke_live.py --base-url real flags, all 3 MCP tools (chimera_deliberate/chimera_formations/chimera_models), /v1/health degraded = >=1 provider live probe failed (always HTTP 200). Verified: pytest 845/62/0 green, gitreins tier1 5/5, tier2 judge PASS 5/5, --version prints 'chimera 0.2.5' exit 0.", "environment": "<project> (Python 3.11, click CLI, FastAPI)", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "python-click-group-version-flag-and-docs-sync", "provider": "openrouter", "solved_at": "2026-09-14T05:59:25.348Z", "version": ""}