Repository navigation
Description
Part 2 of #5276. TALE-369 split #5276 in two. Part 1, worked there, lets a test answer a step's
calls in order (scenarios: { <step>: [<name>, …] }) and closes #5276. This issue is the rest:
the run's own state in mock mode.
Status quo. A connector action's mock is a pure function of its input. Its body runs in the
code runner with { input } alone: toConnector in services/platform/lib/connectors/registry.ts
(in-process runs) and mock mode in services/platform/lib/connectors/dispatcher.ts (durable
runs). A scenario is a fixed answer, and with part 1 a fixed series. So a test cannot simulate
what the run itself wrote:
- create then read, update then read, delete then read;
- a repeated write with the same idempotency key, answered from what the run already wrote;
- an in-doubt write: the write reached the service, but its answer was lost.
Asked. In mock mode, the run's own state for each connector, so that read-after-write, a
repeated key and an in-doubt write can be proven:
- One JSON value per connector per run. A mock body receives a copy beside
inputand returns
the next value with its output, so the body stays inside the code runner's sandbox. The value
has a size cap, and a step whose state outgrows it fails with a sentence that says so. - The outermost run creates the state and shares it with the automations it calls, so one run
has one state. It is never shared between runs or organizations, and it is dropped when the
run ends. - A write whose idempotency key the run already used is answered from the run's record of that
key, the answer it gave the first time, without running the mock again. That is what an
idempotent live action does. - An in-doubt write is a scenario marked as applied (for example
error.applied: true). It runs
the mock, keeps the state change and the answer, then fails as the scenario says. A repeated
write with the same key is answered from the record. - The mocks of the shipped
taskconnector (create,get,list,update_status) keep the
run's tasks, so a test can prove create then read.
Fit with #4929.
- Durable stand-ins: the state goes into the run's checkpoint
(services/platform/backend/core/automations/checkpoints.ts) and is committed with the step's
outcome, so a resumed step sees what the steps before it wrote. This may need Improvement: durable test runs with stand-ins, preview mode, a wait step and the approval line in the run record #4929's protocol
stamp. - Preview: held writes run against the state, and real reads never see it. Whether a preview's
reads should see the run's held writes is for Improvement: durable test runs with stand-ins, preview mode, a wait step and the approval line in the run record #4929 to settle.
Note. An in-process run never repeats a key today. connectorIdempotencyKey(runId, path, item, pass) in services/platform/lib/engine/core/protocol.ts is unique per call. A key
repeats only with #4928's retries, a durable resume, or "run the step again" on an in-doubt park.
A test of a repeated key needs one of those.
Tests (from #5276's triage):
- read-after-write;
- an in-doubt write;
- a repeated key answered from the record;
- isolation across two runs and across two organizations;
- the state is gone once the run ends.
Activity
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences
yannickmonney commentedon Nov 14, 2026
Decision
Build the run's own mock state to the design on
feat/connector-mock-run-state, rebased ontorelease/0.6throughfeature-train.The rule
mockState: truegets{ input, state }, wherestateis a JSON copy of its connector's part (nullbefore any write). It returns{ output, state? }: an absentstatekeeps the current one, andnullclears it. Reads return no state. Every other mock stays a pure function ofinput. Both executors go through one door,lib/connectors/mock-call.ts.idempotent: trueanswer a repeated key from the first answer. Other writes run again.errorscenario may seterror.applied: true. The mock runs, the state and the keyed answer are kept, and the step then fails. In durable runs that state commits with the failure outcome and is never rolled back.CONNECTOR_MOCK_STATE_TOO_LARGE, in every locale.mockState) and is committed in the same fenced statement as the step. A step that is cut off is restored to its mark. Finish or cancel drops the key. No protocol stamp.release/0.6is output cutting, are retargeted. The connector docs (en/de/fr) drop "same input, same output" for the opt-in rule.Answers
{ output, state }.error.applied: true.Rationale. The design keeps the sandbox data-only, copies what an idempotent live action does, commits state atomically with each step, and keeps the pure mocks deterministic. The run-wide cap bounds checkpoint rows. The spec rules and docs fill gaps the branch left.
Units (into
release/0.6viafeature-train)feat(shared): themockStateanderror.appliedschema, with its refusals. (S)feat(platform): in-process state, the door, the idempotency record, the in-doubt write, both caps, the failure reason in every locale, spec rules AUTO-R81/CONN-R37, and the docs. (M)feat(platform): the durable commit, restore after a cut, the in-doubt state kept with the failure, and drop at the end of the run. (M)feat(platform): the task connector keeps the run's tasks. (M)task.createis answered from the record, once retries reuse the key. (S)Cross-issue amendments (decisions taken together with #4929):
feat(platform): let connector scenarios answer call sequences
feat(platform): let connector scenarios answer call sequences