Skip to content

fix(cli): fold and suggest near-miss parameter choice values - #889

Merged
Birfy merged 1 commit into
mainfrom
fix/888-param-choice-aliases
Nov 8, 2026
Merged

Birfy merged 1 commit into
mainfrom
fix/888-param-choice-aliases

Conversation

@Birfy

@Birfy Birfy commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Closes #888

Algorithm parameter values that declare choices now fold case and -/_ the same way parameter names already do (#876). --param sampling=sigmoid-novelty, archive_mode=KEEP_ALL, and mode=Linear resolve to the declared spelling, and algorithms run writes that canonical value into the spec. A close typo (novlty) ends with did you mean 'novelty'?; a nonsense value (greedy) still lists the choices and does not guess.

The fold lives in Param.coerce, so plan / MCP / plugin hosts inherit it too.

Verification

  • pytest -q tests/test_algorithms.py tests/test_cli_algorithms_run.py tests/test_mcp_algorithm_spec.py tests/test_cli_algorithms_bare.py tests/test_changelog_fragments.py passed

Closes #888

Choice values such as sigmoid-novelty, KEEP_ALL and Linear now resolve
to the declared spelling, and a close typo ends with did you mean…?
algorithms run --param writes the canonical value into the spec.
@Birfy

Birfy commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS
Tip SHA: dacde8b

Ran: pytest -q tests/test_algorithms.py tests/test_cli_algorithms_run.py tests/test_mcp_algorithm_spec.py tests/test_cli_algorithms_bare.py tests/test_changelog_fragments.py at the tip → passed. resolve_params folds sigmoid-novelty / KEEP_ALL / Linear; novlty suggests novelty; greedy still lists choices with no guess.

risk_gate: T2 (94 lines / 5 files). No CHANGES REQUESTED. AGENT_PAUSE=false.

@Birfy
Birfy enabled auto-merge (squash) November 8, 2026 12:12
@Birfy

Birfy commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS
Tip SHA: dacde8b
Ran: pytest -q tests/test_algorithms.py tests/test_cli_algorithms_run.py tests/test_mcp_algorithm_spec.py tests/test_cli_algorithms_bare.py tests/test_changelog_fragments.py at the tip → passed.
Not run: full suite (CI covers 3.9–3.13).
risk_gate: T2 (94 lines / 5 files). No CHANGES REQUESTED. AGENT_PAUSE=false.

Correctness. Param.coerce now treats a string choice the same way parameter names already work (#876): if exactly one declared choice matches once case and -/_ are folded (_fold replaces - with _ after casefold), the value becomes that canonical spelling (sigmoid-novelty → sigmoid_novelty, KEEP_ALL → keep_all, Linear → linear). Two choices that fold together stay unresolved rather than guessed. A remaining unknown uses the same difflib.get_close_matches(_fold(value), named, n=1, cutoff=0.75) bar as parameter-name suggestions, so novlty ends with did you mean 'novelty'? while a nonsense value (greedy) still lists the choices and does not guess.

algorithm_override now stores {k: resolved[k] for k in params} after resolve_params, so algorithms run --param sampling=sigmoid-novelty writes the canonical value and only the user-supplied keys (defaults stay out of the spec). Because the fold lives in coerce, plan / MCP / plugin hosts inherit it without a second path.

Design. This is the natural counterpart of #876 / #874 / #882 / #884: names already folded, choice values did not. Putting the logic in Param.coerce rather than the CLI parser is the right layer — every caller that already validates types and choices gets the alias and the hint. Non-goals are respected (no space/punctuation folding, no change to what algorithms do with a canonical value).

Tests / docs. New resolve_params cases cover the #888 acceptance list (hyphen/case aliases on archive_selection.sampling, dgm.archive_mode, skillopt.mode; near-miss did you mean; greedy with no guess). CLI tests check that algorithms run --param sampling=sigmoid-novelty persists sigmoid_novelty and that sampling=novlty exits 2 with the hint and no leftover spec. Changelog fragment 888-param-choice-aliases.md is valid.

Risk. T2 by risk_gate.py (package validation only; 94 changed lines / 5 files, under the 250-line cap). No evolve-loop change. AGENT_PAUSE=false; will squash-merge when required CI is green.

@Birfy
Birfy merged commit 25e957b into main Nov 8, 2026
9 checks passed
@Birfy
Birfy deleted the fix/888-param-choice-aliases branch November 8, 2026 12:39
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.

cli: choice parameter values reject hyphen/case aliases (sigmoid-novelty → sigmoid_novelty)

1 participant