Repository navigation
Description
Step 3 of 3 of #4927: option 1, one walker behind ports, as triage decided on TALE-195 on 2026-10-30. It follows step 2 (#5257), which gives the in-process executor one walker behind ports. Like the other steps, it changes no behaviour.
What this step asks
The durable stepper (services/platform/backend/core/automations/stepper.ts) becomes a host on step 2's walker. Its own walk goes:
walkAutomation;- the loop half of
stepNode; - the document sorted twice per turn, once for the effects order and once for the walk.
What stays is host, plugged into the walker's ports:
- the lease and the claim, and fenced writes;
- the ledger:
durableLedger,callThroughLedger,StaleClaim,InDoubtPark(backend/core/automations/ledger.ts); - in-doubt handling on resume;
- the hand-off on shutdown;
- the subautomation pins;
- the run record;
- the agent lane.
Step 1 already moved the walk's types into services/platform/lib/engine/core/walk/: limits, progress, the ledger port, the progress sink and the approval gate's port. The types still in stepper.ts move to the walker or stay with the host here: WalkResult, StepOutcome and RunContext, which carry RunFailureCode and ActionCtx. So does the choice of whether AgentCursor (durable agent-lane state, in core/walk/progress.ts because NodeCursor names it) becomes opaque to the walk.
How much of stepper.ts is walk
#4927 left this "not examined". I counted it by section at 6f46e442691d4a811c89fa624b5c9e959d43ba60, step 1's head on feature-train 1a17c9efbaaae3b1526915f646581447f71788d3. There stepper.ts is 2,683 lines; it was 2,771 before step 1 moved the types out.
| Lines | Section | Side |
|---|---|---|
| 1–127 | Header and imports | (none) |
| 128–163 | Turn budget, poll intervals, CORE_TYPES |
host |
| 165–329 | Approvals: the gate, the agent host factory, a node type's effect and idempotency | host |
| 330–415 | WalkResult, RunContext, yieldNote, asPromptText |
both |
| 416–929 | Node bodies (runNodeBody: transform, llm, agent, subautomation, connector) |
behind step 2's calls port |
| 930–1058 | walkAutomation: the next node, the hand-off between nodes, the output |
walk |
| 1059–1194 | StepArgs, StepOutcome, the credential probe, the input preview, the pins |
host |
| 1195–1764 | stepNode |
both (below) |
| 1765–2253 | The agent lane (stepAgentNode) |
host, behind the agent port |
| 2254–2683 | The action: settleLiveTurns, stepRunImpl, stepRunTurn, stepClaimedRun, durableSink |
host |
Inside stepNode:
- Walk: the skip verdict, the
forEachandrepeatUntilloop with its cursor, and the execution cap. - Host:
- the approval park;
- the agent lane's entry;
- the pins' commit;
- the ledger's errors;
- the cut on shutdown;
- the failure record.
By section, the walk is the 129 lines of walkAutomation plus the loop half of stepNode's 570. The host is 1,256 lines:
- the turn budget, the poll intervals and
CORE_TYPES: 36; - approvals: 165;
- the step's helpers: 136;
- the agent lane: 489;
- the action: 430.
The rest:
- the 514 lines of node bodies go behind the calls port;
- the 86 lines of
WalkResult,RunContext,yieldNoteandasPromptTextserve both sides; - 127 lines are header and imports.
What was not done:
stepNodewas not split line by line.- The design pass of 2026-10-09 counted about 1,600 lines of code that carries invariants; that was not recounted.
Constraints
From #4927:
- What the lease and shutdown work made true still holds (fix(platform): keep automation runs safe across restarts and redeploys #4516):
- fenced writes;
- a lease that is not stolen;
- in-doubt handling on resume;
- the hand-off on shutdown;
- the ledger of effects.
- The run record stays keyed per unit, and the replays (retry from a failed node, compare) read it (feat(platform): keep, read and replay a step-by-step record of every automation run #4647).
ENGINE_PROTOCOLstays2: nothing is written that a previous engine would misread. The frozen legacy-v1 fixtures (services/platform/tests/fixtures/automation-legacy-v1/) and their guards (services/platform/tests/guards/automation-legacy-*.test.ts) keep passing.
Done means
stepper.tskeeps no walk of its own: no loop over the nodes, items or passes. It drives the shared walker through the ports.- These pass unedited:
- every
backend/core/automations/stepper*.test.ts; - both parity suites:
stepper.record-parity.test.tsandlib/engine/core/analysis/flow.parity.test.ts; - the real-Postgres lanes, on a fresh database.
- every
lib/engine/selftest/purity.test.tsstays green.- The fast gate (format, typecheck, build) is green, and so is
knip:check.
Parent: #4927
Activity
yannickmonney commentedon Nov 14, 2026
Decision
The durable stepper becomes a host on step 2's walker (
lib/engine/core/execute/walker.ts). That walker becomes resumable and port-driven, so one walk serves both hosts.The walker's contract
RunCheckpoints, includingNodeCursorandexecutions). The next step is always the first step in order that has no checkpoint, and the execution cap counts across turns. A long loop commits its cursor every few items or seconds. Finished steps commit throughRunSink.commit. It hands off at step, item and pass boundaries under today's rule: a turn always advances one step, and a stopping server hands off before the first step.Mock calls and top-level reads never touch the ledger, as today.
in_doubtparks the run, andstaleends the turn.failstops the run: it is never isolated as an item failure, and the write is logged as one that may have happened.failedreplays the stored code, and the host turns it back into its failure. The host classifies each attempt's failureCode.WalkHost, incore/walk/ports.ts):beforeEffect: the credential probe, the approval gate and its preview;agentStep: the durable agent lane;pins: the subautomation version pins;interruption: a stale claim, an in-doubt park, a run stop, or the cut on shutdown.Answers
stepper.ts:walkAutomation, the loop half ofstepNode, the duplicate transform, llm and connector bodies, and the second sort.WalkResult: replaced by the widenedWalkOutcome.StepOutcome: becomes internal to the walker. The agent port getsAgentStepOutcome.RunContext: stays in the host.RunFailureCode: stays in the backend. A subautomation's failure keeps its inner code.AgentCursor: stays typed, and is opaque to the walker by a rule a guard enforces.execute/.Rationale
The #4516 invariants stay in the host, and the walker reaches them only through ports. Writing today's ledger rule into the shared body keeps both hosts ledgering the same calls without adding rows. Widening the calls port lets the durable host keep its connector door and failure codes. Turning
failinto a run stop keeps a loop from walking past a person's decision. Choosing the next step by checkpoint, with persisted executions and periodic cursor commits, makes a resumed run behave like a fresh one.Implementation (three PRs on feature-train, no behaviour change in any)
go; mock calls and top-level reads skip the ledger;failstops a loop withonItemError: continue; failure codes are unchanged.WalkHost, withexecute()as the first host. Done whenexecute()output is unchanged, and tests pass for resuming mid-forEach and mid-repeatUntil, the cap across a resume, the cursor cadence, the hand-off boundaries and an approval park. A guard keepsAgentCursorout of the walker.walkAutomationand the loop half ofstepNode. Subautomations walk throughwalkStepsand keep their inner code. A guard banstopoSort,decideNode,resolveForEachandrepeatSettledinbackend/core/automations/. Done when the done list passes unedited, the attempt rows are unchanged,ENGINE_PROTOCOLis still2, and the perf bench is flat.