RunSummaryWriter

Writer + builder for RunSummary.

All builders are pure functions over the inputs so callers can exercise the projection without filesystem access; write is the only filesystem-touching call.

The TOML encoder delegates to tomlkt with explicitNulls = false, so optional fields with null values are omitted from the encoded file rather than rendered as key = null lines. Round-trip decoding through decode is symmetric — a missing key takes the property's declared default.

Substrate-level API — usable by any UI shell (Swing, web, CLI, text) that wants to materialise an optimization run summary.

Functions

Link copied to clipboard

Round-trip decoder. Lets downstream tooling (a future "compare runs" view, batch result inspection, etc.) load a summary.toml back into the typed model without writing its own parser.

Link copied to clipboard
fun encode(summary: RunSummary): String

Serialise summary to a TOML string, prefixed with the DOCUMENT_HEADER banner. Field order matches the declaration order on RunSummary; per-field @TomlComment annotations are emitted as # lines above each key, making the file self-documenting for anyone cracking it open in a text editor.

Link copied to clipboard
fun forCompleted(config: OptimizationRunConfiguration, result: RunResult.OptimizationCompleted, solverInstance: Solver? = null, runDir: Path? = null): RunSummary

Build a RunSummary from a successful run. solverInstance is the live Solver reference captured before the host cleared its handle — its Solver.configurationProperties are projected into the summary's solverConfiguration field for the [solverConfiguration] TOML block. runDir is the run- output directory path; its leaf name becomes the human- friendly RunSummary.runDirectory identifier.

Link copied to clipboard
fun forIncomplete(config: OptimizationRunConfiguration, status: ResultsStatus, runId: String, startTimeIso: String, endTimeIso: String, elapsedMillis: Long, latestBest: LatestBestSnapshot?, statusReason: String?, solverInstance: Solver? = null, runDir: Path? = null): RunSummary

Build a partial RunSummary for a run that did not complete successfully. latestBest is the best-so-far data the host captured from the last IterationCompleted event; it may be null if the run aborted before any iteration fired.

Link copied to clipboard
fun write(summary: RunSummary, path: Path): Boolean

Encode summary and write to path (creating parent directories as needed). Best-effort — returns true on success, false if the write threw.