Skip to content

Commit aef7954

Browse files
committed
ci(lane): derive the migration head from migrations/ instead of hard-coding 18
With W2-PROOF's suites wired in, running the official-binary lane end to end locally surfaced four assertions that hard-coded the Wave-1 migration head of 18. Wave 2 added migrations 0019-0023, so each was stale: - exact successful migration prefix (count/max) - migration history after exact index replay - later success remains visible during failed migration 12 - failed migration 12 is not masked by the head version All four now derive the head from the migrations/ directory, which is the source of truth, so a future wave adding migrations cannot leave this proof asserting a stale prefix. The assertions stay exactly as strict: contiguity from 1, the exact count, and bool_and(success) are all still required -- only the literal "how many" is derived. A floor guards against an empty or implausible migrations directory silently satisfying the check. Verified: full lane green against a live CockroachDB v26.2.3 ("official-binary connected correctness proof passed", 100 connected tests incl. all 44 newly wired Wave-2 proofs). fmt/clippy -D warnings/test --all-targets green (1408 passed, 0 failed); all frozen source pins match. Claude-Session: https://claude.ai/code/session_01BxEBa1v242Fo1AJJGftFnZ
1 parent 31edea8 commit aef7954

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

deploy/cockroach/tests/registry-activation-cli.sh

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,11 +2026,18 @@ FLEET_RECONCILIATION_TEST_DATABASE_URL="$root_url" \
20262026

20272027
# Freeze the authoritative schema independently of the two Stage-2/Stage-3
20282028
# command preflights. The database must have exactly the successful embedded
2029-
# migration chain through 18 and all three successor authority tables.
2030-
assert_root_scalar "exact successful migration prefix 1 through 18" '
2031-
SELECT CASE WHEN count(*) = 18
2029+
# migration chain -- every migration, contiguous from 1, all successful -- and
2030+
# all three successor authority tables. The head is derived from migrations/ so
2031+
# that adding a migration (as every wave does) cannot leave this proof asserting
2032+
# a stale prefix; the contiguity check is what makes the derived count exact.
2033+
migration_head=$(find "$repo_root/migrations" -name '*.sql' | wc -l | tr -d ' ')
2034+
if [ "$migration_head" -lt 18 ]; then
2035+
fail "refusing to run with an implausible migration head: $migration_head"
2036+
fi
2037+
assert_root_scalar "exact successful migration prefix 1 through $migration_head" '
2038+
SELECT CASE WHEN count(*) = '"$migration_head"'
20322039
AND min(version) = 1
2033-
AND max(version) = 18
2040+
AND max(version) = '"$migration_head"'
20342041
AND COALESCE(bool_and(success), false)
20352042
THEN '\''ready'\'' ELSE '\''not_ready'\'' END
20362043
FROM _sqlx_migrations' 'ready'
@@ -2079,19 +2086,19 @@ do
20792086
"$crdb" sql --url="$root_url" < "$migration_path" >/dev/null
20802087
done
20812088
assert_root_scalar "migration history after exact index replay" \
2082-
'SELECT count(*)::STRING FROM _sqlx_migrations' '18'
2089+
'SELECT count(*)::STRING FROM _sqlx_migrations' "$migration_head"
20832090

20842091
# Demonstrate why MAX(successful version) is not a readiness check: version 18
20852092
# remains successful while a failed version 12 makes the complete-prefix gate
20862093
# false. Restore the row before exercising the v3/v9-compatible private CLIs.
20872094
"$crdb" sql --url="$root_url" \
20882095
--execute='UPDATE _sqlx_migrations SET success = false WHERE version = 12' >/dev/null
20892096
assert_root_scalar "later success remains visible during failed migration 12" \
2090-
'SELECT max(version)::STRING FROM _sqlx_migrations WHERE success' '18'
2091-
assert_root_scalar "failed migration 12 is not masked by version 18" '
2092-
SELECT CASE WHEN count(*) = 18
2097+
'SELECT max(version)::STRING FROM _sqlx_migrations WHERE success' "$migration_head"
2098+
assert_root_scalar "failed migration 12 is not masked by the head version" '
2099+
SELECT CASE WHEN count(*) = '"$migration_head"'
20932100
AND min(version) = 1
2094-
AND max(version) = 18
2101+
AND max(version) = '"$migration_head"'
20952102
AND COALESCE(bool_and(success), false)
20962103
THEN '\''ready'\'' ELSE '\''not_ready'\'' END
20972104
FROM _sqlx_migrations' 'not_ready'

0 commit comments

Comments
 (0)