app.domain.validation

Validation of a loaded frontmatter mapping against the record schema.

parse_fields() validates every known field, applies the legacy mappings (deprecates -> obsoletes, signed-off-by -> legacy sign-off) and collects issues in a stable order. It never raises.

A document is an erratum if and only if its frontmatter has erratum-for. Errata use type, section, reported-by and date instead of decision-date; those fields on a decision are reported as unknown. The retired erratum shape (kind: erratum, any case, or any corrects: key) yields legacy_erratum_format and creates no link. kind is obsolete: kind: decision is reported with the obsolete_kind_field warning and the record stays a normal decision; any other value yields bad_field_type.

An erratum whose erratum-for is its own uuid yields the erratum_targets_itself error and has no corrects link (it is still stored and browseable). updates/obsoletes are decision relationships: on an erratum they are validated, then dropped with the erratum_relationship_ignored warning. Whether erratum-for names another erratum needs the target’s kind and is checked at read time (erratum_target_is_erratum).

Public API: KNOWN_FIELDS, DECISION_FIELDS, ERRATUM_FIELDS, LEGACY_ERRATUM_FIELDS, FieldValues, parse_fields().

app.domain.validation.DECISION_FIELDS = frozenset({'decision-date', 'deprecates', 'obsoletes', 'signed-off-by', 'title', 'updates', 'uuid'})

Frontmatter fields understood on a decision.

app.domain.validation.ERRATUM_FIELDS = frozenset({'date', 'deprecates', 'erratum-for', 'obsoletes', 'reported-by', 'section', 'signed-off-by', 'title', 'type', 'updates', 'uuid'})

Frontmatter fields understood on an erratum.

app.domain.validation.KNOWN_FIELDS = frozenset({'date', 'decision-date', 'deprecates', 'erratum-for', 'obsoletes', 'reported-by', 'section', 'signed-off-by', 'title', 'type', 'updates', 'uuid'})

Frontmatter fields understood by the catalog.

app.domain.validation.LEGACY_ERRATUM_FIELDS = frozenset({'corrects', 'kind'})

Fields of the retired erratum shape (legacy_erratum_format).

class app.domain.validation.FieldValues(adr_uuid, title, decision_date, erratum, links, legacy_signoff, issues)

Bases: object

Validated frontmatter values plus the issues found.

Parameters:
  • adr_uuid (UUID | None) – Record UUID, None if missing or invalid.

  • title (str | None) – Explicit title, if valid.

  • decision_date (date | None) – Authored decision date (the report date for an erratum), if valid.

  • erratum (ErratumHeader | None) – Erratum frontmatter, None for a decision.

  • links (Links) – Outbound links; empty when there is no valid UUID.

  • legacy_signoff (tuple[str, ...]) – Legacy signed-off-by entries.

  • issues (tuple[Issue, ...]) – Issues in a stable order.

adr_uuid: UUID | None
title: str | None
decision_date: date | None
erratum: ErratumHeader | None
legacy_signoff: tuple[str, ...]
issues: tuple[Issue, ...]
classmethod empty()

Build the values used when the frontmatter could not be read.

Return type:

FieldValues

Returns:

Values for a decision with no UUID and no links.

app.domain.validation.parse_fields(data, inferred)

Validate all known frontmatter fields.

Parameters:
Return type:

FieldValues

Returns:

The validated values and issues.