Repository navigation
1140 R2–R3: R2 loop; R3 loop_group #4566
Description
Problem
packages/workflows/src/dag/nodes/ is one of the large files #1140 splits. Steps R2–R3 of lane R, done together in one run: R2 loop; R3 loop_group.
Why
#1140's goal is a clean, maintainable core: modules with one owner each, tests that move with their code, and no dead code. The lane plan is #1140 (comment).
Why now
The steps before these in lane R have merged. They're batched because the overnight one-step-per-run pace was too small (maintainer, 2026-10-18).
Desired outcome
Steps R2–R3 as the plan describes them below, landed as one PR, in order, one commit per step. Re-read the code first, because earlier steps have changed it. A later step may adjust to what an earlier one found.
Invariants
- No behavior change. No engine functionality that works today is removed. The public entry stays where it is, and the internals move.
- Each deleted test names the test that still covers its behavior, in the PR body, or is a test that only pinned structure.
- The A complexity ratchet whose baseline the change cannot edit #3020 complexity ratchet holds or goes down.
- No new dependency.
Acceptance
- The moved suites' pass count equals their count before the move, minus the deletions the PR body names.
- Type-check and lint pass in the touched packages, and CI is green.
The steps (from the lane plan)
R2. loop
(dag/nodes/loop/loop.ts): extract the resume-state prelude (from // Detect interactive loop resume through the finalize-on-approve branch, Finalize-on-approve (#2074)) and the per-iteration body.
R3. loop_group
(dag/nodes/loop-group/loop-group.ts): extract the resume-state prelude (from // Detect loop resume (mirrors executeLoopNode) through session-cursor restoration) and the per-iteration body. If R2 and R3 find byte-identical finalize-on-approve logic, move it to dag/loop-completion.ts in the later of the two; if the copies differ, do not unify them (that is a behavior change) and record the difference as a discovery.
Lane R rules (from the lane plan)
These lower function complexity. Each step extracts helpers inside its folder only, keeps every value identical, and adds no field to RunLayersContext. Anchors are the comment headings already in each function.
Conflicts: none between R2–R5. R1 conflicts with D19b. R3 and R2 both may touch dag/loop-completion.ts only in the identical-logic case; run R3 after R2 if so.
Part of #1140.
Activity
Loop and loop_group executors read as resume, setup and one call per …