Coverage for scripts / live_release_validation / registry.py: 100.00%
16 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-09-14 22:07 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-09-14 22:07 +0000
1"""The ordered live-validation action registry.
3This is the single source of truth for which actions exist, what each one
4promises, the order they run in, and which actions must precede them. The
5runner derives selection, dependency expansion, and ``--actions all`` from
6this mapping alone, and ``tests/test_live_release_validation_structure.py``
7holds it in lockstep with the contract table in
8``docs/LIVE_RELEASE_VALIDATION.md``.
10Registering a new action is one entry here plus one module under
11``actions/``; see ``scripts/live_release_validation/README.md``.
12"""
14from __future__ import annotations
16from collections.abc import Callable
17from dataclasses import dataclass
18from typing import Any
20from .actions import (
21 action_api_lifecycle,
22 action_baseline,
23 action_central_queue_lifecycle,
24 action_convergence,
25 action_deploy,
26 action_destroy,
27 action_final_inventory,
28 action_inference,
29 action_network_posture,
30 action_opencost,
31 action_platform_workloads,
32 action_policy,
33 action_preflight,
34 action_schedulers,
35 action_sqs_lifecycle,
36 action_topology,
37)
38from .models import RunContext
40ActionHandler = Callable[[RunContext], dict[str, Any]]
43@dataclass(frozen=True)
44class ActionDefinition:
45 """One selectable action and its safety dependencies."""
47 name: str
48 description: str
49 dependencies: tuple[str, ...]
50 handler: ActionHandler
53def build_action_registry() -> dict[str, ActionDefinition]:
54 """Return actions in dependency-safe execution order."""
55 definitions = (
56 ActionDefinition(
57 "preflight",
58 "Verify exact git, account, configuration, and ownership identity",
59 (),
60 action_preflight,
61 ),
62 ActionDefinition(
63 "baseline",
64 "Capture protected CloudFormation and ECR baselines",
65 ("preflight",),
66 action_baseline,
67 ),
68 ActionDefinition(
69 "deploy",
70 "Deploy the configured GCO topology",
71 ("baseline",),
72 action_deploy,
73 ),
74 ActionDefinition(
75 "topology",
76 "Verify stacks, EKS, API endpoints, queues, and DynamoDB",
77 ("deploy",),
78 action_topology,
79 ),
80 ActionDefinition(
81 "inference",
82 "Run vLLM/TGI baseline and HPA matrix, then prove stable absence",
83 ("topology",),
84 action_inference,
85 ),
86 ActionDefinition(
87 "policy",
88 "Require all three admission layers to be readable per Region",
89 ("topology",),
90 action_policy,
91 ),
92 ActionDefinition(
93 "api",
94 "Run the authenticated API Job lifecycle",
95 ("topology",),
96 action_api_lifecycle,
97 ),
98 ActionDefinition(
99 "sqs",
100 "Run the direct regional SQS Job lifecycle",
101 ("topology",),
102 action_sqs_lifecycle,
103 ),
104 ActionDefinition(
105 "central-queue",
106 "Run the idempotent DynamoDB-backed queue lifecycle",
107 ("topology",),
108 action_central_queue_lifecycle,
109 ),
110 ActionDefinition(
111 "schedulers",
112 "Prove every enabled batch scheduler against a scheduling-gated workload",
113 ("topology",),
114 action_schedulers,
115 ),
116 ActionDefinition(
117 "opencost",
118 "Require healthy, data-returning OpenCost and a working cost report pipeline",
119 ("topology",),
120 action_opencost,
121 ),
122 ActionDefinition(
123 "convergence",
124 "Require stable SQS/DLQ and DynamoDB convergence",
125 ("topology",),
126 action_convergence,
127 ),
128 # The two cluster-facing checks run after every workload action on
129 # purpose: a zero restart count and an intact policy posture mean more
130 # once the services have carried real Job, queue, and inference traffic.
131 ActionDefinition(
132 "platform-workloads",
133 "Require converged, restart-free, drain-safe platform services with the "
134 "configured autoscalers",
135 ("topology",),
136 action_platform_workloads,
137 ),
138 ActionDefinition(
139 "network-posture",
140 "Prove the shipped NetworkPolicies decide traffic on the live cluster",
141 ("topology",),
142 action_network_posture,
143 ),
144 ActionDefinition(
145 "destroy",
146 "Destroy all run-owned infrastructure in dependency order",
147 ("deploy",),
148 action_destroy,
149 ),
150 ActionDefinition(
151 "final-inventory",
152 "Verify zero residual resources and exact baseline preservation",
153 ("destroy",),
154 action_final_inventory,
155 ),
156 )
157 return {definition.name: definition for definition in definitions}