History is kept by flow id: runs, cascades, rollups and events file the id in their flow column and nodes as <flow id>.<node>, the API answers flow plus flow_name and shows and takes nodes as <key>.<node>; events carry flow_id from the moment they are published; run queue items, the stage cache and cached curves keep ids and keys apart; endpoints, the brain graph, device bindings and search name the id to open

This commit is contained in:
2026-11-02 19:01:19 +01:00
parent e6027af8fe
commit d4a1b1db47
34 changed files with 1374 additions and 329 deletions
+15 -7
View File
@@ -3,7 +3,7 @@ from datetime import UTC, datetime
from typing import Any
from pydantic import EmailStr
from sqlalchemy import JSON, Column, Index
from sqlalchemy import JSON, Column, Index, String
from sqlmodel import Field, SQLModel
from fluksio.core.types import UTCDateTime
@@ -237,7 +237,8 @@ class MetricBucket(SQLModel, table=True):
__tablename__ = "metric_minute"
flow: str = Field(primary_key=True, max_length=255)
flow_id: str = Field(sa_column=Column("flow", String(255), primary_key=True))
#: ``<flow id>.<node>``.
node: str = Field(primary_key=True, max_length=255)
bucket: datetime = Field(
primary_key=True,
@@ -273,7 +274,9 @@ class EngineEvent(SQLModel, table=True):
)
#: node_error, flow_quarantined, engine_degraded, …, or audit.
type: str = Field(max_length=32, index=True)
flow: str = ""
#: The flow's id, empty for the engine as a whole.
flow_id: str = Field(default="", sa_column=Column("flow", String, nullable=False))
#: ``<flow id>.<node>``, or empty.
node: str = ""
#: The error and its traceback, or what an audit entry says was done.
detail: str = ""
@@ -298,7 +301,9 @@ class FlowRun(SQLModel, table=True):
#: The queue entry id, a `manual-` one for a run that never queued, or the
#: `Run.id` of a batch run.
id: str = Field(primary_key=True, max_length=64)
flow: str = Field(index=True, max_length=255)
flow_id: str = Field(
sa_column=Column("flow", String(255), index=True, nullable=False)
)
#: What caused it: the work item's cause, "manual", or "run" for a batch.
source: str = ""
#: The run this one continues: on a rate-limit flush, the run whose value
@@ -345,7 +350,9 @@ class Run(SQLModel, table=True):
)
id: str = Field(primary_key=True, max_length=64)
flow: str = Field(index=True, max_length=255)
flow_id: str = Field(
sa_column=Column("flow", String(255), index=True, nullable=False)
)
#: The flow document this ran, and the commit it was read at, so a result
#: can be traced back to the code that produced it.
flow_version: int = 1
@@ -390,8 +397,9 @@ class Run(SQLModel, table=True):
)
#: Where it was asked for: api, cli, sdk, hook, sweep, import or train.
cause: str = Field(default="api", max_length=32)
#: The node it was asked for from, as `flow.node`: the wren node a
#: training run is for. Null for every other run.
#: The node it was asked for from, as ``<flow id>.<node>``: the wren node a
#: training run is for, in another flow than the run's own. Null for every
#: other run.
for_node: str | None = Field(default=None, max_length=255)
#: Re-execute every node, whatever the stage cache holds for it.
no_cache: bool = False