Skip to content

Analyzer Showcase

Each example comes from a TypeScript fixture in the analyzer test suite. Switch between the diagram and its source. Runtime examples add a recorded-run tab over the same static graph. Open steps analyzed to inspect inferred output types, error unions, dependency policies, and step metadata.

Start with the examples that match the work in front of you:

You need to inspect Open this example
A short request handler Linear steps
Retry and timeout policy declared on dependencies run() with dependency policies
Branches, parallel work, and iteration in one graph Complex (parallel + conditional + forEach)
Ownership, external calls, state changes, and error severity Architecture and error metadata
Rollback order after a partial failure Saga workflow
Where cancellation stopped work Cancellation: recorded run
Which steps resumed from saved state Persistence: resumed run
Rollback order and a failed undo Saga rollback and compensation failure

The analyzer generates the diagrams below from the source shown beside them. Recorded runs pass through the same trace overlay used by the CLI and live inspector. Edit a step id, branch, policy, or error type in the fixture and regenerate the data; the diagram and step facts change with the code.

Linear steps

Result:Promise<{ user: User; orders: Order[]; }>Errors:NOT_FOUNDFETCH_ERRORSEND_ERROR
3 steps analyzed
getUserdeps.fetchUser
dep: fetchUserNOT_FOUND→ Usererr: "NOT_FOUND"
getOrdersdeps.fetchOrders
dep: fetchOrdersFETCH_ERROR→ Order[]err: "FETCH_ERROR"
notifydeps.sendEmail
dep: sendEmailSEND_ERRORerr: "SEND_ERROR"

step.sleep

Result:Promise<string>
2 steps analyzed
pausestep.sleep
sleep
longPausestep.sleep
sleep

step.retry

Result:Promise<{ data: string; }>Errors:NETWORK_ERROR
1 step analyzed
fetchstep.retry
dep: fetchDataretryNETWORK_ERRORretry: 3 exponential→ { data: string; }err: "NETWORK_ERROR"

step.withTimeout

Result:Promise<number>Errors:TIMEOUT
1 step analyzed
slowCallstep.withTimeout
dep: slowOpwithTimeoutTIMEOUTtimeout: 5000ms→ numbererr: "TIMEOUT"

step.try & step.fromResult

Result:Promise<string>Errors:RISKY_ERRORFETCH_ERROR
2 steps analyzed
attemptstep.try
dep: riskyOptryRISKY_ERROR→ numbererr: "RISKY_ERROR"
loadstep.fromResult
dep: fetchResultfromResultFETCH_ERROR→ stringerr: "FETCH_ERROR"

step.withFallback

Result:Promise<string>Errors:NOT_FOUNDnever
1 step analyzed
fetchWithFallbackstep.withFallback
dep: fetchPrimaryNOT_FOUND→ stringerr: "NOT_FOUND"

step.withResource

Result:Promise<string>Errors:ACQUIRE_ERRORUSE_ERROR
1 step analyzed
useConnstep.withResource
withResourcedeps.acquire → deps.useResource → inline

step.dep

Result:Promise<{ id: string; }>Errors:NOT_FOUND
1 step analyzed
getUserdeps.fetchUser
dep: userServiceNOT_FOUND→ { id: string; }err: "NOT_FOUND"

step.race

Result:Promise<string>Errors:MISS
2 steps analyzed
race.0.cacheAdeps.cacheA
dep: cacheAMISS→ stringerr: "MISS"
race.1.cacheBdeps.cacheB
dep: cacheBMISS→ stringerr: "MISS"

when / unless / whenOr / unlessOr

Result:Promise<ConditionalResult>Errors:AUDIT_FAILEDCOMPUTE_ERROR
4 steps analyzed
whenStepdeps.audit
dep: auditAUDIT_FAILED→ booleanerr: "AUDIT_FAILED"
unlessStepdeps.compute
dep: computeCOMPUTE_ERROR→ numbererr: "COMPUTE_ERROR"
whenOrStepdeps.audit
dep: auditAUDIT_FAILED→ booleanerr: "AUDIT_FAILED"
unlessOrStepdeps.compute
dep: computeCOMPUTE_ERROR→ numbererr: "COMPUTE_ERROR"

switch

Result:Promise<string>Errors:ADMIN_ERRORUSER_ERRORnever
3 steps analyzed
admindeps.adminAction
dep: adminActionADMIN_ERRORerr: "ADMIN_ERROR"
userdeps.userAction
dep: userActionUSER_ERRORerr: "USER_ERROR"
defaultdeps.defaultAction
dep: defaultAction

