judgevet.media_audit

Status: draft.

judgevet.media_audit

Build explicit keyed media provenance without retaining request content.

Equal inputs under one key leak equality. Callers own key custody and rotation. Revision metadata describes caller declarations, not verified preprocessing. Source: https://github.com/Alberto-Codes/judgevet/issues/203#issuecomment-5851443210.

Examples:

from judgevet import Noul
from judgevet.media import ImageEvidence
from judgevet.media_audit import media_provenance

value = media_provenance(
    ImageEvidence([], {}), {"q": Noul()}, fingerprint_key=b"example-only-key"
)
assert value.attachments == ()
See Also

MediaProvenance dataclass

Snapshot fingerprints and opaque caller-declared revision identifiers.

Attributes:

Name Type Description
attachments Sequence[tuple[str, str]]

Ordered immutable ID/digest pairs.

by_question Mapping[str, Sequence[str]]

Immutable ordered associations.

evidence_fingerprint str

Keyed digest of the entire evidence snapshot.

request_fingerprint str

Keyed digest of normalized question definitions.

prompt_revision str | None

Caller-declared opaque prompt revision.

provider_identity str | None

Caller-declared provider identity.

preprocessing_revision str | None

Caller-declared preprocessing revision.

Examples:

value = MediaProvenance((), {}, "a" * 64, "b" * 64)
assert value.attachments == ()

__post_init__()

Validate fields and detach all collection aliases.

Raises:

Type Description
ValueError

A digest, attachment or association is malformed.

TypeError

Revision metadata is neither a string nor None.

media_provenance(evidence, questions, *, fingerprint_key, prompt_revision=None, provider_identity=None, preprocessing_revision=None)

Fingerprint evidence and questions for an existing caller-owned audit record.

This helper emits no record, observes no retries and estimates no usage. State fingerprints remain separate. Use opaque IDs and revision identifiers.

Parameters:

Name Type Description Default
evidence ImageEvidence

Immutable ordered evidence snapshot.

required
questions Mapping[str, Question | Mapping[str, Any]]

Typed or raw question definitions with original instructions.

required
fingerprint_key bytes

Explicit caller-owned nonempty bytes key.

required
prompt_revision str | None

Optional caller-declared prompt revision.

None
provider_identity str | None

Optional caller-declared provider identity.

None
preprocessing_revision str | None

Optional caller-declared preprocessing revision.

None

Returns:

Type Description
MediaProvenance

Immutable metadata and keyed fingerprints without raw request content.

Raises:

Type Description
TypeError

Evidence, key, metadata or JSON content has an invalid type.

ValueError

Key is empty or definitions, Unicode or JSON values are invalid.