Skip to content

feat(workflows): side-effect-free dry runs - #10402

Merged
waleedlatif1 merged 10 commits into
stagingfrom
feat/workflow-dry-runs
Nov 25, 2026
Merged

waleedlatif1 merged 10 commits into
stagingfrom
feat/workflow-dry-runs

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Adds side-effect-free test runs: sim workflows run --dry (v2 run.dry). It runs the saved draft with reads, model calls and code for real, sends no externally visible write, and keeps nothing beyond the run's own log. It builds on the per-tool effect labels from #10401.

What a dry run does

  • Tool calls: every tool call goes through one decision point in executeToolImplementation, after credentials resolve and before the request is sent.
    • A read tool runs.
    • A write tool, including agent tool calls, MCP and custom tools, gets a placeholder output shaped like a real one. It is listed in sideEffects.stubbed with the request it would have sent. Credentials, secrets, password-type fields and PII are redacted from that request, and request is null whenever redaction cannot be vouched for.
  • Code runs for real and is listed once per block in sideEffects.unchecked, because its network calls cannot be intercepted. That covers Function blocks, Condition expressions, While/Do-While conditions and code an Agent's model writes.
  • Child workflows inherit dry mode.
  • Blocks answered whole with a placeholder: custom blocks, Mothership, Pi, Human in the loop and Wait. A dry run never pauses.
  • Nothing persists beyond the run's own log, which is recorded under the test trigger:
    • no workspace execution events, and test runs are excluded from alert-rule statistics;
    • no runCount/lastRunAt update;
    • no agent memory writes;
    • no hosted-key rate-limit budget drawn for a write that will be stubbed;
    • files uploaded to a provider's Files API are deleted after use, including on partial failure.
  • --allow <block> sends that block's writes for real. It is keyed by workflow and block, and refused for Workflow, custom, Human in the loop and Wait blocks.
  • --mock <block>=<json> answers a block with fixed output. It works only in dry runs, is refused on locked blocks, and refuses fields the executor or billing reads (cost, tokens, model, _*, …). Mock values are never stored.
  • Test runs as a source: a test run (a dry run or a workflow test) is never the source state of a non-dry run. This is enforced where execution state is loaded, so the v2 API, the editor and Copilot all follow it, and "latest" skips test runs. A test run is never resumed.
  • Rerun hints: a failed dry run's next keeps --dry and --allow.
  • Workflow tests use the same policy: any write they don't mock is stubbed.

Docs and guidance: the source primers, .sim/AGENTS.md, run --help, the docs and the integration skills now test with --dry and read sideEffects.

Type of Change

  • New feature

Testing

  • Integration, real Postgres and Redis (dry-run.integration.ts, dry-run-hosted-key.integration.ts). Each case was shown red with its guard reverted before green:
    • no row written and no request sent;
    • a child workflow's write is stubbed, including one called by an Agent through workflow_executor;
    • custom blocks and Wait are answered whole;
    • agent memory is not written;
    • no workspace event or subscriber run fires, and runCount is unchanged;
    • password, URL-query and PII redaction;
    • --allow scoping and the refusals for Workflow and custom blocks;
    • --mock steering a branch, and the mock refusals (locked blocks, _pauseMetadata, billing fields);
    • a test run refused as a source by the v2 use case, the editor route and Copilot (by name and as latest);
    • resume refused for a test run;
    • a failed dry run keeps sideEffects;
    • the hosted-key counter is unchanged after a dry write, with a live run drawing a key as the positive control;
    • the v2 route forwards run.dry.
  • Unit:
    • MCP and custom tools are recorded by their arguments only;
    • provider Files API uploads are removed after a partial failure, a Gemini processing failure, and on success;
    • a cached-final Agent turn uploads nothing;
    • the CLI next hints are correct.
  • Benchmark: executeTool with no policy (non-dry), staging vs branch, 3 × 10,000 calls, shows no difference (read about 19.6 µs median, write about 19.4 µs). A stubbed dry write adds about 3 µs.
  • Gate:
    • bun run generate, lint, type-check, root bun run test, check:audits, check:api-validation:strict, check:test-types;
    • docs content:verify-compatibility, check-block-registry.ts origin/staging;
    • test:integration for the dry-run, rerun, pause/resume, memory, execute-version and settlement suites.
  • Review: three adversarial review rounds, plus /simplify and /cleanup (comments and test-audit).

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

