ai-agents-metrics

Data Invariants

What this document is: Business rules that must always hold for data in metrics/events.ndjson and the replayed in-memory state.

When to read this:

Related docs:


Summary

Invariants are grouped by record type: GoalRecord, AttemptEntryRecord, cross-record rules, and the summary block. The most important rules are: closed goals must have a failure_reason when status=fail; result_fit is only valid on product goals; and every entry must reference an existing goal.


How invariants are enforced

This document is a human-readable summary — keep it in sync when changing validation logic.


GoalRecord

Status rules

Timestamp rules

result_fit rules

Token rules

Field value constraints


AttemptEntryRecord

Status rules

Timestamp rules

Token rules


Cross-record rules


Summary block


Warehouse: derived_projects token coverage invariants

These invariants apply to the derived_projects aggregate table populated by history-derive.