cellmap_flow.ai_annotate.audit

A record of every AI annotation: what was sent where, and what became of it.

Each event is one JSON line in <corrections_dir>/ai_annotate_log.jsonl, next to the volumes it concerns, so whoever reviews a dataset’s annotations can see which labels a hosted model drew, with which prompt, and that data left the building for it. A line holds the time, the user, the event and the fields the caller gives, nothing else: callers pass ids, the provider and model, the plane and counts, never a credential. As a second guard each line goes through secrets.redact before it is written.

Attributes

logger

LOG_NAME

EVENTS

Functions

log_path(corrections_dir) → pathlib.Path

The audit log of the volumes in corrections_dir.

record(corrections_dir, event, **fields) → None

Append {"time", "user", "event", **fields} to the audit log.

Module Contents

cellmap_flow.ai_annotate.audit.logger
cellmap_flow.ai_annotate.audit.LOG_NAME = 'ai_annotate_log.jsonl'
cellmap_flow.ai_annotate.audit.EVENTS = ('requested', 'staged', 'failed', 'resent', 'accepted', 'rejected')
cellmap_flow.ai_annotate.audit.log_path(corrections_dir) → pathlib.Path

The audit log of the volumes in corrections_dir.

cellmap_flow.ai_annotate.audit.record(corrections_dir, event: str, **fields) → None

Append {"time", "user", "event", **fields} to the audit log.

event is one of EVENTS. Values that are not JSON (numpy numbers, paths) are written as their str. Raises OSError when the log cannot be written: the caller decides whether that stops the action.