Claude/fix aggregate race condition u xw vz#3
Merged
Davidiusdadi merged 2 commits intorefactorfrom Feb 14, 2026
Merged
Conversation
Fixed a race condition where aggregate() would complete while other frames for the same node were still executing their initial attempt, causing those frames to later execute with empty _invocations and return incorrect results. ## Problem When multiple frames for the same node executed in parallel, the aggregate readiness check only waited for ancestor nodes to complete. This allowed one frame to execute aggregate() while sibling frames were still running, leading to extra invocations after _invocations was cleared. ## Solution Added `no_sibling_frames` check to ensure aggregate only executes when ALL frames for that node have completed their initial execution and pushed back to the stack. This guarantees aggregate happens on the very last invocation, as designed. ## Testing - ✅ All 7 feature-tour tests pass - ✅ aggregate-async.canvas: 21 items (async waves work correctly) - ✅ aggregate-loop.canvas: 21 items (loop aggregation works) - ✅ zip-and-aggregate.canvas: 2 items (mixed operations work) https://claude.ai/code/session_01871jyJg9rKfR4QAooAyHmU
- Added docs/how-to-create-a-canvas.md with canvas format guide - Removed claude-vault test canvases (no longer needed) - Documentation covers purpose, JSON format, and node instructions https://claude.ai/code/session_01871jyJg9rKfR4QAooAyHmU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new documentation file explaining how to create and structure canvas files, and also refines the canvas execution logic to ensure correct aggregation behavior. The documentation provides a comprehensive guide for users to define visual node-based programs, while the code change improves the runtime's handling of node aggregation.
Documentation additions:
docs/how-to-create-a-canvas.mdwith detailed instructions on canvas file structure, node and edge formats, code execution, emissions, aggregation, state management, and special syntax for markdown and templating.Runtime aggregation fix:
execCanvasinpackages/canvas-engine/src/runtime/exec-canvas.tsto ensure aggregation only completes when all frames for a given node have finished their initial execution, preventing premature aggregation and ensuring correctness in multi-frame scenarios.