fix(cli): guard --max-action-delta against invalid explicit values#155
Merged
jeqcho merged 2 commits intoJul 21, 2026
Merged
Conversation
An explicit --max-action-delta that is non-finite or non-positive was caught by _build_guardrails's degrade-per-component except ValueError and downgraded to a stderr warning, so the run proceeded on clamp-only guardrails instead of the clamp + delta-limit chain the operator asked for. That degrade path is correct for a *derived* default an embodiment's space can't support; it should not also swallow a malformed explicit value, which is a CLI input error. - Validate args.max_action_delta in _check_shared_run_conflicts, which already runs before component resolution in both run and eval-set and already houses the sibling --disable-guardrails conflict check. A non-finite or non-positive value now exits with a guided SystemExit before anything resolves or energizes. - argparse's type=float means the CLI value is always a plain float, so DeltaLimitApprover._validate_max_delta's other failure mode (array broadcast) can only be reached via the Python API, not this flag; no change needed there. - Derived-limit degradation (no explicit flag, an embodiment declaring no bounds) is untouched: verified manually and via the existing test_cli_degraded_guardrails_warn_but_run, which passes no explicit --max-action-delta and still warns-and-continues. - Add parametrized tests for run and eval-set (-1, 0, inf, nan) and a CHANGELOG entry under Unreleased -> Fixed.
Collaborator
|
Merged, thank you @Tushar2604. Two things stood out. Putting the guard in Good hunting on this one. More where it came from is always welcome. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An explicit invalid
--max-action-deltasilently weakened guardrails instead of erroring.The bug:
_build_guardrailswrapsDeltaLimitApprover(space, max_delta=max_action_delta)in a blanketexcept ValueErrorand degrades to a stderr warning for any failure.0— silently, unless they are watching stderr.Changes
args.max_action_deltain_check_shared_run_conflicts, which already runs before component resolution in bothrunandeval-set, and already houses the sibling--disable-guardrailsconflict check. A non-finite or non-positive value now exits with a guidedSystemExitbefore anything resolves or energizes._build_guardrailsorDeltaLimitApprover—argparse'stype=floatmeans the CLI value is always a plain float, so the other failure mode in_validate_max_delta(array broadcast) can only be reached via the Python API, not this flag.--max-action-deltastill warns and continues, exactly as before. Verified manually and confirmed the existingtest_cli_degraded_guardrails_warn_but_runstill passes unchanged.runandeval-set(-1,0,inf,nan).CHANGELOG.mdentry underUnreleased→Fixed.Checklist
pre-commit run --all-filesshells out touv, not on PATH here; ranruff check .,ruff format --check .,mypy, andpytest --covdirectly, plus the full suite on a Linux checkout.ruff check .andruff format --check .passmypypasses (strict) — full run, 63 source files.CHANGELOG.mdupdated under "Unreleased" —Fixedentry._check_shared_run_conflictsis a private CLI function.Note: I did not run the
docs-buildjob locally (it needs a full Node/npm toolchain for the Docusaurus site). Confirmed by inspection this diff is out of scope for it — no changes todocs/,website/, or any public docstring, andCHANGELOG.mdis not referenced by the site build.Related
Closes #154.