Add failing tests for #774: detect_structural_test_patterns previous_content API#775
Draft
prompt-driven-github[bot] wants to merge 1 commit intomainfrom
Draft
Add failing tests for #774: detect_structural_test_patterns previous_content API#775prompt-driven-github[bot] wants to merge 1 commit intomainfrom
prompt-driven-github[bot] wants to merge 1 commit intomainfrom
Conversation
…vious_content API Add 8 failing tests to tests/test_structural_test_guard.py that verify the fix for the off-by-one bug in detect_structural_test_patterns(). Tests cover: - Off-by-one regression: unchanged file with previous_content returns [] - Appended violations: only newly appended patterns are flagged - Pre-existing violations: patterns in snapshot are not reported - Truncation safety: rewritten-shorter file scanned correctly - Cross-boundary variable tracking: var defined in snapshot, used in new lines - New file: previous_content=None scans everything - Multiple pattern types: various structural test patterns detected - Caller API: orchestrator passes previous_content= not start_line= Tests fail with TypeError on current code (start_line param, not previous_content). Fix: replace start_line with previous_content + difflib.SequenceMatcher in pdd/agentic_bug_orchestrator.py:931 and update callers. Fixes #774 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Adds 8 failing tests that detect the bug reported in #774.
Test Files
tests/test_structural_test_guard.pyWhat This PR Contains
Failing unit tests that reproduce the reported bug. Tests are verified to fail on current code and will pass once the bug is fixed.
Tests 1–7 call
detect_structural_test_patterns(path, previous_content=...)directly → fail withTypeErrorbecause theprevious_contentparameter doesn't exist yet (current param isstart_line).Test 8 mocks the orchestrator through step 9 and verifies the caller passes
previous_content=<str>notstart_line=<int>→ fails because the caller currently passes{'start_line': 3}.Root Cause
pdd/agentic_bug_orchestrator.py:980— the clamp:fires when
start_line = N+1(the normal "nothing appended" case, since callers passlen(splitlines()) + 1). BecauseN+1 > Nis alwaysTrue, it clampseffective_start = 1and rescans the entire file — flagging pre-existing structural test patterns as violations and triggering destructive retries.File-on-disk scanning with line-count offsets cannot distinguish "nothing new" from "file truncated."
Fix Location
pdd/agentic_bug_orchestrator.py:931— replacestart_line: Optional[int]withprevious_content: Optional[str], remove clamp at line 980, add_compute_changed_lineshelper usingdifflib.SequenceMatcherpdd/agentic_bug_orchestrator.py:1528— renamepre_step9_line_counts: Dict[str, int]topre_step9_content: Dict[str, str]pdd/agentic_bug_orchestrator.py:1537— snapshot fullread_text()instead oflen(splitlines())pdd/agentic_bug_orchestrator.py:1868-1871— passprevious_content=pre_step9_content.get(...)to callersNext Steps
Fixes #774
Generated by PDD agentic bug workflow