`sim workflows run --dry` (v2 execute `run.dry`, manual runs only) runs the
saved draft without sending its writes. Every tool call not declared `read`
(table writes, sends, HTTP calls, custom tools, and every MCP tool, which
declares no effect) is answered with a placeholder shaped like the tool's
outputs and listed in the run result's `sideEffects.stubbed` with the request
it would have sent: an in-process operation's input or an HTTP call's method,
URL and body, with the credentials the call resolved and the run's resolved
secrets redacted. Reads, model calls, conditions and credential resolution run
for real. Function blocks run their code and are listed in
`sideEffects.unchecked`. Mothership and Pi blocks, which act outside the tool
seam, and Human in the loop and Wait blocks, whose paused run would resume
without the dry run, are answered whole. Dry runs are logged under the `test`
trigger and are synchronous only (no stream, async or waitTimeoutSeconds).

The interception is one check in `executeToolImplementation`, after
credentials resolve and before dispatch, so block and Agent tool calls are
covered alike. The policy rides on the execution context as `sideEffects`,
which every child inherits: Workflow blocks, custom blocks, and workflows or
custom blocks an Agent calls as tools, so a child's writes stay stubbed.

`run.allowBlocks` (`--allow <block>`) sends one block's writes for real and
lists them in `sideEffects.allowed`; `run.mocks` (`--mock <block>=<json|@file>`)
answers a block with a fixed output through the existing mock seam, with or
without `--dry`. Both resolve blocks by id, name or key like `--stop-after`.
Workflow tests now answer the writes their mocks do not with the same
placeholders. A failed dry run's `next` rerun keeps `--dry`.

The source primers, `sim workflows source --help`, `run --help`, the CLI,
build-and-run and coding-agent docs, and the integration skills now test with
`--dry`.
…view

A dry run now sends no externally visible write and keeps nothing beyond its
own `test`-trigger log:

- Test runs raise no workspace event (emitExecutionCompletedEvent) and are
  left out of alert-rule statistics (excludeEventlessExecutionsCondition), so
  a dry run never starts a Sim-trigger subscriber.
- Test runs do not bump workflow.runCount or lastRunAt.
- Agents read memory but write none under a side-effect policy (no turn
  session, no appended messages).
- The policy decides a write before a hosted key is drawn, so a stubbed write
  spends no rate-limit slot; credential resolution still runs.
- Files a dry run uploads to a provider Files API are deleted once the model
  call settles.
- Custom blocks, on a canvas or called by an Agent (deployed_block_executor),
  are answered whole and never run, so nothing lands in the publisher's
  workspace and none of its internals reach the consumer.
- Code (function_execute) runs for real for a Function block or an Agent and
  is listed unchecked with a reason naming the caller; Condition evaluation is
  not listed.
- run.mocks requires run.dry. Allowed and mocked blocks are keyed by the run's
  own workflow and block; --allow on a Workflow or custom block is refused.
- A tool's nested executeTool calls (postProcess) run in the caller's
  _context, so an allowed block's follow-up writes are allowed too; Pi's Sim
  tools carry the Pi block id.
- A test run is refused as the source of a non-dry from-block run.
- A failed dry run keeps its sideEffects, compacted inside the result's own
  error mapping; the run result and `runs get` report the dry run's allowed and
  mocked blocks (`dryRun`), so every `next` rerun keeps --dry, --allow and
  --mock (a workflow test's run keeps --dry).
- sideEffects requests: MCP and custom tool calls are recorded by their
  arguments only (never envVars or other run context), password-field values
  are masked whatever the field is called, and the workspace's PII redaction
  is applied; a request that cannot be vouched for is null.

Contract and CLI: mocks are typed as objects, `omitted` is counted per list,
`allowed` is deduped per block and tool, blockId/block are null instead of
empty, the policy is WriteStubPolicy with decideWrite/answerBlock and mocks
live on it (block-mocks.ts and the service's testHooks param are gone),
`--dry --async` says to drop --async, and the CLI's repeated-option collector
and plain-object check are shared. The workflow-dir guide names `apply
--dry-run` and `run --dry` apart, and the primer's run line is reworded; its
other rewordings from the previous commit stay because the 4096-byte primer
budget forces them.
…p persisting mocks

- A test run (trigger test: dry runs and workflow tests) is never the source of a run that sends
  its writes: getExecutionStateForWorkflow refuses one unless the caller passes allowTestRun (only
  a dry run from a block does), and getLatestExecutionStateWithExecutionId skips them. This
  covers the v2 use case, the editor execute route (named and latest) and Copilot
  run_from_block/run_block, and replaces the per-surface check.
- A test run is never resumed: resume admission refuses an execution logged under test, the CLI
  names no resume command for one, and workflow tests answer Human in the loop and Wait blocks
  whole like dry runs, so the pausingBlocks option is gone.
- run.mocks are data: a field starting with _ (_pauseMetadata and other executor control fields)
  is refused, and so is a mock of a locked block or one inside a locked container.
- Mock outputs are no longer persisted: the log records only allowed and mocked block ids.
  readWorkflowRun reads them from the execution data the status read already materialized (so
  they survive externalization), validated with the contract schema and gated like other
  execution data. The CLI rerun keeps --dry and --allow; --mock values are passed again.
- Provider Files API uploads register their removal as soon as the provider names the file, the
  caller owns the list, and the try/finally starts before the first upload, so a dry or test run
  deletes every file that landed, including on a partial or Gemini processing failure.
- A dry run never rejects a large inline response, so its result always carries sideEffects.
- Nested tool calls inherit the caller's _context only under a side-effect policy.
- Cleanups: one response-too-large mapping, request passed directly to answerUnsentWrite, one
  run-context param set, one log lookup for the source run, recordSettledRun reads the trigger
  from the LoggingSession, a TEST_TRIGGER constant, tool special cases in one declarative map,
  password fields indexed once from the registry, agent memory decided once, and toArray in the
  CLI. Allowing an Agent covers only its own tool calls (documented; the CLI notes when an
  allowed block sent nothing).
…n in a dry run

- One rule for mocks (run.mocks and workflow-test mockBlock): refuse any _ field and the
  output fields the trace span and bill are built from (cost, tokens, model, providerTiming,
  toolCalls, executionData, childTraceSpans, child workflow ids); block samples omit them too
- List Condition expressions and While/Do While loop conditions under sideEffects.unchecked,
  once per block, via a new SideEffectPolicy.ranCode
- Upload provider Files API attachments only after the cached-final early return
- Keep a failed dry run's sideEffects when compacting its error output fails
- Read the paused run's trigger in the same locked query; memoize getBlockByToolName and
  password params lazily; drop the test-only removals default; simplify answered-block and
  tool decisions; narrow the editor route try
- Tests: durable-state check instead of sleep, specific refusals, positive controls, transport
  guard on the hosted-key test, success-path upload cleanup
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 25, 2026 12:48pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue remains from the reviewed changes.

Summary

Adds dry workflow runs that hold back writes, report their requests, and carry the same policy into child workflows.

  • Workflow drafts can run with writes held back and reported.
  • Test runs leave workflow activity and temporary provider files behind.
  • Test-run outputs no longer feed live workflow reruns.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Dry workflow run] --> B[Read or model call]
  A --> C[Write tool call]
  B --> D[Run for real]
  C --> E{Block allowed?}
  E -->|Yes| D
  E -->|No| F[Check credentials]
  F --> G[Return placeholder]
  G --> H[Report redacted request]
  A --> I[Child workflow inherits dry policy]
Loading

Reviews (6) · Last reviewed commit: "fix(mcp): read-only discovery takes ever..." · Reviewed by Greptile

Comment thread apps/sim/tools/side-effects.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 82 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/tools/side-effects.ts Resolved
Comment thread apps/sim/tools/index.ts Resolved
Comment thread .agents/skills/add-tools/SKILL.md Resolved
@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 83 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/tools/index.ts Resolved
…ry reads

- Build a stubbed write's request from params whose secrets are already masked
  (credential fields and password fields by field and value, collected at any
  depth, then the run's resolved secrets by its registry), so no builder
  transformation such as base64 document content can carry a secret; the
  payload pass and registry projection stay as defense in depth.
- Authorize and check an MCP write against the server's tools (checkOnly) before
  answering it, so an unusable one fails in a dry run as it would live.
- Let a dry run's Agent read its stored conversation (rich history and the memory
  retrieval tool) without opening a turn or writing memory.
- CLI: refuse --mock __proto__, and count omitted entries in the dry-run summary.
- Contract: run.mocks emits maxProperties 50; texts now say the rerun record keeps
  only mocked block ids while the log shows a mocked output redacted like any
  other block's.
- Primer and guide name sideEffects.unchecked and warn that live runs write real
  data; integration skills mention the 50-entry cap and null requests.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/sim/tools/side-effects.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 88 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread .agents/skills/add-tools/SKILL.md Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 91 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mcp/service.ts Resolved
Comment thread .agents/skills/add-tools/SKILL.md Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 91 files

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mcp/service.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 91 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 16add2e into staging Nov 25, 2026
87 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 31dd5cbc Deployed Nov 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant