← back to Tk11438 Postgres Migration

verification/fleet-classification/annotate-schedulers.py

29 lines

import json,collections,datetime,pathlib
p=pathlib.Path('/tmp/tk11438-fleet-classification/schedulers.json');x=json.loads(p.read_text())
for r in x['rows']:
 for s in r['referenced_sources']:
  s['findings']=[f for f in s['findings'] if not(f.get('source')=='/Users/macstudio3/cncp-starter/server.js' and f.get('line')==21739)]
  for f in s['findings']:
   source=f['source'];line=f.get('line')
   if source.endswith('/db-restore-drill/drill.sh') and line==72 or source.endswith('/dw-restore-rehearsal/rehearse.sh') and line==81:
    f.update(target_machine='remote SSH destination from dynamic HOST/host variable',transport='remote_tcp_via_ssh',manual_review='127.0.0.1 is evaluated inside quoted ssh command, not on this Mac')
   elif source.endswith('/catalog-push-to-kamatera.sh') and line==26:
    f.update(target_machine='Kamatera remote command target',transport='remote_target_uri',manual_review='KAM target URI is declared alongside separate MAC3 hostless source URI; remote operation not executed')
   elif source.endswith('/Ken/kalshi-dash/follow-the-winners.mjs') and line==13:
    f.update(target_machine='macstudio3',manual_review='Fallback URI only. Scheduled wrapper now explicitly supplies ?host=/tmp, verified in completed Ken batch; do not count this as active TCP regression')
   elif source.endswith('/fabricut-landing/scripts/localize-images.js') and line in (43,44):
    f.update(target_machine='macstudio3',manual_review='Pool selects /tmp when /tmp/.s.PGSQL.5432 exists, otherwise TCP127.0.0.1; static branch not executed')
   elif source=='/Users/macstudio3/cncp-starter/server.js' and line==150:
    f.update(target_machine='macstudio3',manual_review='dwUnified defaults set enabled:false; persisted CNCP config may override. No effective-config claim')
   else:f.setdefault('target_machine','macstudio3 execution context unless remote/dynamic caveat applies')
 r['manual_review_note']='Static inventory only; unreviewed inheritance and transitive branches remain. Email or write-capable launchers were read as text only.'
fs=[f for r in x['rows'] for f in r['plist_pg_findings']+[f for s in r['referenced_sources'] for f in s['findings']]]
x['summary']['finding_occurrences_by_transport']=dict(collections.Counter(f['transport'] for f in fs))
labels=collections.Counter(r['label'] for r in x['rows'] if r['label']);x['summary']['duplicate_labels']={k:v for k,v in labels.items() if v>1}
x['summary']['candidate_rows_with_local_tcp_literal']=sum(any(f['transport']=='local_tcp' for f in r['plist_pg_findings']+[f for s in r['referenced_sources'] for f in s['findings']]) for r in x['rows'])
x['summary']['candidate_rows_with_unreviewed_edges']=sum(r['postgres_candidate'] and bool(r['unreviewed_edges']) for r in x['rows'])
x['summary']['candidate_rows_with_dynamic_caveats']=sum(r['postgres_candidate'] and bool(r['dynamic_or_inherited_caveats']) for r in x['rows'])
x['manual_review_at']=datetime.datetime.now(datetime.timezone.utc).isoformat()
x['manual_review_findings']=['Excluded unrelated HTTP health-check host from CNCP PG candidate targets','Identified remote SSH localhost references in restore drills, and Kamatera target URI in catalog-push launcher','Ken fallback TCP literal is overridden by migrated scheduled wrapper socket setting; no Ken runtime tests repeated','Fabricut image-localizer TCP branch is conditional on absent local socket','CNCP dwUnified TCP host is a disabled default; persisted configuration unresolved','3 top-level plist parse/root-shape failures remain explicit coverage gaps']
p.write_text(json.dumps(x,indent=2)+'\n');print(json.dumps(x['summary'],indent=2))