Repository navigation
Complete loops on steps add, and remove empty loops with their closer - #98
Closed
jbedient-kizen wants to merge 2 commits into
Closed
jbedient-kizen wants to merge 2 commits into
jbedient-kizen wants to merge 2 commits into
Conversation
Kizen's builder creates a loop's next_or_finish and its item variable together, but 'steps add' refused a loop and sent a one-step edit through a whole-automation spec. It now adds all three: the item variable is always created, named '<array>_item', and the parent's children follow the closer so they still run once, after the loop. Removing a loop needed --cascade, which also deleted every step after it. A loop with an empty body now goes with its closer and the steps after it move up.
This was referenced Oct 27, 2026
Merged
Contributor
Author
|
Included in the 0.4.0 release PR #102; merge that instead. |
sangyeT
approved these changes
Oct 27, 2026
sangyeT
left a comment
Contributor
There was a problem hiding this comment.
Reviewed build_wire_loop / insert_loop (closer and _item variable created together, item step placed after the last initialize_variable, parent's children follow the closer) and the empty-loop removal that takes the closer with it. The undeclared-array case correctly yields no item and fails validation rather than guessing. Approving.
Contributor
Author
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.
Stacked on #97; merge #96 and #97 first, then retarget this to main.
Problem
Kizen's builder creates a loop's
next_or_finishand its item variable together with the loop, butsteps addrefused a loop, so a one-step edit had to go through a whole-automation spec. And removing a loop needed--cascade, which also deleted every step after it.Solution
steps addof aloopinserts the loop, its closer and its item variable in one plan. The item variable goes at the end of the variable steps, named<array>_item(then_item_2,_3when taken), the name the UI gives. It's always created, never chosen or reused, so asteps addspec that setsstep_loop.item_variableis refused. The array variable must already exist. The parent's existing children go after the closer, so they still run once, after the loop, as in the UI. A wrong type, nesting past three levels and one array at two levels are refused by the graph checks everystepsverb already runs.steps removeof a loop with an empty body removes its closer with it and moves the steps after it up. A loop with a body is still refused.Testing
Local checks after merging main: lint, format, typecheck, pytest (
2981 passed, 4 skipped, 1 xfailed) and the CLI-tree diff,passed: lint format typecheck test extra_checks.Live on a test tenant, on a scratch automation:
steps add --dry-runof a loop reported the loop, closer, item variablearr_itemand the adopted child; applied,showhad them in the right places androundtrip --execute→drift: []. With a body step added, an activated run completed three body passes and then the step after the loop. A second loop over the same array gotarr_item_2.steps removeof the empty second loop removed it and its closer and reparented the next step; removing the first loop with a body was refused, and after its body step went, removing it worked. Each step ended withdrift: []. Drift tier: 109 passed, 4 failed, all also failing on main (schema snapshot predates the 2026-10-26 release).Design notes / tradeoffs
build_wire_loopandinsert_loopsit besidebuild_wire_stepandinsert_step. The spec path (create/update --spec-file) stays explicit, for thediffreason in #97. Rejected: keeping the refusal, which sends a one-step edit through a whole-automation spec. The fiddly part is placing the item variable last among the variable steps while keeping variables first, including when the loop's own parent is the last variable step; tests cover that case.Overlaps: as #96 and #97, plus
tools/automations.py,tools/steps.pyanddocs/specs/automation-step.md.