// 0pt.source_rate_policy.schema.v1 // // The genuine ownership repair this contract encodes: crawl-domain rate // limiting and compliance posture belongs to 0pt, not N0D. N0D's // `ComputePolicy.sourceRatePolicy` field (per-domain crawl rate limits) is // deprecated/removed from N0D's seed data per ADR-0030's audit -- 0pt already // owns the sourcing chain (docs/06-data-engine.md, `sources.yaml`) and is the // only product that should hold this policy. // // Field names reconcile two prior specs written for this same contract: // docs/11-lakehouse-write-plan.md item 5 (domain/requests_per_second/ // robots_ok/access) and this pass's task spec (rate_limit_per_minute/ // crawl_budget/compliance_notes). Both are kept: the task-spec fields are // primary, the docs/11 fields are additional optional detail for the same // row, not a competing shape. export type SourceRatePolicyStatus = "active" | "paused" | "deprecated"; export interface SourceRatePolicy { source_rate_policy_id: string; tenant_id: string; project_id: string; /** References source.source_id (src/types/source.ts). */ source_id: string; rate_limit_per_minute: number; /** Max requests/pages/records this policy permits per crawl run or per day (unit documented in compliance_notes when non-obvious). */ crawl_budget: number; /** Free-text compliance rationale: robots.txt posture, licence terms, contact/ToS reference. */ compliance_notes?: string; /** Crawl-target domain, e.g. "allabolag.se" -- optional convenience field mirroring docs/06-data-engine.md's sources.yaml rate_limit entries. */ domain?: string; /** Whether robots.txt permits the access pattern this policy governs. */ robots_ok?: boolean; /** Mirrors dim_source.access (docs/03-data-model.md): api | bulk | authorized_web | licensed. */ access?: "api" | "bulk" | "authorized_web" | "licensed"; status: SourceRatePolicyStatus; correlation_id?: string; created_at: string; updated_at?: string; created_by?: string; } export interface CreateSourceRatePolicyInput { source_rate_policy_id: string; tenant_id: string; project_id: string; source_id: string; rate_limit_per_minute: number; crawl_budget: number; compliance_notes?: string; domain?: string; robots_ok?: boolean; access?: "api" | "bulk" | "authorized_web" | "licensed"; status?: SourceRatePolicyStatus; correlation_id?: string; created_by?: string; }