-- ALBERT LANE DIGITAL INFRASTRUCTURE -- License: ALDI Sovereign License - see https://albertlane.net -- Manifest: https://albertlane.net -- ALDI VERIFIED No. 17684-273-411-436 SOVEREIGN AUDIT -- NO_BEZOS NO_AWS NO_OPENAI NO_INTEL -- Provenance: Defensive anti-trafficking relationship analysis only. -- No victim PII. Signals are risk / priority for human review, never a verdict. -- Single-bucket design: every entity is also a node in the graph. -- Companies, cost-cutting events, offshore sites, and trafficking signals -- all resolve into nodes + edges so relationship analysis is one query. CREATE TABLE IF NOT EXISTS sources ( id TEXT PRIMARY KEY, name TEXT NOT NULL, source_type TEXT NOT NULL CHECK (source_type IN ('corporate-filing','news','osint-ad','osint-review','hotel','financial-intel','ngo-report','law-enforcement-release','registry','other')), url TEXT, reliability REAL DEFAULT 0.5 CHECK (reliability BETWEEN 0 AND 1), fetched_at TEXT, notes TEXT ); CREATE TABLE IF NOT EXISTS companies ( id TEXT PRIMARY KEY, name TEXT NOT NULL, normalized_name TEXT NOT NULL UNIQUE, ticker TEXT, sector TEXT, country TEXT, website TEXT, created_at TEXT DEFAULT (datetime('now')), source_id TEXT REFERENCES sources(id) ); CREATE TABLE IF NOT EXISTS cost_cutting_events ( id TEXT PRIMARY KEY, company_id TEXT NOT NULL REFERENCES companies(id), event_type TEXT NOT NULL CHECK (event_type IN ('layoff','offshoring','outsourcing','contractor-switch','site-closure','automation','wage-cut','benefit-cut','restructuring','other')), announced_date TEXT, effective_date TEXT, description TEXT, jobs_affected INTEGER, estimated_savings_usd REAL, destination_country TEXT, destination_city TEXT, source_id TEXT REFERENCES sources(id), created_at TEXT DEFAULT (datetime('now')) ); CREATE TABLE IF NOT EXISTS sites ( id TEXT PRIMARY KEY, company_id TEXT REFERENCES companies(id), site_type TEXT NOT NULL CHECK (site_type IN ('offshore-hub','call-center','bpo','factory','sweatshop','warehouse','contractor-site','other')), name TEXT NOT NULL, contractor_name TEXT, city TEXT, region TEXT, country TEXT NOT NULL, lat REAL, lon REAL, opened_date TEXT, closed_date TEXT, headcount INTEGER, is_contractor_operated INTEGER DEFAULT 0, source_id TEXT REFERENCES sources(id), created_at TEXT DEFAULT (datetime('now')) ); -- Unified signal bucket: corporate + trafficking signals live here together. -- signal_category = corporate OR trafficking OR financial OR review OR hotel OR ad -- status = preexisting (signal existed before linked cost-cutting event) -- | emergent (first signal in that location/family after event) -- | unlinked (no cost-cutting link yet) CREATE TABLE IF NOT EXISTS trafficking_signals ( id TEXT PRIMARY KEY, signal_category TEXT NOT NULL, indicator_family TEXT NOT NULL, indicator_code TEXT NOT NULL, weight REAL NOT NULL CHECK (weight BETWEEN 0 AND 1), description TEXT, observed_at TEXT NOT NULL, city TEXT, region TEXT, country TEXT, lat REAL, lon REAL, confidence REAL DEFAULT 0.5 CHECK (confidence BETWEEN 0 AND 1), status TEXT DEFAULT 'unlinked' CHECK (status IN ('preexisting','emergent','unlinked')), company_id TEXT REFERENCES companies(id), site_id TEXT REFERENCES sites(id), source_id TEXT REFERENCES sources(id), evidence_ref TEXT, created_at TEXT DEFAULT (datetime('now')) ); -- Graph: every company, site, event, signal, contractor, phone, ad is a node. CREATE TABLE IF NOT EXISTS nodes ( id TEXT PRIMARY KEY, node_type TEXT NOT NULL CHECK (node_type IN ('company','site','event','signal','contractor','location','phone','email','ad','review','account','wallet','other')), label TEXT NOT NULL, external_key TEXT UNIQUE, city TEXT, region TEXT, country TEXT, lat REAL, lon REAL, first_seen TEXT, last_seen TEXT, created_at TEXT DEFAULT (datetime('now')) ); CREATE TABLE IF NOT EXISTS edges ( id TEXT PRIMARY KEY, from_node_id TEXT NOT NULL REFERENCES nodes(id), to_node_id TEXT NOT NULL REFERENCES nodes(id), edge_type TEXT NOT NULL CHECK (edge_type IN ('owns','operates','contracted','located-in','near','same-phone','same-email','same-photo','same-text','paid-for','reviewed','transferred-to','shared-signer','temporal-after','geographic-near','cost-cutting-precedes','signal-follows','other')), weight REAL DEFAULT 0.5, distance_km REAL, time_delta_days INTEGER, evidence TEXT, observed_at TEXT, source_id TEXT REFERENCES sources(id), created_at TEXT DEFAULT (datetime('now')) ); CREATE INDEX IF NOT EXISTS idx_edges_from ON edges(from_node_id); CREATE INDEX IF NOT EXISTS idx_edges_to ON edges(to_node_id); CREATE INDEX IF NOT EXISTS idx_edges_type ON edges(edge_type); -- Materialized relationship: cost-cutting event -> site -> signal cluster CREATE TABLE IF NOT EXISTS relationships ( id TEXT PRIMARY KEY, company_id TEXT NOT NULL REFERENCES companies(id), event_id TEXT REFERENCES cost_cutting_events(id), site_id TEXT REFERENCES sites(id), signal_id TEXT REFERENCES trafficking_signals(id), relationship_type TEXT NOT NULL CHECK (relationship_type IN ('cost-cutting-then-site','site-then-signal','cost-cutting-then-signal','preexisting-co-located','emergent-co-located','shared-contractor','shared-location','other')), distance_km REAL, time_delta_days INTEGER, correlation_score REAL, is_emergent INTEGER DEFAULT 0, evidence TEXT, computed_at TEXT DEFAULT (datetime('now')) ); CREATE INDEX IF NOT EXISTS idx_rel_company ON relationships(company_id); CREATE INDEX IF NOT EXISTS idx_rel_event ON relationships(event_id); CREATE INDEX IF NOT EXISTS idx_rel_score ON relationships(correlation_score DESC); CREATE TABLE IF NOT EXISTS risk_scores ( id TEXT PRIMARY KEY, entity_id TEXT NOT NULL, entity_type TEXT NOT NULL CHECK (entity_type IN ('company','site','location','cluster')), score REAL NOT NULL CHECK (score BETWEEN 0 AND 1), tier TEXT CHECK (tier IN ('low','medium','high','priority-review')), features_fired TEXT, signal_count INTEGER DEFAULT 0, emergent_count INTEGER DEFAULT 0, preexisting_count INTEGER DEFAULT 0, computed_at TEXT DEFAULT (datetime('now')) ); CREATE INDEX IF NOT EXISTS idx_risk_entity ON risk_scores(entity_id, computed_at DESC); CREATE TABLE IF NOT EXISTS audit_log ( id TEXT PRIMARY KEY, action TEXT NOT NULL, entity_id TEXT, detail TEXT, actor TEXT DEFAULT 'engine', created_at TEXT DEFAULT (datetime('now')) );