Problem
During local investigation of #1641 / PR #1644, one pdd sync agentic_bug_orchestrator failure block showed that the subprocess path was using the installed package instead of the checkout:
pdd.__file__: /opt/anaconda3/lib/python3.12/site-packages/pdd/__init__.py
pdd --version: pdd, version 0.0.276
git SHA: cf1a456a2e3e0bf45a12bbd3ae534393da4078d8
git status: dirty
source: site-packages
From the same checkout, python -m pdd --version reported 0.0.278.dev0.
This may make self-sync/debugging misleading: the user thinks they are testing the current branch, but subprocess sync can execute whatever pdd binary appears first on PATH.
Suspected area
pdd/agentic_sync_runner.py has _find_pdd_executable() that currently prefers shutil.which("pdd"), then builds subprocess commands from that executable.
That behavior is reasonable for normal installed CLI usage, but it may be risky inside a source checkout, especially when syncing PDD itself or when the parent process was invoked as python -m pdd.
Possible direction, not a final design
Consider making subprocess sync prefer the same codebase/interpreter as the parent process when running from a checkout, for example:
- use
[sys.executable, "-m", "pdd"] when imported pdd.__file__ is under the current repo/worktree
- only use
shutil.which("pdd") when the parent process is also an installed CLI path
- add a warning when
pdd on PATH and imported pdd.__file__ disagree
- include the resolved command in sync logs/core dumps
The sync owner should decide the exact policy because installed CLI behavior may still be desired in some automation contexts.
Acceptance criteria ideas
- A test covers a repo-checkout invocation where PATH contains an older
pdd, and sync subprocess command still targets the checkout/interpreter.
- A diagnostic warning or core-dump field makes version/source mismatch obvious.
- Existing installed-package usage is not broken.
Related
This is separate from the compatibility-surface question in #1647. It does not explain every sync failure, but it can make investigation results unreliable.
Problem
During local investigation of #1641 / PR #1644, one
pdd sync agentic_bug_orchestratorfailure block showed that the subprocess path was using the installed package instead of the checkout:From the same checkout,
python -m pdd --versionreported0.0.278.dev0.This may make self-sync/debugging misleading: the user thinks they are testing the current branch, but subprocess sync can execute whatever
pddbinary appears first onPATH.Suspected area
pdd/agentic_sync_runner.pyhas_find_pdd_executable()that currently prefersshutil.which("pdd"), then builds subprocess commands from that executable.That behavior is reasonable for normal installed CLI usage, but it may be risky inside a source checkout, especially when syncing PDD itself or when the parent process was invoked as
python -m pdd.Possible direction, not a final design
Consider making subprocess sync prefer the same codebase/interpreter as the parent process when running from a checkout, for example:
[sys.executable, "-m", "pdd"]when importedpdd.__file__is under the current repo/worktreeshutil.which("pdd")when the parent process is also an installed CLI pathpddon PATH and importedpdd.__file__disagreeThe sync owner should decide the exact policy because installed CLI behavior may still be desired in some automation contexts.
Acceptance criteria ideas
pdd, and sync subprocess command still targets the checkout/interpreter.Related
This is separate from the compatibility-surface question in #1647. It does not explain every sync failure, but it can make investigation results unreliable.