"""Shared bounded Docker helpers for reproducible, scoped failure experiments.""" import json from pathlib import Path import subprocess import time ROOT=Path(__file__).resolve().parents[1] def docker(*args): return subprocess.check_output(['docker',*args],cwd=ROOT,text=True,encoding='utf-8',stderr=subprocess.PIPE).strip() def replicas(): return docker('compose','ps','-q','api').splitlines() def ready_replicas(count=2,timeout=60): deadline=time.monotonic()+timeout while time.monotonic()