A scheduled comparison should report a tenant's DNS migration as verified only when a complete observation agrees with the intended records. A zone appearing in a list is too little evidence. For a customer support team moving zones off a registrar-specific API, the useful result is a migration acceptance report that preserves the difference between missing records, conflicting records, and records that could not be checked.
TL;DR: Join the tenant table to a complete zone inventory, then compare the relevant published records against versioned intent. Treat incomplete collection as unknown. The example below uses Python; a Node.js scheduled job can use the same input contract and comparison rules.
The experiment constraint is deliberately strict: an unavailable observation must never produce a clean bill of health. This is a proposed acceptance exercise, with synthetic fixtures rather than production measurements. Its simplest candidate compares tenant domain names with zone names. That candidate cannot satisfy the constraint because membership says nothing about the record values the tenant intended to publish.
Keep those layers separate.
How should a scheduled job reconcile the tenant table against live DNS?
Start with the customer's support operation. A tenant has an expected support hostname and an expected mail authentication policy. During migration, those expectations need to survive the move away from the registrar-specific interface. The primary question is whether published state still matches intent; the number of zones successfully copied is only an intermediate observation.
For this design, define three inputs. Intent is a tenant-owned, revisioned set of desired records. Inventory is the collector's list of managed zones, with an explicit completeness flag. Publication evidence is a separate observation of the record sets the migration needs to preserve. These are application contracts: the collector has to implement them, and the reconciler must refuse to infer publication from inventory alone. In particular, the list returned by a management interface should not be relabeled as an independent observation of published DNS.
A domain-name intersection would make a tempting notebook cell. It's short, legible, and useful for spotting an obviously absent zone. But consider a listed zone whose observed TXT value differs from the tenant's requested value. The intersection is unchanged. So is its reassuring count.
That's the trap.
Mail authentication makes this distinction concrete. RFC 7489 describes discovery of a DMARC policy through DNS TXT records at a name formed with the _dmarc prefix. Its policy-discovery rules also address multiple remaining candidate records: discovery does not proceed by arbitrarily selecting a convenient one. A migration report should therefore retain the observed record set instead of collapsing it into the first string returned by a collector. The RFC supplies the mail-policy semantics; the migration's acceptance rules still need to state which records are in scope.
The report should answer a narrower question than “is this domain healthy?” A matching DMARC fixture doesn't establish that support messages will be delivered, that all mail authentication passes, or that a support application is reachable. Each of those would require additional evidence.
A focused experiment: preserve the evidence through the join
Use two synthetic tenants to exercise the boundary. Tenant help-east expects a monitoring policy, and tenant help-west expects a quarantine policy. Both zones appear in the inventory. The published observation for the second tenant still contains the monitoring policy, so the report must identify a value mismatch despite successful inventory membership.
These policy strings are comparison fixtures, not a recommendation about which enforcement policy a customer support team should deploy. Selecting a policy requires its own mail assessment.
The code deliberately accepts plain data. A notebook can supply fixtures; a scheduled worker can supply collected snapshots. Neither environment gets permission to silently turn an incomplete read into an empty collection. A Node.js worker could emit the same fields as JSON and keep collection in the existing runtime while this Python example serves as an executable acceptance specification.
def reconcile(tenants, inventory, publication): if not inventory["complete"] or not publication["complete"]: return [{"status": "unknown", "reason": "incomplete_snapshot"}] zones = set(inventory["zones"]) records = publication["records"] findings = [] for tenant in tenants: zone = tenant["zone"] base = { "tenant_id": tenant["tenant_id"], "intent_revision": tenant["revision"], "zone": zone, } if zone not in zones: findings.append({**base, "status": "missing_zone"}) continue for expected in tenant["records"]: key = (expected["name"], expected["type"]) observed = records.get(key) if observed is None: status = "unknown" elif not observed: status = "missing_record" elif sorted(observed) == sorted(expected["values"]): status = "match" else: status = "record_mismatch" findings.append({ **base, "name": expected["name"], "type": expected["type"], "expected": expected["values"], "observed": observed, "status": status, }) return findings tenants = [ { "tenant_id": "help-east", "zone": "east.example", "revision": 7, "records": [{ "name": "_dmarc.east.example", "type": "TXT", "values": ["v=DMARC1; p=none"], }], }, { "tenant_id": "help-west", "zone": "west.example", "revision": 12, "records": [{ "name": "_dmarc.west.example", "type": "TXT", "values": ["v=DMARC1; p=quarantine"], }], }, ] inventory = { "complete": True, "zones": ["east.example", "west.example"], } publication = { "complete": True, "records": { ("_dmarc.east.example", "TXT"): ["v=DMARC1; p=none"], ("_dmarc.west.example", "TXT"): ["v=DMARC1; p=none"], }, } findings = reconcile(tenants, inventory, publication) assert [item["status"] for item in findings] == [ "match", "record_mismatch" ] partial = {**publication, "complete": False} assert reconcile(tenants, inventory, partial)[0]["status"] == "unknown" Read the collector contract carefully. An absent key means the name was not successfully observed. An empty list means a successful observation returned no values for that key. Those meanings are assigned by this example; they aren't assumptions about a registrar's response format. An adapter must preserve them explicitly, including when a lookup fails or an inventory collection stops early.
The TXT values here are already assembled logical strings. The collector must handle DNS representation before providing these values. This comparator checks exact equality after sorting the lists; it doesn't parse DMARC, validate policy syntax, or determine semantic equivalence between differently written policies. That restriction is useful for a migration acceptance test because an intentional textual change remains visible for review.
It also costs something. Exact matching can send harmless differences to a human reviewer. A semantic comparison may reduce that burden, but only after its normalization rules have fixtures showing which changes are acceptable. Don't normalize case or whitespace across every DNS record type as a shortcut.
This is a small example. Keep it small.
Moving the notebook check into a scheduled migration gate
The notebook-to-prod step is primarily about evidence lifetime. Package the comparison as a deterministic function, and make collection a separate stage. For each scheduled run, store the intent revision, collection start and end times, completeness indicators, and the observation used to reach each finding. A revision number such as 12 in the fixture is an identifier, not proof that intent remained unchanged while the worker was collecting.
Before publishing an acceptance result, check whether the tenant's intent revision still matches the revision the run read. If it changed, mark that result stale and schedule another comparison. Likewise, define a maximum acceptable observation age as an operational policy. A historical match should retain its timestamp; it shouldn't quietly become a statement about the present.
Schedule collection with explicit rules for overlapping runs, bounded retries, and collection deadlines. A practical design can allow only one active collection for a migration scope, or publish results conditionally against a run identifier. The choice depends on the team's scheduling infrastructure. What matters to the report is that a late run cannot overwrite newer evidence merely because it finished last. A retry that exhausts its deadline should produce unknown evidence and preserve the last successful observation separately.
Make the consequence visible. Unknown means the migration hasn't met the acceptance constraint.
For alerting, distinguish a newly observed mismatch from the same unresolved mismatch seen again. Deduplicate notifications using the tenant, intent revision, record identity, and finding. That proposal reduces repeated notifications while leaving an audit trail of observations. Avoid automatically deleting an extra zone just because it has no matching tenant row: establish ownership and migration scope before treating inventory surplus as a cleanup instruction.
The focused function doesn't detect those extra zones. Add a separate reverse-join finding for inventory entries outside the expected scope, and route it to review. Keeping that limitation explicit is more useful than presenting a small comparator as a complete DNS controller.
For a Python AI application, keep the core decision deterministic. An agent may summarize reviewed findings, but it shouldn't decide whether two record sets match. This keeps prompt cost out of the scheduled comparison and leaves the acceptance rule available to an eval harness without requiring a model call.
What should you measure before adopting this gate?
Evaluate the decision boundary before connecting the report to a cutover. Extend the two-tenant fixture with an absent zone, a successfully observed empty record set, an unobserved name, an incomplete inventory, duplicate TXT values, and an intent change during collection. Assert the expected finding for each case. These are proposed acceptance tests, not a claim of measured reliability.
Measure how often the collector returns unknown, how old observations are when acceptance is requested, and how many mismatches require manual review. Keep these dimensions separate. A reduction in mismatch alerts could reflect a better comparison, or it could reflect a collector that stopped observing the records you care about.
Track the work, too: observations per run, run duration, retry volume, and review time. Rechecking every record at the shortest available interval may increase collection work without improving a particular migration decision. Choose cadence from the time the support team can tolerate between an unintended change and its detection, then evaluate whether the collector can meet it.
The acceptance rule should remain easy to explain: a complete, sufficiently recent observation must match the current tenant intent for every required record. Anything else needs a named finding or another observation. That gives the migration a concrete stopping condition and gives the support team an auditable reason to proceed.
References
RFC 7489, especially Sections 6.1 and 6.6.3, defines DMARC policy publication and discovery. It supports the mail-policy example; the reconciliation algorithm and acceptance workflow above are proposed application design.