topmark.core.machine.payloads¶
topmark / core / machine / payloads
Payload builders for core machine-readable output.
"Payload" here means: the domain object that will be inserted into a JSON envelope (top-level JSON output) or into an NDJSON record (streaming output).
This module is intentionally:
- Click-free
- Console-free
- serialization-free (no json.dumps)
It provides small, stable "global" payloads used across multiple commands:
build_meta_payload(): A minimal{tool, version}mapping. This is stable for the lifetime of the process and is therefore cached.
If a payload needs keys/kinds/domains, import those from
topmark.core.machine.schemas (not from a serializer/emitter).
build_meta_payload
cached
¶
Build the base metadata payload for machine-readable output.
This payload contains process-stable information about the running TopMark instance and is reused across all machine-format serializers.
The result is cached because its content does not change during the lifetime of the process.
Returns:
| Type | Description |
|---|---|
MetaPayload
|
A |
MetaPayload
|
|
MetaPayload
|
|
MetaPayload
|
|
Notes
- This function deliberately excludes output-specific fields such as
detail_level. - Use
with_detail_level()to derive a fullMetaPayloadwhen needed.
Source code in src/topmark/core/machine/payloads.py
with_detail_level ¶
Derive a full machine metadata payload with detail-level information.
This helper augments a cached [BaseMetaPayload] with a
[DetailLevel] derived from CLI options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Base metadata payload (typically from |
required |
show_details
|
bool
|
Whether the CLI is operating in detailed mode
(e.g. |
required |
Returns:
| Type | Description |
|---|---|
DetailedMetaPayload
|
A |
DetailedMetaPayload
|
|
Notes
- This function should be called at the command boundary, where output format decisions are known.
- It keeps
build_meta_payload()pure and cacheable.