Fan-In Distributions in Human-Written vs AI-Generated Python Codebases: A Constructal Law Analysis

Bilar, Daniyel Yaacov · 2026-05-20 · publication/preprint · cc-by-4.0

This PDF (v1.0.0, superseded): https://doi.org/10.5281/zenodo.20313669
Latest (v1.1): 10.5281/zenodo.22908061 · concept 10.5281/zenodo.20313668
Download this PDF (Zenodo): open

Abstract

Import fan-in, the count of intra-repo modules that import a given file, encodes hierarchical coupling structure. By analogy with Constructal flow systems (Bejan 1997), we hypothesize that finite networks shaped by iterative optimization develop log-normal, not power-law, size distributions. We measure fan-in across 15 mature Python OSS projects (Cohort A) and 22 AI-attributed repositories created 2024-2026 (Cohort B, identified by AI attribution signals in commits, config files, or READMEs; these skew toward single-author short-lifespan projects). In Cohort A, 14/15 show log-normal fan-in (model-selection z > 1.96, Gini mean 0.882). In Cohort B, three repos (88, 92, and 30 files) show total isolation with zero intra-repo imports (Gini=0.000), 7 more are too small or inaccessible to fit, and among 12 fitted repos Gini mean is 0.725 (Mann-Whitney p = 0.0011, r = -0.744). We term this the agentic flattening effect. We note a partial framework confound: at least three Cohort B repos are FastAPI-style backends whose thin-router design independently reduces intra-repo coupling. An exploratory longitudinal pilot on N=2 mature repos (Celery, Django) before and after documented AI adoption detects no Gini decline on a 12-month horizon (Celery: +0.0016, p=0.031 in the direction opposite to flattening). With N=1 effective repo and no matched control, this pilot lacks the power to adjudicate between a structural-genesis hypothesis (flattening confined to new-project construction) and a null AI-adoption effect on mature codebases. The cross-sectional flattening, if confirmed in larger samples, implies that architectural maintainability risk from AI coding concentrates at project inception, where no prior hierarchy constrains the agent.

Keywords

fan-in · constructal law · software metrics · Gini coefficient · log-normal distribution · AI-generated code · Github · Python · software architecture

← All research