Skip to content

fix(state): repair duplicate migration version 68 - #532

Merged
andrei-hasna merged 1 commit into
mainfrom
fix/a59d3086-migration-version-remediation
Aug 9, 2026
Merged

fix(state): repair duplicate migration version 68#532
andrei-hasna merged 1 commit into
mainfrom
fix/a59d3086-migration-version-remediation

Conversation

@andrei-hasna

@andrei-hasna andrei-hasna commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Rename 0068_usage_profile_leases.sql to the unused 0069_usage_profile_leases.sql without changing its SQL.
  • Add a fresh-state regression that initializes through monitor migration 0068 and usage-profile-leases migration 0069 exactly once.
  • Add an upgrade regression for an existing database already stamped with thread monitor authorization at version 68.

Root cause

PR #528 merged two different SQLx migrations with version 68. Existing databases stamped by the monitor migration can fail with VersionMismatch(68), while fresh databases can collide on _sqlx_migrations(version).

Regression-first evidence

Before the production rename, the migration inventory reported:

migration_files=69
version_68_count=2
version_69_count=0
PRE_FIX_CONTROL: duplicate_68_present_and_69_absent

After the rename:

version_68_count=1
version_69_count=1
POST_FIX_CONTROL: unique_68_and_69_present

The old and new lease-migration files have identical SHA-256 content hashes.

Local lightweight verification

  • cargo fmt -- --config imports_granularity=Item — exit 0; no compilation.
  • git diff --check — exit 0.
  • shield review — exit 0: No security issues found in staged changes.
  • gitleaks git --staged --redact --no-banner . — exit 0: no leaks found.
  • gitleaks git --log-opts='origin/main..HEAD' --redact --no-banner . — one commit scanned, exit 0: no leaks found.

No local Rust or Bazel build/test was run. Exact-head remote affected CI and a full Blacksmith Testbox gate remain required.

Review scope and constraints

This is remediation cycle 1 for Todos task a59d3086-a01e-4152-b315-aee3ca2e470f, limited to the migration-version P1 and direct regressions. Fixed reviewer Erdos will re-review only this named defect, the repair, and direct regressions after exact-head gates are terminal. Do not merge, release, install, or enable Package Arrivals production automation from this PR.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Add fresh and monitor-stamped SQLite regression coverage for the migration sequence.

Agent: quintilianus
@andrei-hasna

Copy link
Copy Markdown
Contributor Author

Superseded by PR #531 for Todos task a59d3086-a01e-4152-b315-aee3ca2e470f. Both candidates implement the same 0068-to-0069 migration repair and StateRuntime fresh/prior-0068 regressions; #531 is the authoritative Beauvoir branch with exact-head CI and full Testbox already running. This close preserves the branch and worktree and prevents duplicate review/merge.

@andrei-hasna

Copy link
Copy Markdown
Contributor Author

Restored as the user-authorized R5 candidate from the existing task worktree and branch. Exact head cb617b4; no merge/release/install. PR #531 is a preserved semantic duplicate and will be closed after this readback.

@andrei-hasna andrei-hasna reopened this Aug 9, 2026
@andrei-hasna
andrei-hasna marked this pull request as draft August 9, 2026 23:01
@andrei-hasna

Copy link
Copy Markdown
Contributor Author

[REVIEW] GO — #532 @ cb617b4 — lens: correctness+security+gates, reviewer Xenon (1 of 1)

Reviewed

  • git log --oneline origin/main..HEAD — exit 0; one commit: cb617b4ca fix(state): give usage profile lease migration a unique version.
  • git diff origin/main...HEAD --stat — exit 0; 2 changed files, 137 insertions, one 100% migration-file rename.
  • Full diff and surrounding source read for codex-rs/state/migrations/0069_usage_profile_leases.sql and codex-rs/state/src/runtime.rs, plus the state migrator, runtime initialization, usage-profile lease implementation/tests, state BUILD.bazel, and state Cargo.toml.
  • Exact base/head readback: base 202ebca08df2bf0f2d489beaf82b79a963aa8cd0, head cb617b4cad0c7bd06efd604a31eb6f0e60e2d526.
  • The target base contains both monitor authorization and usage-profile lease migrations numbered 68. The candidate preserves monitor authorization as 68, moves usage-profile leases to 69, and tests fresh initialization plus upgrade from a database stamped with monitor migration 68.
  • Exact merge-tree check — exit 0; merge tree 7069f127c740e91a8b05ec95c32d21dcbdeca8f1; git diff --quiet HEAD <merge-tree> exit 0.

