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_stream_json_envelope ¶
Build the probe JSON envelope from durable-result stream events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared metadata payload ( |
required |
config
|
FrozenConfig
|
Effective configuration instance. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources. |
required |
events
|
Iterable[MachineProcessingStreamEvent]
|
Internal machine stream events in deterministic producer order. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
JSON-serializable envelope mapping preserving the existing probe JSON schema. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the stream lifecycle or command identity is invalid. |
Source code in src/topmark/pipeline/machine/envelopes.py
iter_probe_results_stream_ndjson_records ¶
Yield probe NDJSON records from an internal processing stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared metadata payload ( |
required |
config
|
FrozenConfig
|
Effective configuration instance. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources. |
required |
events
|
Iterable[MachineProcessingStreamEvent]
|
Internal machine stream events in deterministic producer order. |
required |
Yields:
| Type | Description |
|---|---|
dict[str, object]
|
Shaped NDJSON records preserving the existing probe machine schema. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the stream contains events for another command, duplicate lifecycle events, missing lifecycle events, file events before start or after completion, or non-contiguous file-result indexes. |
Source code in src/topmark/pipeline/machine/envelopes.py
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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
build_processing_results_stream_json_envelope ¶
build_processing_results_stream_json_envelope(
*, meta, config, resolved_toml, events, summary_mode
)
Build the processing JSON envelope from durable-result stream events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared metadata payload ( |
required |
config
|
FrozenConfig
|
Effective configuration instance. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources. |
required |
events
|
Iterable[MachineProcessingStreamEvent]
|
Internal machine stream events in deterministic producer order. |
required |
summary_mode
|
bool
|
If True, emit flat summary rows instead of per-file results. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, object]
|
JSON-serializable envelope mapping preserving the existing processing JSON schema. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the stream lifecycle or command identity is invalid. |
Source code in src/topmark/pipeline/machine/envelopes.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
iter_processing_results_stream_ndjson_records ¶
iter_processing_results_stream_ndjson_records(
*, meta, config, resolved_toml, events, summary_mode
)
Yield processing NDJSON records from an internal processing stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meta
|
MetaPayload
|
Shared metadata payload ( |
required |
config
|
FrozenConfig
|
Effective configuration instance. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
ResolvedTopmarkTomlSources. |
required |
events
|
Iterable[MachineProcessingStreamEvent]
|
Internal machine stream events in deterministic producer order. |
required |
summary_mode
|
bool
|
Whether to emit summary records instead of per-file result records. |
required |
Yields:
| Type | Description |
|---|---|
dict[str, object]
|
Shaped NDJSON records preserving the existing processing machine schema. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the stream contains events for another command, duplicate lifecycle events, missing lifecycle events, file events before start or after completion, or non-contiguous file-result indexes. |
Source code in src/topmark/pipeline/machine/envelopes.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |