cadrumo.application.provisioning_browser module

Provisioning of the Playwright Chromium build Cadrumo’s browser automation drives.

The installed playwright package pins exact browser revisions in its bundled browsers.json manifest, and launches only those revisions. The probe here therefore reads that manifest and checks the revision-exact cache directories and their completion markers, so a stale build left by an earlier Playwright version never reads as installed. It is a filesystem read: the Playwright driver can hang inside the CLI process, so nothing here launches it.

install_playwright_browser() is the explicit acquisition step behind aeat config provision browser. It is idempotent and runs the vendor installer only through the injected runner, which the outbound browser-runtime adapter supplies. A missing build is refused with a recovery action naming that command rather than surfacing Playwright’s raw launch error.

BROWSER_PROVISION_ACTION_ID

Catalogue action whose target command provisions the browser.

PLAYWRIGHT_BROWSER_INSTALL_TIMEOUT_S

Two archives of roughly two hundred megabytes each over an operator’s connection.

BrowserInstallerRunner

Runs the vendor browser install within a timeout and returns its exit code.

alias of Callable[[float], int]

class BrowserBuild(**data)[source]

Bases: BaseModel

One revision-pinned browser build the installed Playwright launches.

Parameters:

data (Any)

name: str
revision: str
property directory_name: str

Return the cache directory Playwright extracts this build into.

playwright_browsers_root(cache_root=None, *, env=None)[source]

Return the directory Playwright installs browser binaries into.

Uses an explicit cache_root when supplied, otherwise honours PLAYWRIGHT_BROWSERS_PATH then falls back to the per-OS default cache. The cache is vendor-owned: Cadrumo reads it and lets the vendor installer write it, and it is intentionally not a Cadrumo storage setting. env is injectable so the override precedence is testable without mutating the process environment.

Return type:

Path

Parameters:
required_browser_builds(manifest_path=None)[source]

Return the Chromium builds the installed Playwright pins, or None when unreadable.

A manifest entry carrying per-host revision overrides is treated as unreadable rather than guessed, because the host key it is selected by is Playwright’s own internal classification.

Return type:

tuple[BrowserBuild, ...] | None

Parameters:

manifest_path (Path | None)

browser_not_provisioned_verdict(facts)[source]

Return the refusal for a missing browser build, recovered by the provisioning command.

Return type:

PreconditionVerdict

Parameters:

facts (Mapping[str, str | int | bool])

probe_playwright_browser(cache_root=None, *, manifest_path=None)[source]

Report whether every Chromium build the installed Playwright launches is present.

Missing builds are refused with the provisioning action. An unreadable manifest (Playwright absent or its layout unrecognised) is refused without a recovery action, because installing a browser cannot repair it.

Return type:

DependencyStatus

Parameters:
  • cache_root (Path | None)

  • manifest_path (Path | None)

class BrowserInstallOutcome(**data)[source]

Bases: ProvisioningOutcome

The result of a browser provisioning request, including one that needed no download.

Parameters:

data (Any)

installed: bool
already_installed: bool
installer_exit_code: int | None
install_playwright_browser(*, run, probe=<function probe_playwright_browser>)[source]

Download the pinned Chromium builds when any is missing, then confirm them.

Idempotent: when the probe already reports every build installed, nothing runs. Success is decided by re-probing the cache, never by the installer’s exit code alone.

Return type:

BrowserInstallOutcome

Returns:

A BrowserInstallOutcome. Never raises for installer failure.

Parameters: