Skip to content

fix(deep): remove duplicate --deep block - closes #32#81

Merged
Wolfvin merged 1 commit into
mainfrom
fix/32-deep-duplicate-block
Jun 28, 2026
Merged

fix(deep): remove duplicate --deep block - closes #32#81
Wolfvin merged 1 commit into
mainfrom
fix/32-deep-duplicate-block

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

Fix for P0 issue #32. The --deep post-processing block in codelens.py was implemented twice for the same set of commands (dead-code, query, impact, smell, complexity). Both blocks ran in sequence when --deep was set:

  • Block 1 (~L1024-1059): used HybridEngine(workspace, deep=True) directly
  • Block 2 (~L1070-1121): used create_hybrid_engine() factory + add_confidence_to_result()

Each block instantiated a fresh HybridEngine, so the engine was created twice per --deep invocation — doubling LSP subprocess calls and potentially double-counting findings in confidence_distribution.

Fix

  • Deleted Block 1 entirely (the less capable one — didn't handle complexity, didn't call add_confidence_to_result)
  • Kept Block 2 (strictly more capable)
  • Folded Block 1's "unsupported command" hint into Block 2's elif branch, so users running --deep on commands outside the supported list still get a clear deep_analysis_hint message

Verification

  • grep 'Post-processing: --deep' scripts/codelens.py returns 1 (was 2)
  • codelens smell /tmp --deep --format json still produces valid JSON output
  • codelens symbols foo /tmp --deep --format json (unsupported command) now sets deep_analysis: false + deep_analysis_hint instead of silently doing nothing

Regression tests

2 tests added to tests/test_hybrid_engine.py::TestDeepSingleInvocation:

  1. test_smell_deep_invokes_create_hybrid_engine_once — patches hybrid_engine.create_hybrid_engine with a MagicMock, calls main() in-process (not subprocess — mocks don't cross process boundaries), asserts mock_create.call_count == 1. This is the direct regression guard for issue [BUG-02] --deep flag runs HybridEngine twice — LSP findings double-counted #32.

  2. test_deep_unsupported_command_sets_hint — runs codelens symbols foo --deep (symbols is NOT in the supported list), asserts output contains deep_analysis: false + deep_analysis_hint mentioning the command name. Verifies the "unsupported command" behavior was preserved from deleted Block 1.

Both tests pass.

Files

  • scripts/codelens.py (Block 1 deleted, elif branch added to Block 2, +37/-37 LOC net but cleaner)
  • tests/test_hybrid_engine.py (+87 LOC, 2 new tests)

Related

The --deep post-processing block in codelens.py was implemented twice
for the same set of commands (dead-code, query, impact, smell,
complexity). Both blocks ran in sequence when --deep was set:

- Block 1 (L1024-1059): used HybridEngine(workspace, deep=True) directly
- Block 2 (L1070-1121): used create_hybrid_engine() factory +
  add_confidence_to_result()

Each block instantiated a fresh HybridEngine, so the engine was created
TWICE per --deep invocation — doubling LSP subprocess calls and
potentially double-counting findings in confidence_distribution.

Fix: delete Block 1 entirely, keep Block 2 (strictly more capable: also
handles complexity, adds confidence distribution). Folded Block 1's
'unsupported command' hint into Block 2's elif branch so users running
--deep on unsupported commands still get a clear message.

2 regression tests added to tests/test_hybrid_engine.py::TestDeepSingleInvocation:
- test_smell_deep_invokes_create_hybrid_engine_once: patches
  create_hybrid_engine, calls main() in-process, asserts call_count == 1
- test_deep_unsupported_command_sets_hint: verifies --deep on unsupported
  command sets deep_analysis_hint instead of crashing

Verified:
- grep 'Post-processing: --deep' codelens.py returns 1 (was 2)
- smell --deep still produces valid JSON output
- Both new tests pass
@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.

@Wolfvin Wolfvin merged commit 4c66743 into main Jun 28, 2026
0 of 6 checks passed
@sonarqubecloud

Copy link
Copy Markdown

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.

[BUG-02] --deep flag runs HybridEngine twice — LSP findings double-counted

1 participant