-
Notifications
You must be signed in to change notification settings - Fork 42
Fix/issue 225 prompt includes + sync paths #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix/issue 225 prompt includes + sync paths #286
Conversation
…-detection Fix/windows uv path detection
…<include> tags Problem: LLM generates <include> tags referencing non-existent files like: <include>[File not found: context/pydantic_example.py]</include> Tests added: - test_generate_prompt_template.py: Tests that template should NOT instruct LLM to assume files exist, and should provide alternatives for missing deps - test_validate_prompt_includes.py: Unit tests for the validation module - context/validate_prompt_includes_example.py: Usage examples for the validation module (following pdd's module-example convention)
…> tags Solution: 1. pdd/validate_prompt_includes.py: New module that detects and cleans invalid <include> tags like "[File not found: ...]" from generated prompts 2. pdd/code_generator_main.py: Integrate validation into prompt generation pipeline to automatically clean invalid includes 3. pdd/templates/generic/generate_prompt.prompt: Update template to instruct LLM to NOT assume files exist and provide alternatives for missing deps
…ores architecture.json Problem: When architecture.json specifies filepath like "src/backend/models/findings.py", pdd sync ignores it and uses .pddrc defaults, generating files at wrong paths. Tests added to test_sync_determine_operation.py: - TestSyncArchitecturePaths: Basic architecture.json filepath extraction - TestSyncArchitecturePathIntegration: Integration tests for sync with architecture - TestArchitectureJsonLookup: Architecture.json discovery and module matching - TestGetPddFilePathsWithArchitecture: Verify get_pdd_file_paths uses architecture.json
… architecture.json Solution in pdd/sync_determine_operation.py: 1. _find_architecture_json(): Search upward from CWD to find architecture.json 2. _get_filepath_from_architecture(): Extract filepath for a prompt filename 3. Modified get_pdd_file_paths(): Check architecture.json FIRST before .pddrc Path resolution priority (highest to lowest): 1. User-specified output path (command line) 2. architecture.json filepath field 3. .pddrc context configuration 4. Default naming convention Paths are resolved relative to architecture.json location, not CWD.
|
what manual testing did you do? |
|
target 1/12 |
…e Tool,. This is an indepth example of how to use the template tool. - Created .gitignore to exclude unnecessary files and directories. - Added .pddrc for project configuration settings. - Introduced API_FAILURE_ANALYSIS.md for documenting API failure scenarios. - Developed architecture diagram in HTML format for visual representation. - Created architecture.json to define project structure and dependencies. - Added README.md to provide an overview and usage instructions for the tool. - Implemented example.py to demonstrate basic functionality. - Included INFISICAL_SETUP.md for centralized secret management setup. - Established Makefile for build automation and testing. - Added project_dependencies.csv to track project dependencies. - Created pyproject.toml for package metadata and configuration. - Developed various example scripts to illustrate usage of the Edit File Tool. - Implemented core functionality in src/edit_file_tool directory, including caching and cost tracking utilities. - Added tests for core functionality and utilities to ensure reliability.
…ma validation Unit test (test_llm_invoke.py): - test_openai_strict_mode_schema_includes_additional_properties_false E2E test (test_e2e_issue_295_openai_schema.py): - Exercises full CLI path from pdd generate to litellm.completion - Verifies additionalProperties: false is included in schema Both tests fail on current code, confirming the bug: - Standard completion path (llm_invoke.py:1899-1906) is missing additionalProperties: false that OpenAI requires for strict mode Fixes promptdriven#295
…ests Add failing tests for promptdriven#295: OpenAI strict mode schema validation
Remove accidentally committed *_fixed.py files that are artifacts from the pdd fix workflow and should not be in the repository. Files removed: - pdd/generate_test_pdd_fix_errors_generate_test_fixed.py - pdd/generate_test_test_generate_test_fixed.py - tests/test_generate_test_test_generate_test_fixed.py
Remove accidentally committed error_log.txt which is a test artifact and should not be in the repository.
Remove accidentally committed report_python.prompt which is an artifact from the pdd fix workflow and should not be in the repository.
After the fix to re-raise UsageError in errors.py, these tests needed to be updated to expect exit_code 2 instead of 0 for error cases.
Add failing tests for sys.path isolation in generated tests (promptdriven#342)
Add failing tests for promptdriven#364: Cumulative cost display bug
Add failing tests for promptdriven#349: sys.modules pollution
Add failing tests for loop mode log file bug (promptdriven#360)
Fix Step 10 pdd bug command to remove non-existent log file reference
Add failing tests for promptdriven#340
feat(which): New command "pdd which" that exposes effective config and search paths (Fixes promptdriven#21)
Fix promptdriven#54: Add --format option to the example command to control output format
…-path-support Fix promptdriven#334: Support paths with spaces in regression tests
Add failing tests for promptdriven#296: llm_models.csv control
New example for onboarding people + template for generating pddrc file
Resolved conflicts by combining both features: - Keep Issue promptdriven#225 fixes (validate_prompt_includes + architecture.json filepath) - Integrate new architecture_sync tags injection feature - Merge all test cases from both branches
- Fix type checking issue in validate_prompt_includes.py by initializing parent_size to float('inf')
- Extract _ensure_trailing_slash helper to reduce code duplication in sync_determine_operation.py
- Keep is_negated as local function (only used once, no need to extract)
3364d6d to
a60b4cc
Compare
Manual Testing CompletedI have completed comprehensive manual testing to verify both bugs in Issue #225 are fixed. Below are the detailed test results. Test SetupCreated a test project structure matching the Issue #225 scenario: Architecture Configuration ( {
"modules": [
{
"filename": "models_findings_Python.prompt",
"filepath": "src/backend/models/findings.py",
"description": "Findings data model using Pydantic",
"dependencies": []
},
{
"filename": "rules_engine_Python.prompt",
"filepath": "src/backend/rules/engine.py",
"description": "Rules engine for processing findings",
"dependencies": ["models_findings_Python.prompt"]
}
]
}Configuration ( version: "1.0"
contexts:
default:
defaults:
generate_output_path: "src/" # Would cause bug if used
test_output_path: "tests/"
example_output_path: "examples/"Directory Structure: Bug 1: Invalid
|
a60b4cc to
56a969d
Compare
Resolved conflicts by combining both features: - Keep Issue promptdriven#225 fixes (validate_prompt_includes + architecture.json filepath) - Integrate new architecture_sync tags injection feature - Merge all test cases from both branches
Review FindingsBoth bugs addressed in this PR are real and confirmed by testing against main. The fixes work, but there's one naming bug to address before merge. Bug 1 (Invalid
|
| File | PR produces | README convention |
|---|---|---|
| Code | src/backend/models/findings.py |
✅ correct (from architecture.json) |
| Example | findings_example.py |
❌ should be models_findings_example.py |
| Test | test_findings.py |
❌ should be test_models_findings.py |
Fix: Line 559 should use the basename parameter already passed to get_pdd_file_paths() instead of code_path.stem.
Minor issues
CLOUD_REQUEST_TIMEOUT = 400added tocode_generator_main.py(line 107) but never used — appears copied fromfix_code_loop.pyby accident- Some tests reimplement functions inline rather than importing the actual code under test (e.g.,
TestArchitectureJsonLookupdefines its ownfind_architecture_jsoninstead of importing_find_architecture_json)
- Fix naming bug: use basename instead of code_path.stem for example/test paths (e.g., models_findings_example.py instead of findings_example.py) - Remove unused CLOUD_REQUEST_TIMEOUT constant from code_generator_main.py - Refactor TestArchitectureJsonLookup to import actual functions instead of inline reimplementation
|
Thanks for the detailed review! All issues have been addressed in the latest commit: Naming Bug ✅ Fixed
Minor Issues ✅ Fixed
All 35 Issue #225 related tests pass. |
Description
Fixes the example import issue with template where LLM generates invalid
<include>tags referencing non-existent files, and sync ignores filepath field in architecture.json.Fixes #225
Changes Made
Bug 1: Invalid
<include>Tags in Generated PromptsProblem: When using
generic/generate_prompttemplate, LLM generates<include>tags like:Code Changes
pdd/validate_prompt_includes.py: New module that detects and cleans invalid<include>tagspdd/code_generator_main.py: Integrate validation into generation pipeline - validates.promptfiles before savingpdd/templates/generic/generate_prompt.prompt: Update template to instruct LLM NOT to assume files existTest Changes
tests/test_generate_prompt_template.py: Tests that template should NOT instruct LLM to assume files existtests/test_validate_prompt_includes.py: Unit tests for the validation modulecontext/validate_prompt_includes_example.py: Usage examples following pdd conventionPrompt Changes
pdd/prompts/validate_prompt_includes_python.prompt: New prompt for the validation modulepdd/prompts/code_generator_main_python.prompt: Updated viapdd update- added validate_prompt_includes example and documented validation stepBug 2:
pdd syncIgnores architecture.json filepathProblem: When architecture.json specifies:
sync ignores filepath and uses
.pddrcdefaults, generating files at wrong paths likesrc/findings.py.Code Changes
pdd/sync_determine_operation.py:_find_architecture_json(): Search upward from CWD to find architecture.json_get_filepath_from_architecture(): Extract filepath for a prompt filenameget_pdd_file_paths(): Check architecture.json FIRST before.pddrcTest Changes
tests/test_sync_determine_operation.py: Added 4 test classes with 11 tests:TestSyncArchitecturePaths: Basic architecture.json filepath extractionTestSyncArchitecturePathIntegration: Integration testsTestArchitectureJsonLookup: Discovery and module matchingTestGetPddFilePathsWithArchitecture: Function behavior verificationPrompt Changes
pdd/prompts/sync_determine_operation_python.prompt: Updated viapdd update- documented path resolution priority orderPath Resolution Priority (Issue #225)
.pddrcoutputs config (template-based paths).pddrcgenerate_output_path configTesting
Test Results
Coverage
Testing Environment
Prompt Generation Verification
Verified that
validate_prompt_includes_python.promptcan generate functionally equivalent code:pdd generatesucceedsDev Unit Checklist
pdd updatefor both modified modulesvalidate_prompt_includes_example.pyRegression Testing
.pddrcconfigurationsCommit Structure (PDD)
Related Issues
Additional Notes
This fix follows PDD principles:
code_generator_mainandsync_determine_operationprompts updated to reflect new functionality