livery.workshop._workflow_decision¶
livery.workshop._workflow_decision ¶
The pure decision: given the state, what does a workflow driver do?
Every reserved-branch workflow shares one lifecycle: cut a
workflow/<name> branch, do the work, open a squash PR, arm, and
merge (a release then publishes). The engine
(livery.workshop._workflow_engine.run_workflow) gathers the inputs,
asks workflow_decision, and acts; each driver plugs in only
its do-the-work and after-the-merge steps.
The decision is a pure function so every branch is table-testable. Order is load-bearing and stated inline. Every STOP message teaches: it names what stopped the driver and lists the options with when each applies.
Classes:
| Name | Description |
|---|---|
WorkflowAction |
What a driver does next; the same vocabulary for every kind. |
WorkflowDecision |
The chosen action, a line to announce or teach, and a tidy target. |
Functions:
| Name | Description |
|---|---|
workflow_decision |
Decide what the name driver does next. Pure, no I/O. |
Attributes:
| Name | Type | Description |
|---|---|---|
ACTIVE |
|
ACTIVE
module-attribute
¶
ACTIVE = frozenset({WorkflowState.IN_PROGRESS, WorkflowState.AWAITING_REVIEW, WorkflowState.PREPARING})
WorkflowAction ¶
Bases: Enum
What a driver does next; the same vocabulary for every kind.
Attributes:
| Name | Type | Description |
|---|---|---|
START |
|
|
ARM |
|
|
RETRY |
|
|
REOPEN |
|
|
REPREPARE |
|
|
TIDY_THEN_START |
|
|
MERGE_DEFAULT |
|
|
STOP |
|
WorkflowDecision
dataclass
¶
WorkflowDecision(action: WorkflowAction, message: str = '', tidy_target: WorkflowStatus | None = None)
The chosen action, a line to announce or teach, and a tidy target.
tidy_target names WHICH workflow a TIDY_THEN_START removes: a
finished other under coexistence, or None for the driver's own
leftover. Without it the engine could not tell somebody else's
leftover from its own live branch, and tidying the wrong one
closes a live PR.
Attributes:
| Name | Type | Description |
|---|---|---|
action |
WorkflowAction
|
|
message |
str
|
|
tidy_target |
WorkflowStatus | None
|
|
workflow_decision ¶
workflow_decision(*, kind: WorkflowKind, name: str, wf: WorkflowStatus, members: tuple[str, ...], branch: str, dirty: bool, behind_default: int, default_branch: str, current_user: str, others: tuple[WorkflowStatus, ...] = ()) -> WorkflowDecision
Decide what the name driver does next. Pure, no I/O.
wf is this driver's own detected workflow (NONE when absent); others are the coexisting workflows on different names; members are a release driver's package directories, used for the intersection refusal. Order matters: the wrong-branch refusal, then the fail-safe and human stops, then coexistence, then the automatic actions keyed on the detector's state.
Source code in packages/workshop/src/livery/workshop/_workflow_decision.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |