"""Coordinator experiment-only stats flush; emits no model data and imports no engine. Uses the existing proxy housekeeping FLUSH_REQ/ACK control words. No tensor bytes are read or written. Never use this against production or an unreviewed layout. """ from __future__ import annotations import argparse import json import os from pathlib import Path import struct import time PAGE = 65536 MAGIC = 0x31565344 FLUSH_REQ = 448 FLUSH_ACK = 512 def flush(fd: int, *, timeout: float = 2) -> None: def word(offset: int) -> int: return int(struct.unpack('= end: raise TimeoutError('proxy stats flush ACK not received') time.sleep(.01) def main() -> None: ap = argparse.ArgumentParser(description=__doc__) ap.add_argument('--pid',type=int,required=True) args = ap.parse_args() process = Path('/proc')/str(args.pid) maps = (process/'maps').read_text() if any(name in maps for name in ('libtorch','libc10','libcuda','libcudart')): raise ValueError('proxy loaded torch/CUDA library') candidates = [p for p in (process/'fd').iterdir() if os.readlink(p).startswith('/memfd:dsv41-remote-dspark')] if not candidates or len({os.stat(p).st_ino for p in candidates}) != 1: raise ValueError('expected one distinct proxy memfd (duplicate handles allowed)') fd = os.open(candidates[0],os.O_RDWR) try: if struct.unpack('