feat(cli): standardize CLI and CI outcomes around governance decisions (#30) - #181
Merged
ElliotSun merged 3 commits intoAug 29, 2026
Conversation
#30) - Add ProcessOutcome and CliExitCode vocabulary in semapact.interfaces.outcomes - Implement centralized outcome and exit code mapping functions - Update CLI top-level exception handling to map exceptions to standardized exit codes - Remove hardcoded sys.exit calls in command modules to route through central handler - Add comprehensive unit, matrix, and subprocess-level acceptance tests
…g files (#30) - Add ReleaseValidationError(ValidationError) for domain release precondition failures - Raise ReleaseValidationError in apply_release_candidate when no bump or insufficient bump (exit code 2) - Wrap raw Pydantic and ODCS structure errors in loader.py as SemaPact ValidationError - Keep outcome_from_exception strictly focused on SemaPact exception taxonomy - Enforce exact exit code 5 (RUNTIME_ERROR) assertion for missing files
…ring sanitization' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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
Closes #30
Standardizes process exit codes and semantic outcomes across the CLI and CI automation layers based on authoritative
GovernanceDecisionandGovernanceGateResultevaluations.Key Changes
semapact/interfaces/outcomes.py):ProcessOutcome:SUCCESS,VALIDATION_FAILED,GOVERNANCE_BLOCKED,REVIEW_REQUIRED,RUNTIME_ERROR.CliExitCode:0(SUCCESS),2(VALIDATION_FAILED),3(GOVERNANCE_BLOCKED),4(REVIEW_REQUIRED),5(RUNTIME_ERROR).outcome_from_gate_result,outcome_from_exception,exit_code_from_outcome,exit_code_from_exception.semapact/interfaces/cli.py):exit_code_from_exception.raise SystemExit(1)andsys.exit()in commands with structured domain exceptions to route through central handler.PublicGovernanceDecisionV1and internalGovernanceDecisionmodels remain strictly independent from shell exit codes (noexitCodeinjected into domain/public JSON).ReleaseValidationError(ValidationError)for domain release precondition failures (exit code 2).ValidationError(exit code 2).RUNTIME_ERROR).Verification
tests/interfaces/test_cli_outcomes.py): Evaluates all 5 outcomes, exit codes, and operation/decision matrices.tests/interfaces/test_cli_subprocess_outcomes.py): Verifies CLI execution acrossANALYZE,PROPOSE,APPLY,CI, syntax/validation errors, and runtime failures.uv run ruff check: 0 errors.uv run pytest: 475 passed in 37.70s.