WorkspaceLayout

Pure path-resolution helpers for the workspace layout described in scenario workflow §2. Subdirectories are created lazily — the resolver methods accept a flag controlling whether to create on miss.

The workspace is the outer layout under user control; the engine's per-model OutputDirectory is the inner layout. See bindOutputDirectory for the bridge that ties them together.

Functions

Link copied to clipboard
fun abbreviate(path: Path, maxLen: Int = 40, userHome: Path = Path.of(System.getProperty("user.home"))): String

Abbreviates a path for compact display in a status bar. Returns the original toString() when shorter than maxLen; otherwise collapses the leading segments to ~/.../ (or .../ when not under the user's home) and keeps the last three segments.

Link copied to clipboard
fun bindOutputDirectory(model: Model, workspace: Path, runId: String, outFileName: String = "kslOutput.txt")

Redirects model's Model.outputDirectory to the workspace's per-run output folder. The engine's excelDir, dbDir, csvDir, plotDir subfolders are auto-created underneath by OutputDirectory's constructor — no engine change required.

Link copied to clipboard
fun configsDir(workspace: Path, createIfMissing: Boolean = false): Path

Resolves <workspace>/configs/, optionally creating it.

Link copied to clipboard
fun outputDir(workspace: Path, runId: String, createIfMissing: Boolean = false): Path

Resolves <workspace>/output/<runId>/, optionally creating it.

Link copied to clipboard
fun reportsDir(workspace: Path, runId: String, createIfMissing: Boolean = false): Path

Resolves <workspace>/reports/<runId>/, optionally creating it.

Link copied to clipboard
fun runId(scenariosFileName: String? = null, timestamp: Instant = Instant.now()): String

Builds a sortable, filesystem-safe runId. When scenariosFileName is non-null its stem (no extension) is prepended after sanitization; any character outside [A-Za-z0-9._-] is replaced with _.