Repository navigation
Commit d7a1f2c
authored
refactor(ios-runner): make the snapshot quality verdict state a closed enum (#2888)
* refactor(ios-runner): close the snapshot quality verdict state vocabulary
The runner wrote the verdict `state` as a free String while the host accepts only
healthy | recovered | sparse, and the contracts annotation reader cast any string state into
the verdict type. A typo or a one-sided rename therefore dropped the verdict and its
disclosure.
`SnapshotQualityState` now owns the runner side, raw-value Codable keeps the wire JSON
unchanged, and `reasonCode` stays open. The kernel states the vocabulary once as
`SNAPSHOT_QUALITY_STATES` with `isSnapshotQualityState`; capture-kit and contracts both read
through it, so neither keeps a second accepted-state set and the annotation reader rejects an
unknown state instead of casting it. `contracts/fixtures/ios-snapshot-quality-states.json` is
the table the Swift `allCases` order and the kernel tuple are each pinned to.
* refactor(substrate): hold the verdict state map in each eager-frozen reader
The readers reached the vocabulary through `isSnapshotQualityState` in `kernel/snapshot.ts`, which
made that module eager in six entry closures the eager-closure gate holds at its merge-base size —
the contracts capture façade at 9 modules, capture-kit's verdict reader at 2. The only module those
two closures already evaluate is the one whose edge the gate rejects, so no single runtime home for
the set exists.
Each reader now keys a `Record<SnapshotQualityState, true>` over the kernel union, the home the
gate prescribes for code that has to live where it is already evaluated. Membership goes through
`Object.hasOwn`, so an inherited key is never a state, and a state added to the tuple without a key
in a reader is a compile error there: the guarantee the shared import was bought for, without the
eager edge. Both reader tests walk the tuple and the kernel test still pins it to the fixture.
* refactor(snapshot): gate the backend name, and stop pinning vocabulary order
The annotation reader was one predicate plus a blanket cast. `backend` names the recovery strategy
in the warning line, so it goes through a declared map keyed against the kernel union now, and
capture-kit lost both of its `as` casts on the way: the strategy is gated on the capability table it
already imports, the reason code on an exhaustive map over its union.
A full projection in contracts was tried and the repo's own gates refuse it — fallow reports a
4-group, 104-line clone family against capture-kit's normalizer, on top of the eager-closure gate
that already forbids a shared reader. The re-read stays in the shape `readTargetActivation` in the
same file uses: check the two names that decide presentation, forward what this module published, and
pin the pair payload-by-payload from capture-kit's test.
Order pinning drops out. The fixture is compared as a set on both sides, the stamping test asserts
each case's own raw value, and the unread 28-line capture builder and its import are gone.
* refactor(contracts): name the verdict re-read apart from the strict reader
Two same-named readers with different trust levels is how the half-migration read as validating more
than it does. This module's version checks the two load-bearing names and forwards what this repo
published, in the shape `readTargetActivation` uses, so it is now `readPublishedSnapshotQualityVerdict`
and the strict per-field reading keeps the plain name for capture-kit's untrusted-payload reader.
* refactor(snapshot): answer the review round on sharing, parity, and evidence
The eager-closure refusal the review asked to be pointed at or filed is not a table of budgets: the
gate ratchets every entry's closure against the committed merge-base tree, so the numbers to read are
9 for `facades/capture.ts` and 2 for `snapshot-quality-verdict.ts`. Re-installing one shared kernel
predicate for both readers on this head fails six entries and names both of those, which is why the
vocabulary stays a map per reader; recorded on #2872 as the accepted deviation.
The `android-helper` asymmetry is not real: `SNAPSHOT_QUALITY_BACKEND_CAPABILITIES` merges the
Android declaration, so both readers accept that strategy and the parity table now carries the row
instead of omitting it. The client-side drop of an unknown state or backend gets its CHANGELOG entry,
the justification comments shrink to one constraint sentence each, the kernel test keeps only its
`@ts-expect-error`, and the word left dangling by the last rename goes.1 parent 3e5af3a commit d7a1f2c
13 files changed
Lines changed: 351 additions & 69 deletions
File tree
- apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests
- UnitTests
- contracts/fixtures
- packages
- capture-kit/src
- contracts/src
- kernel/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
11 | 23 | | |
12 | 24 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 25 | + | |
16 | 26 | | |
17 | 27 | | |
18 | 28 | | |
| |||
391 | 401 | | |
392 | 402 | | |
393 | 403 | | |
394 | | - | |
| 404 | + | |
395 | 405 | | |
396 | 406 | | |
397 | 407 | | |
| |||
416 | 426 | | |
417 | 427 | | |
418 | 428 | | |
419 | | - | |
| 429 | + | |
420 | 430 | | |
421 | 431 | | |
422 | 432 | | |
423 | | - | |
| 433 | + | |
424 | 434 | | |
425 | 435 | | |
426 | 436 | | |
| |||
679 | 689 | | |
680 | 690 | | |
681 | 691 | | |
682 | | - | |
| 692 | + | |
683 | 693 | | |
684 | 694 | | |
685 | 695 | | |
| |||
704 | 714 | | |
705 | 715 | | |
706 | 716 | | |
707 | | - | |
| 717 | + | |
708 | 718 | | |
709 | 719 | | |
710 | 720 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
228 | | - | |
| 227 | + | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
| 240 | + | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| |||
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
510 | | - | |
| 510 | + | |
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
50 | 68 | | |
51 | 69 | | |
52 | 70 | | |
| |||
98 | 116 | | |
99 | 117 | | |
100 | 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 | + | |
0 commit comments