scripts/vectors.py
scripts/vectors.pyBrowse 56 files
496 tokens
2,122 bytes
Token encoding: o200k_base
Snapshot 24fd22b
← Back to SKILL.md
1"""Enumerate the search queries to run per broker, across ALL of a subject's identifiers.2 3People-search sites index a person under every name, phone, email, and address they4have. A subject with two names (maiden/married) and three past cities can have many5distinct listings on one broker, each found via a different search. `search_vectors`6expands the dossier into the concrete searches to run, filtered by what each broker7supports (`broker.search.by`, default ["name"]).8"""9from __future__ import annotations10 11import dossier as dossier_mod12 13# What a broker can be searched by; default if a record doesn't declare it.14DEFAULT_BY = ["name"]15 16 17def supported_by(broker: dict) -> list[str]:18 return list((broker.get("search") or {}).get("by") or DEFAULT_BY)19 20 21def search_vectors(subject_dossier: dict, broker: dict) -> list[dict]:22 """List of {by, query} searches to run for this subject on this broker."""23 by = set(supported_by(broker))24 ident = subject_dossier.get("identity", {})25 vectors: list[dict] = []26 27 if "name" in by:28 names = dossier_mod.all_names(subject_dossier)29 locations = dossier_mod.all_locations(subject_dossier)30 if locations:31 for name in names:32 for loc in locations:33 vectors.append({"by": "name",34 "query": {"full_name": name, "city": loc.get("city"), "state": loc.get("state")}})35 else:36 for name in names:37 vectors.append({"by": "name", "query": {"full_name": name}})38 39 if "phone" in by:40 for phone in ident.get("phones") or []:41 vectors.append({"by": "phone", "query": {"phone": phone}})42 43 if "email" in by:44 for email in ident.get("emails") or []:45 vectors.append({"by": "email", "query": {"email": email}})46 47 if "address" in by:48 for a in dossier_mod.all_addresses(subject_dossier):49 if a.get("line1"):50 vectors.append({"by": "address",51 "query": {k: a.get(k) for k in ("line1", "city", "state", "postal")}})52 53 return vectors54