Skip to content

Validate --k and --seed in the CLI - #28

Merged
bamdadd merged 1 commit into
bamdadd:mainfrom
dchaudhari7177:fix/validate-k-seed
Jul 22, 2026
Merged

Validate --k and --seed in the CLI#28
bamdadd merged 1 commit into
bamdadd:mainfrom
dchaudhari7177:fix/validate-k-seed

Conversation

@dchaudhari7177

Copy link
Copy Markdown
Contributor

Closes #6.

--k and --seed were parsed as unbounded ints, so leakgauge --k 0 ran zero seeded repeats (a degenerate/empty result) and a negative --seed was accepted too — both failing confusingly downstream instead of giving a clear message.

Change: reject --k < 1 and --seed < 0 in _run, matching the existing --max-steps guard exactly — a clear stderr message naming the flag and return 2, with nothing written. No other logic changes.

Acceptance criteria:

  • leakgauge --k 0 and a negative --seed exit with code 2 and a message naming the offending flag. ✅
  • Valid values still work unchanged. ✅

Tests: added tests/test_cli_validation.py asserting exit code 2 for --k 0, --k -1, and --seed -1 (nothing written), plus a valid --k 2 --seed 0 run still succeeding. Full suite + ruff check/format pass locally.

--k and --seed were parsed as unbounded ints, so `leakgauge --k 0` ran
zero seeded repeats (a degenerate, empty result) and negative values were
accepted too — both failing confusingly downstream.

Reject --k < 1 and --seed < 0 in _run with a clear message naming the
flag, matching the existing --max-steps check (stderr message + return 2,
nothing written). Add test_cli_validation.py covering the rejections and
a valid run.

Closes bamdadd#6
@bamdadd
bamdadd merged commit 4d051c5 into bamdadd:main Jul 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate --k and --seed in the CLI

3 participants