livery.workshop._reconcile¶
livery.workshop._reconcile ¶
The per-command hook: a sync runs before a command, frozen and offline.
Runs at footman's per-task moment, before the first task of a command,
from the hook in livery.workshop._env_tasks. It runs the sync
verb's work on the root the hook found
(livery.workshop._sync.sync_checkout), in the mode that changes
nothing a commit holds and touches no network, as a plain call: footman
gives a task called from a hook a directory of its own and a row in the
run's report, and a failed row fails the command. The sync reads the
receipts a checkout keeps of its last sync
(livery.workshop._reconcile.current): the uv lock and the
manifests the venv was installed from, the tool receipts against
toolroom.lock, and the receipt of the files the extensions write
for the checkout alone. A current checkout costs those reads and
nothing else; one that is not is brought current from what the machine
holds, and the command re-runs on the installed code when that sync
changed it, so a pull that moved the lock never judges from stale
code. When sync is the command, the hook leaves the work to it.
The receipts live here beside the hook. What a sync records at its end and what it reads at its start are one record.
Never fatal: on any failure the command proceeds and the failure is reported in the sync's own words. A task that cannot run without what is missing is still caught by its own gate.
Functions:
| Name | Description |
|---|---|
receipt_path |
Where root's sync receipt lives. |
manifests_receipt_path |
Where root's manifests receipt lives. |
manifests_digest |
A digest of the root |
record_receipt |
Record |
is_cli_process |
Whether this process is a real runner invocation. |
installed_distributions |
Every |
current |
Why root is not current, in a few words; empty when it is. |
tools_current |
Why the tool receipts do not match |
apply |
Sync root before task, the command's first; whether the sync did work. |
Attributes:
| Name | Type | Description |
|---|---|---|
MOVED |
|
|
SYNCED |
|
|
INSTALLED |
|
|
RELOCATED |
|
|
RECEIPT_NAME |
|
|
MANIFESTS_RECEIPT_NAME |
|
receipt_path ¶
manifests_receipt_path ¶
manifests_digest ¶
A digest of the root pyproject.toml and every package's pyproject.toml.
Path order, each path and its bytes, so a member added, removed, or edited changes the digest.
Source code in packages/workshop/src/livery/workshop/_reconcile.py
record_receipt ¶
record_receipt(root: Path) -> None
Record uv.lock and the manifests as the venv's receipts; silent otherwise.
Called after every successful sync so the next command's compare is a no-op instead of a second sync.
Source code in packages/workshop/src/livery/workshop/_reconcile.py
is_cli_process ¶
is_cli_process() -> bool
Whether this process is a real runner invocation.
The reconcile is opt-in from the runner's own console script,
never opt-out by recognising footman's manifest-refresh child:
that child is spawned as python -c ... and a test suite runs
under pytest, so neither carries the runner's name in argv[0]
and both leave the reconcile inert. The refresh child's contract
is quick and quiet (no network, no prompts), and a test that
shelled out to uv sync once per test would be slow and
destructive.
Source code in packages/workshop/src/livery/workshop/_reconcile.py
installed_distributions ¶
Every *.dist-info name in the venv, to its entry points' digest.
Read across platform layouts. A name alone misses an editable
member re-installed at the same version with new entry points: its
directory keeps its name, and a process that mounted the old entry
points would go on with them. The digest of each
entry_points.txt (empty without one) makes that re-install a
change.
Source code in packages/workshop/src/livery/workshop/_reconcile.py
current ¶
Why root is not current, in a few words; empty when it is.
Four receipts, all local reads. The uv lock receipt and the
manifests receipt against uv.lock and the manifests on disk;
a venv synced before the manifests receipt existed adopts the
manifests on disk as the ones installed, since the emitted
setup.sh's fresh venv is that case, and the next move is seen.
Then a receipt per tool toolroom.lock holds for this host, at
the locked version and still in the store, with the stubs beside
them; then the receipt a delivery leaves. A checkout with no lock
or no venv has nothing to compare and is not current.
Source code in packages/workshop/src/livery/workshop/_reconcile.py
tools_current ¶
Why the tool receipts do not match toolroom.lock; empty when they do.
A receipt matches when it names the locked version and the
directory it points into is still in the store; a receipt whose
tool the store has lost reads as off, so a sync supplies it again.
The stubs the checkers read stand beside the receipts: a checkout
locked for this host with no typings/ is off too. A checkout
with no toolroom.lock has nothing to match and is current here.
Source code in packages/workshop/src/livery/workshop/_reconcile.py
apply ¶
Sync root before task, the command's first; whether the sync did work.
Nothing happens when task is sync, the verb itself, or inside
a process the hook's own sync started, which env, the task's own
environment, marks for the processes the sync starts. Otherwise the
verb's work runs on root, frozen and offline, as a plain call
(livery.workshop._sync.sync_checkout), its lines on stderr so
a command whose stdout a shell evaluates stays clean. It reads the
receipts first and does nothing, silently, for a current checkout;
otherwise it says what is off and brings the checkout current, and
the command re-runs on the installed code when that changed it. A
sync that fails is said and the command runs on what is here: the
sync is not a task of the run, so its failure adds no failed row,
and the command's verdict is its own.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the sync did work. The caller entered the environment |
bool
|
before it, from receipts the sync may have written since, so it |
bool
|
enters again. |