Runtime configuration¶
runtime ¶
Resolve parsed CLI input into immutable runtime command objects.
This module owns the application-specific boundary between argparse values
and the project's domain APIs. It loads word and candidate files, constructs
TypoGenerationTask
objects, resolves the AutoCorrect2 project directory, and validates paths
before a pipeline starts.
AUTOCORRECT2_PROJECT_DIR_ENV
module-attribute
¶
Environment variable containing the local AutoCorrect2 project path.
DEFAULT_ENV_FILE
module-attribute
¶
DEFAULT_ENV_FILE: Final[Path] = PROJECT_ROOT / '.env'
Project-local dotenv file consulted as the final configuration source.
CommandConfig ¶
CommandConfig = (
TypoGenerationCommand
| AutoCorrect2CheckCommand
| FullPipelineCommand
)
Union of all command objects accepted by the execution layer.
CliConfigurationError ¶
Bases: ValueError
Indicate invalid runtime configuration supplied through the CLI.
Source code in hotstring\cli\runtime.py
40 41 | |
GenerationRuntimeConfig
dataclass
¶
Store resolved inputs shared by typo-generating workflows.
Attributes:
| Name | Type | Description |
|---|---|---|
words |
tuple[str, ...]
|
Ordered, de-duplicated source words. |
tasks |
tuple[TypoGenerationTask, ...]
|
Ordered typo-generation tasks derived from CLI settings. |
config |
TypoGenerationConfig
|
Shared MULTYPO generator configuration. |
n_workers |
int | None
|
Optional process-pool size. |
Source code in hotstring\cli\runtime.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
AutoCorrect2RuntimeConfig
dataclass
¶
Store resolved inputs shared by AutoCorrect2-aware workflows.
Attributes:
| Name | Type | Description |
|---|---|---|
project_dir |
Path
|
Validated AutoCorrect2 project directory. |
write_accepted |
bool
|
Whether accepted candidates may be appended to the generated include file. |
Source code in hotstring\cli\runtime.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
TypoGenerationCommand
dataclass
¶
Represent one standalone typo-generation invocation.
Attributes:
| Name | Type | Description |
|---|---|---|
generation |
GenerationRuntimeConfig
|
Resolved typo-generation inputs. |
report_path |
Path | None
|
Optional report destination. |
Source code in hotstring\cli\runtime.py
81 82 83 84 85 86 87 88 89 90 91 92 93 | |
AutoCorrect2CheckCommand
dataclass
¶
Represent one standalone AutoCorrect2 conflict-check invocation.
Attributes:
| Name | Type | Description |
|---|---|---|
candidates |
tuple[AutoCorrect2CandidateHotstring, ...]
|
Candidate hotstrings supplied directly by the user. |
autocorrect2 |
AutoCorrect2RuntimeConfig
|
Resolved AutoCorrect2 integration settings. |
report_path |
Path | None
|
Optional report destination. |
Source code in hotstring\cli\runtime.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
FullPipelineCommand
dataclass
¶
Represent one composed generation-and-check invocation.
Attributes:
| Name | Type | Description |
|---|---|---|
generation |
GenerationRuntimeConfig
|
Resolved typo-generation inputs. |
autocorrect2 |
AutoCorrect2RuntimeConfig
|
Resolved AutoCorrect2 integration settings. |
report_path |
Path | None
|
Optional combined report destination. |
Source code in hotstring\cli\runtime.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
create_command_config ¶
create_command_config(
namespace: Namespace,
) -> CommandConfig
Convert parsed arguments into one validated command object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
Namespace
|
Namespace returned by
|
required |
Returns:
| Type | Description |
|---|---|
CommandConfig
|
Immutable configuration for the selected workflow. |
Raises:
| Type | Description |
|---|---|
CliConfigurationError
|
If a file, path, environment value, candidate, or domain setting is invalid. |
Source code in hotstring\cli\runtime.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
_create_generation_config ¶
_create_generation_config(
namespace: Namespace,
) -> GenerationRuntimeConfig
Build the shared typo-generation runtime configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
Namespace
|
Parsed command arguments. |
required |
Returns:
| Type | Description |
|---|---|
GenerationRuntimeConfig
|
Resolved generation configuration. |
Source code in hotstring\cli\runtime.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
_create_autocorrect2_config ¶
_create_autocorrect2_config(
namespace: Namespace,
) -> AutoCorrect2RuntimeConfig
Build the shared AutoCorrect2 runtime configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
Namespace
|
Parsed command arguments. |
required |
Returns:
| Type | Description |
|---|---|
AutoCorrect2RuntimeConfig
|
Resolved AutoCorrect2 configuration. |
Source code in hotstring\cli\runtime.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
_load_words ¶
Load, normalize, and de-duplicate source words.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
Namespace
|
Parsed command arguments. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
Ordered source-word tuple. |
Raises:
| Type | Description |
|---|---|
CliConfigurationError
|
If the word source is unreadable or contains no usable words. |
Source code in hotstring\cli\runtime.py
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 | |
_load_candidates ¶
_load_candidates(
namespace: Namespace,
) -> tuple[AutoCorrect2CandidateHotstring, ...]
Load and validate directly supplied candidate hotstrings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
Namespace
|
Parsed command arguments. |
required |
Returns:
| Type | Description |
|---|---|
tuple[AutoCorrect2CandidateHotstring, ...]
|
Candidate tuple in source order. |
Raises:
| Type | Description |
|---|---|
CliConfigurationError
|
If candidate data is missing, malformed, or invalid. |
Source code in hotstring\cli\runtime.py
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 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
_candidate_fields ¶
Extract the three candidate fields from CLI or JSON input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
object
|
Three-value CLI sequence or JSON object. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str, str]
|
Semantic trigger, semantic replacement, and option declaration. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the record shape or a field type is invalid. |
ValueError
|
If a JSON object has missing or unexpected fields. |
Source code in hotstring\cli\runtime.py
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 | |
_resolve_autocorrect2_project_dir ¶
_resolve_autocorrect2_project_dir(
*,
direct_path: Path | None,
explicit_env_file: Path | None,
) -> Path
Resolve the AutoCorrect2 project path by documented precedence.
Resolution stops at the first configured source:
--project-dir;- the process environment;
- an explicitly selected
--env-file; - the project-root
.envfile.
Lower-priority sources are not opened or validated after a higher-priority value is found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direct_path
|
Path | None
|
Optional path supplied directly on the command line. |
required |
explicit_env_file
|
Path | None
|
Optional dotenv file selected on the command line. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Validated absolute AutoCorrect2 project path. |
Raises:
| Type | Description |
|---|---|
CliConfigurationError
|
If no source supplies a usable path or the selected project is invalid. |
Source code in hotstring\cli\runtime.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 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 | |
_project_dir_from_dotenv ¶
Read and validate the AutoCorrect2 path from one dotenv file.
Relative values are interpreted from the dotenv file's directory, making project-local configuration independent of the caller's working directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_file
|
Path
|
Existing dotenv file to read. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Validated absolute AutoCorrect2 project path. |
Raises:
| Type | Description |
|---|---|
CliConfigurationError
|
If the variable is absent, empty, or resolves to an invalid project directory. |
Source code in hotstring\cli\runtime.py
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 | |
_validate_autocorrect2_project_dir ¶
Validate the selected AutoCorrect2 project directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Absolute candidate directory. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The validated path. |
Raises:
| Type | Description |
|---|---|
CliConfigurationError
|
If the directory or a required hotstring source is missing. |
Source code in hotstring\cli\runtime.py
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 | |
_require_input_file ¶
Resolve a CLI path and require an existing regular file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path supplied on the command line. |
required |
label
|
str
|
Human-readable input name used in an error message. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Absolute file path. |
Raises:
| Type | Description |
|---|---|
CliConfigurationError
|
If the path is not an existing regular file. |
Source code in hotstring\cli\runtime.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
_optional_cli_path ¶
Resolve an optional CLI path against the current directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | None
|
Optional path supplied on the command line. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
Absolute path, or |
Source code in hotstring\cli\runtime.py
501 502 503 504 505 506 507 508 509 510 511 | |
_absolute_path ¶
Return an expanded absolute path without requiring it to exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to normalize. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Expanded absolute path. |
Source code in hotstring\cli\runtime.py
514 515 516 517 518 519 520 521 522 523 524 | |
_unique_nonempty_text ¶
Normalize text values and remove duplicates while preserving order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Iterable[str]
|
Text values to normalize. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
Ordered tuple of unique, non-empty stripped values. |
Source code in hotstring\cli\runtime.py
527 528 529 530 531 532 533 534 535 536 537 | |