Skip to content

Add failing tests for #1677: pdd sync module resolver ambiguous basename#1681

Draft
prompt-driven-github[bot] wants to merge 1 commit into
mainfrom
fix/issue-1677
Draft

Add failing tests for #1677: pdd sync module resolver ambiguous basename#1681
prompt-driven-github[bot] wants to merge 1 commit into
mainfrom
fix/issue-1677

Conversation

@prompt-driven-github

Copy link
Copy Markdown
Contributor

Summary

Adds failing tests that detect the bug reported in #1677: pdd sync resolves modules by short leaf basenames (e.g., page) rather than canonical path-qualified IDs, causing wrong-path file generation when multiple modules share the same basename.

Test Files

  • Unit test: tests/test_issue_1677_module_resolver.py

What This PR Contains

  • Failing unit tests that reproduce all four bugs identified in the root cause analysis
  • Tests are verified to fail on current code and will pass once the bugs are fixed
  • Sanity checks that must continue passing after the fix (unambiguous basenames, path-qualified names)

Root Cause

Four implementation bugs in the module identity resolution path:

Bug 1 (agentic_sync.py:391): if fp_stem not in basename_counts guard prevents any filepath stem from being counted more than once. Two page.tsx entries in different directories never produce count > 1 for the bare "page" stem.

Bug 2 (agentic_sync.py:394): set(basename_counts.keys()) discards all count data before the validity loop. Even if count reaches 2 (via the filename path), the set conversion makes "page" (count=2) indistinguishable from "page" (count=1).

Bug 3 (sync_determine_operation.py:528): The filepath cross-check safeguard is gated on "/" in basename; bare basenames like "page" fall through to unconditional first-match return, silently selecting the wrong module path.

Bug 4 (agentic_sync.py:2279-2289): AsyncSyncRunner in the agentic code path is constructed without module_targets; _build_command at agentic_sync_runner.py:2098 falls back to bare basename for all child sync subprocesses.

Real production evidence: pdd_cloud PR #1828, PDD bot commits 82f2723b/7782f10c (2026-05-29) generated frontend/src/page.tsx instead of frontend/src/app/login/page.tsx.

Test Results (Current Code)

5 failed, 5 passed in 1.46s

FAILED test_bare_basename_rejected_when_two_entries_share_same_filename   <- Bug 2
FAILED test_bare_basename_rejected_when_two_filepath_stems_match           <- Bug 1
FAILED test_bare_ambiguous_basename_does_not_silently_return_first_match   <- Bug 3
FAILED test_async_runner_receives_module_targets_in_agentic_path           <- Bug 4
FAILED test_ambiguous_bare_page_rejected_not_silently_resolved             <- Bugs 1+2

Next Steps

  1. Fix Bug 1: Change if fp_stem not in basename_counts: to if fp_stem: at agentic_sync.py:391
  2. Fix Bug 2: Replace set(basename_counts.keys()) with count-aware check at agentic_sync.py:394
  3. Fix Bug 3: Remove if "/" in basename: gate at sync_determine_operation.py:528; return (None, None) when multiple entries match a bare basename
  4. Fix Bug 4: Build and pass module_targets dict to AsyncSyncRunner in the agentic path (agentic_sync.py:2279-2289)
  5. Verify all 10 unit tests pass: pytest -vv tests/test_issue_1677_module_resolver.py
  6. Run full test suite: pytest -vv tests/
  7. Mark PR as ready for review

Fixes #1677


Generated by PDD agentic bug workflow

Adds regression tests covering four bugs in module identity resolution:

Bug 1 (agentic_sync.py:391): `if fp_stem not in basename_counts` guard
prevents any filepath stem from being counted more than once, making
ambiguity detection impossible for modules with the same leaf filename.

Bug 2 (agentic_sync.py:394): `set(basename_counts.keys())` discards all
count data before the validity loop, so even correctly-counted ambiguous
basenames pass through as valid.

Bug 3 (sync_determine_operation.py:528): The filepath cross-check safeguard
is gated on `"/" in basename`; bare basenames like "page" fall through to
unconditional first-match return, silently selecting the wrong module path.

Bug 4 (agentic_sync.py:2279-2289): AsyncSyncRunner in the agentic code
path is constructed without `module_targets`, so _build_command falls back
to bare basename for all child sync subprocesses.

Real production evidence: pdd_cloud PR #1828 generated
`frontend/src/page.tsx` instead of `frontend/src/app/login/page.tsx`.

Fixes #1677

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.

pdd sync should resolve modules by canonical path, not ambiguous short basenames

1 participant