Name and time the raw SQL in cmd/artifact-registry, and sweep cmd/ for unnamed statements
Split from #1606 (closed) (gap 4). Parent epic: &24088. Follows #1208 (closed), which covered internal/ only.
Problem
Two statements in the composition root run outside any named timer, and no sweep test covers cmd/:
cmd/artifact-registry/bulk_enqueuer.go:220:tx.QueryRowContext(ctx, "SELECT now()"), the bulk-delete acceptance time.cmd/artifact-registry/remote_eviction_enqueuer.go:69:tx.QueryRowContext(ctx, "SELECT statement_timestamp()"), the remote-eviction acceptance time.
The transaction around the first one (cmd/artifact-registry/bulk_enqueuer.go:110) is also unnamed. It belongs to #1720 (closed), not to this issue.
Evidence
Research base: origin/main at e2c420456, 2026-10-25.
git grep -n "QueryRowContext\|ExecContext\|QueryContext" origin/main -- 'cmd/**/*.go' ':!*_test.go'returns exactly these two lines.TestEveryStatementIsInstrumented(internal/datastore/queries_test.go:494) andTestEveryStatementIsTimed(internal/storage/queries_test.go:247) read only their own package's sources.- !3474 (merged) (
60cc2b95d, #1208 (closed)) moved the raw-SQL sites ininternal/toInstrumentQueryErr. It did not touchcmd/.
Fix direction
- Move both reads into
internal/datastore, for example asReadTransactionClock(ctx, tx, …)or two small methods. Give them catalog names such asclock_select_nowandclock_select_statement_timestamp. They then pass throughinstrumentQueryand the existing sweep, and the startup seeding picks them up (cmd/artifact-registry/main.go:307). TheErrEnqueueUnavailablewrap stays incmd/. - Add a source sweep in
cmd/artifact-registrythat rejects anydatabase/sqlexecution verb (QueryContext,QueryRowContext,ExecContext,PrepareContext) in a non-test file. Leave an explicit allowlist hook, empty today.
Acceptance criteria
- Both acceptance-time reads are published under catalog names, with errors and cancellations booked.
- A new
tx.QueryRowContextin a non-testcmd/file fails the sweep test. - Each moved function keeps its doc comment about which clock it reads and why. The
now()versusstatement_timestamp()distinction atremote_eviction_enqueuer.go:65survives the move. - The cardinality audit passes. The catalog grows by two names.
Size and fit
About 150-250 Go lines. This fits one smurfit unit.
Dependencies
None. The bulk_enqueuer.go:110 transaction is timed by #1720 (closed).
Edited by Pawel Rozlach