When accepting previously recorded state (digests, coverage manifests, etc.), revalidate it against the current computed/authoritative data before proceeding. If the value no longer matches, fail fast with a message that tells the user exactly what to do next. If you tighten validation rules, preserve backward compatibility by versioning the stricter behavior (or adding legacy/empty allowances) so older artifacts aren’t rendered unusable.
Example (digest revalidation with clear failure):
def require_committed_diff_digest(target, base, head, content_digest=None):
current = committed_diff_content_digest(target, base, head)
if content_digest and content_digest != current:
raise SystemExit(
"The committed changes selected for review no longer produce the same "
"diff. Select the changes to review again."
)
return current
Example (compatibility-aware validation):