fix(cli): add regression tests for argparse -f conflict (closes #174)#175
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
5 tasks
b9971a9 to
9a03092
Compare
Issue #174 reported a P0 argparse conflict: 'argument --format/-f: conflicting option string(s): -f'. The bug was introduced by PR #153 (graphml, issue #59 Phase 3) which accidentally dropped the existing_option_strings guard in the subparser --format registration loop. Commit 23487af (fix #171) restored the guard, fixing the crash. This PR adds: 1. Defensive comment in scripts/codelens.py (lines 896-904) explaining why the guard is critical and referencing the regression test. 2. 7 regression tests in tests/test_cli.py::TestArgparseFormatConflictRegression: - test_help_does_not_crash: codelens --help exits 0 - test_command_count_does_not_crash: codelens --command-count exits 0 - test_scan_with_format_long_does_not_crash: codelens scan . --format json - test_scan_with_format_short_does_not_crash: codelens scan . -f json - test_affected_with_filter_short_does_not_crash: codelens affected . -f '*.py' (verifies -f for --filter doesn't conflict with -f for --format) - test_parser_construction_no_argparse_error: module imports cleanly - test_no_duplicate_f_in_subparsers: iterates 5 commands' --help, asserts no 'conflicting option string' in stderr Also runs sync_command_count.py --apply to fix pre-existing command count drift (76 in docs vs 77 runtime) — unrelated to issue #174 but caught during testing. Definition of Done (issue #174): - [x] codelens --help runs without error - [x] codelens scan . --format json runs without argparse error - [x] codelens scan . -f json works - [x] test_cli.py and test_doctor.py pass (82 passed: 75 existing + 7 new) - [x] No regression on --diff-base functionality (verified manually) Tests: 142 passed in test_cli + test_doctor + test_command_count + test_command_registry + test_formatters (no regressions).
|
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.



What
Adds regression tests + defensive comment for the argparse
-fconflict bug reported in issue #174.Why
Issue #174 reported a P0 crash: every
codelensCLI invocation failed with:Root cause: The global parser registers
--format/-f(line ~934). Subparsers also register--format/-fvia a loop that adds the format flag to every subparser. A guard checksexisting_option_stringsbefore adding-fto a subparser, so commands likeaffected(issue #62, uses-ffor--filter) don't conflict. PR #153 (graphml, issue #59 Phase 3) accidentally dropped this guard, breaking every CLI invocation.Timeline:
existing_option_stringsguard23487af(fix [FIX] PR #141: missing @WHO header on baseline_diff.py + wrong command count #171) restored the guard — merged at 2026-07-03T03:30:25ZThe bug is already fixed on
main. This PR prevents it from regressing by:Files touched
scripts/codelens.py— defensive comment (9 lines added at lines 896-904) explaining why theexisting_option_stringsguard is critical, referencing the regression test. No code logic changed.tests/test_cli.py— newTestArgparseFormatConflictRegressionclass with 7 tests (129 lines added)README.md,SKILL-QUICK.md,SKILL.md,pyproject.toml,scripts/graph_model.py,skill.json— command count sync 76→77 (pre-existing drift caught during testing, fixed viasync_command_count.py --apply)Verification
New regression tests — 7 passed
Regression check — 142 passed, 0 failed
Definition of Done (issue #174)
codelens --helpruns without errorcodelens scan . --format jsonruns without argparse errorcodelens scan . -f jsonworkstest_cli.pyandtest_doctor.pypass (82 passed: 75 existing + 7 new)--diff-basefunctionality (verified:codelens scan . --diff-base HEAD~1reports 11 files in scope)Findings
23487af(fix [FIX] PR #141: missing @WHO header on baseline_diff.py + wrong command count #171, merged 2026-07-03T03:30:25Z) restored theexisting_option_stringsguard that PR feat(formatters): GraphML XML export for graph-producing commands (closes #59 phase-3) #153 had accidentally dropped. Issue [BUG] argparse -f conflict: --diff-base PR introduced global --format/-f that clashes with subparser --format/-f #174 was created 14 seconds before the fix merged — a race condition between BOS creating the issue and the worker merging the fix. The bug is not reproducible on currentmain.orientcommand from PR feat(orient): 10-second codebase orientation brief (closes #160) #165 was merged but docs weren't synced). Fixed viasync_command_count.py --apply. This is unrelated to issue [BUG] argparse -f conflict: --diff-base PR introduced global --format/-f that clashes with subparser --format/-f #174 but was caught during testing.if "-f" not in existing_option_stringscheck. If a future PR refactors the subparser registration loop and drops this check, the bug will return. The regression testtest_no_duplicate_f_in_subparsersiterates 5 commands'--helpoutput and asserts noconflicting option stringappears — this should catch any future regression at test time.Issue link
Closes #174 — #174