- What was implemented
- Fixed _register_subcommands in src/cleveragents/cli/main.py: replaced bare return with raise SystemExit(1) from exc in the exception handler to propagate a non-zero exit code and preserve the original traceback context.
- Removed # pragma: no cover from the exception handler, enabling test coverage for this path.
- Why this change
- Ensures the CLI exits with a non-zero status on subcommand registration failure and provides proper error context for debugging, aligning with the project's error-handling goals and B904 linting requirements.
- Tests and verification
- Added Behave BDD issue-capture test features/tdd_cli_incomplete_subcommand_registration.feature with 3 scenarios to exercise and validate the failure path.
- Added step definitions features/steps/tdd_cli_incomplete_subcommand_registration_steps.py corresponding to the new scenarios.
- The @tdd_expected_fail scenario captures the previous buggy behavior (silent return with exit code 0) to ensure regression is addressed.
- All nox quality gates pass (lint, typecheck).
- Key design decisions
- Use raise SystemExit(1) from exc to exit with a clear non-zero status while preserving the original exception chain (satisfies B904).
- Coverage ensured by removing the pragma, bringing the error path under test.
- Behavior now explicitly signals failure to the shell and any orchestrating tooling, avoiding silent failures.
- Affected modules and artifacts
- src/cleveragents/cli/main.py
- features/tdd_cli_incomplete_subcommand_registration.feature
- features/steps/tdd_cli_incomplete_subcommand_registration_steps.py
ISSUES CLOSED: #2604