judgevet.domain.media

Status: draft.

judgevet.domain.media

Immutable evidence and static model capability declarations.

Source: https://github.com/Alberto-Codes/judgevet/issues/203#issuecomment-5851219798.

Examples:

from judgevet.domain.media import ImageAttachment, ImageEvidence

image = ImageAttachment("scan", b"opaque", "image/png")
evidence = ImageEvidence([image], {"claim": ["scan"]})
assert evidence.images[0].data == b"opaque"
See Also

ImageAttachment dataclass

An opaque encoded image with a caller-owned identity.

Attributes:

Name Type Description
id str

Nonempty attachment identity.

data bytes

Exact nonempty encoded bytes, never decoded here.

media_type str

Nonempty declared MIME type.

Examples:

image = ImageAttachment("scan", b"opaque", "image/png")

__post_init__()

Validate declarations without interpreting bytes.

Raises:

Type Description
ValueError

An identifier or the byte payload is invalid.

ImageEvidence dataclass

Snapshot ordered images and question associations.

Attributes:

Name Type Description
images tuple[ImageAttachment, ...]

Images in caller order.

by_question Mapping[str, tuple[str, ...]]

Immutable ordered associations.

required frozenset[str]

Questions requiring nonempty evidence at dispatch.

Examples:

evidence = ImageEvidence([], {})

__init__(images, by_question, required=())

Validate structure and take defensive snapshots.

Parameters:

Name Type Description Default
images Sequence[ImageAttachment]

Ordered attachments, each referenced at least once.

required
by_question Mapping[str, Sequence[str]]

Ordered attachment IDs for each associated question.

required
required Collection[str]

Questions whose evidence must be present at dispatch.

()

Raises:

Type Description
ValueError

A shape, identifier, duplicate or association is invalid.

MediaCapabilities dataclass

Static supported formats and ceilings for one selected model.

Attributes:

Name Type Description
image_types frozenset[str]

Declared MIME types.

max_images int

Positive attachment-count ceiling.

max_image_bytes int

Positive per-image byte ceiling.

max_total_bytes int

Positive total byte ceiling.

Examples:

caps = MediaCapabilities({"image/png"})

__init__(image_types, max_images=16, max_image_bytes=8 * 1024 * 1024, max_total_bytes=32 * 1024 * 1024)

Snapshot declarations without acquisition or inference.

Parameters:

Name Type Description Default
image_types Collection[str]

Supported MIME declarations.

required
max_images int

Provider count ceiling.

16
max_image_bytes int

Provider per-image byte ceiling.

8 * 1024 * 1024
max_total_bytes int

Provider total byte ceiling.

32 * 1024 * 1024

Raises:

Type Description
ValueError

Formats or positive integer bounds are malformed.