feat(timeline): one record of what happened to the infrastructure, newest first (#6348)
CI / lint (push) Successful in 2s
CI / unit (push) Failing after 1m31s
CI / integration (push) Successful in 1m41s
CI / publish (push) Skipped

A stored log, timeline_entries, with one row per thing that happened. Each
source writes its row in the same transaction as its own record, so the
history outlives the 30/90/365-day retention of the tables it points to:

- alert events (core/alerts._add_event): fired, resolved, acknowledged,
  went silent, readings back;
- finished Ansible runs (executor, and the startup sweep of interrupted
  runs): changed something, changed nothing, failed, dry run;
- audit rows (core/audit.log_audit): Steward's settings, users and access,
  sign-ins, backups. Actions another writer records are left to it.

Entries carry a kind (fixed) and an area (Service, Host OS, Hardware,
Storage, Network, Security, Monitoring). Settings → Timeline edits the
areas and each type's area and visibility; both are applied when the
timeline is read, so a change re-sorts past entries and a hidden type
comes back when shown. Kept forever unless a retention is set.

The first start fills the timeline from the last 90 days of records once,
skipping any already covered. A host rename carries its entries.

UI: Timeline in the sidebar (filter by host, area, kind; scrolls on), a
History card on each host page. MCP: get_timeline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 17:03:05 -04:00
co-authored by Claude Opus 5.5
parent 8e2f17d198
commit 4ea735d87c
36 changed files with 1882 additions and 25 deletions
@@ -0,0 +1,43 @@
"""The timeline: one row per thing that happened to the infrastructure.
Revision ID: 0047_timeline
Revises: 0046_metric_anomalies
Create Date: 2026-10-24
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import ARRAY
revision: str = "0047_timeline"
down_revision: Union[str, None] = "0046_metric_anomalies"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"timeline_entries",
sa.Column("id", sa.String(36), primary_key=True),
sa.Column("at", sa.DateTime(timezone=True), nullable=False),
sa.Column("until", sa.DateTime(timezone=True), nullable=True),
sa.Column("type", sa.String(64), nullable=False),
sa.Column("area", sa.String(32), nullable=False),
sa.Column("hosts", ARRAY(sa.String(128)), nullable=False, server_default="{}"),
sa.Column("subject", sa.String(255), nullable=True),
sa.Column("summary", sa.Text, nullable=False),
sa.Column("detail", sa.JSON, nullable=True),
sa.Column("actor", sa.String(64), nullable=False, server_default="system"),
sa.Column("ref_type", sa.String(32), nullable=True),
sa.Column("ref_id", sa.String(64), nullable=True),
)
op.create_index("ix_timeline_entries_at", "timeline_entries", ["at", "id"])
op.create_index("ix_timeline_entries_hosts", "timeline_entries", ["hosts"],
postgresql_using="gin")
op.create_index("ix_timeline_entries_type", "timeline_entries", ["type"])
op.create_index("uq_timeline_entries_ref", "timeline_entries", ["ref_type", "ref_id"],
unique=True, postgresql_where=sa.text("ref_id IS NOT NULL"))
def downgrade() -> None:
op.drop_table("timeline_entries")