Skip to content

Honor architecture.json filepath for prompts in nested .pddrc contexts - #2019

Closed
Serhan-Asad wants to merge 18 commits into
recovery/pr2003-narrow-port-20260713from
recovery/pr1971-stacked-20260713
Closed

Honor architecture.json filepath for prompts in nested .pddrc contexts#2019
Serhan-Asad wants to merge 18 commits into
recovery/pr2003-narrow-port-20260713from
recovery/pr1971-stacked-20260713

Conversation

@Serhan-Asad

Copy link
Copy Markdown
Collaborator

Clean replacement for #1971

This is the narrow, reviewed replacement for #1971. It is intentionally stacked on #2017 so GitHub shows only the resolver change; merge #2017 first, then retarget/rebase this PR to main before the manager merges it.

Problem

When a nested .pddrc sets prompts_dir to a subdirectory such as prompts/backend, prompt discovery can produce a context-relative filename such as credits_Python.prompt while architecture.json stores the repository-prompt-root-relative name backend/credits_Python.prompt. That mismatch can skip the authoritative architecture filepath and incorrectly fall back to configured output paths.

Fix

  • Preserve the context-relative lookup as the primary path.
  • Retry exactly once with a filename relative to <architecture root>/prompts only after a complete primary miss.
  • Keep a matching primary architecture row with a null filepath authoritative; do not borrow an alternate row.
  • Do not activate the retry for custom prompt roots outside <architecture root>/prompts.
  • Compute lookup keys lexically so approved prompt-root aliases remain valid.
  • Parse architecture.json once and thread a frozen module snapshot through ambiguity checks, prompt discovery, and code-path selection, including failed/empty loads.
  • Continue using that snapshot if the architecture file disappears mid-resolution.
  • Update the governing PDD prompt plus fingerprints and verification-profile rotation required by the prompt change.

Validation

  • 203 resolver tests passed.
  • 268 resolver/metadata/profile/governance tests passed after the final review fix.
  • 369 broader sync/architecture/alias-policy tests passed earlier in the bounded review cycle.
  • Python compilation, JSON parsing, metadata/profile hash recomputation, and git diff --check passed.
  • Full GPT-5.6-sol xhigh review found one actionable snapshot-disappearance issue; it was fixed.
  • Targeted GPT-5.6-sol xhigh re-review of that finding ended with zero actionable findings at a9876f16dad191875333664e7527b12dda2ac521.

Tracking issue: #1976. Supersedes #1971 after this replacement is accepted.

Manager order: merge #2017 first; then retarget/rebase this PR to main and merge it second.

Serhan-Asad and others added 18 commits July 13, 2026 09:31
…se regression

Cover the PR #1971 replacement behavior for get_pdd_file_paths:

- Nested prompts/backend regression: a module resolved under a nested .pddrc
  prompt root still selects the repository-prompt-root-relative architecture
  filepath (red before the fix; falls back to the wrong .pddrc code template).
- Control: a context-relative architecture filename resolves via the primary
  lookup, without needing the repository-prompt-root retry.
- Control: a custom prompt root outside <project>/prompts does not activate the
  fallback (the architecture filepath is not honored).
- Single-architecture-parse regression: one get_pdd_file_paths resolution parses
  architecture.json exactly once, so a concurrent rewrite cannot pair a prompt
  from one registry version with a code target from another.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…d .pddrc

get_pdd_file_paths resolves a prompt's code deliverable with architecture.json's
`filepath` as tier-1. architecture.json `filename` fields are stored relative to
the repository `prompts/` root (e.g. "backend/credits_Python.prompt"), but a
nested .pddrc context whose `prompts_dir` points at a subdirectory (e.g.
"prompts/backend") makes the primary lookup key relative to that subdirectory
("credits_Python.prompt") — which never matches the stored filename. Tier-1 then
silently missed and fell back to the wrong .pddrc code template.

Fix: only after a complete primary architecture miss, recompute the lookup key
relative to <architecture root>/prompts and retry. Both keys are computed
lexically with os.path.abspath (not Path.resolve()), so approved lexical prompt
aliases (#1991) remain valid, and the != guard plus try/except ValueError keep
this a pure no-op fallback that never fires when the prompt tree is not under
`prompts/`.

Parse architecture.json once per resolution and thread the same in-memory module
snapshot through _architecture_module_choices, _find_prompt_file, and
_get_filepath_from_architecture (new optional `modules` parameter, backward
compatible). A single snapshot means a concurrent architecture rewrite
mid-resolution cannot pair a prompt selected from one registry version with a
code target from another. Preserves current-main _architecture_artifact_paths,
global-sync, approved-alias, and path/fingerprint governance behavior.

Add the smallest observable contract for this behavior to the governing prompt
(requirement 6). Reported downstream: promptdriven/pdd_cloud#3203.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…0713' into recovery/pr1971-stacked-20260713

# Conflicts:
#	.pdd/verification-profile-rotations.json
…0713' into recovery/pr1971-stacked-20260713

# Conflicts:
#	.pdd/verification-profile-rotations.json
@Serhan-Asad
Serhan-Asad force-pushed the recovery/pr2003-narrow-port-20260713 branch 7 times, most recently from ebd2cd0 to 55bd43a Compare July 20, 2026 21:38
@Serhan-Asad

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by merged #1971 (e10bd9b3d0d5ac94d1a56af88f5abf07cf8af775) and its merged base #2017 (ee9fcff457b23fb7123bb7e15666c9287409ad0f); any intentionally unique delta should return as a narrow PR against current main.

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.

1 participant