Skip to content
Merged
19 changes: 19 additions & 0 deletions .changeset/33757-flow-dry-run-contract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@objectstack/spec': patch
---

feat(spec): `IAutomationService.dryRun`, a dry run of a flow definition that need not be published: once, unarmed, as a named user, against a supplied start, without changing live data (#33757)

Clause-②: yes (widening) — a new optional member on `IAutomationService` and new exported types. No existing member, type or code changes, and an implementation without the member still satisfies the contract.
Metadata-protocol: none

The contract half of #33661 (objectstack-ai/cloud#3309 item 5, option A, ruled by the account owner); #33661 implements it in `@objectstack/service-automation` and `@objectstack/runtime`. The method's doc block states the semantics the implementation owes:

- **Writes are simulated, never made.** `create_record`, `update_record` and `delete_record` report the write they would make (object, operation, target rows, values as computed) and a three-way `permission`: an insert or update answers `allowed` or `refused` from the object-level write check, a delete answers `not_judged`, and every write answers `not_judged` when no object-level check is installed; `not_judged` never means allowed, and row-level refusals are never reported. A create binds an opaque placeholder id that later reads by id see, holding only the fields the flow set; an updated row reads as the live row with the simulated fields laid over it. No hook, trigger, other flow or audit row runs, since nothing is written.
- **Identity is the named user**, whose own grants the engine resolves, and the run is never elevated, a `runAs: 'system'` definition included. A `tenantId` must be an organization the user is a member of. Admission is the by-name start rule (`flowStartRefusal`), judged on the supplied definition against the named user; a refusal answers `status: 'refused'` with `PERMISSION_DENIED`, before any node runs.
- **A start condition that does not hold** answers `status: 'condition_not_met'` with the condition, mirroring the live run's skip exit. One whose evaluation throws answers `status: 'failed'` with no steps, the condition and the thrown message in `startCondition`, as the live run's catch does on the default error strategy; under `errorHandling.strategy: 'retry'` the live run's retry attempts do not evaluate the start condition (#33935), so there the dry run's answer is its own. Both answer before the node input-schema check.
- **Approval nodes and waits stop the run** (every node type whose descriptor declares `supportsPause: true`), reported with who would be asked, what would resume it, the screen, or the flow it would start. Nothing is created or scheduled.
- **Side effects outside the data** (`notify`, `http`, `connector_action`, `script`, `save_notice`) are never sent, only reported with their computed payload.
- **Unarmed and unregistered**: never registered or listed, the trigger never armed, no run persisted, one pass with no retry. An invalid definition throws what `registerFlow` throws.

**In-process APIs.** `@objectstack/spec/contracts` exports `FlowDryRunOptions`, `FlowDryRunResult`, `FlowDryRunStatus`, `FlowDryRunRefusalCode`, `FlowDryRunWritePermission`, `FlowDryRunStep` and the step types it unions over (`FlowDryRunStepBase`, `FlowDryRunRouteStep`, `FlowDryRunAssignmentStep`, `FlowDryRunDecisionStep`, `FlowDryRunReadStep`, `FlowDryRunWriteStep`, `FlowDryRunOutboundStep`, `FlowDryRunStopStep`). All additive.
14 changes: 14 additions & 0 deletions packages/spec/api-surface/contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@
"FieldFileDescription (interface)",
"FieldFileSlot (interface)",
"FinishReason (type)",
"FlowDryRunAssignmentStep (interface)",
"FlowDryRunDecisionStep (interface)",
"FlowDryRunOptions (interface)",
"FlowDryRunOutboundStep (interface)",
"FlowDryRunReadStep (interface)",
"FlowDryRunRefusalCode (type)",
"FlowDryRunResult (interface)",
"FlowDryRunRouteStep (interface)",
"FlowDryRunStatus (type)",
"FlowDryRunStep (type)",
"FlowDryRunStepBase (interface)",
"FlowDryRunStopStep (interface)",
"FlowDryRunWritePermission (type)",
"FlowDryRunWriteStep (interface)",
"FlowRuntimeState (interface)",
"FlowUnboundCause (type)",
"GenerateDraftOpts (interface)",
Expand Down
14 changes: 14 additions & 0 deletions packages/spec/export-origins/contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@
"FieldFileDescription": "src/contracts/storage-service.ts#FieldFileDescription (interface)",
"FieldFileSlot": "src/contracts/storage-service.ts#FieldFileSlot (interface)",
"FinishReason": "node_modules/ai/dist/index.d.ts#FinishReason (type)",
"FlowDryRunAssignmentStep": "src/contracts/automation-service.ts#FlowDryRunAssignmentStep (interface)",
"FlowDryRunDecisionStep": "src/contracts/automation-service.ts#FlowDryRunDecisionStep (interface)",
"FlowDryRunOptions": "src/contracts/automation-service.ts#FlowDryRunOptions (interface)",
"FlowDryRunOutboundStep": "src/contracts/automation-service.ts#FlowDryRunOutboundStep (interface)",
"FlowDryRunReadStep": "src/contracts/automation-service.ts#FlowDryRunReadStep (interface)",
"FlowDryRunRefusalCode": "src/contracts/automation-service.ts#FlowDryRunRefusalCode (type)",
"FlowDryRunResult": "src/contracts/automation-service.ts#FlowDryRunResult (interface)",
"FlowDryRunRouteStep": "src/contracts/automation-service.ts#FlowDryRunRouteStep (interface)",
"FlowDryRunStatus": "src/contracts/automation-service.ts#FlowDryRunStatus (type)",
"FlowDryRunStep": "src/contracts/automation-service.ts#FlowDryRunStep (type)",
"FlowDryRunStepBase": "src/contracts/automation-service.ts#FlowDryRunStepBase (interface)",
"FlowDryRunStopStep": "src/contracts/automation-service.ts#FlowDryRunStopStep (interface)",
"FlowDryRunWritePermission": "src/contracts/automation-service.ts#FlowDryRunWritePermission (type)",
"FlowDryRunWriteStep": "src/contracts/automation-service.ts#FlowDryRunWriteStep (interface)",
"FlowRuntimeState": "src/contracts/automation-service.ts#FlowRuntimeState (interface)",
"FlowUnboundCause": "src/contracts/automation-service.ts#FlowUnboundCause (type)",
"GenerateDraftOpts": "src/contracts/external-datasource-service.ts#GenerateDraftOpts (interface)",
Expand Down
Loading
Loading