Precondition

One thing that must still hold when a plan is applied.

Usage

Source

Precondition(
    kind,
    expected=None,
    key=None,
    params=dict(),
    detail="",
)

The drift contract in data: a plan records what it saw (a manifest hash, a branch head, a history digest) and apply refuses with ~tether.errors.StalePlanError if the world says otherwise. Kept out of context so the checks are typed, listed, and run in one place rather than re-implemented per command.

Attributes

kind: str

One of PRECONDITION_KINDS.

expected: Any

The value seen at plan time (a hash, a state, a commit id).

key: str | None

The object key, for per-object checks.

params: dict[str, Any]

What the check needs to look again (locator, backend, ref, rev, pin, bookmark).

detail: str
The refusal message; may use {observed}.