DEV Community

Jordan Li
Jordan Li

Posted on

Reviewing an Agent's Rollback PR: Rehearse It Before Merge

Illustrative case: an agent opens a PR to reverse an orders migration. It adds a rollback script, a force option, and a test that looks only at exit status. Should the reviewer merge or ask for a change?

The decision

Review the data recovery goal separately from adding a CLI option. Write down which pre-migration schema and data the team expects to recover. A passing process-status assertion never queried these tables.

What to trust

Read each statement against the forward migration. Confirm which tables and columns it changes, which rows any copy-back step selects, and which backup the proposal assumes. Mark any lossy change so that it cannot disappear behind a green check.

What to revert

Keep the force option out of this change until its owner has a separate use case. Replace the status-only test with observations of the target schema and selected records. Record process errors too; they answer a different question.

Test: rehearse on a scratch copy

Use a disposable database with representative data and no unrelated writers. Before changing it, capture the column definitions, a few identifiable rows, counts and a repeatable checksum over a stable ordering of the fields being compared. Record which fields the migration is expected to preserve.

Apply the forward change, then the proposed rollback. Compare the observed state with the stated recovery target. If reapplication is supported, apply the forward change again and verify the resulting schema and rows. In a separate reset copy, run the rollback twice only if the author claims a repeated call is supported. Define the expected second state before the trial.

If a comparison differs, isolate the first step at which it changed. Look for missing or extra records, changed values or different column definitions. A matching row count alone cannot distinguish these cases. Capture the mismatch for the PR before selecting a fix.

If the target is SQLite, repeat the rehearsal with representative concurrent access. SQLite transaction documentation allows concurrent read transactions but only one write transaction at a time. Record what happens if another connection already has the write transaction.

Limits

This proposed rehearsal does not cover backups, replication lag or partial process failure. Document which of those needs a separate test. If the change is intentionally forward-only, name the forward fix and its owner.

This article was created with AI assistance.

Top comments (0)