Skip to content

pdd change pre-flight drift heal overwrites unrelated same-stem prompt #2004

Description

@Serhan-Asad

Summary

During a live hosted pdd-issue change → sync → checkup run, pdd change Step 8.5 pre-flight drift healing overwrote an unrelated same-stem prompt before the requested change began.

The drift detector already held the authoritative prompt/code pair for hackathon_event_detail_page, but the healer invoked pdd update --sync-metadata with only the generated code path. The update command re-derived prompt identity from the leaf code stem page.tsx and frontend context, selected the unrelated existing homepage prompt, and replaced it with the hackathon event specification.

This is a generalized data-corruption risk for repositories with multiple generated files sharing leaf names such as page.tsx, layout.tsx, or config.ts.

Live evidence

The requested change was only for:

  • prompts/frontend/app/marketplace/page_TypescriptReact.prompt

Step 8.5 detected drift for:

  • basename: hackathon_event_detail_page
  • authoritative prompt: prompts/hackathon_event_detail_page_TypeScriptReact.prompt
  • authoritative code: frontend/src/app/hackathon/[eventId]/page.tsx

The healer ran the equivalent of:

python -m pdd update --sync-metadata frontend/src/app/hackathon/[eventId]/page.tsx

The resulting change commit unexpectedly rewrote:

  • prompts/frontend/page_TypeScriptReact.prompt

That file changed wholesale from the PDD public homepage specification to a Hackathon Event Detail Page specification (84 additions / 97 deletions). The Step 9/10/11 reports listed only the marketplace prompt and architecture change, so the unrelated overwrite also escaped the workflow review.

The later pdd sync correctly saw the corrupted homepage prompt as changed, regenerated frontend/src/page.tsx, its tests/examples/metadata, and spent additional time/cost on the unrelated module. Step 8.5 itself spent approximately $3.38 healing the wrong target.

Root cause

pdd/agentic_change_orchestrator.py::_preflight_drift_heal has an authoritative DriftInfo containing both prompt_path and code_path, but passes only drift.code_path to pdd update.

The update path then calls its normal prompt/code resolver. For a code path whose leaf is a common name such as page.tsx, that re-derivation can choose another prompt in the same context instead of the authoritative prompt already discovered by drift detection.

The pre-flight healer must not discard stronger identity evidence and ask a weaker basename/context resolver to rediscover it.

Duplicate/reuse audit

Expected behavior

  • Step 8.5 must pass or preserve the authoritative prompt identity from DriftInfo when running pdd update.
  • pdd update <code-path> must fail closed when the code path can map to multiple prompt candidates; it must never silently overwrite a different existing prompt.
  • A successful heal may modify only the authoritative prompt and explicitly owned metadata/artifacts.
  • The change workflow must surface every pre-flight-healed path in Step 9/10/11 review scope and in the final PR summary.
  • Existing unique/unambiguous update flows must remain compatible.

Acceptance criteria

  • Regression fixture has two or more page.tsx modules/prompts, including an unrelated existing homepage prompt.
  • Pre-flight drift healing for frontend/src/app/hackathon/[eventId]/page.tsx updates only prompts/hackathon_event_detail_page_TypeScriptReact.prompt.
  • prompts/frontend/page_TypeScriptReact.prompt remains byte-identical.
  • The healer threads authoritative prompt identity instead of relying on leaf-basename re-derivation.
  • Direct pdd update <ambiguous-code-path> either resolves through exact architecture filepath ownership or exits non-zero with candidate choices before writing.
  • Tests cover nested/path-qualified Next.js pages, a unique basename compatibility case, and no-write behavior on ambiguity.
  • Step reports/final PR scope include every file mutated by pre-flight healing.
  • Live replay of test_repo_3#99 produces only the marketplace prompt/module changes and no unrelated homepage cost.

Campaign constraint

This was found during an isolated pdd-issue E2E campaign. Implement the generalized fix on a topic branch and integrate only into the campaign PDD runtime branch/pin for validation. Do not merge or deploy to production/main until the full campaign completes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions