from pathlib import Path import os,json,hashlib,subprocess,shutil p=Path(Path('/tmp/turkos-k2150-flush-io-preparation.txt').read_text()) def art(x): x=Path(x);return {'path':str(x),'sha256':hashlib.sha256(x.read_bytes()).hexdigest()} env=os.environ.copy();env.pop('RUSTFLAGS',None);env.pop('CARGO_ENCODED_RUSTFLAGS',None);env['CARGO_BUILD_JOBS']='2' commands=[] def run(name,manifest,args,target,expected): e=env.copy();e['CARGO_TARGET_DIR']=str(target.resolve()) r=subprocess.run(['nice','-n','10','cargo',*args,'--manifest-path',str(manifest),'--locked','--offline'],env=e,capture_output=True,text=True) out=r.stdout+r.stderr;log=p/(name+'.log');log.write_text(out);commands.append({'name':name,'exitCode':r.returncode,'log':art(log)}) assert r.returncode==expected,(name,r.returncode,out[-1500:]);return out try: source=p/'source/os-shutdown-io';manifest=source/'Cargo.toml' run('aarch64-check',manifest,['check','--lib','--target','aarch64-unknown-none'],p/'target-aarch64',0) orig=(source/'src/flush_io.rs').read_text() mutants=[ ('skip-barrier','self.backend.flush().map_err(|error| Error::Storage { stage, operation: Operation::Flush, error })?;','Ok::<(), Error>(())?;'), ('ignore-write-failure','self.backend.write_sector(write.lba, write.data).map_err(|error| Error::Storage { stage, operation: Operation::Write, error })?;','let _ = self.backend.write_sector(write.lba, write.data);'), ('ignore-quiescence','gate.require_quiesced().map_err(|_| Error::NotQuiesced)?;',''), ('allow-cross-stage-alias',' || stages.iter().flat_map(|s| s.iter()).take(i).any(|prior| prior.lba == write.lba)',''), ('allow-out-of-capacity','write.lba >= capacity || ','false || '), ('allow-repeat','if self.attempted { return Err(Error::AlreadyAttempted); }',''), ('swap-data-metadata','[(flush::Stage::Data, plan.data), (flush::Stage::Metadata, plan.metadata), (flush::Stage::Journal, plan.journal)]','[(flush::Stage::Metadata, plan.metadata), (flush::Stage::Data, plan.data), (flush::Stage::Journal, plan.journal)]'), ('grant-clean-on-error','self.progress.error = Some(error);','self.progress.clean = true; self.progress.error = Some(error);'), ('skip-flush-count','self.progress.completed_flushes += 1;',''), ] controls=[] for name,before,after in mutants: assert orig.count(before)==1,name d=p/('mutant-'+name);shutil.copytree(source,d);m=d/'src/flush_io.rs';m.write_text(orig.replace(before,after)) out=run('mutant-'+name,d/'Cargo.toml',['test','--test','flush_io'],p/('target-'+name),101) assert 'test result: FAILED.' in out and 'error[E' not in out,name controls.append({'name':name,'source':art(m),'testFailureObserved':True}) report={'status':'STORAGE_FLUSH_ADAPTER_COMPONENT_PASSED','guestAccepted':False,'productAccepted':False, 'scope':'Host storage-backend orchestration only: calls write_sector/flush itself, validates the whole plan before I/O, and creates a private clean receipt only after three successful barriers. The fake host backend is an explicit test boundary. Native virtio driver wiring and physical device completion/EIO/timeout evidence remain pending; K2150 is not accepted.', 'hostTests':8,'adapterTests':4,'failureSchedules':14,'invalidPlans':8,'unquiescedSchedules':2,'sourceMutantsRejected':len(controls), 'hostLog':art(p/'host-tests.log'),'commands':commands,'mutants':controls,'sources':[art(x) for x in sorted(source.rglob('*')) if x.is_file()], 'unchangedGuestCandidate':art('reports/os-implementation/K2150-shutdown-io-flush-candidate-vEzW4Y/report.json'), 'priorUserBuildFailure':art('reports/os-implementation/K2150-shutdown-io-flush-user-build-96Kdti/report.json'), 'userBuild':art('reports/os-implementation/K2150-shutdown-io-flush-user-build-nweFxE/report.json'), 'localModelReport':art('reports/os-implementation/K2150-shutdown-io-flush-local-FVJNCw/report.json')} except Exception as error: report={'status':'STORAGE_FLUSH_ADAPTER_COMPONENT_FAILED','guestAccepted':False,'productAccepted':False,'error':str(error),'commands':commands} raise finally: shutil.copyfile(__file__,p/'harness.py.txt');report['harness']=art(p/'harness.py.txt') for x in p.iterdir(): if x.is_dir() and (x.name=='target' or x.name.startswith('target-')):shutil.rmtree(x) report['buildOutputsRemoved']=True (p/'report.json').write_text(json.dumps(report,indent=2)+'\n') print(json.dumps({'status':report['status'],'report':str(p/'report.json'),'mutants':report.get('sourceMutantsRejected')}))