/** * Source Authority * * Classifies a URL by domain into a trust tier so downstream * consumers can rank or filter sources by how authoritative they * are. Used by: * * - The research engine, to prioritize official sources when * multiple sources conflict * - The browse response (via verification engine), so any caller * can apply their own "minimum authority" policy without * reimplementing the classifier * - The future /v1/verify endpoint, where AI-citation validation * can reject or downweight non-authoritative sources * * ## Categories * * Categories are ordered by authority. Each carries a `score` in * [0..1] for callers that want a continuous signal: * * - government (.95) — national/federal government domains * - institutional (.90) — major libraries, archives, museums * (loc.gov, archives.gov, britishmuseum.org) * - academic (.85) — universities (.edu, .ac.uk, .ac.jp) * - scientific (.85) — peer-reviewed journals, preprint * servers (nature.com, arxiv.org, pubmed) * - intergovernmental (.85) — UN, EU, WHO, OECD * - reference (.70) — Wikipedia, Britannica, Encyclopedia.com * - news (.70) — established mainstream news * - official (.70) — generic .org / .gov.* not in the * specific lists * - commercial (.50) — generic for-profit sites * - unknown (.50) — anything that doesn't classify * * Categories are NOT mutually exclusive in principle (a domain * could be both government and academic) but the classifier returns * the highest-authority match it finds. * * ## Updating the lists * * The phrase lists are intentionally curated, not exhaustive. Add * domains as real-world traffic surfaces gaps. The classifier is * a fast first pass — for high-stakes decisions, callers should * combine this with their own domain allowlist. */ /** * Authority categories, ordered roughly by trust tier. */ export type AuthorityCategory = 'government' | 'institutional' | 'academic' | 'scientific' | 'intergovernmental' | 'reference' | 'news' | 'official' | 'commercial' | 'unknown'; /** * Authority classification result returned by `classifySource`. */ export interface AuthorityClassification { category: AuthorityCategory; /** Score in [0..1]. Higher = more authoritative. */ score: number; /** Domain that was matched (for diagnostics). */ matchedDomain: string; /** Optional country code for government sources. */ country?: string; /** * Human-readable reason explaining why this category was assigned. * Useful for surfacing in UIs or for debugging unexpected * classifications. */ reason: string; } /** * Classify a URL by its domain into an authority category. * * The classifier walks the lists in order of authority (highest * first) and returns on the first match. So a domain that's both * government and reference (rare but possible) classifies as * government, the higher tier. * * Walk order (load-bearing for some classifications): * * 1. Country-specific government (so we can attribute the country) * 2. Institutional archives — runs BEFORE the generic .gov TLD * check so loc.gov, archives.gov, ndl.go.jp etc. get their * richer "institutional" classification instead of the * anonymous "generic government" tag. * 3. Intergovernmental * 4. Scientific publishers — same reason as institutional: * pubmed.ncbi.nlm.nih.gov, ncbi.nlm.nih.gov should classify * as scientific even though they're also under .gov. * 5. Academic (explicit list, then TLD patterns) * 6. Generic .gov / .gob / .gouv / .govt — fallback for any * remaining government domain that didn't get a richer tag * 7. Reference encyclopedias * 8. News * 9. Generic .org / .edu fallback (.edu is already caught at * step 5, this is the .org branch) * 10. Unknown — neutral default * * Within equal-score tiers (intergovernmental / scientific / * academic, all 0.85), the walk order above determines which * category label wins on a domain that could match multiple. The * `score` field is the same regardless, so consumers filtering by * score see identical behavior. Don't build logic on * "scientific always wins over academic" — it's walk-order * dependent and could change if the lists are reordered. * * Returns `unknown` (score 0.5) for any domain that doesn't match * any of the curated lists. This is a deliberate safe default — * callers reading the result should treat unknown as "no signal," * not "low quality." */ export declare function classifySource(url: string): AuthorityClassification; /** * Returns true if the URL meets a minimum authority score. Cheap * convenience wrapper for the common "filter by trust tier" path. */ export declare function meetsMinimumAuthority(url: string, minScore: number): boolean; /** * Exposed for tests and for callers that want to extend the * classifier with their own domains. */ export declare const _internalForTests: { GOVERNMENT_DOMAINS: Record; INSTITUTIONAL_ARCHIVES: readonly string[]; ACADEMIC_DOMAINS: readonly string[]; ACADEMIC_TLDS: readonly string[]; SCIENTIFIC_DOMAINS: readonly string[]; INTERGOVERNMENTAL_DOMAINS: readonly string[]; REFERENCE_DOMAINS: readonly string[]; NEWS_DOMAINS: readonly string[]; CATEGORY_SCORES: Record; }; //# sourceMappingURL=source-authority.d.ts.map