Repository navigation
Loop and loop_group executors read as resume, setup and one call per iteration (1140 R2–R3) - #4571
Conversation
…40 R2) The resume-state prelude becomes readLoopResume and finalizeOnBareApprove in loop.ts. The per-iteration body moves into the loop folder: iteration.ts runs one iteration (stop check, completion channels, until_bash, completion record and the interactive gate), iteration-stream.ts streams its attempts and folds their usage, and iteration-outcome.ts judges an attempt (cancelled, empty, unsettled, transient retry, structured-output gate). The values the iterations shared through closures now live on one LoopState, and the values fixed for the node on one LoopRun; failLoopNode reads both. Every value, event and message is unchanged. Each attempt of an iteration still resumes the session the previous iteration ended in, never one a failed attempt reported. executeLoopNode drops from cognitive complexity 539 to 39; no extracted function scores above 15. Part of #1140 (step R2, #4566).
…n (1140 R3) The resume-state prelude moves to resume.ts: reading the resume shape and restoring named owner session cursors, the bare-approve finalize, the terminal wait resume, the $LOOP_PREV snapshot restore, the escalated completion check and the state the first iteration starts from. The per-iteration body moves to iteration.ts: the stop checks, the body's run context, usage, body failure and suspension, completion and the interactive gate. Both until_bash call sites share one subprocess and rejection path in until-bash.ts, each keeping its own order of path resolution, artifact listing and substitution. Every value, event and message is unchanged. executeLoopGroupBody drops from cognitive complexity 259 to 9; no extracted function scores above 15. The two finalize-on-approve branches are not unified: the loop node records a completed execution with the gate's usage and session through finalizeLoopFromSignal, while the group returns its output and lets executeLoopGroupNode record it. A gate comment that pointed at a finalizeLoopFromSignal call the group never makes now says what the group's finalize writes. Part of #1140 (step R3, #4566).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Reviewed commit: Review reportVerdictReady. Action: none. The delta since 743ca8a only resolves a merge of origin/dev; no code from dev's side was lost and nothing else changed. Accepted contractRequired outcome: R2 (loop) and R3 (loop_group) of lane R in #1140 (issue #4566), one PR, one commit per step: extract the resume prelude and per-iteration body into helpers inside each node's folder. Acceptance: moved suites keep pass counts; type-check, lint and CI pass. Invariants: no behavior change; deleted tests named; #3020 ratchet holds; no new dependency; folder-only helpers, no field added to RunLayersContext. Steering: finalize-on-approve moved only if byte-identical, otherwise recorded as a discovery; re-read code first; one commit per step. No part assignment. Reviewed head SHAContract coverage
FindingsNone blocking, no notes. Rejected findings: none. Prior findingsThe prior report had no findings. Nothing to carry forward. DiscoveriesNo new discoveries. The prior round's discovery (finalizeLoopFromSignal keeps loop_group generality with no caller) is already preserved in an earlier run's discoveries.md; this round adds none. See /Users/rasmus/.archon/workspaces/coleam00/Archon/artifacts/runs/080d56fb-ab92-4d78-b426-abd9559beada/discoveries.md. Unrelated discoveries do not affect readiness. Review coverageContinuation round. The route selected seams, code and errors; all three reports exist with completed review-lens artifacts. Each found nothing. I verified the prior report against them and checked directly: no conflict markers in loop/ or loop-group/, and dev's side of the conflict was comment-only. Tests and docs lenses were off; the delta adds no user-facing surface, so no gate was re-evaluated. |
# Conflicts: # packages/workflows/src/dag/nodes/loop/loop.ts
Problem and outcome
executeLoopNodeandexecuteLoopGroupBodywere single functions of about 1,500 and 1,000 lines (cognitive complexity 539 and 259). Their resume prelude and per-iteration body could not be read, tested or changed without holding the whole function in your head. This is steps R2 and R3 of lane R in #1140.executeLoopNodegoes 539 to 39,executeLoopGroupBody259 to 9.dag/nodes/loop/anddag/nodes/loop-group/. No new field onRunLayersContext, no new dependency, no test changes.Known failing check, not from this change:
bun run test src/dag/has one failure,executeDagWorkflow -- durable wait node > persists a future wait and returns without invoking a provider. It fails the same way at the starting commit, andsrc/dag/nodes/wait/alone passes 18/18. The wait node is untouched.Review guidance
packages/workflows/src/dag/nodes/loop/loop-state.ts—LoopRun(fixed for the node) andLoopState(what iterations used to share through closures) define the seam for R2. For R3 it isloop-group/loop-group-state.ts.loop.ts/loop-group.ts, theniteration*.tsandresume.ts. Diff with--color-moved=dimmed-zebra --color-moved-ws=allow-indentation-changeto dim the moved lines.iteration*.tsfunctions are the original code moved, withctx./state.prefixes.Solution
R2, loop.
loop.tskeepsexecuteLoopNode,readLoopResumeandfinalizeOnBareApprove. The iteration moves intoiteration.ts(stop check, events, completion channels, until_bash, completion record, interactive gate),iteration-stream.ts(retry and reask attempt loops, result chunks, usage folding) anditeration-outcome.ts(judging an attempt: cancelled, empty, unsettled, transient retry, structured-output gate).R3, loop_group.
resume.tsholds resume-shape detection, owner session cursor restore, the bare-approve finalize, the terminal wait resume, the$LOOP_PREVsnapshot restore and the escalated completion check.iteration.tsholds the per-iteration body. The twountil_bashsites share one subprocess and rejection path inuntil-bash.ts, each keeping its own order of path resolution, artifact listing and substitution.Finalize-on-approve is not unified. The plan said to unify only if byte-identical. They are not: the loop records a completed execution through
finalizeLoopFromSignalwith the gate's usage and session, while the group returns its output and letsexecuteLoopGroupNoderecord it.dag/loop-completion.tsis untouched. A group comment that pointed at afinalizeLoopFromSignalcall the group never makes was corrected.Dropped as dead: the per-iteration
AbortController, provider event handler and cancel-check clock that the original created and then overwrote at the start of every attempt.Validation
bun run type-checkinpackages/workflowsandbun run lintat the root (cleanup-drift, persistence and SDK drift checks included) — pass.bun run scripts/check-ratchet.tsagainstorigin/devafter each commit — pass, noRatchet-Allowtrailer needed.bun run test src/dag/nodes/loop/ src/dag/nodes/loop-group/— 189 pass, 0 fail. The same command at the starting commit gives 189 pass, so the moved suites keep their count. No tests were deleted.dag-executor,executor,run-resume,fixture-runner,packaged-workflowanddry-runtest files, each run alone — all pass (12, 185, 12, 57, 3, 115).bun run test src/dag/— 1066 pass, 1 fail:executeDagWorkflow -- durable wait node > persists a future wait and returns without invoking a provider. It fails the same way at the starting commit, andsrc/dag/nodes/wait/alone passes 18/18. The wait node is untouched.bun run testcall gives mass mock-pollution failures. That combination is not a valid check, so each file was run separately.Links
Summary by CodeRabbit