fix: deduplicate contained search blocks and add is_test to JSON output#554
fix: deduplicate contained search blocks and add is_test to JSON output#554
Conversation
…ut (#553) - Add deduplicate_contained_blocks() that removes blocks fully contained within another block from the same file, preserving matched keywords. Runs unconditionally regardless of --no-merge flag. - Add is_test field to JSON output (only present when true) computed from file naming conventions and code content patterns across languages. - Structural declarations (type_declaration, struct_item) are excluded from test detection to distinguish implementation-level Verifies comments from actual test/witness blocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
OverviewThis PR fixes issue #553 by introducing two improvements to
Files Changed
Architecture & ImpactComponent Flowgraph TD
A[Search Results] --> B[deduplicate_contained_blocks]
B --> C[Optional Block Merging]
C --> D[JSON Serialization]
D --> E[is_test_file + is_test_code_block]
E --> F[JSON Output with is_test field]
B --> B1[Group by file]
B1 --> B2[Sort by start line, span size]
B2 --> B3[Mark contained blocks]
B3 --> B4[Merge keywords]
B4 --> B5[Return deduped results]
Key Technical ChangesDeduplication Logic (
Test Detection (
Affected Components
Scope DiscoveryRelated Files (Inferred)
Test Coverage
Review NotesFocus areas:
Potential concerns:
Metadata
Powered by Visor from Probelabs Last updated: 2026-04-06T08:40:43.298Z | Triggered by: pr_opened | Commit: 2a897ca 💡 TIP: You can chat with Visor using |
Security Issues (1)
Security Issues (1)
Quality Issues (16)
Powered by Visor from Probelabs Last updated: 2026-04-06T08:39:54.150Z | Triggered by: pr_opened | Commit: 2a897ca 💡 TIP: You can chat with Visor using |
Summary
Fixes #553 — two improvements to
probe search --allow-tests --exact --no-merge -o jsonfor requirement-annotation indexing:--no-merge, reducing 4 results to 2 in the reported repro case. Matched keywords from removed blocks are preserved on the surviving block.is_testfield to JSON output: Computed at serialization time from file naming conventions (is_test_file()) and code content patterns (is_test_code_block()). Only present whentrue(omitted for non-test blocks). Structural declarations (type_declaration,struct_item) are excluded from test detection, letting consumers distinguish top-levelVerifies:comments on implementation code from actual test/witness blocks.Test plan
deduplicate_contained_blocks()(containment, partial overlap, different files, keyword merging, same-range, edge cases)is_test_code_block()(Rust, Python, JS/TS, Go, comment-with-function, type declarations, plain comments)type_declarationhas nois_test, Python/TS test blocks have"is_test": true🤖 Generated with Claude Code