DistributionModelingSession

class DistributionModelingSession(catalog: FittingCatalog = FittingCatalog, importer: DatasetImporter = DatasetImporter.default, scope: CoroutineScope? = null) : AutoCloseable(source)

UX-agnostic facade for distribution-fitting work, parallel to ksl.app.KSLAppSession. UI code (Swing, CLI, REST host, MCP server) holds one session for the application lifetime, submits FitSpec instances through submit, observes the returned FitHandle, and calls close during shutdown.

Quick start (synchronous)

Callers that just want to "run a fit and read the result" — test code or a non-coroutine main — can use submitAndAwaitBlocking and skip coroutines entirely.

Dispatch

Validation runs by default through FitConfigurationValidator; failures return an immediately-failed handle rather than throwing, so the event/result protocol covers every outcome. Successful submissions dispatch to FittingExecutor on the session's coroutine scope.

Lifecycle

Every handle returned by submit is retained on the session so that close can cancel any in-flight fits and release the owned scope when the session created it. close is idempotent.

Constructors

Link copied to clipboard
constructor(catalog: FittingCatalog = FittingCatalog, importer: DatasetImporter = DatasetImporter.default, scope: CoroutineScope? = null)

Functions

Link copied to clipboard
open override fun close()

Cancels any in-flight fits and, when the session owns its scope, cancels that scope. Idempotent.

Link copied to clipboard
fun submit(spec: FitSpec, validate: Boolean = true): FitHandle

Submit a fit for asynchronous execution.

Link copied to clipboard
fun submitAndAwaitBlocking(spec: FitSpec, validate: Boolean = true): FitResult

Synchronously submit and await the terminal FitResult. Bridges the Deferred result into a non-coroutine caller via runBlocking.