Files
amethyst/tools/kind-census/findings_md.py
Claude dc43b6ab67 chore(tools): kind census of live relays vs quartz typed kinds
Crawled 743 of 5,846 reachable relays with amy for events signed
2026-10-07..08: 2.36M events, 573 kinds, 386 without a typed quartz
class. Adds the crawl/harvest/profile scripts, the kind histogram, the
per-kind profiles and researched findings (what each kind is,
spec/source, relevance to Amethyst). Raw samples stay local: they hold
third-party personal data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FrQx1ZvQka64aFAnZM1Hjd
2026-10-08 15:23:21 +00:00

43 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""Render data/<date>/findings.json as FINDINGS.md. usage: findings_md.py DATA_DIR"""
import json, os, sys
d = sys.argv[1]
f = json.load(open(os.path.join(d, "findings.json")))
order = {"render-worthy": 0, "protocol-infra": 1, "app-private": 2, "spam/noise": 3}
out = ["# Unsupported kinds: findings", "",
"Generated from `findings.json` by `findings_md.py`. Kinds with 3+ distinct authors in the "
"window, grouped by relevance to Amethyst, then by author count. Samples: `samples/kind-<K>.jsonl`.",
"Author counts overstate real users where an app signs with throwaway keys (noted per kind).", ""]
def cell(s):
return (s or "").replace("|", "\\|").replace("\n", " ")
for rel in sorted({x["amethyst_relevance"] for x in f["identified"]}, key=lambda r: order.get(r, 9)):
rows = [x for x in f["identified"] if x["amethyst_relevance"] == rel]
out += [f"## {rel} ({len(rows)})", "", "| kind | class | authors | events | name | app / protocol | conf | spec |",
"|---|---|---|---|---|---|---|---|"]
for x in sorted(rows, key=lambda x: -(x["authors"] or 0)):
spec = f"[link]({x['spec_url']})" if x.get("spec_url") else ""
out.append(f"| {x['kind']} | {x['class']} | {x['authors']} | {x['events']} | {cell(x['name'])} | "
f"{cell(x['app_or_protocol'])} | {x['confidence']} | {spec} |")
out.append("")
for x in sorted(rows, key=lambda x: -(x["authors"] or 0)):
out.append(f"- **{x['kind']} {cell(x['name'])}** — {cell(x['what_it_is'])}"
+ (f" _Notes:_ {cell(x['notes'])}" if x.get("notes") else ""))
out.append("")
lt = f["long_tail"]
out += ["## Long tail (1-2 authors per kind)", "", "### Notable", "",
"| kind | name | app / protocol | relevance | conf |", "|---|---|---|---|---|"]
for x in lt["notable"]:
out.append(f"| {x['kind']} | {cell(x['name'])} | {cell(x.get('app_or_protocol'))} | "
f"{x.get('amethyst_relevance', '')} | {x.get('confidence', '')} |")
out += ["", "### Clusters", "", "| label | kinds | relevance | what it is |", "|---|---|---|---|"]
for c in lt["clusters"]:
out.append(f"| {cell(c['label'])} | {', '.join(map(str, c['kinds']))} | {c['relevance']} | {cell(c['what_it_is'])} |")
open(os.path.join(d, "FINDINGS.md"), "w").write("\n".join(out) + "\n")
print("wrote", os.path.join(d, "FINDINGS.md"))