topmark.config.machine.serializers¶
topmark / config / machine / serializers
Serialization helpers for config-related machine-readable output.
This module turns shaped config records/envelopes into JSON or NDJSON strings.
Responsibilities
- Validate that the requested format is a supported machine-readable format.
- Delegate envelope construction to
topmark.config.machine.envelopes. - Delegate JSON/NDJSON string rendering to
topmark.core.machine.serializers.
This module is intentionally I/O-free: it returns strings (JSON) or iterators of strings (NDJSON lines) for the CLI layer to print.
serialize_config ¶
Serialize the effective FrozenConfig snapshot in a machine-readable format.
Shapes
- JSON, default:
- JSON, with provenance:
- NDJSON, default:
- NDJSON, with provenance: {"kind": "config_provenance", "meta": ..., "config_provenance": ...}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Machine-output metadata (tool/version). |
required |
config
|
FrozenConfig
|
Immutable runtime configuration to serialize. |
required |
fmt
|
OutputFormat
|
Target machine-readable format (JSON or NDJSON). |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
Resolved TOML sources for optional provenance export. |
required |
show_config_layers
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
str | Iterator[str]
|
A pretty-printed JSON string, or an iterator of NDJSON lines, depending on |
str | Iterator[str]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/topmark/config/machine/serializers.py
serialize_config_json ¶
Serialize the effective FrozenConfig snapshot as a JSON envelope.
Shapes
- default:
- with provenance:
{
"meta":
, "config_provenance": , "config": , }
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Machine-output metadata (tool/version). |
required |
config
|
FrozenConfig
|
Immutable runtime configuration to serialize. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
Resolved TOML sources for optional provenance export. |
required |
show_config_layers
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Pretty-printed JSON string (no trailing newline). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/topmark/config/machine/serializers.py
serialize_config_ndjson ¶
Serialize the effective FrozenConfig snapshot as NDJSON.
Record sequence
- default:
1) {"kind": "config", "meta":
, "config": } - with provenance:
1) {
"kind": "config_provenance",
"meta":
, "config_provenance": , } 2) {"kind": "config", "meta": , "config": }
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Machine-output metadata (tool/version). |
required |
config
|
FrozenConfig
|
Immutable runtime configuration to serialize. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
Resolved TOML sources for optional provenance export. |
required |
show_config_layers
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
Iterator[str]
|
Iterator of NDJSON lines (no trailing newline). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/topmark/config/machine/serializers.py
serialize_config_diagnostics ¶
Serialize FrozenConfig diagnostics in a machine-readable format.
Shapes
- JSON: one envelope object: {"meta": ..., "config_diagnostics": ...}
- NDJSON: counts-only record + streamed diagnostic records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Machine-output metadata (tool/version). |
required |
config
|
FrozenConfig
|
Immutable runtime configuration providing diagnostics. |
required |
fmt
|
OutputFormat
|
Target machine-readable format (JSON or NDJSON). |
required |
Returns:
| Type | Description |
|---|---|
str | Iterator[str]
|
Rendered JSON string or iterable of NDJSON lines (no trailing newline). |
Raises:
| Type | Description |
|---|---|
ValueError
|
if |
Source code in src/topmark/config/machine/serializers.py
serialize_config_diagnostics_json ¶
Serialize FrozenConfig diagnostics as a JSON envelope.
Shape
{"meta":
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Machine-output metadata (tool/version). |
required |
config
|
FrozenConfig
|
Immutable runtime configuration providing diagnostics. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Pretty-printed JSON string (no trailing newline). |
Source code in src/topmark/config/machine/serializers.py
serialize_config_diagnostics_ndjson ¶
Serialize FrozenConfig diagnostics as NDJSON.
Record sequence
1) config_diagnostics (counts-only) 2+) diagnostic (domain="config") one per diagnostic
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Machine-output metadata (tool/version). |
required |
config
|
FrozenConfig
|
Immutable runtime configuration providing diagnostics. |
required |
Returns:
| Type | Description |
|---|---|
Iterator[str]
|
Iterator of NDJSON lines (no trailing newline). |
Source code in src/topmark/config/machine/serializers.py
serialize_config_check ¶
Serialize topmark config check results in a machine-readable format.
JSON
- One envelope: meta, config, config_diagnostics (full), summary.
NDJSON record sequence
1) config 2) config_diagnostics (counts-only) 3) summary (command="config", subcommand="check") 4+) diagnostic (domain="config") one per diagnostic
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Machine-output metadata (tool/version). |
required |
config
|
FrozenConfig
|
Immutable runtime configuration providing diagnostics. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
Resolved TOML sources used to include TOML-authored writer options in the config payload. |
required |
strict
|
bool
|
If True, warnings are treated as failures. |
required |
ok
|
bool
|
Whether the config passed validation |
required |
fmt
|
OutputFormat
|
Target machine-readable format (JSON or NDJSON). |
required |
Returns:
| Type | Description |
|---|---|
str | Iterator[str]
|
Rendered JSON string or iterator of NDJSON lines (no trailing newline). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/topmark/config/machine/serializers.py
serialize_config_check_json ¶
Serialize topmark config check results as a JSON envelope.
Shape
{"meta": ..., "config": ..., "config_diagnostics": ..., "summary": ...}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Machine-output metadata (tool/version). |
required |
config
|
FrozenConfig
|
Immutable runtime configuration providing diagnostics. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
Resolved TOML sources used to include TOML-authored writer options in the config payload. |
required |
strict
|
bool
|
If True, warnings are treated as failures. |
required |
ok
|
bool
|
Whether the config passed validation |
required |
Returns:
| Type | Description |
|---|---|
str
|
Pretty-printed JSON string (no trailing newline). |
Source code in src/topmark/config/machine/serializers.py
serialize_config_check_ndjson ¶
Serialize topmark config check results as NDJSON.
Record sequence
1) config 2) config_diagnostics (counts-only) 3) summary 4+) diagnostic (domain="config") one per diagnostic
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Machine-output metadata (tool/version). |
required |
config
|
FrozenConfig
|
Immutable runtime configuration providing diagnostics. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
Resolved TOML sources used to include TOML-authored writer options in the config payload. |
required |
strict
|
bool
|
If True, warnings are treated as failures. |
required |
ok
|
bool
|
Whether the config passed validation |
required |
Returns:
| Type | Description |
|---|---|
Iterator[str]
|
Iterator of NDJSON lines (no trailing newline). |