Skip to content

Add failing tests for #1648: pdd sync subprocess runner may use installed pdd instead of checkout#1659

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

Add failing tests for #1648: pdd sync subprocess runner may use installed pdd instead of checkout#1659
prompt-driven-github[bot] wants to merge 1 commit into
mainfrom
fix/issue-1648

Conversation

@prompt-driven-github

Copy link
Copy Markdown
Contributor

Summary

Adds failing tests that detect the bug reported in #1648, where _find_pdd_executable() in multiple modules prefers shutil.which("pdd") over [sys.executable, "-m", "pdd"], causing sync subprocesses to execute an installed binary (e.g., 0.0.276) rather than the current source-checkout version (e.g., 0.0.278.dev0).

Root Cause

_find_pdd_executable() in three separate files returns shutil.which("pdd") immediately when any pdd binary exists on PATH, so the else: [sys.executable, "-m", "pdd"] branch in callers is never reached. The same antipattern exists in the MCP runner tool. This contradicts the documented intent in pdd/__main__.py and the correct pattern already used in pdd/agentic_change_orchestrator.py.

Files with the bug:

  • pdd/agentic_sync_runner.py:236 — primary _find_pdd_executable()
  • pdd/server/routes/commands.py:434 — duplicate copy
  • pdd/server/jobs.py:199 — duplicate copy
  • utils/mcp/pdd_mcp_server/tools/runner.py:66 — MCP runner

Test Files

  • Unit tests: tests/test_agentic_sync_runner.py (Tests 1 & 6: TestBuildCommandInterpreterParity)
  • Unit tests: tests/test_jobs_sync_failure_detection.py (Test 2: TestBuildSubprocessCommandArgsInterpreterParity)
  • Unit tests: tests/test_server_routes_commands.py (Test 3: TestBuildPddCommandArgsInterpreterParity) — new file
  • Unit tests: tests/test_mcp_runner.py (Test 4: TestRunPddCommandInterpreterParity + prompt regression guards) — new file
  • Unit tests: tests/test_run_pdd_sync_helper.py (Test 5) — new file
  • E2E tests: tests/test_e2e_sync_interpreter_parity.py — new file (real PATH manipulation, no mocks)

Prompt Files Fixed

Prompt specifications encoded the wrong executable-resolution strategy and have been corrected to mandate [sys.executable, "-m", "pdd"]:

  • utils/mcp/prompts/runner_python.prompt
  • pdd/prompts/agentic_sync_runner_python.prompt
  • pdd/prompts/server/routes/commands_python.prompt
  • pdd/prompts/server/jobs_python.prompt

What This PR Contains

  • 6 failing unit tests that reproduce the reported bug (fail on current code, will pass once fixed)
  • 4 failing E2E tests that verify the bug using real OS PATH manipulation (no shutil.which mocking)
  • 2 passing prompt regression guards (prompt was already corrected; guards against reintroduction)
  • Prompt file fixes ensuring code regenerated from specs won't reintroduce the bug

Test Verification

All 6 behavioral unit tests and 4 E2E tests fail on current buggy code with clear error messages pointing to the exact binary path resolved incorrectly. Example:

AssertionError: Expected sys.executable ('/opt/venv/bin/python') as first element,
got '/opt/anaconda3/bin/pdd'. Bug: _find_pdd_executable() returned the PATH binary.

Next Steps

  1. Fix _find_pdd_executable() in pdd/agentic_sync_runner.py to always return None
  2. Fix _find_pdd_executable() in pdd/server/routes/commands.py to always return None
  3. Fix _find_pdd_executable() in pdd/server/jobs.py to always return None
  4. Fix run_pdd_command() in utils/mcp/pdd_mcp_server/tools/runner.py to use [sys.executable, "-m", "pdd"]
  5. Fix _run_pdd_sync() in tests/test_one_session_eval.py
  6. Verify all 10 tests pass
  7. Run full test suite to check for regressions
  8. Mark PR as ready for review

To auto-fix using PDD:

pdd fix https://github.com/promptdriven/pdd/issues/1648

Fixes #1648


Generated by PDD agentic bug workflow

Adds tests that detect the bug where _find_pdd_executable() in
pdd/agentic_sync_runner.py, pdd/server/routes/commands.py, and
pdd/server/jobs.py prefers shutil.which("pdd") over sys.executable -m pdd,
causing sync subprocesses to execute an installed binary rather than the
current checkout version.

Also fixes prompt specifications that encoded the wrong executable-resolution
strategy in utils/mcp/prompts/runner_python.prompt,
pdd/prompts/agentic_sync_runner_python.prompt,
pdd/prompts/server/routes/commands_python.prompt, and
pdd/prompts/server/jobs_python.prompt.

Tests fail on current buggy code and will pass once the fix is applied.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 subprocess runner may use installed pdd instead of checkout during self-sync

1 participant