Files
at-container-registry/pkg/appview
Evan JarrettandClaude Opus 5 ff0942196e db: cover the orphan drop in 0034, the case production actually presents
TestMigration0034PreservesLayersAndReferences seeds no orphan and says why: the
live foreign key refuses to create one, so the migration's join through
manifest_id is "insurance for a database whose foreign keys were off at some
point, not for anything reachable now".

Production is that database. It carries 160 layers and 22 manifest_references
pointing at manifests.id values that no longer exist, left by deletes performed
under mattn/go-sqlite3, where the constraint the DDL declared was not enforced.
libSQL turns foreign keys on by default and mattn did not, so the rows predate
the driver swap. The insurance is load-bearing on the only database that
matters, and nothing tested it.

The new case rebuilds the pre-0034 shape with the child foreign keys absent,
which is what that era's schema behaved like, and seeds three orphaned layers
and two orphaned references beside live ones. It asserts the orphans are gone,
the live rows survive attached to the right key, nothing lands keyless, and
foreign_key_check is clean afterwards.

Verified against the defect: with the child manifest_key made nullable and the
joins turned into LEFT JOINs, all five orphans survive and the test fails on
both counts. Recorded honestly, the two guards are redundant with each other —
LEFT JOIN alone still drops them, because INSERT OR IGNORE swallows the NOT NULL
violation. Only removing both carries an orphan forward, and such a row counts,
selects, and joins to no manifest ever again.

Confirmed on a copy of the production database: layers 18803 -> 18643 and
manifest_references 2175 -> 2153, exactly the rows the join excludes, with
manifests unchanged at 3864.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011rmjvU2gSRL9wFnmqVsWaF
2026-08-25 16:34:26 -05:00
..
2026-05-09 21:21:20 -05:00
2026-01-04 22:39:48 -06:00
2026-01-06 23:56:17 -06:00
2026-02-03 20:35:13 -06:00