livery.workshop._proved¶
livery.workshop._proved ¶
The proved record: per-unit step verdicts written beside today's records.
A unit is one thing that gives a verdict: a step over one package
(lint.ruff@packages/workshop), or a workspace step over the root
(drift.check@.). Each CI check leg writes its unit rows under the
keyed family proved/<base>/<leg> in the state store (livery.git),
one file per unit holding the newest KEEP_READ_SETS distinct
fingerprints seen for that unit on that platform.
A row records the unit, the platform (OS, runner image version, Python
version), the verdict (green, red, skipped or
unfinished), how many times each verdict was seen under the same
fingerprint (so two verdicts under one fingerprint mark the unit flaky),
the run metadata, and the fingerprint of what the step read (its matched
files, pinned tool versions, and declared options).
Concurrent writers targeting the same ref (such as shards of one
platform leg) combine through compare-and-swap with merge_unit_files,
so both writers land and per-fingerprint verdict counts accumulate
instead of clobbering one another.
Classes:
| Name | Description |
|---|---|
Platform |
The execution platform recorded on every proved row. |
ItemReadSet |
What one test item read while executing, language-agnostic. |
ReadSetEntry |
One fingerprint's verdict history on a unit row. |
UnitRow |
One unit's stored row on a proved ref, holding its newest read-sets. |
Observation |
One unit outcome observed during a gate walk, ready to record. |
ShadowDiff |
One disagreement between today's decision and the proved record. |
ShadowReport |
Result of comparing today's gate decision with the proved record. |
UnitDecision |
Gate decision computed from the proved record for a set of candidate units. |
ItemSelection |
Shadow (or live) selection verdict for a set of test items. |
RanItems |
What per-item test execution ran and skipped during one check leg. |
Escape |
One test item proved green by its row that failed during a scheduled audit. |
FingerprintContext |
Shared per-walk cache for computing step unit fingerprints quickly. |
ProvedTree |
Record that a git tree hash was proved green across a set of check legs. |
Functions:
| Name | Description |
|---|---|
current_platform |
The platform of the current process, including runner image when reported. |
read_set_blob_name |
Content-addressed blob path on a proved ref for read-set digest. |
dir_listing_digest |
SHA-256 of sorted direct entry names under |
item_read_set_matches |
Whether read_set still matches root on disk, and the first mismatch. |
unit_id |
Canonical unit identifier for step over target. |
row_name |
Stable ref-safe filename for one unit's row file on a proved ref. |
current_keys |
The keys the world produces: main and every branch on origin, per check leg. |
current_parts_keys |
Active |
proved_parts_series |
Return the proved-parts series for extension, base, and leg. |
proved_parts_prefixes |
Return ref prefixes to fetch extension's proved parts for bases. |
put_proved_part |
Store an opaque payload for extension under unit and row_key. |
read_proved_part |
Read an opaque payload stored by |
leg_base |
The proved-record base key ( |
leg_key |
The platform leg key for run, stripping any shard suffix. |
merge_unit_files |
Combine existing and incoming proved unit files for CAS retry. |
write_observations |
Write observations to the proved store; |
spool_proved_observations |
Merge observations into |
record_item_observations |
Write per-item verdicts and read-sets for step to the proved store. |
item_read_details |
Find proved rows and decoded read-sets for item across proved refs. |
read_unit_rows |
Read all proved unit rows from one series; |
flaky_units |
Every flagged flaky entry (green and red under one fingerprint) across refs. |
rows_for_run |
All |
is_proved_unit |
Whether row proves fingerprint on platform, and the reason. |
is_proved_from_rows |
Whether candidate rows for one unit prove fingerprint on platform. |
lookup_proved_rows |
Load candidate proved unit rows for run (CI) or offline mirror (desk). |
lookup_proved_rows_for_decision |
Load primary proved rows plus lingering branch rows for a |
decide_units |
Decide which candidate_units are proved green and which must run. |
copy_branch_rows_to_main |
Copy matched branch unit rows and item read-sets onto |
evaluate_shadow |
Compare today_running against what rows_by_unit would skip. |
write_shadow_report |
Record one CI leg's shadow comparison on |
read_shadow_differences |
Read shadow comparison rows newest first: |
without_item_selection |
Temporarily disable live per-item selection in this process. |
item_selection_disabled |
Whether live per-item selection is disabled by context or environment. |
clear_ran_items |
Remove any prior check leg's per-item execution record under root. |
read_ran_items |
Read the per-item execution record under root; empty when absent. |
record_ran_items |
Merge ran, skipped, and narrowed into root's ran-items file. |
lookup_proved_item_rows |
Load candidate proved rows and decoded read-set blobs for target_units. |
is_item_proved |
Whether candidates prove a test item on root and platform. |
shadow_select_items |
Compute which items existing proved rows would select or skip. |
record_selection_measure |
Record one |
read_measures |
Read measure rows newest first from |
detect_item_escapes |
Return |
record_escapes |
Write escapes to |
read_escapes |
Read recorded escapes newest first from |
active_escaped_packages |
Packages put back to whole runs due to an unaddressed recorded escape. |
step_fingerprint |
Deterministic SHA-256 fingerprint of what record reads on target. |
proving_branch |
Return |
proved_unit_key |
Return the proved row key for target's registered steps in phase. |
proved_unit_keys |
Return a |
base_proved |
Whether |
head_tree_id |
Return the git tree object id of |
tree_row_name |
Stable row filename on |
read_proved_tree |
Look up a green |
stamp_proved_tree |
Record tree_id as proved green across legs on |
sweep_proved_store |
Prune unreferenced |
promote_proved_tree_to_main |
Promote branch proved rows and extension proved-parts to |
Attributes:
PROVED_PARTS
module-attribute
¶
PROVED_PARTS: Keyed = git.Keyed('proved-parts', ('extension', 'base', 'leg'), schema=PARTS_SCHEMA, current=current_parts_keys, linger=timedelta(days=1), blobs=PARTS_BLOBS_PREFIX)
FAMILY
module-attribute
¶
FAMILY: Keyed = git.Keyed('proved', ('base', 'leg'), schema=SCHEMA, current=current_keys, linger=timedelta(days=1), blobs=READS_PREFIX)
LOCAL
module-attribute
¶
LOCAL: Series = git.Series('proved-local', window=None, ci_only=False, local=True, schema=SCHEMA, blobs=READS_PREFIX)
SHADOW_DIFFS
module-attribute
¶
ESCAPES
module-attribute
¶
LOCAL_ESCAPES
module-attribute
¶
LOCAL_ESCAPES: Series = git.Series('proved-escapes-local', window=200, ci_only=False, local=True, schema=SCHEMA)
Platform
dataclass
¶
The execution platform recorded on every proved row.
Attributes:
| Name | Type | Description |
|---|---|---|
os |
str
|
Runner or host OS label (e.g. |
image |
str
|
Runner image identifier and version when reported by CI, or the host OS release outside CI. |
python |
str
|
Exact Python interpreter version ( |
Methods:
| Name | Description |
|---|---|
matches |
Whether self proves work for other. |
to_dict |
Serialize as a JSON-compatible dictionary. |
from_dict |
Deserialize from a row's |
matches ¶
Whether self proves work for other.
CI requires an exact OS family, runner image, and exact interpreter version; a desk reading CI's mirrored rows matches OS family and major.minor interpreter version.
Source code in packages/workshop/src/livery/workshop/_proved.py
to_dict ¶
from_dict
classmethod
¶
Deserialize from a row's platform mapping.
Source code in packages/workshop/src/livery/workshop/_proved.py
ItemReadSet
dataclass
¶
ItemReadSet(files: Mapping[str, str], absent: tuple[str, ...] = (), dirs: Mapping[str, str] = dict(), dists: Mapping[str, str] = dict(), native_tools: tuple[str, ...] = (), unrecorded: bool = False)
What one test item read while executing, language-agnostic.
Attributes:
| Name | Type | Description |
|---|---|---|
files |
Mapping[str, str]
|
Repository-relative paths opened or imported, mapped to their SHA-256 hex digest at observation time. |
absent |
tuple[str, ...]
|
Sorted repository-relative paths opened or checked that did not exist at observation time; creating one invalidates the item. |
dirs |
Mapping[str, str]
|
Repository-relative directories listed during execution, mapped to the SHA-256 digest of their sorted direct child names. |
dists |
Mapping[str, str]
|
Third-party distributions imported during execution, mapped to their installed version string. |
native_tools |
tuple[str, ...]
|
Sorted basenames of non-Python executables spawned while the item ran. |
unrecorded |
bool
|
|
Methods:
| Name | Description |
|---|---|
to_dict |
Serialize as a canonical JSON-compatible dictionary. |
from_dict |
Deserialize from a |
fingerprint |
Deterministic SHA-256 hex digest of this read-set. |
to_dict ¶
Serialize as a canonical JSON-compatible dictionary.
Source code in packages/workshop/src/livery/workshop/_proved.py
from_dict
classmethod
¶
from_dict(data: Mapping[str, Any]) -> ItemReadSet
Deserialize from a reads/<digest>.json blob payload.
Source code in packages/workshop/src/livery/workshop/_proved.py
ReadSetEntry
dataclass
¶
ReadSetEntry(fingerprint: str, verdict: str, counts: Mapping[str, int], run: str = '', sha: str = '', branch: str = '', attempt: str = '', trigger: str = '', when: str = '', platform: Platform | None = None, read_set: str = '')
One fingerprint's verdict history on a unit row.
Attributes:
| Name | Type | Description |
|---|---|---|
fingerprint |
str
|
SHA-256 hex digest of what the unit read. |
verdict |
str
|
Latest verdict observed for this fingerprint. |
counts |
Mapping[str, int]
|
Cumulative counts per verdict in |
run |
str
|
Forge run identifier that last wrote this entry. |
sha |
str
|
Commit SHA of the run. |
branch |
str
|
Branch name of the run. |
attempt |
str
|
Run attempt string (empty when unreported). |
trigger |
str
|
CI point / trigger name (e.g. |
when |
str
|
ISO 8601 UTC timestamp of the observation. |
Methods:
| Name | Description |
|---|---|
to_dict |
Serialize as a JSON-compatible dictionary. |
from_dict |
Deserialize one entry from a unit row's |
to_dict ¶
Serialize as a JSON-compatible dictionary.
Source code in packages/workshop/src/livery/workshop/_proved.py
from_dict
classmethod
¶
from_dict(data: Mapping[str, Any], *, default_platform: Platform | None = None) -> ReadSetEntry
Deserialize one entry from a unit row's entries list.
Source code in packages/workshop/src/livery/workshop/_proved.py
UnitRow
dataclass
¶
One unit's stored row on a proved ref, holding its newest read-sets.
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str
|
Canonical unit identifier ( |
step |
str
|
Step name ( |
target |
str
|
Target unit path ( |
platform |
Platform
|
Execution platform that produced the row. |
entries |
tuple[ReadSetEntry, ...]
|
Newest distinct read-set entries, newest first. |
Methods:
| Name | Description |
|---|---|
to_dict |
Serialize as a JSON-compatible dictionary (without store stamp). |
from_dict |
Deserialize from a store row's data mapping. |
to_dict ¶
Serialize as a JSON-compatible dictionary (without store stamp).
Source code in packages/workshop/src/livery/workshop/_proved.py
from_dict
classmethod
¶
Deserialize from a store row's data mapping.
Source code in packages/workshop/src/livery/workshop/_proved.py
Observation
dataclass
¶
Observation(step: str, target: str, verdict: str, fingerprint: str, platform: Platform, run: str = '', sha: str = '', branch: str = '', attempt: str = '', trigger: str = '', when: str = '', read_set: ItemReadSet | None = None)
One unit outcome observed during a gate walk, ready to record.
Attributes:
| Name | Type | Description |
|---|---|---|
step |
str
|
Registered step name ( |
target |
str
|
Package path ( |
verdict |
str
|
One of |
fingerprint |
str
|
SHA-256 hex digest of the step unit's inputs. |
platform |
Platform
|
Platform that ran (or skipped) the unit. |
run |
str
|
Forge run id (empty locally). |
sha |
str
|
Commit SHA of the run. |
branch |
str
|
Branch name of the run. |
attempt |
str
|
Run attempt string. |
trigger |
str
|
CI point / trigger name. |
when |
str
|
ISO 8601 UTC timestamp (stamped now when omitted). |
Methods:
| Name | Description |
|---|---|
__post_init__ |
|
to_dict |
Serialize this observation (including any item read-set) for spooling. |
from_dict |
Deserialize a spooled observation written by |
__post_init__ ¶
to_dict ¶
Serialize this observation (including any item read-set) for spooling.
Source code in packages/workshop/src/livery/workshop/_proved.py
from_dict
classmethod
¶
from_dict(data: Mapping[str, Any]) -> Observation
Deserialize a spooled observation written by to_dict.
Source code in packages/workshop/src/livery/workshop/_proved.py
ShadowDiff
dataclass
¶
One disagreement between today's decision and the proved record.
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str
|
Canonical unit identifier ( |
today |
str
|
Today's decision for this unit ( |
proved |
str
|
What the proved record would decide ( |
reason |
str
|
Why the proved record made its decision. |
Methods:
| Name | Description |
|---|---|
to_dict |
Serialize as a JSON-compatible dictionary. |
from_dict |
Deserialize one difference entry. |
ShadowReport
dataclass
¶
ShadowReport(checked: int, would_skip: int, today_skip: int, differences: tuple[ShadowDiff, ...])
Result of comparing today's gate decision with the proved record.
Methods:
| Name | Description |
|---|---|
format_lines |
Concise human-readable lines for gate logs. |
Attributes:
| Name | Type | Description |
|---|---|---|
checked |
int
|
|
would_skip |
int
|
|
today_skip |
int
|
|
differences |
tuple[ShadowDiff, ...]
|
|
format_lines ¶
Concise human-readable lines for gate logs.
Source code in packages/workshop/src/livery/workshop/_proved.py
UnitDecision
dataclass
¶
UnitDecision(proved: frozenset[str], running: tuple[tuple[StepRecord, str, str], ...], copied: tuple[Observation, ...] = (), matched_branches: tuple[str, ...] = ())
Gate decision computed from the proved record for a set of candidate units.
Attributes:
| Name | Type | Description |
|---|---|---|
proved |
frozenset[str]
|
Canonical unit ids proved green and skipped. |
running |
tuple[tuple[StepRecord, str, str], ...]
|
|
copied |
tuple[Observation, ...]
|
Observations matched on lingering branch refs during a |
matched_branches |
tuple[str, ...]
|
Sorted branch base keys whose rows supplied |
ItemSelection
dataclass
¶
ItemSelection(selected: tuple[str, ...], skipped: tuple[str, ...], reasons: Mapping[str, str], fingerprints: Mapping[str, str] = dict())
Shadow (or live) selection verdict for a set of test items.
Attributes:
| Name | Type | Description |
|---|---|---|
selected |
tuple[str, ...]
|
Repository-relative test items that would run. |
skipped |
tuple[str, ...]
|
Repository-relative test items proved by existing rows. |
reasons |
Mapping[str, str]
|
Per-item explanation ( |
fingerprints |
Mapping[str, str]
|
Matched proved row fingerprint for each skipped item. |
RanItems
dataclass
¶
RanItems(ran: Mapping[str, str] = dict(), skipped: Mapping[str, str] = dict(), narrowed: bool = False)
What per-item test execution ran and skipped during one check leg.
Attributes:
| Name | Type | Description |
|---|---|---|
ran |
Mapping[str, str]
|
Executed test item path to its recorded read-set fingerprint (empty string when the item collected no tests). |
skipped |
Mapping[str, str]
|
Live-skipped (or carried) test item path to its matched proved read-set fingerprint. |
narrowed |
bool
|
Whether live per-item selection skipped at least one test item during the gate run. |
Escape
dataclass
¶
Escape(unit: str, item: str, package: str, changed_files: tuple[str, ...], proved_sha: str = '', proved_run: str = '', audit_sha: str = '', audit_run: str = '', leg: str = '', contract_digest: str = '', item_digest: str = '', when: str = '', resolved: bool = False)
One test item proved green by its row that failed during a scheduled audit.
Attributes:
| Name | Type | Description |
|---|---|---|
unit |
str
|
Canonical unit identifier ( |
item |
str
|
Repository-relative test file path. |
package |
str
|
Owning package path (or |
changed_files |
tuple[str, ...]
|
Repository-relative files changed since |
proved_sha |
str
|
Commit SHA of the row that proved the item. |
proved_run |
str
|
Forge run id of the proving row. |
audit_sha |
str
|
Commit SHA of the audit run that caught the escape. |
audit_run |
str
|
Forge run id of the audit run. |
leg |
str
|
Platform leg label of the audit run. |
contract_digest |
str
|
SHA-256 of |
item_digest |
str
|
SHA-256 of item at audit time; fixing item clears the block. |
when |
str
|
ISO 8601 UTC timestamp of the audit run. |
resolved |
bool
|
Whether this escape has been explicitly marked resolved. |
Methods:
| Name | Description |
|---|---|
to_dict |
Serialize as a JSON-compatible dictionary. |
from_dict |
Deserialize from a stored escape row. |
to_dict ¶
Serialize as a JSON-compatible dictionary.
Source code in packages/workshop/src/livery/workshop/_proved.py
from_dict
classmethod
¶
Deserialize from a stored escape row.
Source code in packages/workshop/src/livery/workshop/_proved.py
FingerprintContext
dataclass
¶
FingerprintContext(root: Path, packages: tuple[Package, ...], files: tuple[str, ...] = tuple(), _tool_versions: dict[str, str] | None = None, _digests: dict[str, str] = dict(), _channels: dict[str, str] | None = None, _categories: dict[str, tuple[str, str]] | None = None, _sets: dict[str, frozenset[str]] | None = None, _dep_paths: dict[str, tuple[str, ...]] = dict(), _dep_files: dict[str, tuple[str, ...]] = dict(), _root_configs: tuple[str, ...] | None = None)
Shared per-walk cache for computing step unit fingerprints quickly.
Methods:
| Name | Description |
|---|---|
for_root |
Build a context listing the workspace's git-held files once. |
tool_version |
Pinned version token for tool name from |
digest |
Cached SHA-256 digest for relative. |
category_of_path |
|
channel_of_path |
Provenance channel for relative, cached across steps. |
sets_of_path |
Named sets containing relative, cached across steps. |
dependency_paths |
Sorted paths of upstream workspace dependencies of target. |
dependency_files |
Sorted non-test, non-doc files under upstream dependency dep_path. |
root_config_files |
Sorted root workspace configuration files that can affect package steps. |
Attributes:
| Name | Type | Description |
|---|---|---|
root |
Path
|
|
packages |
tuple[Package, ...]
|
|
files |
tuple[str, ...]
|
|
for_root
classmethod
¶
for_root(root: Path, packages: tuple[Package, ...]) -> FingerprintContext
Build a context listing the workspace's git-held files once.
Source code in packages/workshop/src/livery/workshop/_proved.py
tool_version ¶
Pinned version token for tool name from toolroom.lock.
Source code in packages/workshop/src/livery/workshop/_proved.py
digest ¶
Cached SHA-256 digest for relative.
Source code in packages/workshop/src/livery/workshop/_proved.py
category_of_path ¶
(unit_key, category_name) for relative, cached across steps.
Source code in packages/workshop/src/livery/workshop/_proved.py
channel_of_path ¶
Provenance channel for relative, cached across steps.
Source code in packages/workshop/src/livery/workshop/_proved.py
sets_of_path ¶
Named sets containing relative, cached across steps.
Source code in packages/workshop/src/livery/workshop/_proved.py
dependency_paths ¶
Sorted paths of upstream workspace dependencies of target.
Source code in packages/workshop/src/livery/workshop/_proved.py
dependency_files ¶
Sorted non-test, non-doc files under upstream dependency dep_path.
Source code in packages/workshop/src/livery/workshop/_proved.py
root_config_files ¶
Sorted root workspace configuration files that can affect package steps.
Source code in packages/workshop/src/livery/workshop/_proved.py
ProvedTree
dataclass
¶
Record that a git tree hash was proved green across a set of check legs.
Attributes:
| Name | Type | Description |
|---|---|---|
tree |
str
|
Git tree object id ( |
branch |
str
|
Proved-record base key ( |
run |
str
|
Forge run id that stamped this tree. |
sha |
str
|
Commit SHA checked out by that run. |
legs |
tuple[str, ...]
|
Sorted platform leg labels proved green for this tree. |
when |
str
|
ISO 8601 UTC timestamp stamped on the row. |
Methods:
| Name | Description |
|---|---|
to_dict |
Serialize as a JSON-compatible dictionary. |
from_dict |
Deserialize from a |
to_dict ¶
Serialize as a JSON-compatible dictionary.
Source code in packages/workshop/src/livery/workshop/_proved.py
from_dict
classmethod
¶
from_dict(data: Mapping[str, Any], *, when: str = '') -> ProvedTree | None
Deserialize from a TREES row; returns None if malformed.
Source code in packages/workshop/src/livery/workshop/_proved.py
current_platform ¶
The platform of the current process, including runner image when reported.
Source code in packages/workshop/src/livery/workshop/_proved.py
read_set_blob_name ¶
dir_listing_digest ¶
SHA-256 of sorted direct entry names under root / relative.
Source code in packages/workshop/src/livery/workshop/_proved.py
item_read_set_matches ¶
item_read_set_matches(read_set: ItemReadSet, root: Path, *, installed_dists: Mapping[str, str] | None = None) -> tuple[bool, str]
Whether read_set still matches root on disk, and the first mismatch.
Refuses an unrecorded read-set first, then checks opened files,
absent paths (a created file invalidates the item), listed
directories (an added or removed entry invalidates the item), and
imported third-party distributions.
Source code in packages/workshop/src/livery/workshop/_proved.py
unit_id ¶
row_name ¶
Stable ref-safe filename for one unit's row file on a proved ref.
current_keys ¶
The keys the world produces: main and every branch on origin, per check leg.
Source code in packages/workshop/src/livery/workshop/_proved.py
current_parts_keys ¶
Active (extension, base, leg) keys for the proved-parts family.
Combines every extension listed by the workspace with every active
(base, leg) from current_keys. Returns None when the contract
or remote cannot be read so the janitor drops nothing.
Source code in packages/workshop/src/livery/workshop/_proved.py
proved_parts_series ¶
Return the proved-parts series for extension, base, and leg.
The ref lives under proved-parts/<extension>/<base>/<platform-leg>,
separate from proved/. schema lets the owning extension stamp and
validate its own row schema without the base reading the part's format.
Source code in packages/workshop/src/livery/workshop/_proved.py
proved_parts_prefixes ¶
Return ref prefixes to fetch extension's proved parts for bases.
Source code in packages/workshop/src/livery/workshop/_proved.py
put_proved_part ¶
put_proved_part(root: Path, *, extension: str, base: str, leg: str, unit: str, row_key: str, payload: Mapping[str, Any], message: str = '') -> str
Store an opaque payload for extension under unit and row_key.
The proved record keeps the payload untouched and does not inspect its
schema or keys. Returns "" on success or an error description.
Source code in packages/workshop/src/livery/workshop/_proved.py
read_proved_part ¶
read_proved_part(root: Path, *, extension: str, base: str, leg: str, unit: str, row_key: str) -> dict[str, Any] | None
Read an opaque payload stored by put_proved_part for unit at row_key.
Returns None when no part exists, the ref cannot be read, or the
stored key does not match row_key.
Source code in packages/workshop/src/livery/workshop/_proved.py
leg_base ¶
leg_base(run: RunContext) -> str
The proved-record base key (main or branch slug) for run.
Source code in packages/workshop/src/livery/workshop/_proved.py
leg_key ¶
leg_key(run: RunContext) -> str
The platform leg key for run, stripping any shard suffix.
Source code in packages/workshop/src/livery/workshop/_proved.py
merge_unit_files ¶
merge_unit_files(existing: dict[str, str], incoming: dict[str, str], *, keep: int = KEEP_READ_SETS) -> dict[str, str]
Combine existing and incoming proved unit files for CAS retry.
Files present in only one side stand as-is. When both sides write the same unit file, their read-set entries merge by fingerprint, accumulating verdict counts across concurrent writers and retaining the newest keep distinct fingerprints.
Source code in packages/workshop/src/livery/workshop/_proved.py
write_observations ¶
write_observations(root: Path, observations: Sequence[Observation], *, base: str = MAIN, leg: str = '', local: bool = False, keep: int = KEEP_READ_SETS, store: StateStore | None = None) -> str
Write observations to the proved store; "" or the failure reason.
Source code in packages/workshop/src/livery/workshop/_proved.py
spool_proved_observations ¶
spool_proved_observations(root: Path, observations: Sequence[Observation], *, base: str, leg: str, matched_branches: Sequence[str] = (), platform: Platform | None = None, exact_image: bool = True) -> None
Merge observations into LEG_SPOOL / PROVED_SHARDED_FILE for gate flush.
Keeps check legs read-only by carrying proved observations in the
ephemeral leg artifact so the gate job flushes them once.
Source code in packages/workshop/src/livery/workshop/_proved.py
record_item_observations ¶
record_item_observations(root: Path, step: str, results: Sequence[tuple[str, str, ItemReadSet]], *, local: bool = False, store: StateStore | None = None) -> str
Write per-item verdicts and read-sets for step to the proved store.
results is a sequence of (item_path, verdict, read_set) tuples.
Inside CI gate/merge check legs (without an explicit store),
spools observations into the leg bundle so check stays read-only
and gate flushes them once. Otherwise writes to
proved/<base>/<leg> in CI or proved-local when local is
true. Outside CI with local=False, writes nothing and returns
"".
Source code in packages/workshop/src/livery/workshop/_proved.py
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | |
item_read_details ¶
item_read_details(root: Path, item: str, *, store: StateStore | None = None) -> tuple[tuple[tuple[str, str, UnitRow, ReadSetEntry, ItemReadSet | None], ...], str]
Find proved rows and decoded read-sets for item across proved refs.
Searches remote proved/<base>/<leg> refs (and local proved-local
when remote has none), matching units whose target equals item
or whose unit equals item.
Source code in packages/workshop/src/livery/workshop/_proved.py
read_unit_rows ¶
read_unit_rows(root: Path, *, base: str = MAIN, leg: str = '', local: bool = False, store: StateStore | None = None) -> tuple[tuple[UnitRow, ...], str]
Read all proved unit rows from one series; (rows, reason).
Source code in packages/workshop/src/livery/workshop/_proved.py
flaky_units ¶
flaky_units(root: Path, *, store: StateStore | None = None) -> tuple[tuple[tuple[str, str, UnitRow, ReadSetEntry], ...], str]
Every flagged flaky entry (green and red under one fingerprint) across refs.
Source code in packages/workshop/src/livery/workshop/_proved.py
rows_for_run ¶
rows_for_run(root: Path, run_id: str, *, store: StateStore | None = None) -> tuple[tuple[tuple[str, str, UnitRow, ReadSetEntry], ...], str]
All (base, leg, unit_row, entry) records written by run_id.
Source code in packages/workshop/src/livery/workshop/_proved.py
is_proved_unit ¶
is_proved_unit(row: UnitRow | None, fingerprint: str, platform: Platform, *, exact_image: bool) -> tuple[bool, str]
Whether row proves fingerprint on platform, and the reason.
Refuses absence, platform mismatch, fingerprint mismatch, flaky units
(both green and red observed for the same fingerprint), and any
non-green verdict (skipped, red, unfinished).
Source code in packages/workshop/src/livery/workshop/_proved.py
is_proved_from_rows ¶
is_proved_from_rows(rows: Sequence[UnitRow], fingerprint: str, platform: Platform, *, exact_image: bool) -> tuple[bool, str]
Whether candidate rows for one unit prove fingerprint on platform.
Matches each entry's own platform (falling back to the row's platform),
and combines verdict counts across all matching entries for the same
fingerprint so a red on one ref and a green on another still surface
as flaky, while a later skipped observation never erases an
existing green proof.
Source code in packages/workshop/src/livery/workshop/_proved.py
lookup_proved_rows ¶
lookup_proved_rows(root: Path, *, run: RunContext | None, platform: Platform, store: StateStore | None = None) -> tuple[dict[str, list[UnitRow]], str]
Load candidate proved unit rows for run (CI) or offline mirror (desk).
In CI, fetches only the branch's leg ref (when not on main) and main's
leg ref in one snapshot. On a desk, reads local proved-local rows
and every mirrored proved/main/* ref without touching origin.
Source code in packages/workshop/src/livery/workshop/_proved.py
lookup_proved_rows_for_decision ¶
lookup_proved_rows_for_decision(root: Path, *, run: RunContext | None, platform: Platform, store: StateStore | None = None) -> tuple[dict[str, list[UnitRow]], dict[str, list[tuple[str, UnitRow]]], str]
Load primary proved rows plus lingering branch rows for a main CI run.
Returns (primary_rows_by_unit, branch_rows_by_unit, reason).
On desks and PR branches, branch_rows_by_unit is empty. On a
main CI run, lingering proved/<branch>/<leg> refs for the
same platform leg are also loaded so main's run can reuse and copy a
branch's proved rows without re-executing unchanged units.
Source code in packages/workshop/src/livery/workshop/_proved.py
decide_units ¶
decide_units(ctx: PhaseContext, *, candidate_units: Sequence[tuple[StepRecord, str]], primary_rows: Mapping[str, Sequence[UnitRow]], branch_rows: Mapping[str, Sequence[tuple[str, UnitRow]]] | None = None, platform: Platform, exact_image: bool, fp_cache: FingerprintContext | None = None) -> UnitDecision
Decide which candidate_units are proved green and which must run.
Source code in packages/workshop/src/livery/workshop/_proved.py
1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 | |
copy_branch_rows_to_main ¶
copy_branch_rows_to_main(root: Path, *, observations: Sequence[Observation], leg: str, matched_branches: Sequence[str] = (), platform: Platform | None = None, exact_image: bool = True, store: StateStore | None = None) -> str
Copy matched branch unit rows and item read-sets onto proved/main/<leg>.
Source code in packages/workshop/src/livery/workshop/_proved.py
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 | |
evaluate_shadow ¶
evaluate_shadow(ctx: PhaseContext, *, today_running: frozenset[str], candidate_units: Sequence[tuple[StepRecord, str]], rows_by_unit: Mapping[str, Sequence[UnitRow]], platform: Platform, exact_image: bool, fp_cache: FingerprintContext | None = None) -> ShadowReport
Compare today_running against what rows_by_unit would skip.
Source code in packages/workshop/src/livery/workshop/_proved.py
write_shadow_report ¶
write_shadow_report(root: Path, report: ShadowReport, *, run: RunContext, leg: str, trigger: str, platform: Platform, store: StateStore | None = None) -> str
Record one CI leg's shadow comparison on proved/differences.
Source code in packages/workshop/src/livery/workshop/_proved.py
read_shadow_differences ¶
read_shadow_differences(root: Path, *, limit: int = 0, store: StateStore | None = None) -> tuple[int, tuple[dict[str, Any], ...], str]
Read shadow comparison rows newest first: (total_runs, non_empty, reason).
Source code in packages/workshop/src/livery/workshop/_proved.py
without_item_selection ¶
without_item_selection() -> Generator[None]
Temporarily disable live per-item selection in this process.
Source code in packages/workshop/src/livery/workshop/_proved.py
item_selection_disabled ¶
Whether live per-item selection is disabled by context or environment.
Source code in packages/workshop/src/livery/workshop/_proved.py
clear_ran_items ¶
clear_ran_items(root: Path) -> None
Remove any prior check leg's per-item execution record under root.
read_ran_items ¶
Read the per-item execution record under root; empty when absent.
Source code in packages/workshop/src/livery/workshop/_proved.py
record_ran_items ¶
record_ran_items(root: Path, *, ran: Mapping[str, str] | None = None, skipped: Mapping[str, str] | None = None, narrowed: bool = False) -> None
Merge ran, skipped, and narrowed into root's ran-items file.
Items that execute supersede any earlier skipped entry for the same item (for example when a top-up pass runs an item that the gate skipped).
Source code in packages/workshop/src/livery/workshop/_proved.py
lookup_proved_item_rows ¶
lookup_proved_item_rows(root: Path, target_units: frozenset[str], *, run: RunContext | None, platform: Platform, store: StateStore | None = None, bases: Sequence[str] | None = None) -> tuple[dict[str, list[tuple[UnitRow, dict[str, ItemReadSet]]]], str]
Load candidate proved rows and decoded read-set blobs for target_units.
Fetches only the branch and main leg refs in CI (or reads local plus
mirrored proved/main/* offline on a desk), decoding only blobs
referenced by entries belonging to target_units.
Source code in packages/workshop/src/livery/workshop/_proved.py
1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 | |
is_item_proved ¶
is_item_proved(candidates: Sequence[tuple[UnitRow, Mapping[str, ItemReadSet]]], root: Path, platform: Platform, *, exact_image: bool, file_cache: dict[str, str] | None = None, dir_cache: dict[str, str] | None = None, installed_dists: Mapping[str, str] | None = None, check_missing_dists: bool = True) -> tuple[bool, str]
Whether candidates prove a test item on root and platform.
Refuses absence, platform mismatch, flaky fingerprints (both green and red observed across refs), missing or unrecorded read-sets, non-green verdicts, and any changed file, created absent path, modified listed directory, or moved third-party distribution.
Source code in packages/workshop/src/livery/workshop/_proved.py
shadow_select_items ¶
shadow_select_items(root: Path, items: Sequence[str], *, step: str, run: RunContext | None = None, store: StateStore | None = None, exact_image: bool | None = None, platform: Platform | None = None, check_missing_dists: bool = True, bases: Sequence[str] | None = None, file_cache: dict[str, str] | None = None, dir_cache: dict[str, str] | None = None, installed_dists: Mapping[str, str] | None = None) -> tuple[ItemSelection, str]
Compute which items existing proved rows would select or skip.
Fails open on store errors (selecting every item) while returning the reason string so callers can log it without failing the run.
Source code in packages/workshop/src/livery/workshop/_proved.py
2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 | |
record_selection_measure ¶
record_selection_measure(root: Path, *, run: RunContext, selection: ItemSelection, durations: Mapping[str, float], step: str, trigger: str = '', store: StateStore | None = None) -> str
Record one selected share measure row in MEASURES for a CI leg.
Source code in packages/workshop/src/livery/workshop/_proved.py
2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 | |
read_measures ¶
read_measures(root: Path, *, measure: str = '', limit: int = 0, store: StateStore | None = None) -> tuple[tuple[dict[str, Any], ...], str]
Read measure rows newest first from MEASURES.
Source code in packages/workshop/src/livery/workshop/_proved.py
detect_item_escapes ¶
detect_item_escapes(root: Path, *, step: str, selection: ItemSelection, red_items: Sequence[str], packages: Sequence[Package] = (), run: RunContext | None = None, store: StateStore | None = None) -> tuple[Escape, ...]
Return Escape rows for any red_items that selection marked proved.
Source code in packages/workshop/src/livery/workshop/_proved.py
2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 | |
record_escapes ¶
record_escapes(root: Path, escapes: Sequence[Escape], *, local: bool = False, store: StateStore | None = None) -> str
Write escapes to ESCAPES (CI) or LOCAL_ESCAPES (desk/local).
Source code in packages/workshop/src/livery/workshop/_proved.py
read_escapes ¶
read_escapes(root: Path, *, limit: int = 0, store: StateStore | None = None) -> tuple[tuple[Escape, ...], str]
Read recorded escapes newest first from ESCAPES and LOCAL_ESCAPES.
Source code in packages/workshop/src/livery/workshop/_proved.py
active_escaped_packages ¶
active_escaped_packages(root: Path, *, store: StateStore | None = None) -> tuple[frozenset[str], str]
Packages put back to whole runs due to an unaddressed recorded escape.
An escape stays active until the package's contract ([tests] reads)
or the escaped test item itself changes on disk, or the row is marked
resolved.
Source code in packages/workshop/src/livery/workshop/_proved.py
step_fingerprint ¶
step_fingerprint(record: StepRecord, ctx: PhaseContext, target: str, *, cache: FingerprintContext | None = None) -> str
Deterministic SHA-256 fingerprint of what record reads on target.
Source code in packages/workshop/src/livery/workshop/_proved.py
2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 | |
proving_branch ¶
proving_branch(root: Path, *, store: StateStore | None = None) -> tuple[str, str]
Return (branch, reason) for the pull request branch proving root's tree.
Scans proved/main/* and lingering proved/<branch>/* refs for the
newest green entry naming a non-main branch whose recorded fingerprint
matches a current judge unit on root (or whose SHA matches HEAD
when no registered step matches). Returns ("", reason) when the store
cannot be listed.
Source code in packages/workshop/src/livery/workshop/_proved.py
2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 | |
proved_unit_key ¶
proved_unit_key(root: Path, packages: Sequence[Package], target: str, *, phase: str = 'test', cache: FingerprintContext | None = None) -> str
Return the proved row key for target's registered steps in phase.
When a single registered step in phase judges target (the common case),
returns its exact step_fingerprint. When multiple steps in phase judge
target, returns a SHA-256 digest over their sorted step=fingerprint
pairs. Returns "" when no step in phase applies to target.
Source code in packages/workshop/src/livery/workshop/_proved.py
proved_unit_keys ¶
proved_unit_keys(root: Path, packages: Sequence[Package], targets: Sequence[str], *, phase: str = 'test', cache: FingerprintContext | None = None) -> dict[str, str]
Return a target -> proved row key mapping for targets in phase.
Computes one shared FingerprintContext across all targets so callers
measuring or unioning a whole workspace hash each file once.
Source code in packages/workshop/src/livery/workshop/_proved.py
3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 | |
base_proved ¶
Whether proved/main/* already has green rows for origin/<base>'s tip.
Source code in packages/workshop/src/livery/workshop/_proved.py
head_tree_id ¶
Return the git tree object id of HEAD:, or "" on error.
tree_row_name ¶
read_proved_tree ¶
read_proved_tree(root: Path, tree_id: str, *, store: StateStore | None = None) -> tuple[ProvedTree | None, str]
Look up a green ProvedTree stamp for tree_id; (None, "") if absent.
Source code in packages/workshop/src/livery/workshop/_proved.py
stamp_proved_tree ¶
stamp_proved_tree(root: Path, *, tree_id: str, branch: str, run_id: str, sha: str, legs: Sequence[str], store: StateStore | None = None) -> str
Record tree_id as proved green across legs on TREES; "" or reason.
Source code in packages/workshop/src/livery/workshop/_proved.py
sweep_proved_store ¶
sweep_proved_store(root: Path, *, dry_run: bool = False, now: datetime | None = None, store: StateStore | None = None) -> list[str]
Prune unreferenced reads/ blobs and expired proved-parts kept rows.
Runs inside the janitor's remote snapshot. Each proved/<base>/<leg> ref
reads only its unit rows (never decompressing reads/ blobs) and drops
any reads/<digest>.json blob no live row's entries reference. Each
proved-parts/<ext>/<base>/<leg> ref inspects filenames alone and drops
kept rows older than PARTS_KEPT_FOR. All rewrites land in a single
OID-preserving git.merge_refs batch push.
Source code in packages/workshop/src/livery/workshop/_proved.py
3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 | |
promote_proved_tree_to_main ¶
promote_proved_tree_to_main(root: Path, proved_tree: ProvedTree, *, expected_legs: Sequence[str], store: StateStore | None = None) -> tuple[bool, str]
Promote branch proved rows and extension proved-parts to main.
Merges proved/<branch>/<leg> into proved/main/<leg> and every
extension's proved-parts/<ext>/<branch>/<leg> into
proved-parts/<ext>/main/<leg> for each leg in expected_legs in one
OID-preserving batch push. Returns (True, "") when already on main
or when every ref promotes cleanly; returns (False, reason) on any
store read/write failure so callers fail open and run checks normally.
Source code in packages/workshop/src/livery/workshop/_proved.py
3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 | |