nat.atof.events#
ATOF event models for the 2 event kinds per spec v0.1.
Standalone Pydantic models for each event kind. The Event type is a
discriminated union keyed on the kind field.
Two event kinds:
ScopeEvent— a scope lifecycle event (start or end, distinguished byscope_category). A start/end pair shares the sameuuid(spec §5.3).MarkEvent— a point-in-time checkpoint, unpaired.
What kind of work an event represents is carried by the category field.
Category-specific typed fields are packaged into a single optional
category_profile sub-object (spec §4.4) — model_name for llm,
tool_call_id for tool, subtype for custom, with additional
keys reserved for future categories. category is REQUIRED on
ScopeEvent and OPTIONAL on MarkEvent.
See ATOF spec:
§2 (common envelope), §2.1 (attributes)
§3 (event kinds)
§4 (category vocabulary)
§5 (event stream semantics)
Attributes#
Discriminated union of the 2 ATOF event kinds, keyed on |
Classes#
Common fields shared by all ATOF event types (spec §2). |
|
Scope lifecycle event (spec §3.1). |
|
Point-in-time checkpoint (spec §3.2). |
Functions#
|
Normalize an |
|
Enforce §4.2: when |
|
Extract the discriminator value from a raw dict or model instance. |
Module Contents#
- _ATOF_VERSION_PATTERN#
- _canonicalize_attributes(v: Any) list[str]#
Normalize an
attributesfield to a sorted, deduplicated list of strings.Accepts either a list of strings or
FlagsStrEnum members. Unknown flag names are preserved — the spec requires consumers to round-trip them.
- _require_subtype_when_custom( ) None#
Enforce §4.2: when
category == "custom",category_profile.subtypeis REQUIRED.
- class _EventBase(/, **data: Any)#
Bases:
pydantic.BaseModelCommon fields shared by all ATOF event types (spec §2).
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class ScopeEvent(/, **data: Any)#
Bases:
_EventBaseScope lifecycle event (spec §3.1).
A single scope span produces two
ScopeEventinstances sharing the sameuuid: one withscope_category: "start"when the scope is pushed onto the active scope stack, and one withscope_category: "end"when the scope is popped.Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- kind: Literal['scope'] = 'scope'#
- scope_category: Literal['start', 'end'] = None#
- _validate_category_subtype_coherence() Self#
- class MarkEvent(/, **data: Any)#
Bases:
_EventBasePoint-in-time checkpoint (spec §3.2).
Unpaired (no start/end semantics). MAY carry
category+category_profileto indicate the kind of work the checkpoint relates to; when both are absent, the mark is a generic named timestamp. Does NOT carryscope_categoryorattributes.Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- kind: Literal['mark'] = 'mark'#
- _validate_category_subtype_coherence() Self#
- _reject_scope_only_fields() Self#
- Event#
Discriminated union of the 2 ATOF event kinds, keyed on
kind(spec §3).