Skip to content

Commit 0665591

Browse files
Kasper JungeRalphify
authored andcommitted
refactor: validate CLI options before file I/O for fail-fast behavior
Move _validate_run_options to the top of _build_run_config so cheap input checks run before reading and parsing RALPH.md. Also fix import ordering in engine.py to follow PEP 8 alphabetical convention. Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent af95b0c commit 0665591

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/ralphify/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ def _build_run_config(
400400
extra_args: list[str] | None = None,
401401
) -> RunConfig:
402402
"""Read RALPH.md from the given path, validate, and build a RunConfig."""
403+
# Validate CLI options first — cheap checks before file I/O.
404+
_validate_run_options(max_iterations, delay, timeout)
405+
403406
ralph_dir, ralph_file = _resolve_ralph_paths(ralph_path)
404407

405408
ralph_text = ralph_file.read_text(encoding="utf-8")
@@ -413,7 +416,6 @@ def _build_run_config(
413416
ralph_args = _parse_user_args(extra_args, declared_names)
414417

415418
credit = _validate_credit(fm.get(FIELD_CREDIT))
416-
_validate_run_options(max_iterations, delay, timeout)
417419

418420
return RunConfig(
419421
agent=agent,

src/ralphify/engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
RunState,
3939
RunStatus,
4040
)
41-
from ralphify._runner import run_command
4241
from ralphify._resolver import resolve_all, resolve_args
42+
from ralphify._runner import run_command
4343

4444

4545
_PAUSE_POLL_INTERVAL = 0.25 # seconds between pause/resume checks

0 commit comments

Comments
 (0)