climate_ref_core.regression.gate
#
CI coupling gate for test case regression bundles.
For each test case, CI decides how to verify the regression baseline in a pull request, based on what changed relative to the base branch:
- REPLAY: re-run
build_execution_resultagainst the cached native baseline and compare to the committed bundle. Used when extraction code changed but the committed bundle did not, to seed a newly added manifest, and to verify atest_case_versionbump that ships native blobs. - FAIL: the committed bundle or its catalog changed without a
test_case_versionbump, a version moved backwards, or the in-codeDiagnostic.versionno longer matches the recordeddiagnostic_version. - SKIP: nothing relevant changed, the case is not under regression-baseline management, or the committed bundle changed with no native baseline to replay against (the diff review is the only signal in that case).
The gate tracks two orthogonal version axes:
test_case_version (per-case, mint-authored)
and diagnostic_version (per-diagnostic, author-authored).
Both are monotonic. Neither may decrease.
See Regression Baselines for more information about the motivation and workflow for regression baselines.
Action
#
Bases: Enum
The verification action the CI gate selects for a single test case.
Source code in packages/climate-ref-core/src/climate_ref_core/regression/gate.py
FAIL = 'fail'
class-attribute
instance-attribute
#
The change is not permissible (unauthorised baseline change or bad version).
REPLAY = 'replay'
class-attribute
instance-attribute
#
Replay the cached native baseline and compare to the committed bundle.
SKIP = 'skip'
class-attribute
instance-attribute
#
Nothing relevant changed, or the case is not under regression management.
GateDecision
#
The gate's decision for one test case: an :class:Action and why.
Source code in packages/climate-ref-core/src/climate_ref_core/regression/gate.py
decide_coupling(manifest, base_manifest, *, extraction_changed=False, committed_integrity_ok=True, catalog_integrity_ok=True, code_diagnostic_version=None)
#
Decide how CI should verify a single test case's regression baseline.
The decision is pure: it performs no I/O. All on-disk reality is summarised by its arguments, namely the two manifests, whether the diagnostic's extraction code changed, and whether the committed bundle on disk still matches the current manifest's digests.
The gate fails if any state cannot be positively verified. A deleted managed manifest, a committed bundle that drifted from its manifest, an input catalog that drifted from its manifest is a failure rather than a silent skip.
Changes to the native baseline are not failures.
This is due to the workflow for minting requires credentials.
This means fork contributors cannot author or edit native blobs.
replay is therefore only selected when native blobs actually exist to replay.
An absent or removed native baseline downgrades to skip, never fail.
See the module docstring for the meaning of each :class:Action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
Manifest | None
|
The current |
required |
base_manifest
|
Manifest | None
|
The |
required |
extraction_changed
|
bool
|
Whether code that influences |
False
|
committed_integrity_ok
|
bool
|
Whether the committed bundle on disk matches the current manifest's Ignored when |
True
|
catalog_integrity_ok
|
bool
|
Whether the test case's input Always |
True
|
code_diagnostic_version
|
int | None
|
The diagnostic's current in-code |
None
|
Returns:
| Type | Description |
|---|---|
GateDecision
|
The gate's decision, pairing an :class: |
Source code in packages/climate-ref-core/src/climate_ref_core/regression/gate.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
paths_under(changed_files, roots)
#
Return whether any changed file lies within one of the given directory roots.
A small helper for deriving the extraction_changed signal from a pull request's changed-file list.
Paths are compared textually as POSIX-style, repo-relative strings,
so callers must normalise both changed_files and roots to the same convention
(e.g. git diff --name-only output and a package source directory relative to the repo root).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
changed_files
|
Iterable[str]
|
Repo-relative paths changed in the pull request. |
required |
roots
|
Iterable[str]
|
Repo-relative directory prefixes to test against. A trailing slash is optional; an empty root never matches. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|