Files
WoW-Hybrid-gateway/ops/watch_native_channel.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

39 lines
2.6 KiB
Python

#!/usr/bin/env python3
"""Read-only bounded watch of the actual owned native channel call contracts.
Does not clear error latches, send gameplay, change protections or launch clients.
"""
import argparse,datetime,json,os,time
from native_engine_character_test import Controller,ROOT,local_listeners
from native_test_guard import require_local_turtle_ports
def main():
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--seconds',type=float,default=180);args=parser.parse_args()
if not 5<=args.seconds<=900:parser.error('Bound observation to5..900seconds')
require_local_turtle_ports(local_listeners());os.umask(0o077)
directory=ROOT/'runtime'/('native-channel-watch-'+datetime.datetime.now().strftime('%Y%m%d-%H%M%S'));directory.mkdir(mode=0o700)
controller=Controller(int((ROOT/'runtime/native-client.pid').read_text()));began=time.monotonic();last_log=-5;last_report=-15
with (directory/'samples.jsonl').open('w') as output:
while True:
elapsed=time.monotonic()-began;row=controller.rpc('inspect-native-channel-policy')
if elapsed-last_log>=5 or row['error']:
output.write(json.dumps(dict(elapsed_seconds=round(elapsed,3),**row))+'\n');output.flush();last_log=elapsed
if elapsed-last_report>=15 or row['error']:
print(json.dumps(dict(elapsed_seconds=round(elapsed,1),enabled=row['enabled'],error=row['error'],drained=row['drained'],contract_failure=row.get('contract_failure'))),flush=True);last_report=elapsed
if row['error'] or elapsed>=args.seconds:
# A policy error only identifies the stage at which readiness
# disappeared. Preserve the pipe's first error and bounded
# structural movement metadata before the client can exit.
if row['error']:
try:
pipe=controller.rpc('inspect-engine-pipe')
(directory/'failure-pipe.json').write_text(json.dumps(pipe,indent=2)+'\n')
print(json.dumps(dict(pipe_error=pipe['error'],pipe_closed=pipe['closed'],movement_failure=pipe.get('movement_failure'))),flush=True)
except (OSError,RuntimeError,ValueError) as error:
(directory/'failure-inspection.txt').write_text(type(error).__name__+': '+str(error)+'\n')
(directory/'final.json').write_text(json.dumps(dict(elapsed_seconds=round(elapsed,3),**row),indent=2)+'\n')
print('Read-only channel evidence:',directory,flush=True)
return 2 if row['error'] else 0
time.sleep(.25)
if __name__=='__main__':raise SystemExit(main())