Rollback belongs before merge: a gate that accepts an agent patch should accept its rollback claim—and reject patches whose claim it cannot check.
A patch gate can test forward behavior; rollback claims need equal treatment because model-drafted patches cross more layers than the diff shows.
Two documented behaviors anchor this. A Kubernetes Deployment creates a revision on a Pod template change; scaling alone does not. Rollback restores the Pod template only—not unrelated database changes (Deployment docs). RFC 9110 §9.2.2 permits automatic non-idempotent retries only when semantics allow replay or the original was never applied (RFC 9110).
Steps
Proposed practice: three fields per patch, checked by the gate.
- Reversible layers. Code, config, Pod template. Record image digest and the revision the template change will produce.
- Irreversible layers. Schema migrations, external writes, notifications. Each needs a named mitigation (expand/contract, backup, feature flag) before merge; otherwise rollback overstates what is undone.
- Retry class. If the patch adds an automatic retry, state whether the request is idempotent under RFC 9110. A non-idempotent retry fails the gate unless the author documents replay is permitted or the original was never applied.
The gate checks each irreversible layer for a mitigation and keeps anchors in the verdict.
Test
Check on a non-production cluster; these are verification steps, not recorded results.
- Record revision count after a Pod-template patch, then scale replicas. Expected: count unchanged after scaling.
- Roll back to the prior revision. Expected: Pod template restored.
- If the patch includes a migration, inspect it after rollback. Expected: it remains applied; Deployment rollback does not reverse unrelated database changes.
If data looks reverted after a Deployment rollback, check for a hook or job outside the Deployment; the contract does not cover it. If the Pod template is not restored, verify the recorded revision; if not, capture the anchor at verdict time.
Limits
This applies to patches with versioned, observable state. It is not a backup strategy and does not make irreversible steps safe. Skip it for single-layer patches.
This article was created with AI assistance.