Skip to content

feat(cli): standardize CLI and CI outcomes around governance decisions (#30) - #181

Merged
ElliotSun merged 3 commits into
mainfrom
30-standardize-cli-and-ci-outcomes-around-governance-decisions
Aug 29, 2026
Merged

feat(cli): standardize CLI and CI outcomes around governance decisions (#30)#181
ElliotSun merged 3 commits into
mainfrom
30-standardize-cli-and-ci-outcomes-around-governance-decisions

Conversation

@ElliotSun

Copy link
Copy Markdown
Collaborator

Summary

Closes #30

Standardizes process exit codes and semantic outcomes across the CLI and CI automation layers based on authoritative GovernanceDecision and GovernanceGateResult evaluations.

Key Changes

  1. Independent Process Outcome Vocabulary & Shell Exit Code Adapter (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).
    • Central mapping functions: outcome_from_gate_result, outcome_from_exception, exit_code_from_outcome, exit_code_from_exception.
  2. Centralized Exception & Exit Code Routing (semapact/interfaces/cli.py):
    • Mapped top-level exception handler to exit_code_from_exception.
    • Replaced scattered raise SystemExit(1) and sys.exit() in commands with structured domain exceptions to route through central handler.
  3. Decoupled Contracts:
    • PublicGovernanceDecisionV1 and internal GovernanceDecision models remain strictly independent from shell exit codes (no exitCode injected into domain/public JSON).
  4. Refined Exception Taxonomy:
    • Added ReleaseValidationError(ValidationError) for domain release precondition failures (exit code 2).
    • Contract loader translates raw ODCS parse/Pydantic issues into SemaPact ValidationError (exit code 2).
    • Missing/unreadable files deterministically exit with code 5 (RUNTIME_ERROR).

Verification

  • Unit & Matrix Tests (tests/interfaces/test_cli_outcomes.py): Evaluates all 5 outcomes, exit codes, and operation/decision matrices.
  • Subprocess-level Acceptance Tests (tests/interfaces/test_cli_subprocess_outcomes.py): Verifies CLI execution across ANALYZE, PROPOSE, APPLY, CI, syntax/validation errors, and runtime failures.
  • uv run ruff check: 0 errors.
  • uv run pytest: 475 passed in 37.70s.

#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
Comment thread semapact/interfaces/commands/plan_cmd.py Fixed
…ring sanitization'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ElliotSun
ElliotSun merged commit 1fd6443 into main Aug 29, 2026
7 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