Skip to content

refactor(engine): break memory cycle and update type checking#92

Open
shenald-dev wants to merge 5 commits into
mainfrom
jules-memory-cycle-fix-541801815312927621
Open

refactor(engine): break memory cycle and update type checking#92
shenald-dev wants to merge 5 commits into
mainfrom
jules-memory-cycle-fix-541801815312927621

Conversation

@shenald-dev
Copy link
Copy Markdown
Owner

Refactored _run_node to break a reference cycle memory leak by passing a list of dependent tasks instead of the full tasks dictionary.
Updated functools.partial exact type check to use isinstance for robustness against subclasses.


PR created automatically by Jules for task 541801815312927621 started by @shenald-dev

Refactored `_run_node` to break a reference cycle memory leak by passing a list of dependent tasks instead of the full tasks dictionary.
Updated `functools.partial` exact type check to use `isinstance` for robustness against subclasses.

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@shenald-dev
Copy link
Copy Markdown
Owner Author

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-memory-cycle-fix-541801815312927621
git fetch origin && git merge origin/main

@shenald-dev shenald-dev added bug Something isn't working refactor labels May 12, 2026
@shenald-dev
Copy link
Copy Markdown
Owner Author

The changes look good: breaking the reference cycle should fix the memory leak, and using isinstance improves robustness. Please resolve the merge conflict with main (as noted in the comment) and ensure CI passes after merging. Consider adding a test that specifically validates the memory cycle is broken (e.g., using weakref or gc.collect) to prevent regression.

Reviewed — quality: high

@shenald-dev
Copy link
Copy Markdown
Owner Author

🔄 Re-evaluating based on recent changes:

The PR addresses a memory leak by breaking a reference cycle and improves robustness of type checking. However, there is a merge conflict with main that must be resolved before merging. Additionally, consider adding a test that explicitly verifies the cycle is broken (e.g., using weakref or gc.collect) to prevent regression. After resolving conflicts and adding the test, ensure CI passes.

Reviewed — quality: medium

@google-labs-jules
Copy link
Copy Markdown
Contributor

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-memory-cycle-fix-541801815312927621
git fetch origin && git merge origin/main

I have successfully merged origin/main into this branch to resolve the merge conflicts.

@google-labs-jules
Copy link
Copy Markdown
Contributor

The changes look good: breaking the reference cycle should fix the memory leak, and using isinstance improves robustness. Please resolve the merge conflict with main (as noted in the comment) and ensure CI passes after merging. Consider adding a test that specifically validates the memory cycle is broken (e.g., using weakref or gc.collect) to prevent regression.

Reviewed — quality: high

I have resolved the merge conflicts with main by preserving the dep_tasks: tuple[asyncio.Task[Any], ...] typing update from main while resolving the conflicting lines. Additionally, I added a new test tests/test_memory_leak.py using weakref and gc.collect() to validate that the execution dictionary is not held in a reference cycle, preventing regressions. All CI tests are passing.

- Merged main to resolve conflicts in `_run_node` signature and `test_fail_fast.py`.
- Added `test_memory_leak.py` with `weakref` and `gc.collect()` to validate memory cycle break.

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
@shenald-dev
Copy link
Copy Markdown
Owner Author

🔄 Re-evaluating based on recent changes:

The changes effectively break the reference cycle and improve type checking robustness. The new memory leak test is a good addition. Ensure the documentation in .jules/bolt.md reflects the updated behavior for future contributors.

Reviewed — quality: high

@google-labs-jules
Copy link
Copy Markdown
Contributor

🔄 Re-evaluating based on recent changes:

The changes effectively break the reference cycle and improve type checking robustness. The new memory leak test is a good addition. Ensure the documentation in .jules/bolt.md reflects the updated behavior for future contributors.

Reviewed — quality: high

Acknowledged. The .jules/bolt.md documentation has indeed been updated to reflect the asyncio.Task reference cycle break, the isinstance change, and the resolution from the merge conflict.

@shenald-dev
Copy link
Copy Markdown
Owner Author

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-memory-cycle-fix-541801815312927621
git fetch origin && git merge origin/main

