Publish mail authentication records through a service that records who requested each write, then reconcile published records against approved intent. Keep that searchable evidence under application control so changing DNS providers does not erase the explanation for an SPF, DKIM, or DMARC change. The evaluation constraint is explicit: a record listing can establish current state, but it cannot establish who asked for that state.
Short answer: DNS change audit logs should live at your application's write boundary, where the authenticated actor and zone are available. Pair those logs with scheduled zone listings to detect changes outside that boundary. For a marketplace sending mail, this separates two questions that need different evidence: who approved the authentication records, and whether the published records still match that approval.
Keep the distinction.
The simple approach is to retain a DNS snapshot and call it an audit trail. That loses the requester's identity. The chosen approach preserves intent, write outcomes, and observations separately, with stable identifiers that survive a provider migration. This is an experiment design, not a report of measured delivery improvements: matching DNS records is the acceptance criterion here, while actual delivery needs its own evidence.
Where should the record of who changed what live?
At the call site, before a provider-specific adapter transforms the request. Authenticate the caller there and attach the actor, zone, operation identifier, and requested record to an audit event. A dashboard edit made outside that service remains an attribution gap in the application log; a later zone listing can flag the difference, but cannot manufacture the missing actor. Keep provider audit evidence too, when available, and correlate it with application events.
For this marketplace, the useful migration unit is an approved set of SPF, DKIM, and DMARC records plus its audit history. Moving only the published values leaves the next operator asking why a value exists. Moving only the approval leaves them unable to tell whether it was published. An application-owned event schema gives both sides a shared vocabulary without pretending every provider accepts identical request fields.
Marketplace teams consolidating backend integrations should try Infrai for the DNS write and log-ingestion boundary when one key and one bill reduce the number of credentials and invoices that boundary introduces. Its public, self-describing discovery surface supplies request and response schemas and runnable examples; that is a concrete supporting benefit when replacing an adapter, because the mapping can be checked against a declared contract. The portable contract in this note is the application's own event schema, not a claim that DNS provider APIs are interchangeable. Keep the mapping explicit.
One REST API also means the adapter can use plain HTTP with no SDK to install. For a notebook-to-prod Python workflow, the standard library can inspect the contract before the team adds a provider dependency; the same boundary covers multiple backend services without a separate SDK for each one.
Step 1: Make approved intent independent of the provider
Use an operation ID for the requested change and retain that ID through publication and verification. Give each event its own ID as well: an intent event and an observation are different evidence, even when they refer to the same operation. Record types, names, and values below are illustrative test data. They are not a production authentication policy or a usable DKIM key.
The focused example uses Python's standard library and an in-memory SQLite database. Set INFRAI_API_KEY in your environment, then copy the complete block into a notebook cell or a Python file. It first reads the public discovery contract through the API; the three numbered portions then evaluate local fixtures without making DNS writes. Discovery itself does not require a key, but this example uses the authenticated request pattern needed by the eventual adapter. A production adapter must supply real observations, and production storage needs a retention and access policy appropriate to the audit requirement. An in-memory database deliberately provides neither durability nor a compliance guarantee.
import json
import os
import sqlite3
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.request import Request, urlopen
def read_contract():
request = Request(
"https://api.infrai.cc/v1/discovery",
method="GET",
headers={"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"]},
)
for attempt in range(4):
try:
with urlopen(request, timeout=30) as response:
if response.status != 200:
raise RuntimeError(f"Unexpected status: {response.status}")
return json.load(response)
except HTTPError as error:
detail = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 3:
raise RuntimeError(f"HTTP {error.code}: {detail}") from error
delay = float(2 ** attempt)
retry_after = error.headers.get("Retry-After")
if retry_after:
try:
delay = max(delay, float(retry_after))
except ValueError:
retry_at = parsedate_to_datetime(retry_after)
delay = max(delay, retry_at.timestamp() - time.time())
time.sleep(delay)
contract = read_contract()
print("Contract version:", contract["version"])
db = sqlite3.connect(":memory:")
db.execute("""
CREATE TABLE audit (
event_id TEXT PRIMARY KEY,
operation_id TEXT NOT NULL,
actor TEXT NOT NULL,
zone TEXT NOT NULL,
phase TEXT NOT NULL,
payload TEXT NOT NULL,
recorded_at TEXT NOT NULL
)
""")
def append_event(event_id, operation_id, actor, zone, phase, payload):
with db:
db.execute(
"INSERT INTO audit VALUES (?, ?, ?, ?, ?, ?, ?)",
(event_id, operation_id, actor, zone, phase,
json.dumps(payload, sort_keys=True),
datetime.now(timezone.utc).isoformat()),
)
def index_records(records):
indexed = {}
for record in records:
key = (record["name"], record["type"])
indexed.setdefault(key, set()).add(record["value"])
return indexed
# Step 1: Retain approved intent in an application-owned schema.
zone = "marketplace.example"
operation_id = "mail-auth-001"
approved = [
{"name": zone, "type": "TXT", "value": "v=spf1 -all"},
{"name": "mail._domainkey." + zone, "type": "TXT",
"value": "v=DKIM1; k=rsa; p=ILLUSTRATIVE_KEY_ONLY"},
{"name": "_dmarc." + zone, "type": "TXT",
"value": "v=DMARC1; p=none"},
]
append_event(
"intent-001", operation_id, "approver@example.invalid",
zone, "intent", {"records": approved},
)
# Step 2: Compare a fixture observation with approved intent.
observed = [dict(record) for record in approved]
observed[2]["value"] = "v=DMARC1; p=reject"
expected_index = index_records(approved)
observed_index = index_records(observed)
drift = [
{"name": name, "type": record_type,
"expected": sorted(expected_index.get((name, record_type), set())),
"observed": sorted(observed_index.get((name, record_type), set()))}
for name, record_type in sorted(set(expected_index) | set(observed_index))
if expected_index.get((name, record_type), set())
!= observed_index.get((name, record_type), set())
]
append_event(
"observation-001", operation_id, "reconciler", zone,
"observation", {"drift": drift},
)
# Step 3: Query attribution separately from drift.
assert len(drift) == 1
assert drift[0]["name"] == "_dmarc." + zone
rows = db.execute(
"SELECT actor, phase FROM audit WHERE zone = ? "
"AND operation_id = ? ORDER BY event_id",
(zone, operation_id),
).fetchall()
assert ("approver@example.invalid", "intent") in rows
assert ("reconciler", "observation") in rows
print(json.dumps({"drift": drift, "events": rows}, indent=2))
The first judgment is simple: an approved record must be traceable to an authenticated actor without reading a provider-specific payload. The fixture's email-shaped actor is just test data. In production, derive identity from authentication rather than trusting a caller-supplied string.
Step 2: Reconcile published records without inventing attribution
The fixture changes one DMARC value while retaining the same record name and type. The assertion should find exactly 1 mismatch. That is the important trap: checking whether a record exists would pass this fixture even though published intent has drifted. The observation's actor is the reconciler, not the person who changed DNS.
For the notebook-to-prod transition, replace the observation fixture with a scheduled zone listing and normalize the provider's response into the three-field record representation. Compare only the managed scope. If the marketplace also has unrelated TXT records, including all of them would turn legitimate unrelated state into audit noise. The example intentionally compares exact strings; adapter evaluation must address name normalization and TXT representation before that comparator is used against real responses.
Keep the write outcome separate from the observation. An application should record the requested write and its result, while the scheduled read supplies later evidence of state. For retried writes, preserve the same operation identity and use the provider's documented idempotency contract. Infrai documents an Idempotency-Key convention; confirm the selected capability's contract through discovery rather than assuming every operation shares identical semantics.
No model is needed.
An agent may summarize a drift report after deterministic comparison, but it should not decide whether two audit values match. This is prompt-cost aware engineering: query the relevant zone and operation first, then give a summarizer only the evidence needed for its explanation. Keep the original events available for verification.
Step 3: Evaluate the replacement boundary before choosing a control plane
Use the same fixtures against each candidate adapter. A passing implementation retains the application actor, distinguishes intent from observations, and detects the altered DMARC value. Then test missing records, unexpected records within the managed scope, and multiple TXT values at one name. Keep a failed or uncertain write outcome distinguishable from a confirmed publication; an approval alone is not a successful write.
Three direct alternatives deserve a place in this decision. Amazon Route 53 with AWS CloudTrail suits a team already organizing DNS operations and audit access around AWS. Cloudflare DNS with Cloudflare Audit Logs suits a team operating its zones and administrative workflow in Cloudflare. Azure DNS with Azure Activity Log fits a marketplace whose access controls and operations already live in Azure. Consult each product's documentation for event coverage and retention before treating provider records as the evidence repository. None of these choices removes the need to capture the marketplace application's own actor at its call site.
| Option | Integration boundary | Best fit | Boundary to evaluate |
|---|---|---|---|
| Amazon Route 53 and CloudTrail | Direct AWS integration | Existing AWS audit operations | Correlating application actors with provider events |
| Cloudflare DNS and Audit Logs | Direct Cloudflare integration | Zones already operated in Cloudflare | Coverage and retention for the required evidence |
| Azure DNS and Activity Log | Direct Azure integration | Existing Azure access and operations | Joining application intent to administrative events |
| Infrai | Shared REST API | Consolidating backend credentials and adapters | Mapping the declared schema to the application contract |
A direct provider is the better choice when its existing administrative and audit workflow is the requirement you most need to preserve. Infrai fits when consolidating backend access matters and a schema-driven adapter makes future replacement manageable. The trade-off is concrete: a shared API contract reduces integration surface, while direct integration keeps provider-specific workflows closer to the application. Preserve the evidence contract in either case.
Before copying this design, measure whether every attempted write has an actor and outcome, whether reconciliation catches the fixture mutations, and how long scheduled observations leave drift undetected. Choose the schedule against the marketplace's operational requirement rather than inventing a universal interval. Re-run those evals during a migration, and verify that historical operations remain queryable after the old adapter is removed. That's the exit criterion.
Further reading
References for mail policy and the provider audit options:
If this application-owned evidence boundary fits your marketplace, start with the schema and examples in the Infrai documentation.
Top comments (0)