Repository navigation
Compile loops over items, with scope, types, limits and data suggestions - #42
Merged
Merged
Conversation
added 11 commits
October 13, 2026 07:37
…show loops in explain and graph
…ics in plain language
…mit, and name loop limit messages
# Conflicts: # CHANGELOG.md # tests/unit/test_acceptance_journeys.py
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.
Summary
The compiler now checks and compiles Loop over items (
forEach). Loops do not run yet: this platform refuses to publish, import or activate a workflow that uses one, and every workflow without loops compiles to the same bytes as before./itemis the current element and/indexits position from 0; an enclosing loop's are/loops/<loop id>/itemand/loops/<loop id>/index. Body steps see what is visible at the loop plus earlier steps of the same iteration. After the loop only/steps/<loop id>/outputis visible. Reading loop data anywhere else isWV-COMP-LOOP_SCOPE.anyOf), the position is a whole number belowmaxItems, and the loop's output is a list of one body result per element, at mostmaxItemslong, without nulls forcollect: nonNull.WV-COMP-LOOP_ITEMS(items can never be a list; an unproved list warns and keeps a run-timeloop_itemsguard),LOOP_BODY_INCOMPLETE,LOOP_SIGNAL(a body cannot wait for a signal),LOOP_DEPTH(three nested loops at most),LOOP_MAX_ITEMS(10,000),CONCURRENCY_LIMIT(shared with parallel),LOOP_BUDGET(all loops together, each multiplied by the loops around it, need at most 100,000 iterations; the diagnostic suggests a lowermaxItemsfor an inner loop), and aLOOP_FANOUTwarning for nested concurrency above 1,000 tasks.Limitsgainsmax_loop_items,max_loop_depthandmax_run_iterations.forEachnode with oneeachedge into its body, a body result node and aneachjoin; the validator checks the shape, the body scope and that the body completes. A loop selects IRweave/ir-v1alpha4with theflow.forEachfeature, which this platform does not list yet.422 WV-IR-UNSUPPORTEDbefore anything is stored (import, catalog reads, activation and debug sessions already refused such artifacts). A runtime that still receives a loop opens an incident instead of skipping the step.weave workflow explainprints loop settings andeachedges;weave workflow graphdraws compiled loops. Studio's local host answersPOST /studio/local/scopewith the data a field may use, from the compiler's own analysis, including the current loop item and position. The route requires a paired browser and the CSRF token, validates its request strictly, and reads no files, secrets or connections. Studio explains the loop diagnostics in plain language.studio/tests/fixtures/language/scope.json, checked by the Python suite and by Studio's vitest suite against Studio's own type labels.Verification
make check, all stages (6,664 unit and contract tests, worker suites, lint, format, mypy, source coverage, docs and packaging);scripts/golden_corpus.py --checkandscripts/language_fixtures.py --check; Studio type check, format check, vitest (1,797 tests) and production build. A separate review rerun the unit and contract tests, lint, mypy and both checks on the final head, fuzzedscope_atat every position of every example and fixture, and probed the new host route (pairing, origin, CSRF, size and request validation).cross-platformjobs on macOS and Windows run every compiler test of this change (IR, scope, typing, limits,scope_at, fixtures); runtime, CLI and Studio host unit tests run on Linux in CI and ran on macOS locally. TheAcceptanceworkflow runs theprprofile. No integration tests run in CI.Decisions
422 WV-IR-UNSUPPORTEDbefore anything is stored, so the catalog never holds a version the platform cannot read back or activate. Drafts with loops save and validate normally.WV-COMP-UNKNOWN_COMPATIBILITYwarning and a run-timeloop_itemsguard; items that can never be a list areWV-COMP-LOOP_ITEMS. Onceitemshas an error, references into/itemare not checked further, so one mistake gives one diagnostic.maxItemsthat fits both the budget and the platform's item limit, on the inner loop with the most iterations that one edit can fix, or no edit when none can. The fan-out warning counts nested loop concurrency only and appears once, where it first exceeds 1,000 tasks.found: false, not an error, because Studio asks while the author types.WV-RUNTIME-ARTIFACT) instead of being skipped; import already refuses such artifacts.forEachstays marked as not yet editable in Studio until Studio's loop editor ships.Follow-ups
concurrency, collecting results in element order, yields that spread large loops over several turns, theloop_itemsand item-count checks at run time, cleanup of finished iterations, and listingflow.forEach(which replaces the kernel refusal and lifts the publication refusal for loops).WV-IR-UNSUPPORTEDinstead of a generic validation error until then./studio/local/scopefor suggestions, and warning before publishing to a platform that does not list a feature the workflow needs; the CLI gets the same pre-publish warning.weave workflow graphfails on workflows with a decision table (existing issue).