for / while / for-of / for-in

Result:Promise<string>Errors:PROCESS_ERROR
4 steps analyzed
forStepdeps.processItem
dep: processItemPROCESS_ERRORloop: forerr: "PROCESS_ERROR"
forOfStepdeps.processItem
dep: processItemPROCESS_ERRORloop: itemserr: "PROCESS_ERROR"
forInStepdeps.processItem
dep: processItemPROCESS_ERRORloop: objerr: "PROCESS_ERROR"
whileStepdeps.processItem
dep: processItemPROCESS_ERRORloop: n < 2err: "PROCESS_ERROR"

Workflow ref

Result:Promise<{ user: User; enriched: Enriched; }>Errors:NOT_FOUND
2 steps analyzed
getUserdeps.fetchUser
dep: fetchUserNOT_FOUND→ Usererr: "NOT_FOUND"
callChilddeps.enrichUser
dep: enrichUserENRICH_ERRORUnexpectedError→ Enrichederr: "ENRICH_ERROR" | UnexpectedError

Complex (parallel + conditional + forEach)

Result:Promise<ComplexResult>Errors:ERR
4 steps analyzed
parallel.fetchBoth.fetchAdeps.fetchA
dep: fetchAERR→ stringerr: "ERR"
parallel.fetchBoth.fetchBdeps.fetchB
dep: fetchBERR→ stringerr: "ERR"
forEach.processAll.processItemdeps.processItem
dep: processItemERRloop: items→ stringerr: "ERR"
fetchAOnlydeps.fetchA
dep: fetchAERR→ stringerr: "ERR"

Saga workflow

Result:Promise<{ reservation: { reservationId: string; }; payment: { chargeId: string; }; }>Errors:UNAVAILABLERELEASE_FAILEDCHARGE_FAILEDNOTIFY_FAILED
3 steps analyzed
Reservedeps.reserve
dep: reservecompensableundo: release
Chargedeps.charge
dep: chargecompensable
Notifydeps.notify
dep: notifytry

run() with dependency policies

Result:Promise<{ user: User; orders: Order[]; }>Errors:USER_NOT_FOUNDORDERS_UNAVAILABLETimeoutError
2 steps analyzed
getUsergetUser
dep: getUserUSER_NOT_FOUND→ Usererr: "USER_NOT_FOUND"
getOrdersgetOrders
dep: getOrderstimeout policyretry policyORDERS_UNAVAILABLE→ Order[]err: "ORDERS_UNAVAILABLE"
Policies:
timeout(2_000) → retry({ attempts: 3, delay: 100, backoff: "exponential", })

Architecture and error metadata

Result:Promise<Payment>Errors:PaymentError
1 step analyzed
charge-carddeps.chargeCard
dep: chargeCardCARD_DECLINEDGATEWAY_TIMEOUT→ Paymenterr: PaymentErrorpaymentscheckout-teamside-effectexternal-apipci
Intent:
Collect payment before fulfillment starts
Calls:
payment-gateway
State:
order.paymentStatus -> PAID
Emits:
PaymentCaptured
Errors:
CARD_DECLINED · business · no retry; GATEWAY_TIMEOUT · infrastructure · retryable

Cancellation: recorded run

Result:Promise<Profile>Errors:PROFILE_FAILEDEMAIL_FAILED
2 steps analyzed
loadProfiledeps.loadProfile
dep: loadProfilePROFILE_FAILED→ Profileerr: "PROFILE_FAILED"
sendEmaildeps.sendEmail
dep: sendEmailEMAIL_FAILED→ "sent"err: "EMAIL_FAILED"

Persistence: resumed run

Result:Promise<{ reservation: { id: string; }; payment: { id: string; }; }>Errors:OUT_OF_STOCKPAYMENT_FAILED
2 steps analyzed
reserveStockdeps.reserveStock
dep: reserveStockOUT_OF_STOCK→ { id: string; }err: "OUT_OF_STOCK"
chargedeps.charge
dep: chargePAYMENT_FAILED→ { id: string; }err: "PAYMENT_FAILED"

Saga rollback and compensation failure

Result:Promise<{ payment: { id: string; }; stock: { id: string; }; }>Errors:DECLINEDREFUND_FAILEDOUT_OF_STOCKRELEASE_FAILEDSHIPMENT_FAILED
3 steps analyzed
chargedeps.charge
dep: chargecompensableundo: refund
reservedeps.reserve
dep: reservecompensableundo: release
shipdeps.ship
dep: ship

Use Static Analysis for CI, diffs, test matrices, and trace overlays. Visualization covers runtime event streams.