topmark.pipeline.machine.payloads ¶
Payload builders for pipeline-related machine-readable output.
This module contains pure helpers that build the payload fragments used by
pipeline machine-readable output for check, strip, and probe.
Scope:
These helpers do **not**:
- add `"meta"` / `"kind"` envelopes,
- choose between JSON vs NDJSON record layout,
- serialize (`json.dumps`) or print.
They only construct the domain payload shapes consumed by envelope builders
in [`topmark.core.machine.envelopes`][topmark.core.machine.envelopes]
(JSON envelopes and NDJSON records).
Naming conventions:
- `build_*_payload(...) -> <payload object>`: constructs an eager payload object.
- `iter_*_payload_items(...) -> Iterator[...]`: yields payload items lazily.
Probe payloads:
Probe payloads are built from durable `ProcessingResult.probe` snapshots and include
both ordinary file-type probe results and synthetic filtered results for
explicit inputs excluded during discovery before file-type probing.
build_probe_result_payload ¶
Build a machine payload for one durable resolution probe result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
ProcessingResult
|
Durable processing result containing a probe snapshot. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
JSON-compatible probe result payload preserving the existing probe shape. |
Source code in src/topmark/pipeline/machine/payloads.py
iter_probe_results_payload_items ¶
Yield per-path resolution probe payloads for machine-readable output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
Iterable[ProcessingResult]
|
Ordered durable probe results. The list may contain normal file-backed probe results and synthetic results for explicit inputs filtered before file-type probing. |
required |
Yields:
| Type | Description |
|---|---|
dict[str, object]
|
One probe result payload per durable result, in the same order. |
Source code in src/topmark/pipeline/machine/payloads.py
build_processing_result_payload ¶
Build a machine payload for one durable processing result.
The processing result remains status- and outcome-oriented. Retained unified
diff text is moved out of the generic detail snapshot and rendered as an
optional first-class diff payload on the per-file result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
ProcessingResult
|
Durable per-file processing result. |
required |
include_diff
|
bool
|
Whether to include the unified diff in the payload. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
JSON-compatible processing result payload without embedded |
dict[str, object]
|
|
dict[str, object]
|
payload includes |
Source code in src/topmark/pipeline/machine/payloads.py
build_embedded_processing_diff_payload ¶
Build an embedded JSON diff payload for one processing result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
ProcessingResult
|
Durable per-file processing result. |
required |
Returns:
| Type | Description |
|---|---|
EmbeddedProcessingDiffPayload | None
|
Embedded diff payload when a retained unified diff is available, |
EmbeddedProcessingDiffPayload | None
|
otherwise |
Source code in src/topmark/pipeline/machine/payloads.py
build_standalone_processing_diff_payload ¶
Build a standalone NDJSON diff payload for one processing result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
ProcessingResult
|
Durable per-file processing result. |
required |
Returns:
| Type | Description |
|---|---|
StandaloneProcessingDiffPayload | None
|
Standalone diff payload when a retained unified diff is available, |
StandaloneProcessingDiffPayload | None
|
otherwise |
Source code in src/topmark/pipeline/machine/payloads.py
build_processing_results_summary_rows_payload ¶
Build a JSON-friendly summary payload for processing results (summary mode).
The returned payload is a flat list of summary rows, each preserving both bucketing axes:
outcomereasoncount
This avoids collapsing distinct reasons inside the same outcome bucket.
This payload is intended for JSON envelopes where the summary is a flat list, e.g.::
"summary": [
{"outcome": "unchanged", "reason": "no changes needed", "count": 3},
{"outcome": "would insert", "reason": "header missing, changes found", "count": 1}
]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
Iterable[ProcessingResult]
|
Ordered iterable of per-file processing results. |
required |
Returns:
| Type | Description |
|---|---|
list[OutcomeSummaryRow]
|
List of |
Source code in src/topmark/pipeline/machine/payloads.py
iter_processing_results_summary_entries ¶
Yield NDJSON-friendly summary rows for processing results.
Each yielded object preserves the full (outcome, reason, count) tuple so
NDJSON summary mode does not collapse sub-buckets inside the same outcome, e.g.:
{"kind": "summary", "meta": {...},
"summary": {"outcome": "unchanged", "reason": "no changes needed", "count": 3}}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
Iterable[ProcessingResult]
|
Ordered iterable of per-file processing results. |
required |
Yields:
| Type | Description |
|---|---|
OutcomeSummaryRow
|
One summary row object per |