import json
with open('tests/artifacts/PHASE1_AUDIT.json', 'r', encoding='utf-8') as f:
    data = json.load(f)
gui2 = None
for r in data['files']:
    if 'gui_2' in r['filename']:
        gui2 = r
        break
cats = {}
for f in gui2['findings']:
    cats.setdefault(f['category'], []).append((f['line'], f['context'], f['kind']))
for cat in sorted(cats):
    print(f'\n{cat} ({len(cats[cat])}):')
    for line, ctx, kind in sorted(cats[cat]):
        print(f'  L{line:>4} {kind:<10} {ctx}')
