topmark.pipeline.machine.serializers¶
topmark / pipeline / machine / serializers
Pure JSON/NDJSON serializers for TopMark processing and probe machine-readable output.
This module is intentionally console- and Click-free: it takes already-shaped processing/probe envelopes or record streams and produces serialized strings (or streams of strings).
Responsibilities: - JSON: serialize a single, already-shaped processing or probe envelope mapping. - NDJSON: serialize a stream of already-shaped processing or probe record mappings as newline-delimited JSON (one JSON object per line).
Creation of envelopes (adding meta/kind, selecting container keys, etc.) happens in
topmark.pipeline.machine.envelopes, using shared helpers
from topmark.core.machine.envelopes.
Payload normalization for JSON-compatibility is handled by
topmark.core.machine.schemas.normalize_payload.
serialize_probe_results ¶
Serialize resolution probe results in a machine-readable format.
Probe results may include normal file-backed probe contexts and synthetic contexts for explicit inputs filtered during discovery before file-type probing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared machine-readable output metadata payload. |
required |
config
|
FrozenConfig
|
Effective configuration for the run. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources, |
required |
results
|
list[ProcessingContext]
|
Ordered list of probe contexts to serialize. |
required |
fmt
|
OutputFormat
|
Output format ( |
required |
Returns:
| Type | Description |
|---|---|
str | Iterator[str]
|
Serialized JSON string or iterator of NDJSON strings. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/topmark/pipeline/machine/serializers.py
serialize_processing_results ¶
Serialize processing results for check / strip in a machine-readable format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared machine-readable output metadata payload. |
required |
config
|
FrozenConfig
|
Effective configuration for the run. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources, |
required |
results
|
list[ProcessingContext]
|
Ordered list of per-file check/strip processing contexts. |
required |
fmt
|
OutputFormat
|
Output format ( |
required |
summary_mode
|
bool
|
If True, emit aggregated outcome summaries instead of per-file entries. |
required |
Returns:
| Type | Description |
|---|---|
str | Iterator[str]
|
|
str | Iterator[str]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/topmark/pipeline/machine/serializers.py
serialize_processing_results_json ¶
Serialize processing results for check / strip in a machine-readable format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared machine-readable output metadata payload. |
required |
config
|
FrozenConfig
|
Effective configuration for the run. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources, |
required |
results
|
list[ProcessingContext]
|
Ordered list of per-file check/strip processing contexts. |
required |
summary_mode
|
bool
|
If True, emit aggregated outcome summaries instead of per-file entries. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Single pretty-printed JSON string (no trailing newline). |
Source code in src/topmark/pipeline/machine/serializers.py
serialize_processing_results_ndjson ¶
Serialize processing results for check / strip in a machine-readable format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared machine-readable output metadata payload. |
required |
config
|
FrozenConfig
|
Effective configuration for the run. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources, |
required |
results
|
list[ProcessingContext]
|
Ordered list of per-file check/strip processing contexts. |
required |
summary_mode
|
bool
|
If True, emit aggregated outcome summaries instead of per-file entries. |
required |
Returns:
| Type | Description |
|---|---|
Iterator[str]
|
Iterator of JSON strings (one per record), where each yielded string has |
Iterator[str]
|
no trailing newline. The caller controls line joining and whether a final |
Iterator[str]
|
newline is printed. |