Skip to content

Improvement: durable test runs with stand-ins, preview mode, a wait step and the approval line in the run record #4929

Open

Description

@yannickmonney

Summary

Four pieces of the automations program were designed to land alongside or after the walker work, because each needs the durable walker or the engine protocol to change. None is on main. They are independent of each other except where noted. #4936 has the larger picture.

Anchors are at main da3b98b730 (2026-10-13). What the designs say is marked as design pass (2026-10-08 to 2026-10-09).

1. Test stand-ins in durable runs, and what the protocol needs for it

Today. The stand-ins a test names for the calls it replaces (a connector action, a model call, an agent node) are honoured by the in-process walker only (services/platform/lib/engine/core/execute/bench.ts). The durable stepper has none: the word bench does not occur in services/platform/backend/core/automations/stepper.ts. A run's mode is 'mock' | 'live' (services/platform/backend/domains/automations/store.ts:2737, :3181, :3282).

What it would give (design pass): a try or a test run that goes through the same durable machinery as a live run (queued, recorded, survives a restart, can pass a long step) and appears in the Runs list the same way.

Why the protocol is involved. A run that carries stand-ins must not be stepped by an engine that ignores them, because that engine would make the real calls. The protocol stamp is how an engine refuses a run it cannot read (services/platform/lib/engine/core/protocol.ts:1-10: "an engine refuses a run stamped above its own"). Raising the constant today renames every automation queue (services/platform/backend/jobs/tasks.ts:25) and trips the writer guard that expects '2' (services/platform/backend/db/migrations/0163_automation_legacy_protocol.sql:94).

Options for the protocol (no choice made here):

  • Split the constant: what an engine reads moves to 3; what it steps (queue names, writer marker) stays 2. This is what the design pass proposed.
  • Raise it and rename the queues with a drain window, accepting a release in which old and new workers do not share queues.
  • Avoid a stamp by keeping stand-ins in the in-process walker, as today.

2. Preview mode

The owner said yes on 2026-10-08. A preview runs a saved version with real connector reads and real model calls (billed, budgets apply), holds writes back as "would have sent", simulates agent nodes, never starts from a trigger, and is for people who may author the automation. It would add a mode between mock and live, and a way to try a single model step with the real model. Like a test run it may name any saved version, which touches AUTO-R5 (a live run and every trigger run the deployed version; a test run is the exception, services/platform/backend/domains/automations/spec.md:98).

Today there are two modes (see 1). Whether a preview needs item 1 first: the design pass put both in the same engine area; not examined whether they can be separated.

3. A wait step

Not on main: a node is transform, llm, agent, subautomation or a registered capability (services/platform/lib/engine/core/types.ts:43-53), and none waits.

Design pass: type: wait with for: 2d or until: <time>, between one second and 30 days; the walker stores a timer in the cursor and parks the run, so a waiting run holds no lease; mocks and tests complete at once and say what they would have waited for; cancelling is today's cancel. A new node type is a protocol change by the file's own definition (protocol.ts:1-10, "which node types exist"), which is why the design put it after item 1.

Open: the cap (30 days, or 7), and whether a wait inside a forEach is a warning or an error once items run at the same time.

4. The run record says when a write was allowed without approval

