livery.workshop._workflow_engine¶
livery.workshop._workflow_engine ¶
The shared reserved-branch engine and its one kind-specific seam.
Releasing and updating are the same shape underneath: cut a
workflow/<name> branch, do some work, submit through
livery.workshop._submit.submit_flow, and either publish or just
merge. This module runs that shared lifecycle; a
WorkflowDriver plugs in only prepare (do the work) and
on_merged (a release publishes and tags; an update does
nothing). Re-running the engine at any point is the recovery: the
decision extension reads the state and does the right thing.
Classes:
| Name | Description |
|---|---|
Submission |
What a driver's prepare hands back for the shared submit. |
WorkflowDriver |
The only kind-specific seam; everything else is shared. |
Functions:
| Name | Description |
|---|---|
run_workflow |
Drive driver one step: gather, decide, act. |
tidy_leftover |
Tear down a finished workflow's branches; safe, it is merged. |
Attributes:
| Name | Type | Description |
|---|---|---|
PARKS_UPDATES |
|
PARKS_UPDATES
module-attribute
¶
PARKS_UPDATES = frozenset({WorkflowState.IN_PROGRESS, WorkflowState.AWAITING_REVIEW, WorkflowState.UNKNOWN})
Submission
dataclass
¶
WorkflowDriver ¶
Bases: Protocol
The only kind-specific seam; everything else is shared.
Structural, so a driver provides these members and inherits
nothing. branch is always workflow/<name>: one active
workflow per name, the branch name is the identity, different
names coexist.
Methods:
| Name | Description |
|---|---|
prepare |
Do the work; idempotent, called fresh and for recovery. |
discard |
Give the prepared branch up, so the next prepare starts from the base. |
on_merged |
After the merge: a release publishes and tags; else nothing. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
|
kind |
WorkflowKind
|
|
armed |
bool
|
|
members |
tuple[str, ...]
|
|
watch |
float
|
|
branch |
str
|
The reserved branch, |
base |
str
|
The branch the PR merges into. |
prepare ¶
prepare() -> Submission | None
discard ¶
run_workflow ¶
run_workflow(driver: WorkflowDriver, repo: Repository, root: Path, *, current_user: str | None = None) -> None
Drive driver one step: gather, decide, act.
Loops for MERGE_DEFAULT (re-decide on the fresh state) and for a TIDY_THEN_START that removed another workflow's leftover, each other name tidied at most once so the loop cannot spin. STOP raises with its teaching. Everything else terminates.
Source code in packages/workshop/src/livery/workshop/_workflow_engine.py
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 | |
tidy_leftover ¶
tidy_leftover(repo: Repository, root: Path, wf: WorkflowStatus, *, base: str) -> None
Tear down a finished workflow's branches; safe, it is merged.
wf is the decision's tidy target, never assumed to be the driver's own branch: passing a live branch here would close its live PR, the exact mistake the target field prevents.