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/tests/test_workshop_without_docs.py, packages/workshop/tests/test_workshop_vocabulary.py, packages/workshop/tests/test_workshop_traces.py, packages/workshop/tests/test_workshop_sync_install.py, packages/workshop/tests/test_workshop_sync.py, packages/workshop/tests/test_workshop_sweep.py, packages/workshop/tests/test_workshop_store_tasks.py, packages/workshop/tests/test_workshop_shells.py, packages/workshop/tests/test_workshop_shard.py, packages/workshop/tests/test_workshop_runs.py, packages/workshop/tests/test_workshop_proved_shadow.py, packages/workshop/tests/test_workshop_proved_parts.py, packages/workshop/tests/test_workshop_proved_flaky.py, packages/workshop/tests/test_workshop_proved_escapes.py, packages/workshop/tests/test_workshop_proved.py, packages/workshop/tests/test_workshop_prose.py, packages/workshop/tests/test_workshop_new_project.py, packages/workshop/tests/test_workshop_layering.py, packages/workshop/tests/test_workshop_issue.py, packages/workshop/tests/test_workshop_extension_mount.py, packages/workshop/tests/test_workshop_e2e.py, packages/workshop/tests/test_workshop_currency.py, packages/workshop/tests/test_workshop_credential_traces.py, packages/workshop/tests/test_workshop_ci_context.py, packages/workshop/tests/test_workshop_balance.py, packages/extensions/python/tests/test_extensions_python.py, packages/extensions/pytest/tests/test_pytest_observer_shadow.py, packages/extensions/nanobind/tests/test_extensions_nanobind.py, packages/extensions/docs/tests/test_task_links.py, packages/extensions/cpp/tests/test_extensions_cpp.py, packages/extensions/conan/tests/test_extensions_conan.py 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 _metrics,
18 _proved,
19 _shard,
20 _speed,
21 _traces,
22)
23
24if TYPE_CHECKING:
25 from pathlib import Path
26
27#: The local series a loop pass writes its rows to: one file per
28#: pass on the driver's checkout, never pushed, so passes compare
29#: across days on one machine. Declared here rather than beside the
30#: loop, since the loop's module loads the CI verbs and this module
31#: must import without them; `fm store.show loop` reads it.
32LOOP = git.Series("loop", window=200, ci_only=False, local=True)
33
34#: The base's own series and families, remote and local.
35BASE: tuple[git.Series | git.Keyed, ...] = (
36 _metrics.SERIES,
37 _metrics.RUNS,
38 _shard.PLANS,
39 _shard.DURATIONS,
40 _proved.FAMILY,
41 _proved.PROVED_PARTS,
42 _proved.LOCAL,
43 _proved.SHADOW_DIFFS,
44 _proved.MEASURES,
45 _proved.ESCAPES,
46 _proved.TREES,
47 _proved.LOCAL_ESCAPES,
48 _speed.SERIES,
49 _diagnostics.SERIES,
50 _traces.TRACES,
51 _traces.ABOUT,
52 LOOP,
53 git.FETCHED,
54)
55
56
57def declared(root: Path) -> tuple[git.Series | git.Keyed, ...]:
58 """Every series and family *root* keeps: the base's, then the listed extensions'.
59
60 An extension keeps a series by answering ``store.series`` with it.
61 """
62 from livery.workshop._queries import STORE_SERIES, answer
63
64 kept = answer(root, STORE_SERIES)
65 return BASE + tuple(item for item in kept if item not in BASE)
66
67
68def mirrored(item: git.Series | git.Keyed) -> bool:
69 """Whether a sync mirrors *item* into the checkout for a desk's gate to read.
70
71 A remote row series under the store's own namespace is mirrored.
72 A local series is in the checkout already, a keyed family is
73 fetched on read by the verb that needs it, through a live
74 snapshot, and a series of another namespace, a trace, is mirrored
75 by nothing.
76 """
77 return isinstance(item, git.Series) and not item.local and not item.namespace
78
79
80def mirrored_series(root: Path) -> tuple[str, ...]:
81 """The names of the series a sync mirrors for *root*, sorted.
82
83 What [livery.git.fetch_store][] is told to mirror: every declared
84 remote row series ([livery.workshop._series.mirrored][]) and never
85 a keyed family, so a desk's gate reads ``metrics``, ``verified``,
86 ``speed/marks`` and the listed extensions' own from the mirror,
87 and a verb that needs a family opens a live snapshot.
88 """
89 return tuple(sorted(item.name for item in declared(root) if mirrored(item)))
90
91
92def mirrored_prefixes(root: Path) -> tuple[str, ...]:
93 """Bounded keyed-family prefixes a sync mirrors alongside `mirrored_series`.
94
95 Mirrors main's proved rows (``proved/main/``) in the same fetch
96 round trip so a desk reads CI's proved verdicts offline without
97 fetching feature-branch records or coverage families.
98 """
99 del root
100 return (_proved.MAIN_PREFIX,)