"""OMEGA AB-010: offline CSI generation research; no network or device actions.""" import argparse import csv import hashlib import re from datetime import datetime from pathlib import Path RULES = { 'activation': r'iwl_mvm_send_csi_cmd|iwl_dbgfs_csi_enabled|\bcsi_enabled\b', 'frame_selection': r'\bcsi_frame_types\b|iwl_dbgfs_csi_frame_types|\b\w*(?:CSI|MCSI)\w*(?:FRAME|TYPE)\w*\b', 'timing': r'iwl_dbgfs_csi_(?:count|timeout|interval)|\bcsi_(?:count|timeout|interval)\b|\b\w*(?:CSI|MCSI)\w*(?:COUNT|TIMEOUT|INTERVAL)\w*\b', 'address_filter': r'iwl_dbgfs_csi_addresses|\bcsi_addresses\b|\b\w*(?:CSI|MCSI)\w*(?:ADDR|MAC)\w*\b', 'firmware_gate': r'IWL_UCODE_TLV_CAPA_CSI_REPORTING|CSI_(?:HEADER|CHUNKS)_NOTIFICATION', 'delivery': r'iwl_mvm_vendor_csi_register|IWL_MVM_VENDOR_CMD_CSI_EVENT|iwl_mvm_send_csi_event|iwl_mvm_csi_complete', 'interface': r'NL80211_IFTYPE_(?:MONITOR|STATION)|WIPHY_VENDOR_CMD_NEED_\w+|\b(?:vif|wdev)->iftype\b', } RULES = {k: re.compile(v, re.I) for k,v in RULES.items()} # Fixed regions refer to the pinned Core46 revision used in AB-007. REGIONS = {'mvm/debugfs.c': [(1970,2240),(2260,2300),(2485,2530)], 'mvm/vendor-cmd.c': [(1525,1555),(1740,1775),(1840,1888),(1916,2015)], 'fw/api/location.h': [(90,110),(160,185)], 'fw/file.h': [(420,438),(495,508)]} PLAN = [ ('G0','Associated station, idle','No deliberate traffic','30','0','0'), ('G1','Associated station','Local peer sends UDP datagrams to HP','30','10','256'), ('G2','Associated station','Local peer sends UDP datagrams to HP','30','50','256'), ('G3','Associated station','HP sends UDP datagrams to local peer','30','10','256'), ('G4','Associated station','Local peer sends UDP datagrams to HP','30','10','1024'), ('G5','Associated station, idle','No deliberate traffic','30','0','0'), ] def main(): p=argparse.ArgumentParser(description=__doc__) p.add_argument('--root',type=Path,default=Path.home()/'Documents'/'OMEGA'/'OMICRON') p.add_argument('--run',default='AB-007-20261127-162346-512367') a=p.parse_args(); root=a.root.resolve(); run=root/'Analysis'/a.run if not (root/'Index'/'Current-Checkpoint.txt').is_file(): raise SystemExit('OMEGA root not found') with (run/'retrieval.csv').open(encoding='utf-8-sig',newline='') as f: rows=list(csv.DictReader(f)) files=[]; missing=[] for r in rows: if r['status']!='OK': missing.append(f"{r['source']} {r['file']}: {r['status']}"); continue path=run/'sources'/r['source']/r['file']; data=path.read_bytes() if hashlib.sha256(data).hexdigest().lower()!=r['sha256'].lower(): raise SystemExit(f'Hash mismatch: {path}') files.append((r,data.decode('utf-8').splitlines())) if not files: raise SystemExit('No verified sources') out=root/'Analysis'/('AB-010-'+datetime.now().strftime('%Y%m%d-%H%M%S-%f')); out.mkdir() hits=[]; contexts=[]; sections=[] for r,lines in files: windows=[] for i,line in enumerate(lines): tags=[k for k,v in RULES.items() if v.search(line)] # Generic interface matches are only relevant near CSI-specific code. if tags==['interface'] and not (r['source']=='intel-core46' and r['file']=='mvm/vendor-cmd.c' and 1525<=i+1<=1775): continue if not tags: continue hits.append(dict(source=r['source'],file=r['file'],line=i+1,topics=';'.join(tags),text=line.strip(),url=r['url'],sha256=r['sha256'])) windows.append((max(0,i-8),min(len(lines),i+12))) if r['source']=='intel-core46': for lo,hi in REGIONS.get(r['file'],[]): if lo<=len(lines): hi=min(hi,len(lines)); windows.append((lo-1,hi)) sections.append(f"\n=== {r['file']}:{lo}-{hi} | {r['url']} ===") sections.extend(f'{i+1:5} {lines[i]}' for i in range(lo-1,hi)) merged=[] for lo,hi in sorted(windows): if merged and lo<=merged[-1][1]: merged[-1][1]=max(hi,merged[-1][1]) else: merged.append([lo,hi]) if merged: contexts.append(f"\n=== {r['source']}/{r['file']} | {r['url']} | SHA256 {r['sha256']} ===") for lo,hi in merged: contexts.append(f'--- {lo+1}-{hi} ---'); contexts.extend(f'{i+1:5} {lines[i]}' for i in range(lo,hi)) with (out/'evidence.csv').open('w',encoding='utf-8-sig',newline='') as f: w=csv.DictWriter(f,fieldnames=['source','file','line','topics','text','url','sha256']); w.writeheader(); w.writerows(hits) (out/'AB-010-Source-Context.txt').write_text('\n'.join(contexts)+'\n',encoding='utf-8') (out/'AB-010-Control-Details.txt').write_text('\n'.join(sections)+'\n',encoding='utf-8') with (out/'proposed-traffic-plan.csv').open('w',encoding='utf-8-sig',newline='') as f: w=csv.writer(f); w.writerow(['condition','interface','traffic','duration_seconds','target_datagrams_per_second','payload_bytes']); w.writerows(PLAN) report=['OMEGA AB-010 - CSI GENERATION METHODOLOGY','CROSS-0 | offline static evidence and proposed future experiment',f'Input: {run.relative_to(root)}',f'Verified files: {len(files)}; missing: {len(missing)}',*missing,'','SOURCE EVIDENCE (lexical matches; not runtime findings)'] for topic in RULES: group=[h for h in hits if topic in h['topics'].split(';')]; report.append(f'\n{topic}: {len(group)} matching lines') for h in group[:22]: report.append(f" {h['source']} {h['file']}:{h['line']} {h['text']}") if len(group)>22: report.append(' Remaining matches in evidence.csv.') report += ['', 'INTERPRETATION TASKS', 'Read complete control handlers in AB-010-Control-Details.txt to determine accepted values, units, and whether writes apply immediately.', 'Inspect the actual CSI registration entry and function for interface restrictions; nearby generic flags are not evidence of a CSI requirement.', 'Frame-type filtering is not proof that every selected frame produces CSI. Determine firmware command payload and supported receive formats separately.', '', 'PROPOSED BETA ALPHA TRAFFIC EXPERIMENT (NOT EXECUTED)', 'Use only an authorized local network and owned endpoints. First establish working CSI activation and event reception. Keep channel, bandwidth, positions and configuration fixed. Prefer a wired peer on the same router when possible so the intended wireless hop is clear.', 'Run G0-G5 from proposed-traffic-plan.csv with at least three repeats, allowing recovery between conditions. Rates and durations are proposed defaults, not measured capabilities.', 'Log sent/received datagram counts, sequence numbers, monotonic timestamps, CSI event count, valid/invalid reports, and channel/width if available. Record drops and background traffic. Avoid assuming one UDP datagram equals one wireless frame or CSI report.', 'Compare valid CSI reports per second against idle baseline and traffic conditions. Do not infer phase accuracy or packet correspondence without validation.', 'Test monitor mode separately only if ordinary station operation fails or evidence warrants it; use owned traffic and preserve connectivity/recovery options.', '', 'LIMITATIONS', 'No traffic generated. No radio measurements obtained. No exact firmware command definition established unless present in supplied files. Three missing source paths and exact Ubuntu build remain unresolved. Active firmware support, frame eligibility, timing units and actual sample rate require further evidence. No checkpoint or ZIP update. Exodus deferred.'] dest=out/'AB-010-Generation-Report.txt'; dest.write_text('\n'.join(report)+'\n',encoding='utf-8') print(f'AB-010: {len(hits)} candidate lines | {len(files)} verified inputs | {len(missing)} missing') print('Report:',dest); print('Control details:',out/'AB-010-Control-Details.txt'); print('Traffic plan:',out/'proposed-traffic-plan.csv'); print('No traffic generated. Exodus NOT deployed; ZIP unchanged.') if __name__=='__main__': main()