Automation approval allowances are on main (#4763) and can be read and changed over MCP (#4894). The gate's decision knows who allowed it (services/platform/backend/core/approvals/policy.ts:50, by: 'rule' | 'allowance' | 'platform'), but the gate answers { decision: 'allow' } alone (services/platform/backend/domains/approvals/gate.ts:81), so a step an allowance let through is recorded like any other. The design pass wanted the run page's step to say that the write ran without approval and who granted that, and the approval record's metadata to name the grant. Nothing named allowedBy exists on main.

Not examined: where the run record would carry it without touching the walker; whether the Steps view or only the step's detail should say it.

Order

Items 1 and 3 share the protocol question. Items 2 and 4 are independent of each other. All four read more cleanly after #4927.

Related

#4936, #4927, #4928

Activity

  1. added
    needs discussion
    improvement
    service: platform
    on Oct 13, 2026
  2. yannickmonney commented on Nov 14, 2026

    @yannickmonney
    ContributorAuthor

    Decision

    This issue becomes six PR-sized units. All of them are features, so they land on the feature line (feature-train, then release/0.6).

    The rule for the protocol: split the constant.

    • Reader protocol (ENGINE_READER_PROTOCOL): the highest run stamp this engine can step. Only the claim's deferral compares against it.
    • Writer protocol (AUTOMATION_WRITER_PROTOCOL): stays 2. It names the automation.v2.* queues, the writer marker, the 0163 guard and the Dockerfile's build check.

    A run's stamp says what the run needs, not who touched it last. It is set at insert to the reader version the run's features need; a plain run stays at 2. The stepper raises it only when the run brings in something new, for example when a subautomation's version is pinned mid-run. The claim no longer raises it to the engine's own number; otherwise every plain run touched by a new worker would lock out old workers during a rolling deploy. Each feature that an older engine would misread (stand-ins, preview, wait) raises the reader constant by one in its own PR. The queues and the writer guard never move.

    Answers

    • Protocol (split, raise with a drain, or no stamp)? Split, as described above.
    • Does preview need item 1 first? No. Only "try one model step with the real model" needs stored stand-ins.
    • Who may preview, and which version? Owners, admins and developers, on any saved version. A trigger never starts a preview. AUTO-R5's exception now covers test runs and previews.
    • Wait cap? 30 days, with 1 second as the minimum.
    • A wait inside a forEach? An error, both for a wait node with forEach or repeatUntil and for a wait inside a subautomation called per item or per pass. It is checked at save and again at runtime (WAIT_UNDER_ITERATION), because a child version deployed later can escape the save check.
    • Where does the record carry "allowed without approval"? In the approval gate port's answer: who allowed it, plus a snapshot of the grant taken at the step. The host writes it into the step's record meta. The walk does not change.
    • Steps view or only the detail? Both. The detail always names who allowed the write. The Steps view shows a short "Ran without approval" label for an allowance or a policy rule, but not for Tale's own data.
    • Should an approval record name the grant? No approvals row is created for an allowed write. The run record carries the grant.

    Rationale

    The split leaves the writer contract (queues, fencing guard) untouched and still lets an engine refuse a run it cannot read. Raising the shared constant would force a release with a queue drain. Avoiding a stamp would rule out durable tests, preview and the wait step.

    Stand-ins are refused on live runs in three places: the API, a DB CHECK and the stepper. Preview holds every action that is not a declared read and never reaches the approval gate. So no mix of engine versions can send a real write. Real model calls happen only in the stepper, so every billed call goes through the budget and appears in the run's record. The approval line is a snapshot taken at the step, because an allowance can be revoked later; it stores a user id, so erasure keeps working. The wait step reuses the existing park and sweep paths rather than adding a second timer mechanism.

    Units (in order)

    1. refactor(platform): split the engine protocol into reader and writer protocols (S). No behaviour change. The claim keeps a run's stamp instead of raising it. Raising the reader constant leaves the queue names, the writer marker and the Dockerfile check as they are.
    2. feat(platform): say in a run's record when a write ran without approval and on whose word (M). Independent of the protocol. Covers the record meta, the step detail and the Steps view label, the spec rule, docs, locales and a manual box.
    3. feat(platform): let a stored mock run carry a test's stand-ins (L). Comes after refactor(platform): step live runs as a host on the shared walker #5258. Adds a bench column with a CHECK that refuses it on live runs, raises the reader constant, and shows the test verdict on the run. The deploy gate keeps its in-process suite.
    4. feat(platform): preview a saved version with real reads and real model calls, writes held back (L). Adds the preview mode. Reads and model calls are real and budgeted. Writes and actions of unknown effect are held as "would have sent". Agent steps are simulated, a trigger cannot start a preview, and only the AUTO-R1 roles may start one. Raises the reader constant.
    5. feat(platform): start a preview from the editor and try one model step with the real model (M). Needs units 3 and 4.
    6. feat(platform): add a wait step that parks a run until a time (L). for or until, from 1 second to 30 days. A live run parks with no lease through the existing park path, woken by a delayed job plus the existing sweeper. Mock, test and preview runs finish at once and say what they would have waited for. Under forEach or repeatUntil it is an error at save and at runtime. A subautomation pin that brings in a wait raises the run's stamp. Raises the reader constant.

    Related: #4936, #4927, #4928, #4943, #5258.

    Cross-issue amendments (decisions taken together with #4928, #4936, #4936, #5331):

  3. added
    agent-ready
    and removed
    needs discussion
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyimprovementservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions