contract
contract
¶
The consumer half of the matrix capability contract.
The engine exports TEROK_EXPECT (a comma-separated capability list
from matrix.yml) inside every matrix test container — see
inner. A consuming repo's integration
conftest owns the other half: a probe per capability it knows how to
verify, handed to
check_capability_contract
at session start. Inside the matrix the harness built the image, so a
declared-but-missing capability means the slot is broken and must fail
up front — not dissolve into skips that read as green.
Typical conftest wiring::
_CAPABILITY_PROBES = {"podman": lambda: binary_on_path("podman"), ...}
def pytest_sessionstart(session):
if broken := check_capability_contract(_CAPABILITY_PROBES):
pytest.exit(broken, returncode=3)
The probe maps rightly differ per repo (shield probes its own hook chain, clearance only D-Bus); the protocol — env var, separator, unknown-name rejection — lives here so it cannot drift apart again.
check_capability_contract(probes)
¶
Verify TEROK_EXPECT against probes; return the failure, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probes
|
Mapping[str, Callable[[], bool]]
|
Capability name to presence probe, the repo-specific half of the contract. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
A human-readable failure message when the contract names unknown |
str | None
|
capabilities or a declared capability is missing; |
str | None
|
the contract holds (or none is declared — dev-machine runs). |
Source code in src/terok_util/matrix/contract.py
binary_on_path(name)
¶
Whether name resolves on the sbin-extended PATH.
tcp_reachable(ip, port, timeout=5.0)
¶
Whether a TCP connection to ip:port succeeds within timeout.