topmark.diagnostic.machine.schemas¶
topmark / diagnostic / machine / schemas
Typed payload schemas for machine-readable diagnostics.
This module defines small, JSON-friendly dataclasses used by multiple TopMark domains to represent diagnostics in machine-readable output. These classes belong to the payload layer (schemas → payloads → shapes → serializers):
MachineDiagnosticEntryrepresents a single diagnostic (level + message).MachineDiagnosticCountsrepresents aggregated per-level counts.
The NDJSON shape layer emits one record per internal
Diagnostic. For JSON envelopes, domains
typically prebuild lists of MachineDiagnosticEntry and a
MachineDiagnosticCounts instance.
DiagnosticKey ¶
Bases: str, Enum
Stable keys used by diagnostic machine-readable output payloads.
These keys belong to the shared diagnostic domain and are reused by other machine-readable output packages when embedding lists of diagnostics or aggregate diagnostic counts.
Attributes:
| Name | Type | Description |
|---|---|---|
DIAGNOSTIC_COUNTS |
Container key for aggregate per-level counts. |
|
DIAGNOSTICS |
Container key for a list of diagnostic entries. |
|
LEVEL |
Severity level field for a single diagnostic entry. |
|
MESSAGE |
Human-readable diagnostic text for a single entry. |
|
INFO |
Count key for info-level diagnostics. |
|
WARNING |
Count key for warning-level diagnostics. |
|
ERROR |
Count key for error-level diagnostics. |
DiagnosticKind ¶
Bases: str, Enum
Stable NDJSON record kinds owned by the diagnostic domain.
Attributes:
| Name | Type | Description |
|---|---|---|
DIAGNOSTIC |
One diagnostic record in an NDJSON stream. |
MachineDiagnosticEntry
dataclass
¶
Machine-readable diagnostic entry.
Attributes:
| Name | Type | Description |
|---|---|---|
level |
str
|
Severity level string (e.g. "info", "warning", "error"). |
message |
str
|
Human-readable diagnostic message. |
from_diagnostic
classmethod
¶
Create a machine-readable entry from an internal diagnostic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
Diagnostic
|
Internal diagnostic instance. |
required |
Returns:
| Type | Description |
|---|---|
MachineDiagnosticEntry
|
A |
Source code in src/topmark/diagnostic/machine/schemas.py
to_dict ¶
Return a JSON-friendly dict of this diagnostic entry.
MachineDiagnosticCounts
dataclass
¶
Aggregated per-level counts for machine-readable output.
Attributes:
| Name | Type | Description |
|---|---|---|
info |
int
|
Count of info-level diagnostics. |
warning |
int
|
Count of warning-level diagnostics. |
error |
int
|
Count of error-level diagnostics. |
from_iterable
classmethod
¶
Compute per-level counts from an iterable of internal diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diagnostics
|
Iterable[Diagnostic]
|
Internal diagnostics to aggregate. |
required |
Returns:
| Type | Description |
|---|---|
MachineDiagnosticCounts
|
A |
Source code in src/topmark/diagnostic/machine/schemas.py
to_dict ¶
Return a JSON-friendly dict of the per-level counts.