Skip to content

Claude/fix aggregate race condition u xw vz#3

Merged
Davidiusdadi merged 2 commits intorefactorfrom
claude/fix-aggregate-race-condition-UXwVz
Feb 14, 2026
Merged

Claude/fix aggregate race condition u xw vz#3
Davidiusdadi merged 2 commits intorefactorfrom
claude/fix-aggregate-race-condition-UXwVz

Conversation

@Davidiusdadi
Copy link
Copy Markdown
Owner

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:

  • Added docs/how-to-create-a-canvas.md with 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:

  • Updated execCanvas in packages/canvas-engine/src/runtime/exec-canvas.ts to 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.

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
@Davidiusdadi Davidiusdadi merged commit 3b0961d into refactor Feb 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants