topmark.pipeline.machine.envelopes¶
topmark / pipeline / machine / envelopes
Machine-output envelope builders for processing and probe commands.
This module composes machine-readable output shapes for pipeline runs
(topmark check, topmark strip, and topmark probe).
It is intentionally:
- console-/Click-free (no printing, no CLI concerns)
- serialization-free (no json.dumps)
Responsibilities:
- JSON: build a single top-level envelope containing meta, config,
config_diagnostics, and either processing data (results / summary) or
probe data (probes).
- NDJSON: yield a stream of per-record mappings following the project's
NDJSON contract (Pattern A: every record includes kind and meta), starting
with config prefix records and followed by processing records (result /
summary) or probe records (probe).
Where config diagnostics are included, this module exposes the flattened compatibility view derived from staged config-validation logs.
See Also:
- topmark.pipeline.machine.payloads:
domain payload fragments for processing and probe runs.
- topmark.core.machine.envelopes:
shared envelope/record helpers (build_json_envelope, build_ndjson_record,
config prefix and diagnostic record generators).
build_probe_results_json_envelope ¶
Build the JSON envelope for resolution probe results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared metadata payload ( |
required |
config
|
FrozenConfig
|
The effective |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
Resolved TOML sources used to build the optional layered provenance export. |
required |
results
|
list[ProcessingContext]
|
Ordered list of probe contexts. The list may include normal file-backed probe contexts and synthetic contexts for explicit inputs filtered before file-type probing. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
JSON-serializable envelope mapping (not yet serialized to JSON). |
Source code in src/topmark/pipeline/machine/envelopes.py
iter_probe_results_ndjson_records ¶
Yield NDJSON records for resolution probe results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared metadata payload ( |
required |
config
|
FrozenConfig
|
Effective configuration instance. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources, |
required |
results
|
list[ProcessingContext]
|
Ordered list of probe contexts. The list may include normal file-backed probe contexts and synthetic contexts for explicit inputs filtered before file-type probing. |
required |
Yields:
| Type | Description |
|---|---|
dict[str, object]
|
Shaped NDJSON record mappings for config prefix records, config diagnostics, |
dict[str, object]
|
and one |
Source code in src/topmark/pipeline/machine/envelopes.py
build_processing_results_json_envelope ¶
Build the JSON envelope for processing results (check/strip).
Detail mode (summary_mode=False) produces a per-file results list:
{
"meta": ...,
"config": <ConfigPayload>,
"config_diagnostics": <ConfigDiagnosticsPayload>,
"results": [ <per-file result dict> ... ]
}
Summary mode (summary_mode=True) produces a flat summary-row list:
{
"meta": ...,
"config": <ConfigPayload>,
"config_diagnostics": <ConfigDiagnosticsPayload>,
"summary": [
{"outcome": "unchanged", "reason": "no changes needed", "count": 3},
{"outcome": "would insert", "reason": "header missing, changes found", "count": 1}
]
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared metadata payload ( |
required |
config
|
FrozenConfig
|
The effective |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources, |
required |
results
|
list[ProcessingContext]
|
Ordered list of per-file processing contexts. |
required |
summary_mode
|
bool
|
If True, emit flat summary rows instead of per-file results. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
A JSON-serializable envelope mapping (not yet serialized to a JSON string). |
Source code in src/topmark/pipeline/machine/envelopes.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
iter_processing_results_ndjson_records ¶
Yield NDJSON records for processing results (check/strip).
The NDJSON stream is emitted in a stable order:
1) kind="config" record
2) kind="config_diagnostics" record (counts-only)
3) zero or more kind="diagnostic" records for flattened compatibility config diagnostics
4) then either:
- summary mode: one kind="summary" record per (outcome, reason) bucket
- detail mode: one kind="result" record per processed file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared metadata payload ( |
required |
config
|
FrozenConfig
|
Effective configuration instance. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources, |
required |
results
|
list[ProcessingContext]
|
Ordered list of per-file processing contexts. |
required |
summary_mode
|
bool
|
Whether to emit summary records instead of per-file result records. |
required |
Yields:
| Type | Description |
|---|---|
dict[str, object]
|
Shaped NDJSON record mappings (not yet serialized). Each yielded record |
dict[str, object]
|
includes |