Skip to content

feat(dns): retire DNS records only through a reviewed list - #91

Merged
devantler merged 1 commit into
mainfrom
claude/dns-reviewed-retirements
Nov 25, 2026
Merged

devantler merged 1 commit into
mainfrom
claude/dns-reviewed-retirements

Conversation

@devantler

Copy link
Copy Markdown
Contributor

Why

Company mail moves its MX from iCloud to the platform's mail server (devantler-tech/platform#5481). The cutover changes mail_mx_01 to mail.devantler.tech, an in-place update the guards already allow, and must remove mail_mx_02. The guarded DNS apply refuses every delete today: assert-no-destructive-plan.sh rejects any delete action, and check-dns-plan.jq admits only no-op, create, update and forget. AGENTS.md anticipates reviewed DNS replacements once the import migration is complete, and it is.

What

  • .github/dns-retirements.json, committed empty. A deletion is admitted only for a pure ["delete"] of a managed cloudflare_dns_record that meets all of these:

    • its address is listed;
    • its name (full lower-case form), type and content before the change equal the entry;
    • external-dns does not own it.

    Replacements (delete,create or create,delete) stay refused even when listed. The zone, buckets, zone settings and every other resource type can never be deleted.

  • List rules: at most 20 entries, each with exactly address, name, type and content, and no duplicate addresses. Addresses must be cloudflare_dns_record.<id>. Types must be A, AAAA, CNAME, MX or TXT. A malformed list fails the plan, as the handover list already does.

  • Guards: assert-no-destructive-plan.sh takes the list as an optional second argument; without it, behaviour and output are unchanged. check-dns-plan.jq takes it as --slurpfile retirements. apply-dns.sh checks the file the way it checks the handover list and passes it to both. The state-bootstrap scripts still call the guard without it.

  • Docs: AGENTS.md, the README and the runbook say deletes happen only through this list. Each entry is added in the change that removes its record from dns.tf and removed once the deletion is applied.

This change deletes nothing. The cutover PR will add the mail_mx_02 entry together with the dns.tf edit.

Validation

  • RED first: the new cases failed before the implementation.
  • shellcheck is clean. test-no-destructive-plan.sh passes under sh and dash, and test-dns-apply.sh passes. Cases covered:
    • a listed pure delete passes, as does the real cutover (mx01 updated plus mx02 retired);
    • an unlisted delete is refused;
    • a mismatched content, name, type or address is refused;
    • a listed replacement is refused;
    • deleting the zone, a bucket or a setting is refused;
    • deleting a record external-dns owns is refused;
    • a list of 20 passes and a list of 21 or a malformed list is refused;
    • without the list argument, any delete is refused as before.
  • Ablation: I broke each of the 14 matching and validation rules in turn, and every break failed a test. The files were restored byte for byte.
  • tofu fmt -check, tofu init -backend=false, tofu validate and tofu test pass. test-native-state-migration.sh and native-s3-migration_test.go need OpenTofu exactly 1.12.6, which the local host lacks. They fail the same way on unmodified main and cover a migration script this change does not touch. CI pins 1.12.6.

Separate note: .terraform.lock.hcl on main still says constraints = "5.28.1" for the locked 5.29.0, a leftover from #90. A read-only tofu init accepts it. It deserves its own one-line fix.

Part of devantler-tech/platform#5481.

🤖 Generated with Claude Code

