Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/docs/content/docs/workflows/code/diagnostics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Reading and writing `workflow.ts`.
| `E_EDGE_CYCLE` | Wiring that closes a cycle among enabled blocks, a self-loop included: no block on it ever runs. Framed at the edge back to a block declared earlier, the one to remove; repeat work with `loop()`/`parallel()`. |
| `W_EDGE_CYCLE` | A cycle the stored workflow already holds, kept so it round-trips; none of it runs. An offline check reports it for a cycle among blocks the lock binds, which an apply keeps only if the stored workflow holds every edge of it. |
| `W_BRANCH_UNWIRED` | A condition or router branch no edge leaves, so a run that takes it ends there and completes: right for an `else` that should do nothing, so it is never more than a warning; the hint names the wiring. Not reported for a branch the stored workflow already leaves unwired. |
| `W_BODY_UNWIRED` | A loop or parallel with blocks inside but no edge from its start, so a run that reaches it fails; the hint names `p.to(<block>)`. |
| `W_GUARDRAILS_UNHANDLED` | A guardrails block no error edge leaves: a failed check leaves only through the error port, so the run ends there with no output (a condition on `.passed` never runs); the hint names `check.onError(<block>)`. Not reported for a block the stored workflow already holds without one. |
| `E_UNKNOWN_BUILDER` | A builder path the catalog does not have, a bare builder-shaped call (`apii('Name', …)`) nothing binds, or a namespace the SDK lacks or the file did not import; `hint` names the builder a common other name stands for (`http.request` → `api`), then prefers a synonymous verb (`postMessage` → `sendMessage`), then the closest path, then the namespace's builders. |
| `E_UNKNOWN_PARAM` | A param the block does not have; the hint has a did-you-mean, or for block meta written there (`retry`, `disabled`, `locked`, `errorPort`) the third argument that takes it. |
| `E_FIXED_PARAM` | A param the builder already pins. |
Expand Down
20 changes: 20 additions & 0 deletions apps/docs/openapi-v2-workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -19876,6 +19876,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down Expand Up @@ -20363,6 +20365,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down Expand Up @@ -21359,6 +21363,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down Expand Up @@ -22331,6 +22337,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down Expand Up @@ -23113,6 +23121,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down Expand Up @@ -28183,6 +28193,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down Expand Up @@ -28775,6 +28787,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down Expand Up @@ -29192,6 +29206,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down Expand Up @@ -30066,6 +30082,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down Expand Up @@ -30483,6 +30501,8 @@
"E_EDGE_CYCLE",
"W_EDGE_CYCLE",
"W_BRANCH_UNWIRED",
"W_BODY_UNWIRED",
"W_GUARDRAILS_UNHANDLED",
"E_UNKNOWN_BUILDER",
"E_UNKNOWN_PARAM",
"E_FIXED_PARAM",
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/executor/orchestrators/loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class LoopOrchestrator {

if (loopConfig.nodes.length === 0) {
const errorMessage =
'Loop has no executable blocks inside. Add or enable at least one block in the loop.'
'Loop has no block wired from its start. Add or enable a block in the loop and connect the loop start to it.'
const loopType = loopConfig.loopType || 'for'
logger.error(errorMessage, { loopId })
await this.addLoopErrorLog(ctx, loopId, loopType, errorMessage, {})
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/executor/orchestrators/parallel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ParallelOrchestrator {

if (parallelConfig.nodes.length === 0) {
const errorMessage =
'Parallel has no executable blocks inside. Add or enable at least one block in the parallel.'
'Parallel has no block wired from its start. Add or enable a block in the parallel and connect the parallel start to it.'
logger.error(errorMessage, { parallelId })
await this.addParallelErrorLog(ctx, parallelId, errorMessage, {})
this.setErrorScope(ctx, parallelId, errorMessage)
Expand Down
18 changes: 18 additions & 0 deletions packages/sim-cli/src/generated/v2-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,8 @@ export type ApplyWorkflowSourceResponse = {
| 'E_EDGE_CYCLE'
| 'W_EDGE_CYCLE'
| 'W_BRANCH_UNWIRED'
| 'W_BODY_UNWIRED'
| 'W_GUARDRAILS_UNHANDLED'
| 'E_UNKNOWN_BUILDER'
| 'E_UNKNOWN_PARAM'
| 'E_FIXED_PARAM'
Expand Down Expand Up @@ -1386,6 +1388,8 @@ export type ApplyWorkspaceSourceResponse = {
| 'E_EDGE_CYCLE'
| 'W_EDGE_CYCLE'
| 'W_BRANCH_UNWIRED'
| 'W_BODY_UNWIRED'
| 'W_GUARDRAILS_UNHANDLED'
| 'E_UNKNOWN_BUILDER'
| 'E_UNKNOWN_PARAM'
| 'E_FIXED_PARAM'
Expand Down Expand Up @@ -1684,6 +1688,8 @@ export type ApplyWorkspaceSourceResponse = {
| 'E_EDGE_CYCLE'
| 'W_EDGE_CYCLE'
| 'W_BRANCH_UNWIRED'
| 'W_BODY_UNWIRED'
| 'W_GUARDRAILS_UNHANDLED'
| 'E_UNKNOWN_BUILDER'
| 'E_UNKNOWN_PARAM'
| 'E_FIXED_PARAM'
Expand Down Expand Up @@ -5364,6 +5370,8 @@ export type CreateWorkflowFromSourceResponse = {
| 'E_EDGE_CYCLE'
| 'W_EDGE_CYCLE'
| 'W_BRANCH_UNWIRED'
| 'W_BODY_UNWIRED'
| 'W_GUARDRAILS_UNHANDLED'
| 'E_UNKNOWN_BUILDER'
| 'E_UNKNOWN_PARAM'
| 'E_FIXED_PARAM'
Expand Down Expand Up @@ -10596,6 +10604,8 @@ export type GetWorkflowSourceResponse = {
| 'E_EDGE_CYCLE'
| 'W_EDGE_CYCLE'
| 'W_BRANCH_UNWIRED'
| 'W_BODY_UNWIRED'
| 'W_GUARDRAILS_UNHANDLED'
| 'E_UNKNOWN_BUILDER'
| 'E_UNKNOWN_PARAM'
| 'E_FIXED_PARAM'
Expand Down Expand Up @@ -11295,6 +11305,8 @@ export type GetWorkspaceSourceResponse = {
| 'E_EDGE_CYCLE'
| 'W_EDGE_CYCLE'
| 'W_BRANCH_UNWIRED'
| 'W_BODY_UNWIRED'
| 'W_GUARDRAILS_UNHANDLED'
| 'E_UNKNOWN_BUILDER'
| 'E_UNKNOWN_PARAM'
| 'E_FIXED_PARAM'
Expand Down Expand Up @@ -14633,6 +14645,8 @@ export type PlanWorkflowSourceResponse = {
| 'E_EDGE_CYCLE'
| 'W_EDGE_CYCLE'
| 'W_BRANCH_UNWIRED'
| 'W_BODY_UNWIRED'
| 'W_GUARDRAILS_UNHANDLED'
| 'E_UNKNOWN_BUILDER'
| 'E_UNKNOWN_PARAM'
| 'E_FIXED_PARAM'
Expand Down Expand Up @@ -15096,6 +15110,8 @@ export type PlanWorkspaceSourceResponse = {
| 'E_EDGE_CYCLE'
| 'W_EDGE_CYCLE'
| 'W_BRANCH_UNWIRED'
| 'W_BODY_UNWIRED'
| 'W_GUARDRAILS_UNHANDLED'
| 'E_UNKNOWN_BUILDER'
| 'E_UNKNOWN_PARAM'
| 'E_FIXED_PARAM'
Expand Down Expand Up @@ -15394,6 +15410,8 @@ export type PlanWorkspaceSourceResponse = {
| 'E_EDGE_CYCLE'
| 'W_EDGE_CYCLE'
| 'W_BRANCH_UNWIRED'
| 'W_BODY_UNWIRED'
| 'W_GUARDRAILS_UNHANDLED'
| 'E_UNKNOWN_BUILDER'
| 'E_UNKNOWN_PARAM'
| 'E_FIXED_PARAM'
Expand Down
43 changes: 3 additions & 40 deletions packages/workflow-code/src/child-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import type { BlockCatalog } from './catalog/types'
import { type CompileInput, type CompileResult, compileWorkflow } from './compile'
import { stronglyConnected } from './compile/edges'
import type { ChildResultFields } from './json-fields'
import { SOURCE_ENTRY_FILE } from './limits'
import type { WorkflowLockV1 } from './lock'
Expand Down Expand Up @@ -88,7 +89,8 @@ export function resolveChildResults(
nodes: ReadonlyMap<string, ChildResultNode>
): Map<string, ChildResultFields> {
const resolved = new Map<string, ChildResultFields>()
for (const component of stronglyConnected(nodes)) {
const calls = (key: string) => (nodes.get(key)?.calls ?? []).filter((call) => nodes.has(call))
for (const component of stronglyConnected([...nodes.keys()], calls)) {
const members = new Set(component)
for (const key of component) {
const node = nodes.get(key)
Expand All @@ -104,42 +106,3 @@ export function resolveChildResults(
}
return resolved
}

/**
* The strongly connected components of the call graph `nodes` holds (Tarjan's algorithm), each
* listed after every component it calls into.
*/
function stronglyConnected(nodes: ReadonlyMap<string, ChildResultNode>): string[][] {
const index = new Map<string, number>()
const low = new Map<string, number>()
const stack: string[] = []
const onStack = new Set<string>()
const components: string[][] = []
const visit = (key: string) => {
index.set(key, index.size)
low.set(key, index.size - 1)
stack.push(key)
onStack.add(key)
for (const call of nodes.get(key)?.calls ?? []) {
if (!nodes.has(call)) continue
if (!index.has(call)) {
visit(call)
low.set(key, Math.min(low.get(key) ?? 0, low.get(call) ?? 0))
} else if (onStack.has(call)) {
low.set(key, Math.min(low.get(key) ?? 0, index.get(call) ?? 0))
}
}
if (low.get(key) !== index.get(key)) return
const component: string[] = []
let member: string | undefined
do {
member = stack.pop()
if (member === undefined) break
onStack.delete(member)
component.push(member)
} while (member !== key)
components.push(component)
}
for (const key of nodes.keys()) if (!index.has(key)) visit(key)
return components
}
2 changes: 2 additions & 0 deletions packages/workflow-code/src/compile/SYNTAX.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ Errors refuse the whole apply. Warnings are saved as written; info is informatio
| `E_EDGE_CYCLE` | Wiring that closes a cycle among enabled blocks, a self-loop included: no block on it ever runs. Framed at the edge back to a block declared earlier, the one to remove; repeat work with `loop()`/`parallel()`. |
| `W_EDGE_CYCLE` | A cycle the stored workflow already holds, kept so it round-trips; none of it runs. An offline check reports it for a cycle among blocks the lock binds, which an apply keeps only if the stored workflow holds every edge of it. |
| `W_BRANCH_UNWIRED` | A condition or router branch no edge leaves, so a run that takes it ends there and completes: right for an `else` that should do nothing, so it is never more than a warning; the hint names the wiring. Not reported for a branch the stored workflow already leaves unwired. |
| `W_BODY_UNWIRED` | A loop or parallel with blocks inside but no edge from its start, so a run that reaches it fails; the hint names `p.to(<block>)`. |
| `W_GUARDRAILS_UNHANDLED` | A guardrails block no error edge leaves: a failed check leaves only through the error port, so the run ends there with no output (a condition on `.passed` never runs); the hint names `check.onError(<block>)`. Not reported for a block the stored workflow already holds without one. |
| `E_UNKNOWN_BUILDER` | A builder path the catalog does not have, a bare builder-shaped call (`apii('Name', …)`) nothing binds, or a namespace the SDK lacks or the file did not import; `hint` names the builder a common other name stands for (`http.request` → `api`), then prefers a synonymous verb (`postMessage` → `sendMessage`), then the closest path, then the namespace's builders. |
| `E_UNKNOWN_PARAM` | A param the block does not have; the hint has a did-you-mean, or for block meta written there (`retry`, `disabled`, `locked`, `errorPort`) the third argument that takes it. |
| `E_FIXED_PARAM` | A param the builder already pins. |
Expand Down
5 changes: 5 additions & 0 deletions packages/workflow-code/src/compile/catalog.test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const TEST_CATALOG: BlockCatalog = {
condition: { type: 'condition' },
router: { type: 'router_v2' },
fn: { type: 'function' },
guardrails: { type: 'guardrails' },
note: { type: 'note' },
'slack.sendMessage': { type: 'slack', operation: 'send' },
'slack.listChannels': { type: 'slack', operation: 'list_channels' },
Expand Down Expand Up @@ -164,6 +165,10 @@ export const TEST_CATALOG: BlockCatalog = {
{ result: MAY_BE_TEXT, stdout: TEXT },
{ errorOutputs: ['errorMessage'] }
),
guardrails: block('guardrails', [sub('input', 'long-input', 'string', { required: true })], {
passed: { type: 'boolean' },
error: TEXT,
}),
note: block(
'note',
[sub('content', 'long-input', 'string')],
Expand Down
Loading
Loading