fix(hybrid): resolve 4 pre-existing test_hybrid_engine confidence field failures#41
Merged
Wolfvin merged 2 commits intoJun 28, 2026
Merged
Conversation
added 2 commits
June 28, 2026 07:40
…-deep output Root cause: The 4 failing TestHybridIntegration tests (test_query_confidence_without_deep, test_impact_confidence_without_deep, test_ai_format_confidence_distribution, test_dead_code_confidence_fields) were added in commit 52ab89b alongside the hybrid engine itself, but the engine only attached confidence fields when --deep was passed. The non-deep (default) path never called enhance_query/enhance_impact/verify_dead_code, so the confidence field was missing from default output. Verified: even at commit 52ab89b, these 4 tests fail (feature was partially implemented — engine helpers existed but were only wired into the --deep post-processing path in codelens.py). Fix (Path C — complete the partial implementation): Call the existing hybrid engine helpers from each command's execute() entry point with deep=False. The engine's enhance_query/enhance_impact methods already set confidence=MEDIUM when LSP is not active (matching the module docstring: medium = AST matched). verify_dead_code + add_confidence_to_result attach per-finding confidence and confidence_distribution to stats. When --deep is later applied in codelens.py post-processing, LSP verification may override individual fields to HIGH or LOW as before. Files modified: - scripts/commands/query.py: _attach_baseline_confidence helper calls enhance_query - scripts/commands/impact.py: inline confidence attachment via enhance_impact - scripts/commands/dead_code.py: verify_dead_code + add_confidence_to_result Test results: - test_hybrid_engine.py: 4 failed -> 0 failed (16 passed, 1 skipped) - Full suite (excluding test_integration.py OOM + test_graph_incremental.py which is worker 4-b's domain): 649 passed, 12 skipped, 0 new failures
Adds 'Confidence Fields on Non-Deep Output (test fix)' section under [8.2.0] documenting: - Root cause (confidence only attached on --deep path) - New fields added (query.confidence, impact.confidence, dead-code per-finding confidence + stats.confidence_distribution) - Non-breaking guarantees (additive, --deep override still works, ai format surfaces confidence via existing _META_KEYS extraction)
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This was referenced Jun 28, 2026
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
Fixes 4 pre-existing test failures in
tests/test_hybrid_engine.pythat have been present onmainsince commit52ab89b(the original hybrid engine commit) — not caused by any Phase 1 work.Root Cause (with evidence)
Path C — Feature partially implemented.
The 4 failing tests were added in commit
52ab89b("feat: hybrid analysis engine — LSP integration for deep accuracy") alongside the hybrid engine itself. The tests assert thatquery/impact/dead-codeoutput carries confidence metadata (confidencefield,confidence_distributionin stats) even without--deep.However, the engine only attached these fields on the
--deepcode path:scripts/codelens.pylines 1010-1046 and 1056-1107: both--deeppost-processing blocks callHybridEngine.enhance_query/enhance_impact/verify_dead_code/add_confidence_to_result— but only whengetattr(args, 'deep', False)is True.codelens.pylines 1108-1122) only prints an LSP-availability hint; it does not attach any confidence metadata.execute()entry points (scripts/commands/query.py,impact.py,dead_code.py) did not call the engine helpers at all.Evidence that this is a partial implementation, not a removed feature or rename:
git log --oneline --all -- tests/test_hybrid_engine.pyshows only one commit (52ab89b) — the tests were never modified after initial creation.git show 52ab89b:scripts/codelens.pyconfirms the non-deep branch never attached confidence, even at the original commit. I verified the 4 tests fail at52ab89bby checking out that commit's versions of the 3 files and running the tests.HybridEngine.enhance_query(line 162-164),enhance_impact(line 217-219), andverify_dead_code(line 114-118) all setconfidence = CONFIDENCE_MEDIUMwhenlsp_activeis False. The module docstring documents:high = LSP verified,medium = AST matched,low = regex only. CodeLens's default analysis path is tree-sitter AST = medium.Fix (Path C)
Complete the partial implementation by calling the existing engine helpers from each command's
execute()entry point withdeep=False. The engine setsconfidence = MEDIUM(AST-based analysis) when LSP is not active. When--deepis later applied incodelens.pypost-processing, LSP verification may override individual fields toHIGHorLOWas before.Files modified
scripts/commands/query.py— Added_attach_baseline_confidence()helper called fromexecute()aftercmd_query(). Callscreate_hybrid_engine(workspace, deep=False).enhance_query(result, query_name), which setsresult["confidence"] = "medium"when LSP is not active. Only runs whenresult.get("found")is True.scripts/commands/impact.py— Added inline confidence attachment inside the existingif result.get("status") == "ok":block. Callscreate_hybrid_engine(workspace, deep=False).enhance_impact(result, args.name).scripts/commands/dead_code.py— Added confidence attachment inside the existingif result.get("status") == "ok":block. Collects all findings fromresult["results"].values(), callsengine.verify_dead_code(all_findings)(setsconfidence = "medium"on each finding), thenadd_confidence_to_result(result)(addsconfidence_distributiontostats). Includes a best-effort fallback if the engine import fails.CHANGELOG.md— Added "Confidence Fields on Non-Deep Output (test fix)" section under[8.2.0]documenting root cause, new fields, and non-breaking guarantees.Why Path C (not A or B)
confidence,confidence_distribution) match the engine's actual output field names exactly.Test Results
Before (on
main/ branch HEAD before this PR)After (this PR)
Manual verification of command output
--deeppath still worksWithout pyright installed,
--deepgracefully degrades and confidence stays atmedium(the baseline set by this fix). With pyright installed, the--deeppost-processing incodelens.pywould override tohigh/lowbased on LSP verification — exactly as before.Non-Breaking Guarantees
confidence/confidence_distributionfields are added alongside existing fields.--deepoverride preserved — the--deeppost-processing layer incodelens.pystill runs afterexecute()and may override confidence based on LSP verification.--format aisurfaces confidence — the existing_META_KEYSextraction informatters/__init__.py(line 141) already includesconfidenceandconfidence_distribution, so the AI-normalized output picks them up automatically.confidence = "medium"directly.Constraints compliance
direct_dependents/indirect_dependents/affected_filesvars inimpact.pyare pre-existing and out of scope) OKosv_client.py,vuln_scan.py,vulnscan_engine.py(worker 4-a),graph_model.py,scan.py(worker 4-b),hybrid_type_resolver.pyOKCoordination notes
Used an isolated git worktree (
/home/z/my-project/CodeLens-4c) to avoid disturbing parallel workers 4-a and 4-b who share the main checkout. The shared checkout remains onfeat/issue-25-incremental-graphwith worker 4-b's uncommitted changes intact.