Repository navigation
feat(workflows): side-effect-free dry runs - #10402
Conversation
`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
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[Medium impact] The PR appears safe to merge; no blocking issue remains from the reviewed changes. SummaryAdds dry workflow runs that hold back writes, report their requests, and carry the same policy into child workflows.
|
…-delivery baseline
|
@cubic-dev-ai review this PR |
There was a problem hiding this comment.
All reported issues were addressed across 82 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 83 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
…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.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 88 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 91 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
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
…ort discovery takes
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
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
Summary
Adds side-effect-free test runs:
sim workflows run --dry(v2run.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-tooleffectlabels from #10401.What a dry run does
executeToolImplementation, after credentials resolve and before the request is sent.readtool runs.writetool, including agent tool calls, MCP and custom tools, gets a placeholder output shaped like a real one. It is listed insideEffects.stubbedwith the request it would have sent. Credentials, secrets, password-type fields and PII are redacted from that request, andrequestis null whenever redaction cannot be vouched for.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.testtrigger:runCount/lastRunAtupdate;--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.nextkeeps--dryand--allow.Docs and guidance: the source primers,
.sim/AGENTS.md,run --help, the docs and the integration skills now test with--dryand readsideEffects.Type of Change
Testing
dry-run.integration.ts,dry-run-hosted-key.integration.ts). Each case was shown red with its guard reverted before green:workflow_executor;runCountis unchanged;--allowscoping and the refusals for Workflow and custom blocks;--mocksteering a branch, and the mock refusals (locked blocks,_pauseMetadata, billing fields);sideEffects;run.dry.nexthints are correct.executeToolwith 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.bun run generate,lint,type-check, rootbun run test,check:audits,check:api-validation:strict,check:test-types;content:verify-compatibility,check-block-registry.ts origin/staging;test:integrationfor the dry-run, rerun, pause/resume, memory, execute-version and settlement suites./simplifyand/cleanup(comments and test-audit).Checklist
test-auditauthoring gate)