topmark.config.machine.payloads¶
topmark / config / machine / payloads
Machine-output payload builders for TopMark config commands.
This module contains pure helpers that build strongly-typed payload objects (dataclasses) for config-related machine-readable output.
Responsibilities
- Convert
FrozenConfig/ TOML-derived structures into JSON-friendly values. - Return schema dataclasses from
topmark.config.machine.schemas. - Flatten staged config-validation diagnostics at the machine-output boundary when diagnostics payloads are requested.
This module performs no I/O and does not shape envelopes/records.
build_config_payload ¶
Build a JSON-friendly payload capturing an effective config snapshot.
FrozenConfig contains the layered
TopMark configuration. Resolved writer options are runtime-facing but may
originate from TOML, so callers can pass them here to include the effective
[writer] section in machine-readable config output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FrozenConfig
|
Immutable layered configuration instance. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
Resolved TOML sources used to build the optional layered provenance export. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ConfigPayload |
ConfigPayload
|
JSON-serializable representation of the effective configuration snapshot, without diagnostics. |
Source code in src/topmark/config/machine/payloads.py
build_config_diagnostics_payload ¶
Build a JSON-friendly diagnostics payload for a given FrozenConfig.
Staged config-validation logs are flattened here so machine-readable output keeps exposing the current compatibility diagnostics view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FrozenConfig
|
The |
required |
Returns:
| Type | Description |
|---|---|
ConfigDiagnosticsPayload
|
JSON-serializable diagnostics metadata for the given |
ConfigDiagnosticsPayload
|
Source code in src/topmark/config/machine/payloads.py
build_config_diagnostics_counts_payload ¶
Build a counts-only diagnostics payload for a given FrozenConfig.
Useful when emitting aggregate diagnostic statistics without duplicating per-diagnostic entries. Staged config-validation logs are flattened here at the machine-readable output boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FrozenConfig
|
The |
required |
Returns:
| Type | Description |
|---|---|
MachineDiagnosticCounts
|
JSON-serializable mapping containing only |
MachineDiagnosticCounts
|
|
Source code in src/topmark/config/machine/payloads.py
build_config_check_summary_payload ¶
Build the summary payload for topmark config check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FrozenConfig
|
Immutable layered configuration. |
required |
cfg_diag_payload
|
ConfigDiagnosticsPayload | None
|
Optional precomputed diagnostics payload to avoid recomputation. |
None
|
strict
|
bool
|
Whether warnings are treated as failures. |
required |
ok
|
bool
|
Whether the config passed validation. |
required |
Returns:
| Type | Description |
|---|---|
ConfigCheckSummary
|
A JSON-friendly mapping representing the config-check summary. |