feat: add interval projection schema and models

Add time-series tracking tables for animal location, tag, and attribute
history. Each interval represents a period when an animal had a specific
state, with open intervals (end_utc=NULL) for current state.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-28 19:51:28 +00:00
parent 7e9c370c80
commit e3d65283da
4 changed files with 671 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
# ABOUTME: Pydantic models for time-series interval tracking.
# ABOUTME: Tracks animal location, tag, and attribute history over time.
from typing import Literal
from pydantic import BaseModel, Field
class LocationInterval(BaseModel):
"""Represents a period when an animal was at a specific location.
Open intervals (end_utc=None) indicate the animal is still at that location.
"""
animal_id: str = Field(..., min_length=26, max_length=26)
location_id: str = Field(..., min_length=26, max_length=26)
start_utc: int
end_utc: int | None = None
class TagInterval(BaseModel):
"""Represents a period when an animal had a specific tag.
Open intervals (end_utc=None) indicate the tag is still active.
"""
animal_id: str = Field(..., min_length=26, max_length=26)
tag: str
start_utc: int
end_utc: int | None = None
class AttrInterval(BaseModel):
"""Represents a period when an animal had a specific attribute value.
Tracks changes to sex, life_stage, repro_status, and status over time.
Open intervals (end_utc=None) indicate the current attribute value.
"""
animal_id: str = Field(..., min_length=26, max_length=26)
attr: Literal["sex", "life_stage", "repro_status", "status"]
value: str
start_utc: int
end_utc: int | None = None