Combine Evidence into a Review Packet
import json
from collections import defaultdict
by_observable: dict[str, list[dict[str, str]]] = defaultdict(list)
with open("evidence.jsonl", encoding="utf-8") as source:
for line in source:
record = json.loads(line)
by_observable[record["observable"]].append(record)
packet = []
for observable, records in sorted(by_observable.items()):
packet.append({
"observable": observable,
"sources": sorted({record["source"] for record in records}),
"observations": [record["observation"] for record in records],
"recommended_validation": "reconcile with inventory and assigned owner",
})
print(json.dumps(packet, indent=2))