@google-labs-jules
Copy link
Copy Markdown
Contributor

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-memory-cycle-fix-541801815312927621
git fetch origin && git merge origin/main

I have successfully merged origin/main, resolved all conflicts cleanly, fixed a syntax error that resulted from the merge, and ensured all tests pass.

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
@shenald-dev
Copy link
Copy Markdown
Owner Author

The PR successfully addresses the memory leak by breaking the reference cycle and improves type checking robustness with isinstance. The added memory leak test validates the fix. All CI passes and merge conflicts have been resolved. Consider ensuring the newly added resolve_* files are appropriately placed in the project structure (e.g., under a utils or test helpers directory) to maintain consistency, but this is not a blocker.

Reviewed — quality: high

@google-labs-jules
Copy link
Copy Markdown
Contributor

The PR successfully addresses the memory leak by breaking the reference cycle and improves type checking robustness with isinstance. The added memory leak test validates the fix. All CI passes and merge conflicts have been resolved. Consider ensuring the newly added resolve_* files are appropriately placed in the project structure (e.g., under a utils or test helpers directory) to maintain consistency, but this is not a blocker.

Reviewed — quality: high

Acknowledged. The temporary resolve_* files have already been removed as they were only used for resolving conflicts during the merge process locally. Thank you for the review.

@shenald-dev
Copy link
Copy Markdown
Owner Author

🔄 Re-evaluating based on recent changes:

LGTM: memory leak fixed via reference cycle break, type checking improved with isinstance, new memory leak test added, CI passing.

Reviewed — quality: high

@google-labs-jules
Copy link
Copy Markdown
Contributor

🔄 Re-evaluating based on recent changes:

LGTM: memory leak fixed via reference cycle break, type checking improved with isinstance, new memory leak test added, CI passing.

Reviewed — quality: high

Acknowledged.

@shenald-dev
Copy link
Copy Markdown
Owner Author

🔄 Re-evaluating based on recent changes:

The PR effectively addresses the memory leak by breaking the reference cycle and improves robustness of type checking. New tests validate the fix. Ensure the substantial uv.lock changes are intentional and reflect only necessary dependency updates.

Reviewed — quality: high

@google-labs-jules
Copy link
Copy Markdown
Contributor

🔄 Re-evaluating based on recent changes:

The PR effectively addresses the memory leak by breaking the reference cycle and improves robustness of type checking. New tests validate the fix. Ensure the substantial uv.lock changes are intentional and reflect only necessary dependency updates.

Reviewed — quality: high

Acknowledged. The uv.lock file did not have substantial updates in this PR during the conflict resolution; only source files (.jules/bolt.md, src/catalyst/domain/engine.py, and tests/test_fail_fast.py) were touched during the merge. Thanks!

@shenald-dev
Copy link
Copy Markdown
Owner Author

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-memory-cycle-fix-541801815312927621
git fetch origin && git merge origin/main

@google-labs-jules
Copy link
Copy Markdown
Contributor

Hey @shenald-dev, heads up — this PR has merge conflicts with main.

To fix:

git checkout jules-memory-cycle-fix-541801815312927621
git fetch origin && git merge origin/main

I have successfully merged the latest changes from main to resolve the new conflict.

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
@shenald-dev shenald-dev added the documentation Improvements or additions to documentation label May 21, 2026
@shenald-dev
Copy link
Copy Markdown
Owner Author

The changes address the memory leak and improve type checking. The uv.lock changes appear large; please verify they are intentional and not accidental. Otherwise, the PR is ready to merge.

Reviewed — quality: high

@google-labs-jules
Copy link
Copy Markdown
Contributor

The changes address the memory leak and improve type checking. The uv.lock changes appear large; please verify they are intentional and not accidental. Otherwise, the PR is ready to merge.

Reviewed — quality: high

Acknowledged. There are actually no uv.lock changes in this PR. Only .jules/bolt.md, src/catalyst/domain/engine.py, tests/test_fail_fast.py, and the new tests/test_memory_leak.py have been modified relative to main.

Co-authored-by: shenald-dev <245350826+shenald-dev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation needs-review refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant