Skip to content
Claudio Cabrera
Chapter 1 · Component 1 · 24:00src/infrastructure/duckdb_adapter.py

Hexagonal Ingestion Gate & DuckDB Spatial Spine

Alexis King Parse Don't Validate boundary proofs, DuckDB OLAP materialization, and Geodesic K-Means hub synthesis

In This Component

Before formulating stochastic control policies, the orchestrator must establish an uncorrupted empirical spine. Following Alexis King’s “Parse, Don’t Validate” principle, raw dictionaries never cross into the domain core. Every incoming record is parsed at the perimeter into immutable, structurally proven types (ParsedOrder, ParsedOrderLine) verified by hypothesis property-based tests.

High-Performance DuckDB OLAP Materialization

All nine Olist tables totaling 1,550,922 records are ingested into data/aegis_analytics.duckdb in 2.07 seconds behind a strict Hexagonal AnalyticsRepositoryPort. Four normalized analytical views materialize in 0.05 seconds:

Analytical ViewRecord CountKey Engineered Features
v_customer_locations99,441Hierarchical CEP City State coordinate fallback (0% orphans)
v_seller_locations3,095Merchant origin coordinates, historical order throughput, cumulative GMV
v_orders_clean99,441purchase_to_approval_hours, carrier_to_customer_days, delivery_delay_days
v_order_lines112,650Volumetric weight (), English taxonomy, exact Haversine distance

Geodesic Fulfillment Hub Topology

Profiling all 3,095 sellers minimizes geodesic Error Sum of Squares () across five primary Brazilian logistics corridors, producing the vectorized Haversine distance tensor across all 14,994 customer postal clusters in 0.156 seconds (median serving distance , mean ).