flameiq.schema — Data Models
FlameIQ Performance Schema — Version 1.
This module defines the canonical, versioned data contract for all FlameIQ performance snapshots. Schema v1 is stable and immutable — fields will never be removed or renamed. New optional fields may appear in minor patch releases.
All classes use standard-library dataclasses only.
Zero external runtime dependencies in this module.
Schema version: 1 Stability: Production / Stable
- class flameiq.schema.v1.models.Environment(*values)[source]
-
The execution environment for a benchmark run.
- CI = 'ci'
- LOCAL = 'local'
- STAGING = 'staging'
- CUSTOM = 'custom'
- class flameiq.schema.v1.models.LatencyMetrics(mean=None, p50=None, p95=None, p99=None)[source]
Bases:
objectLatency measurements in milliseconds.
At least one field must be provided.
p95is the primary regression signal used by the comparison engine.- Parameters:
- class flameiq.schema.v1.models.Metrics(latency=None, throughput=None, memory_mb=None, cpu_percent=None, custom=<factory>)[source]
Bases:
objectAll performance measurements for a single benchmark run.
At least one metric must be non-null/non-empty.
- Parameters:
latency (LatencyMetrics | None) – Latency breakdown in milliseconds.
throughput (float | None) – Operations or requests per second.
memory_mb (float | None) – Peak memory usage in megabytes.
cpu_percent (float | None) – Average CPU utilisation (0–100).
custom (dict[str, float]) – User-defined numeric metrics. Keys are dotted names.
- latency: LatencyMetrics | None = None
- class flameiq.schema.v1.models.SnapshotMetadata(run_id=<factory>, commit=None, branch=None, timestamp=<factory>, environment=Environment.CI, tags=<factory>)[source]
Bases:
objectContextual metadata attached to a
PerformanceSnapshot.- Parameters:
run_id (str) – UUID4 uniquely identifying this run. Auto-generated.
commit (str | None) – Git commit hash (short or full SHA).
branch (str | None) – Git branch name.
timestamp (datetime) – UTC datetime of the run. Auto-generated if omitted.
environment (Environment) – Execution environment label.
tags (dict[str, str]) – Arbitrary
str → strmetadata for user context.
- environment: Environment = 'ci'
- class flameiq.schema.v1.models.PerformanceSnapshot(metrics, schema_version=1, metadata=<factory>)[source]
Bases:
objectA complete, versioned performance snapshot.
This is the primary data unit in FlameIQ. Every benchmark run produces exactly one
PerformanceSnapshot. Snapshots are immutable in intent — do not mutate after construction.- Parameters:
metrics (Metrics) – All performance measurements for this run.
schema_version (int) – Must be
1for v1 snapshots.metadata (SnapshotMetadata) – Run context (commit, branch, timestamp, etc.).
Example:
snapshot = PerformanceSnapshot( metadata=SnapshotMetadata(commit="abc123", branch="main"), metrics=Metrics( latency=LatencyMetrics(mean=120.5, p95=180.0, p99=240.0), throughput=950.2, memory_mb=512.0, ), )
- metadata: SnapshotMetadata
- __post_init__()[source]
Validate that the snapshot conforms to the expected schema version.
- Return type:
None
- to_dict()[source]
Serialise to a plain
dictsuitable for JSON serialisation.- Returns:
A
dictthat round-trips throughfrom_dict().- Return type:
- classmethod from_dict(data)[source]
Deserialise a
PerformanceSnapshotfrom a plaindict.- Parameters:
data (dict[str, Any]) – A dict as produced by
to_dict(), or a compatible JSON structure conforming to the FlameIQ v1 schema.- Returns:
A validated
PerformanceSnapshot.- Raises:
ValueError – If required fields are missing or invalid.
TypeError – If field types are wrong.
- Return type: