"""Wait for a free ARM64 lane, then run pinned worker component checks. The current K2100 guest/coordinator is neither interrupted nor altered. This queue has no canonical roadmap admission capability. """ from pathlib import Path import datetime,hashlib,json,os,shutil,subprocess,sys,tempfile,time root=Path.cwd().resolve() sys.path.insert(0,str(root/'tools/run_budget')) from budget import execute,Busy,InsufficientSpace from evidence import artifact,atomic_json out=Path(tempfile.mkdtemp(prefix='K2155-worker-component-queue-',dir=root/'reports/os-implementation')) candidate='reports/os-implementation/K2155-shutdown-worker-component-candidate-TnXPgT/report.json' state_path=root/'reports/os-implementation/active-development-continuation.json' def a(p):return artifact(root,str(Path(p).relative_to(root)) if Path(p).is_absolute() else str(p)) def read(p):return json.loads(Path(p).read_bytes()) pins={} def pin(item): if isinstance(item,dict): if 'path'in item and 'sha256'in item: observed=a(item['path']);assert observed['sha256']==item['sha256'],item['path'];pins[item['path']]=observed for value in item.values():pin(value) elif isinstance(item,list): for value in item:pin(value) def verify(): for p,item in pins.items():assert a(p)==item,'queued input changed: '+p report=dict(status='WORKER_COMPONENT_WAITING_FOR_ARM64_LANE',guestAccepted=False,productAccepted=False,componentOnly=True, candidate=a(candidate),startedAt=datetime.datetime.now(datetime.timezone.utc).isoformat(),pid=os.getpid()) def save(status,**extra): report.update(status=status,**extra);atomic_json(out/'report.json',report) state=read(state_path);state.setdefault('K2155',{}).update(workerComponentQueue=str((out/'report.json').relative_to(root)),workerComponentQueueStatus=status) state['updatedAt']=datetime.datetime.now(datetime.timezone.utc).isoformat();atomic_json(state_path,state) try: c=read(candidate);assert c['status']=='COMPILED_FEATURE_CANDIDATE';pin(c);pin(a(candidate)) for name in ['tools/k2155_irq/queue_workers.py','tools/run_budget/budget.py','tools/work_coordination/coordination.py','tools/evidence_store/evidence.py', 'scripts/os-acceptance/k2155-worker-followthrough.mjs','scripts/os-acceptance/k2155-worker-guest-runner.mjs','scripts/os-acceptance/k2155-worker-matrix-check.mjs', 'scripts/os-acceptance/features/k2155-worker-check.mjs','scripts/os-acceptance/features/k2155-worker-capture-check.mjs', 'scripts/os-acceptance/boot-contract-report.mjs','scripts/os-acceptance/paused-capture-qmp.mjs','scripts/os-acceptance/dma-gdb.mjs', 'scripts/os-acceptance/dma-network.mjs','scripts/os-acceptance/file-map-disk.mjs']: pin(a(name)) shutil.copyfile(__file__,out/'harness.py.txt') # Conservative measured-sample equivalents: two firmware pairs, nineteen # profiles plus confirmations, and firmware-sized loader/publication reserve. sample=Path('reports/os-implementation/K2150-shutdown-el0-storage-matrix-BBX3Yi/firmware/edk2-aarch64-code.fd') image=Path(c['artifacts']['image']['path']) manifest=dict(components=[dict(name='candidate-image-and-profile-raw-capture-equivalents',sample=a(image),bytes=image.stat().st_size,count=64), dict(name='firmware-loader-and-publication-equivalents',sample=a(sample),bytes=sample.stat().st_size,count=8)]) pin(manifest);report['pins']=list(pins.values());atomic_json(out/'budget-manifest.json',manifest);report['budgetManifest']=a(out/'budget-manifest.json') report['scope']='Pending native worker component only. A short direct smoke and strict physical checker must pass before the eighteen-profile matrix. No K2155 or product acceptance.' save('WORKER_COMPONENT_WAITING_FOR_ARM64_LANE') Path('/tmp/turkos-k2155-worker-queue.txt').write_text(str(out.relative_to(root))+'\n') while True: verify() try: result=execute(root,manifest,['node','scripts/os-acceptance/k2155-worker-followthrough.mjs',candidate,str(out.relative_to(root))],arm64=True) break except Busy: time.sleep(30) atomic_json(out/'budget-execution.json',result) execution=read(out/'execution.json');matrices=[step['matrix'] for step in execution['steps'] if 'matrix'in step] outputs=[] for matrix in matrices: assert matrix.startswith('reports/os-implementation/K2155-shutdown-worker-component-matrix-') directory=root/matrix;files=[p for p in directory.rglob('*') if p.is_file() and not p.is_symlink()] outputs.append(dict(matrix=matrix,files=len(files),retainedLogicalBytes=sum(p.stat().st_size for p in files),retainedAllocatedBytes=sum(p.stat().st_blocks*512 for p in files))) verify() passed=result['exitCode']==0 and execution['status']=='WORKER_COMPONENT_SEQUENCE_PASSED' save('WORKER_COMPONENT_COMPLETED' if passed else 'WORKER_COMPONENT_FAILED',budgetExecution=a(out/'budget-execution.json'),execution=a(out/'execution.json'), physicalWorkersVerified=passed,ownedRetainedOutputs=outputs,measurementScope='Retained files in the two owned matrices; not peak disk use. Budget also reports whole-filesystem free-space change.') except BaseException: import traceback save('WORKER_COMPONENT_QUEUE_FAILED',error=traceback.format_exc());raise finally: print(json.dumps({'status':report['status'],'report':str((out/'report.json').relative_to(root))}),flush=True)