Skip to content

Conversation

@yesudeep
Copy link
Collaborator

@yesudeep yesudeep commented Jan 23, 2026

fix: add cycle detection to partial resolution across all runtimes

The Rust implementation of resolve_partials only resolved one level of
partials, unlike Python, Java, Go, and JS which all recursively resolve
the entire partial tree. Additionally, none of the runtimes had explicit
cycle detection, which could cause infinite recursion when partials
reference each other (e.g., A -> B -> A).

This fix:

Rust:

  • Refactors resolve_partials to use a new resolve_partials_recursive helper
  • Adds cycle detection using a HashSet to prevent infinite loops
  • Recursively resolves partials in resolved content to handle deep trees

Python, Go, JS, Java:

  • Adds explicit cycle detection using a 'visited' set to track partials
    currently being processed:
    • Python: Added 'visited' parameter to _resolve_partials
    • Go: Added resolvePartialsRecursive helper with 'visited' map
    • JS: Added 'visited' Set parameter to resolvePartials
    • Java: Added overloaded resolvePartialsAsync with ConcurrentHashMap

Tests:

  • Adds comprehensive cycle detection tests in all five runtimes to verify
    that cyclic partial references are handled correctly without infinite
    recursion, with each partial resolved exactly once.

This ensures autoreload and dependency tracking work correctly across
deep partial trees, with consistent behavior across all runtimes.

@yesudeep yesudeep requested a review from MengqinShen January 23, 2026 22:11
@github-actions github-actions bot added fix rust Pull requests that update rust code labels Jan 23, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/complex-plants branch from 3572bce to 3944bb1 Compare January 23, 2026 22:21
@yesudeep yesudeep changed the title fix(rs): add recursive partial resolution for cross-runtime parity fix: add cycle detection to partial resolution across all runtimes Jan 23, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/complex-plants branch from 3944bb1 to 3a1356f Compare January 23, 2026 22:25
The Rust implementation of resolve_partials only resolved one level of
partials, unlike Python, Java, Go, and JS which all recursively resolve
the entire partial tree. Additionally, none of the runtimes had explicit
cycle detection, which could cause infinite recursion when partials
reference each other (e.g., A -> B -> A).

This fix:

Rust:
- Refactors resolve_partials to use a new resolve_partials_recursive helper
- Adds cycle detection using a HashSet to prevent infinite loops
- Recursively resolves partials in resolved content to handle deep trees

Python, Go, JS, Java:
- Adds explicit cycle detection using a 'visited' set to track partials
  currently being processed:
  - Python: Added 'visited' parameter to _resolve_partials
  - Go: Added resolvePartialsRecursive helper with 'visited' map
  - JS: Added 'visited' Set parameter to resolvePartials
  - Java: Added overloaded resolvePartialsAsync with ConcurrentHashMap

Tests:
- Adds comprehensive cycle detection tests in all five runtimes to verify
  that cyclic partial references are handled correctly without infinite
  recursion, with each partial resolved exactly once.

This ensures autoreload and dependency tracking work correctly across
deep partial trees, with consistent behavior across all runtimes.
@yesudeep yesudeep force-pushed the yesudeep/fix/complex-plants branch from 3a1356f to 6e1d9ca Compare January 23, 2026 22:28
@yesudeep yesudeep merged commit 4e23d44 into main Jan 23, 2026
36 checks passed
@yesudeep yesudeep deleted the yesudeep/fix/complex-plants branch January 23, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotpromptz fix go java js python rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants