Skip to content

fix(staleness): pin positional workspace arg with regression tests (closes #178)#181

Merged
Wolfvin merged 1 commit into
mainfrom
fix/issue-178-staleness-workspace-arg
Jul 3, 2026
Merged

fix(staleness): pin positional workspace arg with regression tests (closes #178)#181
Wolfvin merged 1 commit into
mainfrom
fix/issue-178-staleness-workspace-arg

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #178 — pins the positional workspace arg on codelens staleness with regression tests so the bug cannot recur.

Investigation

Issue #178 reported that codelens staleness /path/to/workspace printed usage and exited, unlike every other command. The bug does not reproduce on current main — tested manually with both:

  • python3 scripts/codelens.py staleness /tmp (legacy mode) → exits 0
  • codelens staleness /tmp (pip-installed entry point, Phase 1) → exits 0

The root cause was likely the argparse -f conflict guard regression that PR #171/#174 restored. The workspace positional was correctly registered with nargs="?" in the original PR #166 (staleness Phase 1), but the argparse guard drop in PR #153 (graphml) may have broken subparser registration broadly. PR #171/#174 fixed the guard, which fixed this bug as a side effect.

However, the issue remains open and no test pinned the expected behavior. This PR follows the PR #174 pattern (regression tests for already-fixed bugs) to prevent recurrence.

Changes

scripts/commands/staleness.py

tests/test_staleness.py

# Test Verifies
1 test_positional_workspace_exits_zero staleness <workspace> exits 0 (DoD #1)
2 test_positional_workspace_does_not_print_usage No usage: in stdout/stderr (the exact symptom from the issue)
3 test_no_args_auto_detects_and_exits_zero staleness (no args) auto-detects (DoD #2)
4 test_positional_workspace_with_json_format Positional + --format json produce valid JSON
5 test_workspace_positional_is_optional_nargs_question Inspects argparse: nargs="?", default=None
6 test_workspace_positional_consistent_with_other_commands Compares staleness vs scan — both nargs="?" (DoD #3)
7 test_help_shows_workspace_positional --help lists [workspace]

Tests

tests/test_staleness.py (full suite): 48 passed (was 41, +7 new)
Related suites (staleness + cli + command_count + command_registry + codelens): 166 passed, 0 failed

The broader suite hits a pre-existing segfault from tree-sitter native extensions in the sandbox (unrelated to this change — I only added a comment + tests, no Python logic).

Note for reviewer

  • The bug appears already-fixed on main. This PR adds regression coverage so it stays fixed.
  • No design doc needed (bug fix + tests, not a feature-class file per CONTEXT.md convention).
  • Used closes #178 since this fully addresses the DoD — the positional works and is now pinned by tests.

Files changed

M  scripts/commands/staleness.py   (+4 lines, comment only)
M  tests/test_staleness.py         (+186 lines, 7 new tests)

…loses #178)

Issue #178 reported that 'codelens staleness /path/to/workspace' printed
usage and exited, unlike every other command. Investigation shows the
bug does not reproduce on current main — the argparse -f conflict guard
restoration in PR #171/#174 likely fixed it. However, the issue remains
open and the behavior was not pinned by any test.

This PR follows the PR #174 pattern (regression tests for already-fixed
bugs) to prevent recurrence:

Changes:
- scripts/commands/staleness.py: added defensive comment in add_args()
  documenting that 'workspace' MUST stay nargs='?' (issue #178). No
  logic change — the positional was already correctly registered.
- tests/test_staleness.py: new TestStalenessWorkspaceArgRegression
  class with 7 tests pinning the issue #178 Definition of Done:
    1. test_positional_workspace_exits_zero — 'staleness <ws>' exits 0
    2. test_positional_workspace_does_not_print_usage — no 'usage:' in output
    3. test_no_args_auto_detects_and_exits_zero — 'staleness' (no args) works
    4. test_positional_workspace_with_json_format — positional + --format json
    5. test_workspace_positional_is_optional_nargs_question — inspects argparse
    6. test_workspace_positional_consistent_with_other_commands — compares vs scan
    7. test_help_shows_workspace_positional — --help lists [workspace]

Test results:
- 7 new regression tests: all pass
- Full staleness suite: 48 passed (was 41, +7 new)
- Related suites (staleness + cli + command_count + command_registry +
  codelens): 166 passed, 0 failed

The bug appears already-fixed on main (tested manually with both
'python3 scripts/codelens.py staleness /tmp' and 'codelens staleness /tmp'
via the pip-installed entry point). These tests ensure it stays fixed.

Findings:
- staleness.py had only one commit (df47ffb, PR #166 Phase 1) which
  correctly registered 'workspace' with nargs='?'. The issue may have
  been filed against a stale checkout or the brief window before PR
  #171/#174 restored the argparse guard.
- No design doc needed (bug fix + tests, not feature-class file per
  CONTEXT.md design-doc convention).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@Wolfvin Wolfvin merged commit f03ee1d into main Jul 3, 2026
2 of 8 checks passed
@Wolfvin Wolfvin deleted the fix/issue-178-staleness-workspace-arg branch July 3, 2026 08:48
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.

fix(staleness): command does not accept positional workspace argument

1 participant