"""Track 1, three isolated incident-response repetitions; all accepted originals survive.""" import hashlib,json,subprocess,sys,time from pathlib import Path ROOT=Path(__file__).resolve().parents[1];sys.path[:0]=[str(ROOT/'scripts'),str(ROOT/'tests')] from client import Client from pki import PRIVATE from rotate_worker import rotate def run(*args):return subprocess.check_output(args,text=True,stderr=subprocess.DEVNULL) def result(text):return json.loads(text[text.index('{'):]) def compose(*args):return run('./scripts/compose.sh',*args) run('.venv/bin/python','scripts/wait_ready.py') run('./scripts/operator.sh','python','scripts/provision.py','clear-rate') c=Client(ca_file=str(PRIVATE/'ca.crt'),timeout=20);alice,bob,eve,chat=c.bootstrap();rows=[] for repeat in range(1,4): run('./scripts/operator.sh','python','scripts/seed_security.py') broad=result(run('./scripts/operator.sh','python','tests/worker_privileges.py')) limited=result(subprocess.check_output(['./scripts/compose.sh','exec','-T','worker','python','-','--worker'],input=(ROOT/'tests/worker_privileges.py').read_text(),text=True,stderr=subprocess.DEVNULL)) image_before=run('docker','inspect','--format','{{.Image}}',compose('ps','-q','worker').strip()).strip() compose('stop','-t','5','worker');accepted=[c.attachment(alice,chat) for _ in range(3)] assert all(c.call('GET','/api/v1/attachments/'+a['id'],actor=alice,schema='Attachment')['json']['status']=='queued' for a,_ in accepted) start=time.monotonic();response=rotate();transient=0 for a,payload in accepted: deadline=time.monotonic()+120 while time.monotonic()