-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Circular <include> tags without --recursive cause the preprocessor to enter an infinite loop that never terminates. This is distinct from #521 which covers --recursive mode (hits Python recursion limit and silently succeeds with corrupted output).
File: pdd/preprocess.py — process_include_tags() has no cycle detection and no recursion depth limit in non-recursive mode.
Reproduction
mkdir /tmp/circular && cd /tmp/circular && git init && git commit --allow-empty -m init
mkdir prompts
echo 'Create <include>prompts/b_python.prompt</include>' > prompts/a_python.prompt
echo 'Create <include>prompts/a_python.prompt</include>' > prompts/b_python.prompt
pdd --force preprocess prompts/a_python.prompt
# Process never terminates — must be killed manuallyResult: Process runs forever, printing "Processing XML include" in an infinite loop. After 5 seconds, 17,000+ lines of output and growing. Must be killed with Ctrl+C or kill.
Expected: Error message like "Circular include detected: a_python.prompt → b_python.prompt → a_python.prompt" and exit with non-zero code.
Impact
- HIGH — Process hangs forever consuming CPU. User must manually kill it.
- Any prompt with accidental circular includes will hang
pdd preprocess,pdd sync,pdd generate, etc. - No data loss, but wastes developer time debugging why PDD "hangs"
Comparison with #521
Without --recursive (this issue) |
With --recursive (#521) |
|
|---|---|---|
| Behavior | Infinite loop, never terminates | Hits recursion limit, exits 0 |
| Output | 17K+ lines and growing | ~1,184 bytes corrupted |
| Severity | Process hangs forever | Silent data corruption |
Both should be fixed with cycle detection in process_include_tags().