1"""Every series the workshop keeps, declared in one place.
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"""
10from __future__ import annotations
12from typing import TYPE_CHECKING
14from livery import git
15from livery.workshop import (
16 _diagnostics,
17 _gate_record,
18 _metrics,
19 _shard,
20 _speed,
21 _traces,
22 _verified,
23)
25if TYPE_CHECKING:
26 from pathlib import Path
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)
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)
51def declared(root: Path) -> tuple[git.Series | git.Keyed, ...]:
52 """Every series and family *root* keeps: the base's, then the listed extensions'.
54 An extension keeps a series by answering ``store.series`` with it.
55 """
56 from livery.workshop._queries import STORE_SERIES, answer
58 kept = answer(root, STORE_SERIES)
59 return BASE + tuple(item for item in kept if item not in BASE)
62def mirrored(item: git.Series | git.Keyed) -> bool:
63 """Whether a sync mirrors *item* into the checkout for a desk's gate to read.
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
74def mirrored_series(root: Path) -> tuple[str, ...]:
75 """The names of the series a sync mirrors for *root*, sorted.
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)))