-- A base a build copies into the artifact store is recorded where it is copied (novox/hq ADR 0257). -- -- A build that stands on an image published elsewhere copies it into the store first (ADR 0096, 0097), -- and until now nothing recorded the copy as something the mesh made: the build named it only in what -- it stood on, and a build that failed after copying named it nowhere. So on 2026-10-08 the store held -- 374 manifests of copied bases, in 27 repositories, that the sweep could never let go of, because no -- record said the mesh had put them there (ADR 0189 ยง3). -- -- One row per copy, by the reference as the mesh records it. `build` is the build that first said it -- copied it, whether that build worked or not; `why` is a person's words when the copy was recorded by -- hand (the `mirrors` verb), and empty otherwise. Not a foreign key to build: a build's row may be -- written after its copy is, and a copy recorded by hand has no build. create table artifact_mirrored ( reference text primary key, build text, at timestamptz not null default now(), why text not null default '' ); -- The copies the records already name. A build that worked kept what it stood on, and every reference -- into a module's own `on-` repository there is a copy that build's mirror made: only the -- mirror ever wrote a repository so named (ADR 0097). The earliest build to name each is its maker. insert into artifact_mirrored (reference, build, at) select distinct on (stood_on) stood_on, b.id, b.at from build b, jsonb_array_elements_text(case when jsonb_typeof(b.built_against) = 'array' then b.built_against else '[]'::jsonb end) as stood_on where stood_on ~ '^artifact-store://[a-z0-9][a-z0-9._-]*/on-[a-z0-9_]+@sha256:[0-9a-f]{64}$' order by stood_on, b.at asc, b.id asc on conflict (reference) do nothing;