"""Wait for a free ARM64 lane, then run pinned native DMA 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-dma-component-queue-',dir=root/'reports/os-implementation')) candidate='reports/os-implementation/K2155-shutdown-dma-component-candidate-g8EQOO/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='DMA_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(dmaComponentQueue=str((out/'report.json').relative_to(root)),dmaComponentQueueStatus=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_dma_v2.py','tools/k2155_irq/test_dma_checker_v2.mjs','tools/run_budget/budget.py','tools/work_coordination/coordination.py','tools/evidence_store/evidence.py', 'scripts/os-acceptance/k2155-dma-followthrough-v2.mjs','scripts/os-acceptance/k2155-dma-guest-runner-v2.mjs','scripts/os-acceptance/k2155-dma-matrix-check-v2.mjs', 'scripts/os-acceptance/features/k2155-dma-check-v2.mjs','scripts/os-acceptance/features/k2155-dma-authority-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)) host=read(root/'reports/os-implementation/K2155-dma-preparation-a23isgi2/report.json');assert host['status']=='DMA_COMPONENT_PREPARATION_PASSED';pin(host);pin(a('reports/os-implementation/K2155-dma-preparation-a23isgi2/report.json')) tested=read(root/host['candidate']['path']) for name in ['k2155-dma-reset.rs','k2155-virtio-drain.rs']: assert tested['sources'][name]['sha256']==c['sources'][name]['sha256'],'unchanged source-bound reset/transport component' report['reusedSourceTests']=a('reports/os-implementation/K2155-dma-preparation-a23isgi2/report.json') report['supersededQueue']=a('reports/os-implementation/K2155-dma-component-queue-c_n1pv48/report.json') checked=subprocess.run(['node','tools/k2155_irq/test_dma_checker_v2.mjs',candidate],capture_output=True,text=True,timeout=30) (out/'checker-host-tests.log').write_text(checked.stdout+checked.stderr);assert checked.returncode==0 report['checkerHostTests']=a(out/'checker-host-tests.log');pin(report['checkerHostTests']) 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 DMA component only. A short direct smoke and strict physical checker must pass before the eighteen-profile matrix. No K2155 or product acceptance.' save('DMA_COMPONENT_WAITING_FOR_ARM64_LANE') Path('/tmp/turkos-k2155-dma-queue.txt').write_text(str(out.relative_to(root))+'\n') while True: verify() predecessor=read(root/'reports/os-implementation/K2155-worker-component-queue-xwcnyebj/report.json') if predecessor['status'] not in ['WORKER_COMPONENT_COMPLETED','WORKER_COMPONENT_FAILED','WORKER_COMPONENT_QUEUE_FAILED']: time.sleep(30);continue report['predecessorWorkerOutcome']=a(root/'reports/os-implementation/K2155-worker-component-queue-xwcnyebj/report.json') try: result=execute(root,manifest,['node','scripts/os-acceptance/k2155-dma-followthrough-v2.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-dma-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']=='DMA_COMPONENT_SEQUENCE_PASSED' save('DMA_COMPONENT_COMPLETED' if passed else 'DMA_COMPONENT_FAILED',budgetExecution=a(out/'budget-execution.json'),execution=a(out/'execution.json'), physicalDmaVerified=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('DMA_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)