Repository navigation
Read, round-trip and edit automations that contain loops - #96
Merged
2 commits merged intoOct 27, 2026
Merged
2 commits merged into
2 commits merged into
Conversation
Kizen's 2026-10-26 release added loop steps, which the CLI read with no config block. Every read-modify-write verb then PUT the loop without its step_loop and got a 400 after a clean --dry-run, so activate, deactivate, move, steps and roundtrip --execute failed on any automation with one. Loops now translate with their array and item variables by name, and next_or_finish and exit_loop as the configless closers they are. --dry-run checks the server's loop rules and names the broken step, show puts each loop's body under it, and steps add and remove keep a loop closed. Translate also refuses a live step carrying a config block it doesn't read, instead of silently dropping it on PUT.
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 StepLoopConfig, the configless next_or_finish/exit_loop handling, the unread-block guard in _live_step_to_wire, the server-rule validator (_loop_problems, _in_loop_body) and the show/steps changes. Fixes a real write failure on any automation with a loop and the rules are each tied to a confirmed live 400. Approving.
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.
Problem
Kizen's 2026-10-26 release added loop steps, and the CLI read a loop's config from
action_loop, which doesn't exist. Every read-modify-write verb then PUT the loop withaction_loop: {}and nostep_loop, and gotHTTP 400: … step_loop must be provided for loopafter a clean--dry-run. Soactivate,deactivate,move,steps add|edit|removeandroundtrip --executefailed on any automation with a loop, andshowdidn't render them.Solution
A loop now gets a real builder, sending
step_loopwith its array and item variables by name (ids 400).next_or_finishandexit_loopare configless closers, likebranchandmerge_branches. A loop is modelled as one more branch-group initiator, reusing that machinery:next_or_finishcloses it the waymerge_branchescloses a group, the body hangs off the loop and the steps after it hang off the closer.validate_payloadlearns the six loop rules the server enforces, so--dry-runnames the broken step.showlabels each loop with its array and item variables and puts the body under it.steps add --parent <loop>puts the new step at the head of the body,steps addbuilds anexit_loop, andsteps removerefuses to leave a loop unclosed. The spec model accepts the three types in their wire shape. Translate now refuses a live step carrying a config block it doesn't read, rather than silently emptying it on PUT; it ignores scalar envelope keys, so a new one likestep_errorcan't lock every automation out.Testing
Local checks after merging main: lint, format, typecheck, pytest (
2933 passed, 4 skipped, 1 xfailed) and the CLI-tree diff,passed: lint format typecheck test extra_checks.The 22 non-loop fixtures translate byte-identically on main and this branch, and every readable automation on a test tenant (GETs only) gets the same translate-and-validate outcome on both. Live, on a scratch automation with two loops, a merged condition and an
exit_loopinside a loop:steps add --parent <loop>,activate/deactivate,steps remove,steps addof anexit_loopandsteps editon the loop were each followed byroundtrip --executewith zero drift. A dry-run reparenting the closer exits 1 with both rule texts. Drift-k "loop or coverage": 6 passed. The full drift tier has 4 failures, all also failing on main: its schema snapshot predates the 2026-10-26 release.Design notes / tradeoffs
Rejected: refusing loop automations with a clear error. Safer to write, but it leaves them uneditable now that loops are in the UI. The graph rules are kept to the six seen as live 400s, and the accepted shapes are pinned too, so a rule can't falsely reject what the server accepts.
#97 (the loop-spec authoring PR) (authoring loops from a spec) and #98 (the
steps addloop PR) (steps addcompleting a loop) stack on this one.Overlaps: #95 (the webhook-auth fix) and #99 (the Call LLM MCP-server fix) also change
tools/planners/automations.py,docs/specs/automation.mdandCHANGELOG.md, and #99 (the Call LLM MCP-server fix) adds totests/drift/test_roundtrip_automations.py; #100 (themcp-serverscommand group) and #101 (theservice-accountscommand group) also changescripts/cli-tree-baseline.txt. The second of these to merge should need a small conflict fix. The merge from main also refreshesscripts/cli-tree-baseline.txtfor #92's newkizen upgrade --checkhelp text, which main's baseline lacks; every PR in this set carries that same line.