semantics
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
# [DEF:CleanReleaseCliScript:Module]
|
||||
# @COMPLEXITY: 3
|
||||
# @SEMANTICS: cli, clean-release, candidate, artifacts, manifest
|
||||
# @PURPOSE: Provide headless CLI commands for candidate registration, artifact import and manifest build.
|
||||
# @LAYER: Scripts
|
||||
# @RELATION: CALLS -> ComplianceOrchestrator
|
||||
# #region CleanReleaseCliScript [C:3] [TYPE Module] [SEMANTICS cli, clean-release, candidate, artifacts, manifest]
|
||||
# @BRIEF Provide headless CLI commands for candidate registration, artifact import and manifest build.
|
||||
# @LAYER Scripts
|
||||
# @RELATION CALLS -> [ComplianceOrchestrator]
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -27,8 +25,8 @@ from ..services.clean_release.publication_service import (
|
||||
)
|
||||
|
||||
|
||||
# [DEF:build_parser:Function]
|
||||
# @PURPOSE: Build argparse parser for clean release CLI.
|
||||
# #region build_parser [TYPE Function]
|
||||
# @BRIEF Build argparse parser for clean release CLI.
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(prog="clean-release-cli")
|
||||
subparsers = parser.add_subparsers(dest="command", required=True)
|
||||
@@ -99,13 +97,13 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
return parser
|
||||
|
||||
|
||||
# [/DEF:build_parser:Function]
|
||||
# #endregion build_parser
|
||||
|
||||
|
||||
# [DEF:run_candidate_register:Function]
|
||||
# @PURPOSE: Register candidate in repository via CLI command.
|
||||
# @PRE: Candidate ID must be unique.
|
||||
# @POST: Candidate is persisted in DRAFT status.
|
||||
# #region run_candidate_register [TYPE Function]
|
||||
# @BRIEF Register candidate in repository via CLI command.
|
||||
# @PRE Candidate ID must be unique.
|
||||
# @POST Candidate is persisted in DRAFT status.
|
||||
def run_candidate_register(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
|
||||
@@ -128,13 +126,13 @@ def run_candidate_register(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_candidate_register:Function]
|
||||
# #endregion run_candidate_register
|
||||
|
||||
|
||||
# [DEF:run_artifact_import:Function]
|
||||
# @PURPOSE: Import single artifact for existing candidate.
|
||||
# @PRE: Candidate must exist.
|
||||
# @POST: Artifact is persisted for candidate.
|
||||
# #region run_artifact_import [TYPE Function]
|
||||
# @BRIEF Import single artifact for existing candidate.
|
||||
# @PRE Candidate must exist.
|
||||
# @POST Artifact is persisted for candidate.
|
||||
def run_artifact_import(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
|
||||
@@ -161,13 +159,13 @@ def run_artifact_import(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_artifact_import:Function]
|
||||
# #endregion run_artifact_import
|
||||
|
||||
|
||||
# [DEF:run_manifest_build:Function]
|
||||
# @PURPOSE: Build immutable manifest snapshot for candidate.
|
||||
# @PRE: Candidate must exist.
|
||||
# @POST: New manifest version is persisted.
|
||||
# #region run_manifest_build [TYPE Function]
|
||||
# @BRIEF Build immutable manifest snapshot for candidate.
|
||||
# @PRE Candidate must exist.
|
||||
# @POST New manifest version is persisted.
|
||||
def run_manifest_build(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
from ..services.clean_release.manifest_service import build_manifest_snapshot
|
||||
@@ -195,13 +193,13 @@ def run_manifest_build(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_manifest_build:Function]
|
||||
# #endregion run_manifest_build
|
||||
|
||||
|
||||
# [DEF:run_compliance_run:Function]
|
||||
# @PURPOSE: Execute compliance run for candidate with optional manifest fallback.
|
||||
# @PRE: Candidate exists and trusted snapshots are configured.
|
||||
# @POST: Returns run payload and exit code 0 on success.
|
||||
# #region run_compliance_run [TYPE Function]
|
||||
# @BRIEF Execute compliance run for candidate with optional manifest fallback.
|
||||
# @PRE Candidate exists and trusted snapshots are configured.
|
||||
# @POST Returns run payload and exit code 0 on success.
|
||||
def run_compliance_run(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository, get_config_manager
|
||||
|
||||
@@ -234,13 +232,13 @@ def run_compliance_run(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_compliance_run:Function]
|
||||
# #endregion run_compliance_run
|
||||
|
||||
|
||||
# [DEF:run_compliance_status:Function]
|
||||
# @PURPOSE: Read run status by run id.
|
||||
# @PRE: Run exists.
|
||||
# @POST: Returns run status payload.
|
||||
# #region run_compliance_status [TYPE Function]
|
||||
# @BRIEF Read run status by run id.
|
||||
# @PRE Run exists.
|
||||
# @POST Returns run status payload.
|
||||
def run_compliance_status(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
|
||||
@@ -266,13 +264,13 @@ def run_compliance_status(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_compliance_status:Function]
|
||||
# #endregion run_compliance_status
|
||||
|
||||
|
||||
# [DEF:_to_payload:Function]
|
||||
# @PURPOSE: Serialize domain models for CLI JSON output across SQLAlchemy/Pydantic variants.
|
||||
# @PRE: value is serializable model or primitive object.
|
||||
# @POST: Returns dictionary payload without mutating value.
|
||||
# #region _to_payload [TYPE Function]
|
||||
# @BRIEF Serialize domain models for CLI JSON output across SQLAlchemy/Pydantic variants.
|
||||
# @PRE value is serializable model or primitive object.
|
||||
# @POST Returns dictionary payload without mutating value.
|
||||
def _to_payload(value: Any) -> Dict[str, Any]:
|
||||
def _normalize(raw: Any) -> Any:
|
||||
if isinstance(raw, datetime):
|
||||
@@ -296,13 +294,13 @@ def _to_payload(value: Any) -> Dict[str, Any]:
|
||||
raise TypeError(f"unsupported payload type: {type(value)!r}")
|
||||
|
||||
|
||||
# [/DEF:_to_payload:Function]
|
||||
# #endregion _to_payload
|
||||
|
||||
|
||||
# [DEF:run_compliance_report:Function]
|
||||
# @PURPOSE: Read immutable report by run id.
|
||||
# @PRE: Run and report exist.
|
||||
# @POST: Returns report payload.
|
||||
# #region run_compliance_report [TYPE Function]
|
||||
# @BRIEF Read immutable report by run id.
|
||||
# @PRE Run and report exist.
|
||||
# @POST Returns report payload.
|
||||
def run_compliance_report(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
|
||||
@@ -323,13 +321,13 @@ def run_compliance_report(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_compliance_report:Function]
|
||||
# #endregion run_compliance_report
|
||||
|
||||
|
||||
# [DEF:run_compliance_violations:Function]
|
||||
# @PURPOSE: Read run violations by run id.
|
||||
# @PRE: Run exists.
|
||||
# @POST: Returns violations payload.
|
||||
# #region run_compliance_violations [TYPE Function]
|
||||
# @BRIEF Read run violations by run id.
|
||||
# @PRE Run exists.
|
||||
# @POST Returns violations payload.
|
||||
def run_compliance_violations(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
|
||||
@@ -348,13 +346,13 @@ def run_compliance_violations(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_compliance_violations:Function]
|
||||
# #endregion run_compliance_violations
|
||||
|
||||
|
||||
# [DEF:run_approve:Function]
|
||||
# @PURPOSE: Approve candidate based on immutable PASSED report.
|
||||
# @PRE: Candidate and report exist; report is PASSED.
|
||||
# @POST: Persists APPROVED decision and returns success payload.
|
||||
# #region run_approve [TYPE Function]
|
||||
# @BRIEF Approve candidate based on immutable PASSED report.
|
||||
# @PRE Candidate and report exist; report is PASSED.
|
||||
# @POST Persists APPROVED decision and returns success payload.
|
||||
def run_approve(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
|
||||
@@ -379,13 +377,13 @@ def run_approve(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_approve:Function]
|
||||
# #endregion run_approve
|
||||
|
||||
|
||||
# [DEF:run_reject:Function]
|
||||
# @PURPOSE: Reject candidate without mutating compliance evidence.
|
||||
# @PRE: Candidate and report exist.
|
||||
# @POST: Persists REJECTED decision and returns success payload.
|
||||
# #region run_reject [TYPE Function]
|
||||
# @BRIEF Reject candidate without mutating compliance evidence.
|
||||
# @PRE Candidate and report exist.
|
||||
# @POST Persists REJECTED decision and returns success payload.
|
||||
def run_reject(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
|
||||
@@ -410,13 +408,13 @@ def run_reject(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_reject:Function]
|
||||
# #endregion run_reject
|
||||
|
||||
|
||||
# [DEF:run_publish:Function]
|
||||
# @PURPOSE: Publish approved candidate to target channel.
|
||||
# @PRE: Candidate is approved and report belongs to candidate.
|
||||
# @POST: Appends ACTIVE publication record and returns payload.
|
||||
# #region run_publish [TYPE Function]
|
||||
# @BRIEF Publish approved candidate to target channel.
|
||||
# @PRE Candidate is approved and report belongs to candidate.
|
||||
# @POST Appends ACTIVE publication record and returns payload.
|
||||
def run_publish(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
|
||||
@@ -438,13 +436,13 @@ def run_publish(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_publish:Function]
|
||||
# #endregion run_publish
|
||||
|
||||
|
||||
# [DEF:run_revoke:Function]
|
||||
# @PURPOSE: Revoke active publication record.
|
||||
# @PRE: Publication id exists and is ACTIVE.
|
||||
# @POST: Publication record status becomes REVOKED.
|
||||
# #region run_revoke [TYPE Function]
|
||||
# @BRIEF Revoke active publication record.
|
||||
# @PRE Publication id exists and is ACTIVE.
|
||||
# @POST Publication record status becomes REVOKED.
|
||||
def run_revoke(args: argparse.Namespace) -> int:
|
||||
from ..dependencies import get_clean_release_repository
|
||||
|
||||
@@ -464,11 +462,11 @@ def run_revoke(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
# [/DEF:run_revoke:Function]
|
||||
# #endregion run_revoke
|
||||
|
||||
|
||||
# [DEF:main:Function]
|
||||
# @PURPOSE: CLI entrypoint for clean release commands.
|
||||
# #region main [TYPE Function]
|
||||
# @BRIEF CLI entrypoint for clean release commands.
|
||||
def main(argv: Optional[List[str]] = None) -> int:
|
||||
parser = build_parser()
|
||||
args = parser.parse_args(argv)
|
||||
@@ -500,10 +498,10 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
return 2
|
||||
|
||||
|
||||
# [/DEF:main:Function]
|
||||
# #endregion main
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
||||
# [/DEF:CleanReleaseCliScript:Module]
|
||||
# #endregion CleanReleaseCliScript
|
||||
|
||||
Reference in New Issue
Block a user