"""OMEGA AB-011: offline CSI format evidence and synthetic recording validation.""" import argparse, base64, csv, hashlib, json, math, re, struct from datetime import datetime from pathlib import Path RULES = {k: re.compile(v, re.I) for k,v in { 'vendor_registration': r'iwl_mvm_vendor_csi_register|IWL_MVM_VENDOR_CMD_CSI_EVENT|csi_portid', 'vendor_payload': r'IWL_MVM_VENDOR_ATTR_CSI_(?:HDR|DATA)|iwl_mvm_send_csi_event', 'assembly': r'iwl_mvm_csi_complete|iwl_mvm_rx_csi_(?:header|chunk)|iwl_csi_chunk_notification|IWL_CSI_CHUNK_CTL|csi_notif|IWL_CSI_MAX_EXPECTED_CHUNKS', 'format': r'\b\w*(?:csi|mcsi)\w*(?:header|hdr|chunk|data|buffer|size|format|version)\w*\b', 'configuration': r'iwl_mvm_send_csi_cmd|IWL_UCODE_TLV_CAPA_CSI_REPORTING|IWL_CHANNEL_ESTIMATION_', 'identifiers': r'IWL_MVM_VENDOR_(?:CMD_CSI|ATTR_CSI)|INTEL_OUI', }.items()} def sha(b): return hashlib.sha256(b).hexdigest() def encode(b): return base64.b64encode(b).decode('ascii') def record(header, payload, seq, ns): return dict(schema='omega.raw-csi.v1',origin='SYNTHETIC_NOT_RADIO',trial='AB-011-SYNTHETIC',sequence=seq,host_monotonic_ns=ns,header_b64=encode(header),payload_b64=encode(payload),header_bytes=len(header),payload_bytes=len(payload),header_sha256=sha(header),payload_sha256=sha(payload)) def unpack_record(r): result=[] for key in ('header','payload'): b=base64.b64decode(r[key+'_b64'],validate=True) if len(b)!=r[key+'_bytes'] or sha(b)!=r[key+'_sha256']: raise ValueError('Corrupt '+key) result.append(b) return tuple(result) def synthetic_test(out): # Artificial little-endian signed int16 I/Q pairs. NOT Intel encoding. pairs=[(3,4),(-3,4),(0,-5),(0,0),(32767,-32768)] payload=b''.join(struct.pack('25: report.append(' See evidence.csv and format context for remaining matches.') report += ['', 'INTERPRETATION CHECKLIST','Resolve actual numeric vendor command and attribute IDs from full source headers; do not guess.','Trace header and chunk structures, version-specific masks and length validation. Kernel chunk assembly is distinct from the user-space sample encoding.','Locate evidence for sample widths, signedness, byte order, subcarrier order, antenna mapping and timestamps; mark absent evidence unknown.','Preserve opaque header and payload before any decoding. Keep raw bytes immutable and derived data separate.','Future C++ collector: register through the matching vendor interface, retain socket, validate event identity and lengths, record host receipt timestamps, track drops, preserve raw bytes.','Validate Intel-specific decoding against documented or known reference captures and controlled experiments before interpreting amplitude or phase.','Synthetic I/Q pairs use an invented int16 format solely to test math and recording; this is NOT evidence of Intel 9260 encoding.','No HP access, actual CSI, network activity, driver installation, checkpoint change or ZIP refresh. Exodus deferred.'] dest=out/'AB-011-Recording-Report.txt'; dest.write_text('\n'.join(report)+'\n',encoding='utf-8') print(f'AB-011: {len(hits)} candidate lines | {len(files)} verified inputs | {len(missing)} missing'); print(test); print('Report:',dest); print('Format context:',out/'AB-011-Format-Context.txt'); print('Schema:',out/'proposed-recording-schema.json'); print('No real CSI collected. Exodus NOT deployed; ZIP unchanged.') if __name__=='__main__': main()