The guarded DNS apply refused every delete, so a reviewed change could not
remove a DNS record, such as the second iCloud MX record the company Email
cutover retires (devantler-tech/platform#5481).

Add .github/dns-retirements.json, committed empty. Each entry names one
record by address, name, type and current content; at most 20 entries with
unique addresses, and a malformed list refuses every run, like the handover
list.

scripts/assert-no-destructive-plan.sh takes the list as an optional second
argument and then admits only a pure delete of a managed DNS record that
matches its entry, reporting how many it admitted. Without the argument it
behaves exactly as before. scripts/check-dns-plan.jq takes the list as
$retirements and admits ["delete"] only for a matching record that
external-dns does not own. Replacements, unlisted deletes and deletes of
anything but a DNS record stay refused. scripts/apply-dns.sh checks the file
like the handover list and passes it to both guards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3f53c1ba-ac1d-44b6-a088-cf87af2f3fbf
Commits

Reviewing files that changed from the base of the PR and between 5d065fd and f11d587.

Files selected for processing: 12

  • .github/dns-retirements.json
  • AGENTS.md
  • README.md
  • docs/runbooks/bootstrap-and-recovery.md
  • scripts/apply-dns.sh
  • scripts/assert-no-destructive-plan.sh
  • scripts/check-dns-plan.jq
  • scripts/tests/fixtures/delete-zone.json
  • scripts/tests/fixtures/retire-mx02.json
  • scripts/tests/fixtures/retirements.json
  • scripts/tests/test-dns-apply.sh
  • scripts/tests/test-no-destructive-plan.sh

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Additional context used

Code guidelines: 1

AGENTS.md — auto-discovered
Path-based instructions: 1

Source excerpt: The guarded DNS apply deletes a DNS record only through `.github/dns-retirements.json`: one reviewed entry per record, naming its `address`, `name`, `type` and current `content`, in the change that removes the record from `d...

CodeRabbit inference engine (AGENTS.md)

Files:

  • .github/dns-retirements.json
ast-grep (0.51.3)

scripts/tests/test-no-destructive-plan.sh

[warning] 17-17: Writing to or reading from a hardcoded, predictable path under /tmp is vulnerable to symlink and TOCTOU attacks: a local attacker can pre-create the file (or a symlink pointing elsewhere) and hijack or corrupt the contents. Generate a unique, unpredictable temporary file with mktemp instead, e.g. tmpfile="$(mktemp)" (or mktemp -d for directories) and reference "$tmpfile".
Context: /tmp/cloudflare-plan-safe.out
Note: [CWE-377] Insecure Temporary File.

(predictable-tmp-file-bash)

Additional comments: 1

scripts/tests/test-dns-apply.sh: 1

248-250: Data Integrity & Integration

The reviewed guards match each retirement entry as one conjunction over address, name, type, and content. A deletion is admitted only when a single listed entry matches all four fields. Field matches from different entries cannot combine, because the list rejects duplicate addresses and the address test filters to one entry. The proposed cross-entry case is refused. No defect remains in the matching logic.

Walkthrough

The DNS plan guards now allow pure deletions of managed DNS records when each deletion matches a reviewed retirement entry. The entry must match the resource address and the record’s prior name, type, and content. Replacements, unlisted deletions, and deletions of non-DNS resources remain refused. The apply script validates the retirement list and passes it to both guards. Documentation, fixtures, and tests describe and verify the workflow.

Possibly related issues

  • devantler-tech/cloudflare issue 21 — The PR adds reviewed DNS-record deletions to the guarded apply path, but its committed retirement list is empty and it does not complete the broader roadmap items.
Merge Risk: Minimal · up to f11d5

This change lets DNS-record deletions through the plan guards only when a reviewed list entry matches the record exactly. Replacements and other deletions stay refused. The list is committed empty, so nothing is deleted by this change. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(dns): retire DNS records only through a reviewed list" names the main change: DNS record deletions are now allowed only through a reviewed retirement list, as the summaries and objecti…
Description check Passed The description explains why the change is needed (the MX cutover from iCloud to the platform mail server and the need to remove mail_mx_02). It also lists what changed in the guards, the list rules, …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(dns): retire DNS records only through a reviewed list" names the main change: DNS record deletions are now allowed only through a reviewed retirement list, as the summaries and objectives describe. It is specific and concise, and it does not include file lists or vague terms.

Full details: Description check

Explanation

The description explains why the change is needed (the MX cutover from iCloud to the platform mail server and the need to remove mail_mx_02). It also lists what changed in the guards, the list rules, and the docs, and it gives validation details. It matches the changeset closely.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@devantler

Copy link
Copy Markdown
Contributor Author

Ready at f11d5875.

  • Tested: all required checks are green, including Validate, which runs scripts/test.sh on the pinned OpenTofu 1.12.6, with the native-state steps that could not run locally. The new guard tests failed before the implementation and pass now. Breaking each of 14 matching and validation rules in turn made a test fail every time.
  • Reviewed: CodeRabbit reports no actionable comments and minimal merge risk at f11d5. coderabbit-summary-verdict.sh returns GREEN, and no threads are open.
  • Evaluated: I ran the guard from the command line, as apply-dns.sh does, on plan fixtures. The real cutover shape (mail_mx_01 updated in place, mail_mx_02 retired) passes only with a matching entry. The same plan is refused without the list, with a mismatched entry, or as a replacement.
  • Effect of merging: the list is empty, so this merge deletes nothing, and DNS changes only through the confirmed dispatch. The MX cutover PR will add the mail_mx_02 entry once the mailbox history copy has been verified (Deliver company Email transport and migrate mailbox history platform#5481).

🤖 Generated with Claude Code

@devantler
devantler marked this pull request as ready for review November 25, 2026 00:48
@devantler
devantler merged commit 4eeb50e into main Nov 25, 2026
16 checks passed
@devantler
devantler deleted the claude/dns-reviewed-retirements branch November 25, 2026 01:42
@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

Verified signed merge 4eeb50e42280. The main-branch required checks, CodeQL, and Code Quality passed on that revision. Required checks · CodeQL · Code Quality

I also ran the retirement guard and DNS apply fixture suites from the merged source. They rejected unlisted deletions and replacements and accepted the reviewed retirement fixture. The merged retirement list is empty. These checks exercised the guard with fixtures. Any live retirement requires its own reviewed list and protected apply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant