app.domain.values

Value types shared by record parsing, relationships and storage.

Public API: RecordKind, TitleSource, LinkType, Links (to_dict / from_dict for the stored JSON shape), Identity and record_key().

class app.domain.values.RecordKind(*values)

Bases: StrEnum

Kind of ADR record.

DECISION = 'decision'
ERRATUM = 'erratum'
class app.domain.values.TitleSource(*values)

Bases: StrEnum

Where the display title came from.

FRONTMATTER = 'frontmatter'
H1 = 'h1'
FILENAME = 'filename'
class app.domain.values.LinkType(*values)

Bases: StrEnum

Outbound relationship types, named as written in frontmatter.

UPDATES = 'updates'
OBSOLETES = 'obsoletes'
CORRECTS = 'corrects'

Bases: object

Outbound UUID relationships of one record.

Parameters:
  • updates (tuple[UUID, ...]) – Earlier decisions this record updates.

  • obsoletes (tuple[UUID, ...]) – Decisions this record replaces (includes the legacy deprecates value).

  • corrects (UUID | None) – The decision this erratum corrects, if any.

updates: tuple[UUID, ...]
obsoletes: tuple[UUID, ...]
corrects: UUID | None
pairs()

List every outbound link with its type, in a stable order.

Return type:

tuple[tuple[LinkType, UUID], ...]

Returns:

(link type, target UUID) pairs.

to_dict()

Convert to the JSON-serialisable shape stored in record.links.

Return type:

dict[str, list[str] | str | None]

Returns:

{"updates": [...], "obsoletes": [...], "corrects": uuid-or-None} with UUIDs as strings.

classmethod from_dict(data)

Rebuild links from to_dict() output.

Parameters:

data (Mapping[str, object]) – Stored mapping; missing keys mean no links.

Return type:

Links

Returns:

The links.

Raises:

ValueError – If a stored UUID is malformed.

class app.domain.values.Identity(source_id, project, record_key)

Bases: object

Logical identity of an ADR: record key within registration + project.

Parameters:
  • source_id (str) – Source registration id.

  • project (str) – Owning project path.

  • record_key (str) – UUID string or fallback key (record_key()).

source_id: str
project: str
record_key: str
app.domain.values.record_key(adr_uuid, source_id, project, path)

Compute the stable record key used in the logical identity.

Parameters:
  • adr_uuid (UUID | None) – Authored UUID, if valid.

  • source_id (str) – Source registration id.

  • project (str) – Owning project path.

  • path (str) – File path inside the project.

Return type:

str

Returns:

The lowercase UUID string, or src:<source_id>/<project>/<path> when there is no valid UUID. A UUID is never invented.