Commands and gates

  • bun install — exit 0; setup only, 521 packages installed; not a test gate.
  • This repository declares no typecheck script.
  • This repository declares no test script, so it declares no test gate.
  • gh pr view 532 --repo hasna/codewith --json statusCheckRollup — exit 0.
  • Status rollup: 42 SUCCESS, 7 CANCELLED, 5 SKIPPED, 1 FAILURE across the superseded and latest workflow runs. The latest run for every workflow is terminal and successful: Bazel, Blacksmith Testbox, CLA Assistant, Codespell, blob-size-policy, cargo-deny, ci, codewith-cli, rust-ci, and sdk — 10 passed, 0 failed, 0 pending. The prior cancelled jobs and prior Windows Bazel aggregate failure were superseded; the latest Bazel workflow and latest check of the same name are SUCCESS. CI results (required) is SUCCESS in both reported instances.

Every statusCheckRollup check by name and conclusion

  • Argument comment lint - Linux — SUCCESS x2
  • Argument comment lint - Windows — SUCCESS x2
  • Argument comment lint package — SKIPPED x2
  • Bazel clippy on ubuntu-24.04 for x86_64-unknown-linux-gnu — CANCELLED x1; SUCCESS x1
  • Bazel clippy on windows-latest for x86_64-pc-windows-gnullvm — CANCELLED x1; SUCCESS x1
  • Bazel test on ubuntu-24.04 for x86_64-unknown-linux-gnu — CANCELLED x1; SUCCESS x1
  • Bazel test on ubuntu-24.04 for x86_64-unknown-linux-musl — CANCELLED x1; SUCCESS x1
  • Bazel test on windows-latest for x86_64-pc-windows-gnullvm — FAILURE x1; SUCCESS x1
  • Bazel test on windows-latest for x86_64-pc-windows-gnullvm (native main) — SKIPPED x2
  • Bazel test on windows-latest for x86_64-pc-windows-gnullvm shard 1/4 — SUCCESS x2
  • Bazel test on windows-latest for x86_64-pc-windows-gnullvm shard 2/4 — SUCCESS x2
  • Bazel test on windows-latest for x86_64-pc-windows-gnullvm shard 3/4 — CANCELLED x1; SUCCESS x1
  • Bazel test on windows-latest for x86_64-pc-windows-gnullvm shard 4/4 — CANCELLED x1; SUCCESS x1
  • Blob size policy — SUCCESS x2
  • Build Codewith Linux CLI — SUCCESS x2
  • CI results (required) — SUCCESS x2
  • Check for spelling errors — SUCCESS x2
  • Detect changed areas — SUCCESS x2
  • Format / etc — SUCCESS x2
  • Verify release build on ubuntu-24.04 for x86_64-unknown-linux-gnu — CANCELLED x1; SUCCESS x1
  • Verify release build on windows-latest for x86_64-pc-windows-gnullvm — SUCCESS x2
  • [code]smith — SKIPPED x1
  • build-test — SUCCESS x2
  • cargo shear — SUCCESS x2
  • cargo-deny — SUCCESS x2
  • cla — SUCCESS x2
  • python-sdk — SUCCESS x2
  • sdks — SUCCESS x2

Blocking P0/P1 findings

  • None.

Non-blocking follow-ups

  • The repository has no declared test gate or typecheck script. This review did not invent a replacement gate; the forge checks above are the authoritative validation surface for this PR.

@andrei-hasna
andrei-hasna marked this pull request as ready for review August 9, 2026 23:16
@andrei-hasna
andrei-hasna merged commit 9058265 into main Aug 9, 2026
48 of 56 checks passed
@andrei-hasna
andrei-hasna deleted the fix/a59d3086-migration-version-remediation branch August 9, 2026 23:17
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant