Coverage for packages/workshop/src/livery/workshop/_series.py: 100%

Measured by coverage.py 7.16.2 on CPython 3.14 while the suites of tests, packages/workshop, packages/extensions/ty, packages/extensions/ruff, packages/extensions/python, packages/extensions/pytest, packages/extensions/pyrefly, packages/extensions/nanobind, packages/extensions/mypy, packages/extensions/mkdocstrings, packages/extensions/lfs, packages/extensions/docs, packages/extensions/cpp, packages/extensions/coverage, packages/extensions/conan, packages/extensions/cmake, packages/extensions/claude, packages/extensions/clang-tidy, packages/extensions/clang-format, packages/extensions/changelog, packages/extensions/basedpyright ran.

1"""Every series the workshop keeps, declared in one place.
2
3The janitor walks them to bound them ([livery.git.sweep][]) and a
4reader lists them. Each series is declared where its rows mean
5something; this module only gathers the declarations: the base's own,
6`BASE`, and the ones the listed extensions keep, their answers to
7``store.series`` ([livery.workshop._series.declared][]).
8"""
9
10from __future__ import annotations
11
12from typing import TYPE_CHECKING
13
14from livery import git
15from livery.workshop import (
16 _diagnostics,
17 _gate_record,
18 _metrics,
19 _shard,
20 _speed,
21 _traces,
22 _verified,
23)
24
25if TYPE_CHECKING:
26 from pathlib import Path
27
28#: The local series a loop pass writes its rows to: one file per
29#: pass on the driver's checkout, never pushed, so passes compare
30#: across days on one machine. Declared here rather than beside the
31#: loop, since the loop's module loads the CI verbs and this module
32#: must import without them; `fm store.show loop` reads it.
33LOOP = git.Series("loop", window=200, ci_only=False, local=True)
34
35#: The base's own series and families, remote and local.
36BASE: tuple[git.Series | git.Keyed, ...] = (
37 _metrics.SERIES,
38 _metrics.RUNS,
39 _shard.DURATIONS,
40 _verified.SERIES,
41 _speed.SERIES,
42 _gate_record.SERIES,
43 _diagnostics.SERIES,
44 _traces.TRACES,
45 _traces.ABOUT,
46 LOOP,
47 git.FETCHED,
48)
49
50
51def declared(root: Path) -> tuple[git.Series | git.Keyed, ...]:
52 """Every series and family *root* keeps: the base's, then the listed extensions'.
53
54 An extension keeps a series by answering ``store.series`` with it.
55 """
56 from livery.workshop._queries import STORE_SERIES, answer
57
58 kept = answer(root, STORE_SERIES)
59 return BASE + tuple(item for item in kept if item not in BASE)
60
61
62def mirrored(item: git.Series | git.Keyed) -> bool:
63 """Whether a sync mirrors *item* into the checkout for a desk's gate to read.
64
65 A remote row series under the store's own namespace is mirrored.
66 A local series is in the checkout already, a keyed family is
67 fetched on read by the verb that needs it, through a live
68 snapshot, and a series of another namespace, a trace, is mirrored
69 by nothing.
70 """
71 return isinstance(item, git.Series) and not item.local and not item.namespace
72
73
74def mirrored_series(root: Path) -> tuple[str, ...]:
75 """The names of the series a sync mirrors for *root*, sorted.
76
77 What [livery.git.fetch_store][] is told to mirror: every declared
78 remote row series ([livery.workshop._series.mirrored][]) and never
79 a keyed family, so a desk's gate reads ``metrics``, ``verified``,
80 ``speed/marks`` and the listed extensions' own from the mirror,
81 and a verb that needs a family opens a live snapshot.
82 """
83 return tuple(sorted(item.name for item in declared(root) if mirrored(item)))