82 / BPMN / PROCESS MODELING · EVENTS · GATEWAYS · MESSAGES · WAIT STATES
82 / METHODOLOGY / BUSINESS PROCESS MODEL AND NOTATION

BPMN.

BPMN — Business Process Model and Notation — стандарт графического моделирования процессов. Он показывает кто выполняет работу, в каком порядке идут действия, где процесс ждёт события, где ветвится, где идёт параллельно, где возникает ошибка, какое сообщение пересекает границу участника и как процесс завершается.

Главная идея: BPMN нужен, когда важна динамика выполнения. Если IDEF0 отвечает «какие функции и контексты существуют?», BPMN отвечает «что происходит сначала, что потом, при каком условии, кто ждёт кого и что происходит при исключении?».
00. ARCHITECTURAL STATUS

DESIGN-TIME PROCESS MODELING METHODOLOGY

№82 относится к METHODOLOGY / DEFAULT N/A / SEPARATE COMPONENT N/A / Design-time / Process Modeling. BPMN может быть чисто документационной моделью или стать executable specification для workflow engine — но сама нотация не является runtime service.
TYPEMETHODOLOGYProcess and orchestration modeling.
DEFAULTN/ANot a request-time mechanism.
USE WHENORDER / WAIT / BRANCH / HANDOFF MATTEREspecially long-running workflows.
SEPARATE COMPONENTN/ANotation/specification.
LIVES INDESIGN-TIME / PROCESS MODELINGWorkflow, operations, business process.
COMPLEXITYLOW → HIGHHappy path → full exception/event model.
USE FOR PROCESS DYNAMICS
80% практической ценности: pools/lanes, start/end events, tasks/subprocesses, sequence flow, message flow, exclusive/parallel/event-based gateways, timers, errors/escalations, boundary events, explicit wait states and compensation where relevant. Для AI-workflows этого уже достаточно, чтобы формально описать approvals, retries, tool waits, async jobs, human handoff and cancellation.
01A. ARCHITECTURE BOUNDARIES & OPERATIONS

ГДЕ BPMN НАХОДИТСЯ ОТНОСИТЕЛЬНО СОСЕДНИХ ТЕМ

A. BOUNDARY WITH NEIGHBORS

№81 IDEF0 — functional structure and ICOM; BPMN — executable/process dynamics. №68 Durable Workflow — runtime engine semantics such as replay/timers/checkpoints; BPMN can specify the business flow it executes. №57 Queues, №58 Scheduler, №59 Broker — execution infrastructure, not process logic. №42 Events & Triggers define event semantics; BPMN shows how process reacts to them.

B. PREREQUISITES / CROSS-REFERENCES

Полезные соседи: №10 State Management, №11 Workflows, №42 Events & Triggers, №49 HITL, №50 Contracts, №57–59 execution fabric, №63 Resilience, №68 Durable Workflow, №69 Reliability, №77 Production Architecture, №81 IDEF0.

C. CONTROL / DATA / RUNTIME / OFFLINE

CONTROL PLANE: process definitions, versions, timers, role/pool mapping, error policies. DATA PLANE: process instances, messages, variables, task results, correlation IDs. RUNTIME: workflow engine or orchestrator executes equivalent semantics. OFFLINE: process design, review, optimization, conformance and incident analysis.

D. FAILURE & OPERATIONS CONTRACT

Success: process has explicit start/end, every wait has wake-up event, every consequential task has failure path, participants are clear, branches are semantically correct, and long-running instances can resume. Failure: generic diamonds, implicit waits, sequence flow across pools, swallowed errors, no cancellation semantics, or diagrams that cannot map to real system state.

E. WHAT THIS TOPIC DOES NOT OWN

BPMN does not define internal reasoning, model routing, queue delivery guarantees, API schemas, database state or retry implementation details. It owns PROCESS SEMANTICS: ORDER, PARTICIPANTS, EVENTS, WAITING, BRANCHING, HANDOFF AND TERMINATION.

01. THE CORE ELEMENTS

EVENTS · ACTIVITIES · GATEWAYS · FLOWS · PARTICIPANTS

EVENT

Something happens

Start, intermediate, end; message, timer, error, signal, escalation etc.

ACTIVITY

Work happens

Task or subprocess performed by human/system/service.

GATEWAY

Flow logic

Exclusive, parallel, inclusive, event-based and other routing semantics.

SEQUENCE FLOW

Inside participant

Defines order of execution within a pool/process.

MESSAGE FLOW

Between participants

Represents communication across pool boundaries.

02. POOLS & LANES

WHO PARTICIPATES?

POOL

Participant boundary

Organization, external system, customer, provider or process participant.

LANE

Responsibility inside pool

Team, role, subsystem or responsibility grouping.

RULE

No sequence flow across pools

Cross-participant communication uses Message Flow.

POOL: CUSTOMER
  [Submit request] ──message──▶

POOL: AI PRODUCT
  Lane: API
  Lane: Orchestrator
  Lane: Human Reviewer

POOL: EXTERNAL PROVIDER
  [Model/API]
Для AI architecture pool часто лучше использовать как participant/trust boundary, а lanes — как responsibility grouping. Не превращайте lanes в список микросервисов без необходимости.
03. TASK TYPES

NOT EVERY TASK IS THE SAME KIND OF WORK

USER TASK

Human work

Approval, review, manual correction, data entry.

SERVICE TASK

Automated service call

API call, model invocation, deterministic backend operation.

SCRIPT TASK

Engine-side logic

Small local transformation in engine/runtime when supported.

MANUAL / BUSINESS RULE

Other semantics

Manual offline action or rules engine decision where appropriate.

В AI workflows model call чаще всего логически Service Task. Human approval — User Task. Не надо рисовать “LLM Agent” как participant, если он просто service capability внутри вашего system pool.
04. SUBPROCESS

HIDE DETAIL WITHOUT LOSING PROCESS SEMANTICS

COLLAPSED

One box at parent level

Shows meaningful process unit without visual overload.

EXPANDED

Internal flow visible

Use when child steps/events matter to current audience.

CALL ACTIVITY

Reusable process

Invoke a separately defined reusable process rather than copying it.

Reusable verification, approval or document-ingestion workflows often fit better as Call Activities than duplicated task chains.
05. EXCLUSIVE GATEWAY — XOR

ONE PATH

                    ┌── yes ──▶ [Human approval]
[Check risk] ──▶ ◇
                    └── no  ──▶ [Auto continue]

Exactly one outgoing path
should be selected
for a given token.

Use when:
  mutually exclusive conditions.

Do not use parallel gateway
to represent alternatives.
Typical AI use: if risk_class = HIGH → HITL; else continue automatically.
06. PARALLEL GATEWAY — AND

ALL PATHS

                 ┌──▶ [Retrieve internal knowledge] ──┐
[Prepare task] ─▶ ✚                                  ✚ ─▶ [Synthesize]
                 └──▶ [Fetch external evidence] ─────┘

Split:
  activates all branches.

Join:
  waits for all active branches
  arriving at that synchronization point.

Use when:
  branches are independent
  and all are required.
Parallel fan-out can multiply AI cost. BPMN says branches are parallel; Production Architecture still needs concurrency limits, budgets and cancellation.
07. INCLUSIVE GATEWAY — OR

ONE OR MORE PATHS

USE

Multiple conditions may be true

Need internal RAG and/or web research and/or code calculation.

JOIN

Wait for activated branches

More complex than XOR/AND because not all paths necessarily start.

CAUTION

Don't use by default

If logic can be expressed more clearly with explicit subprocess/rules, prefer simpler model.

08. EVENT-BASED GATEWAY

PATH DEPENDS ON WHICH EVENT HAPPENS FIRST

                  ┌── message: approval received ──▶ [Continue]
[Wait] ────────▶ ◇
                  └── timer: 24h elapsed ──────────▶ [Escalate]

The gateway does NOT inspect data.
It waits for competing events.

This is ideal for:
  human response vs timeout
  external callback vs deadline
  webhook vs cancellation
Это один из самых важных BPMN patterns для agentic workflows: explicit race between asynchronous events.
09. START EVENTS

HOW PROCESS INSTANCE BEGINS

NONE

Generic start

Use when trigger semantics do not matter in diagram.

MESSAGE

External request

Email/API/message arrives and starts process.

TIMER

Scheduled start

Daily report, recurring reconciliation, SLA check.

SIGNAL / OTHER

Broadcast/domain trigger

Use only when actual semantics match.

10. INTERMEDIATE EVENTS

PROCESS CAN WAIT, CATCH, THROW OR REACT MID-FLOW

MESSAGE

Wait/send message

External callback, human response, provider notification.

TIMER

Wait/deadline

Delay, timeout, scheduled continuation.

ERROR / ESCALATION

Failure semantics

Error usually interrupts current scope; escalation can route higher-level handling.

SIGNAL

Broadcast

One signal may be caught by multiple interested processes.

11. END EVENTS

HOW THIS PATH / PROCESS TERMINATES

NONE END

Normal completion

Current path ends with no special throw behavior.

MESSAGE END

Finish + send

Process ends while emitting a message.

ERROR END

Terminate with error

Propagate failure to enclosing scope when modeled accordingly.

TERMINATE END

Stop whole process scope

Ends all active paths in the current process scope; use deliberately.

12. BOUNDARY EVENTS

WHAT IF SOMETHING HAPPENS WHILE TASK IS RUNNING?

                     boundary timer
                          ◷
                          │
                          ▼
                 ┌─────────────────┐
sequence ───────▶ │ Wait for Human  │ ───────▶ approved
                 └─────────────────┘
                          │
                          └────────▶ timeout escalation

Interrupting boundary event:
  cancels attached activity.

Non-interrupting boundary event:
  starts side path
  while activity continues.

Use for:
  timeout
  error
  escalation
  message
  compensation-related handling
For HITL, boundary timer is much cleaner than an invisible “if reviewer doesn't answer eventually do something”.
13. MESSAGE FLOW vs SEQUENCE FLOW

PROCESS ORDER AND INTER-PARTICIPANT COMMUNICATION ARE DIFFERENT

FlowMeaningWhere
Sequence FlowOrder of activity/event execution.Within same pool/process.
Message FlowCommunication between separate participants.Across pool boundaries.
AssociationLinks artifacts/annotations/data to elements.Documentation/data relation, not execution order.
A provider API response is not necessarily a “sequence flow from provider task into our task”. If provider is separate participant, communication is message flow.
14. CORRELATION

ASYNC MESSAGE MUST RESUME THE RIGHT PROCESS INSTANCE

BUSINESS KEY

Stable correlation

run_id, order_id, approval_id, job_id, callback token.

MESSAGE EVENT

Wait by correlation

Process instance waits for matching external event.

LATE MESSAGE

State-aware handling

Expired/cancelled process should not blindly resume from stale callback.

BPMN draws the wait; runtime №68/69 must implement durable correlation and idempotency.
15. HUMAN-IN-THE-LOOP PATTERN

APPROVAL IS A WAIT STATE, NOT A SYNCHRONOUS FUNCTION CALL

[Prepare action]
      ↓
[Create approval task]
      ↓
◇ event-based
 ├── message: APPROVED
 │      ↓
 │   [Execute action]
 │
 ├── message: REJECTED
 │      ↓
 │   [Cancel / revise]
 │
 └── timer: SLA EXPIRED
        ↓
     [Escalate / expire]

Important:
  process state is durable;
  worker need not stay alive;
  approval carries exact frozen operation;
  late approvals are checked against current state.
16. TOOL CALL PATTERN

SIMPLE TOOL CALL vs LONG-RUNNING EXTERNAL JOB

SYNC TOOL

Service Task

Short call with timeout and typed result. Error boundary handles failures.

ASYNC TOOL/JOB

Start + wait for message

Submit job, persist external job ID, wait for callback/message, timeout if needed.

SHORT:
[Call API] → [Use result]

LONG:
[Submit job]
    ↓
[Wait callback]
  ├─ message success → [Consume artifact]
  ├─ message failed  → [Handle failure]
  └─ timer deadline  → [Cancel / fallback]
17. RETRY

DO NOT DRAW AN INFINITE LOOP CALLED “TRY AGAIN”

TRANSIENT ERROR

Retryable

Provider timeout, rate limit, temporary network failure.

BOUNDED

Count / deadline

Retry must stop after explicit bound or remaining deadline.

BACKOFF

Wait semantics

Timer event/subprocess can represent delayed retry.

PERMANENT ERROR

No retry

Schema invalid, permission denied, policy block, unsupported request.

BPMN can model retry logic, but actual retry/idempotency rules belong to №63/69 and service contracts.
18. COMPENSATION

UNDO IS NOT THE SAME AS RETRY

Process:
  reserve hotel
  reserve flight
  charge card

If later step fails:
  may need compensation:
    cancel hotel
    cancel flight
    refund

Compensation means:
  execute business reverse action
  for already completed side effect.

It is NOT:
  database transaction rollback
  guaranteed exact reversal
  automatic for every task.

Each action needs:
  compensability semantics
  operation identity
  current-state checks.
Для agent actions compensation must be explicit. “User said stop” after external commit does not magically reverse the operation.
19. TRANSACTION SUBPROCESS

USE CAREFULLY — BUSINESS TRANSACTION ≠ ACID DATABASE TRANSACTION

SCOPE

Business transaction

Long-running group of actions that may need compensation.

CANCEL / COMPENSATE

Explicit behavior

Handle failed business process via compensation handlers.

CAUTION

Not distributed ACID

External APIs rarely provide one atomic transaction across all systems.

20. MULTI-INSTANCE

RUN ONE ACTIVITY FOR MANY ITEMS

SEQUENTIAL

One by one

Process 20 documents serially when ordering/resource limits matter.

PARALLEL

Concurrent

Process multiple items at once, bounded by real runtime concurrency.

COMPLETION CONDITION

May stop early

For example, stop research branches after enough verified evidence exists.

This maps naturally to agent research fan-out, but must obey TOC/backpressure/budget constraints.
21. AD-HOC SUBPROCESS

WHEN TASK SET EXISTS BUT ORDER IS FLEXIBLE

USE

Flexible work bundle

Investigation/research where several activities may occur in varying order until condition is met.

CAUTION

Don't hide chaos

If order/conditions can be formalized, explicit flow is easier to operate and test.

AI “agentic” behavior can sometimes be represented as ad-hoc subprocess, but runtime ownership still belongs to planner/orchestrator and state manager.
22. DATA OBJECTS & DATA STORES

PROCESS CAN SHOW DATA WITHOUT TURNING INTO ER DIAGRAM

DATA OBJECT

Local process artifact

Request, report, approval packet, evidence set.

DATA STORE

Persistent store

Database, artifact store, knowledge store.

ASSOCIATION

Shows use/production

Does not imply sequence flow.

REFS

Prefer stable refs

Large artifacts should be referenced, not embedded in workflow state.

23. BPMN FOR AI TASK

END-TO-END EXAMPLE

START: message "new task"
  ↓
[Authenticate / create run]
  ↓
[Formulate task]
  ↓
◇ XOR: evidence required?
  ├─ no ───────────────────────┐
  │                            │
  └─ yes                       │
       ↓                       │
   [Retrieve evidence]         │
       ↓                       │
   ◇ XOR: sufficient?          │
       ├─ yes ───────────────┐ │
       └─ no                 │ │
            ↓                │ │
        [External research]  │ │
            ↓                │ │
            └────────────────┘ │
                              ↓
                         [Generate answer]
                              ↓
                         [Verify result]
                              ↓
                     ◇ XOR: verification
                     ├─ PASS → [Commit output] → END
                     ├─ REVISE → [Revise] ─────┐
                     │                         │
                     └─ HIGH RISK              │
                           ↓                   │
                      [Human approval]         │
                       ◷ timeout               │
                       ├ approved →────────────┘
                       ├ rejected → END rejected
                       └ timeout → END escalated
BPMN makes wait and branching semantics explicit; actual model/tool calls remain implemented by R01–R09 and Production Fabric.
24. BPMN FOR INGESTION

EVENT-DRIVEN + PERIODIC RECONCILIATION

START:
  webhook OR scheduler

        ↓
[Discover changes]
        ↓
[Fetch source]
        ↓
[Parse / extract]
        ↓
◇ XOR: parse valid?
  ├─ no → [Quarantine / retry policy]
  └─ yes
       ↓
   [Persist source version]
       ↓
   [Update index]
       ↓
   [Write provenance]
       ↓
   [Publish ingestion completed]
       ↓
END

SEPARATE TIMER PROCESS:
  nightly reconciliation
       ↓
  [Compare source vs local checkpoint]
       ↓
  [Repair missed updates]
25. BPMN FOR HUMAN APPROVAL OF ACTION

FREEZE INTENT BEFORE WAITING

[Prepare exact operation]
  ↓
[Persist operation_id + immutable args]
  ↓
[Create approval request]
  ↓
◇ event-based
  ├─ APPROVED
  │    ↓
  │ [Re-check permission / current state]
  │    ↓
  │ [Execute once]
  │    ↓
  │ [Verify outcome]
  │    ↓
  │ END success
  │
  ├─ REJECTED
  │    ↓
  │ END rejected
  │
  └─ TIMER EXPIRED
       ↓
    [Expire approval]
       ↓
    END expired

Late approval after expiry:
  ignored/rejected by state check.
26. BPMN & DURABLE WORKFLOW

DIAGRAM SEMANTICS MUST SURVIVE PROCESS RESTART

WAIT STATE

Persisted

Human/message/timer waits survive worker restart.

TIMER

Durable

Wake-up not tied to one process thread staying alive.

SIDE EFFECT

Idempotent

Replay cannot repeat external commit.

VERSION

Running instances

Workflow definition changes need migration/version compatibility strategy.

BPMN can be excellent executable spec only when runtime engine preserves these semantics. Otherwise diagram and implementation drift apart.
27. BPMN & EVENTS / QUEUES / BROKER

MODEL THE BUSINESS EVENT; IMPLEMENT TRANSPORT SEPARATELY

BPMN EVENT

Business/process meaning

“Approval received”, “payment failed”, “deadline reached”.

BROKER / QUEUE

Transport/execution

Kafka/SQS/Rabbit/worker queue moves message/work.

CONTRACT

Bridge

Versioned event/message envelope maps runtime delivery to BPMN event semantics.

Do not draw “Kafka message” as business concept unless transport itself matters to the process. Prefer domain event names.
28. BPMN & IDEF0

FUNCTIONAL STRUCTURE → PROCESS DYNAMICS

IDEF0

Defines major functions, inputs, controls, outputs and mechanisms.

SELECT PROCESS

Choose where temporal behavior, waits and handoffs matter.

BPMN

Model event order, branching, participants, timers, exceptions and completion.

29. BPMN & TOC

PROCESS MODEL MAKES WAITING AND WIP VISIBLE

WAIT

Where time accumulates

User task queues, external callbacks, timers.

HANDOFF

Potential friction

Pool/lane boundaries reveal ownership transitions.

TOC

Which one constrains throughput?

Telemetry on BPMN stages can reveal real system constraint.

30. BPMN & KT

INCIDENT LOCATION + DIAGNOSIS

BPMN

Where in lifecycle?

Which task, gateway, wait or participant is associated with deviation?

KT

Why?

Use IS/IS NOT, distinctions and changes to diagnose cause at that process point.

31. BPMN MODEL LEVELS

DON'T PUT EVERY ERROR CODE ON ONE CANVAS

L0

Collaboration view

Main participants and message exchanges.

L1

Main process

Major tasks, gateways, waits and outcomes.

L2

Subprocess detail

Retries, approvals, evidence acquisition, exception handling.

L3

Executable detail where needed

Exact timer/event/error semantics and mappings to runtime contracts.

Use collapsed subprocesses to keep parent diagrams readable. Deep detail only where operation or automation needs it.
32. AI-ASSISTED BPMN

LLM CAN DRAFT PROCESS LOGIC — BUT MUST NOT INVENT WAIT STATES OR BUSINESS RULES

EXTRACT

From SOP/docs

Identify participants, activities, decisions, messages, timers and exceptions.

NORMALIZE

Choose notation

Convert vague “then maybe” descriptions into candidate gateways/events.

CHECK

Find missing paths

What happens on timeout, rejection, failure, cancellation, duplicate callback?

CAUTION

Unknown stays unknown

If SLA or approval rule is missing, mark it as a requirement gap rather than fabricating it.

33. STRUCTURED BPMN-LIKE CONTRACT

PROCESS DEFINITION CAN BE MACHINE-CHECKED

{
  "process_id":"approve_action_v3",
  "participants":["ai_system","human_reviewer"],
  "start":{"type":"message","name":"approval_requested"},
  "steps":[
    {"id":"freeze","type":"service_task"},
    {"id":"wait","type":"event_based_gateway"},
    {"id":"approved","type":"message_catch"},
    {"id":"rejected","type":"message_catch"},
    {"id":"expired","type":"timer_catch","after":"24h"},
    {"id":"execute","type":"service_task"}
  ],
  "end_states":[
    "success","rejected","expired","failed"
  ]
}
VALUE

Static validation

Tooling can detect unreachable nodes, missing end states, invalid cross-pool sequence flows, tasks with no error handling and waits with no resume event.

34. STATIC CHECKS

SOME PROCESS BUGS CAN BE CAUGHT BEFORE DEPLOYMENT

UNREACHABLE

Dead nodes

Task/event cannot be reached from any start.

NO END

Zombie process

Path has no terminal or durable wait state.

XOR AMBIGUOUS

Conditions overlap

Multiple branches can be true when model expects one.

WAIT WITHOUT CORRELATION

Cannot resume safely

External message lacks stable business key.

SIDE EFFECT RETRY

Duplicate risk

Task can retry but has no operation/idempotency semantics.

BOUNDARY MISSING

No timeout/error path

Long external/human task can hang forever.

POOL FLOW ERROR

Wrong connector

Sequence Flow crosses participant boundary.

PARALLEL JOIN RISK

Deadlock

Join waits for branches that may never have been activated.

35. ANTI-PATTERNS

HOW BPMN BECOMES A FLOWCHART WITH FANCY ICONS

GENERIC DIAMOND
No one knows XOR/AND/event semantics.
USE CORRECT GATEWAY
SEQUENCE ACROSS POOLS
Participant boundaries collapse.
MESSAGE FLOW
NO START / END
Process boundary unclear.
EXPLICIT LIFECYCLE
IMPLICIT WAIT
“Then reviewer responds someday”.
MESSAGE/TIMER EVENTS
EVERY FAILURE = RETRY
Permanent errors loop forever.
ERROR CLASS + BOUNDED RETRY
UNDO = RETRY
External side effects duplicated/corrupted.
COMPENSATION SEMANTICS
TECH STACK AS LANES
Diagram becomes service map rather than process.
ROLE / RESPONSIBILITY LANES
BPMN = IMPLEMENTATION
Diagram and runtime semantics drift.
MAP TO WORKFLOW CONTRACTS + TEST
36. PROCESS METRICS

MODEL BECOMES USEFUL WHEN RUNTIME EVENTS MAP BACK TO PROCESS STEPS

CT

Cycle Time

Start → terminal outcome.

WAIT

Wait Time

Human/external/timer waiting by step.

ERR

Error Rate

Failures by task/subprocess and cause class.

RTR

Retry Rate

Transient retries and success after retry.

ESC

Escalation Rate

Share of instances routed to human/escalated path.

EXP

Expiry Rate

Human/tool waits that hit timer deadline.

CMP

Compensation Rate

Business reversals triggered after partial completion.

STUCK

Stuck Instances

Instances with no valid terminal/wait transition beyond expected SLA.

37. 30-MINUTE BPMN SESSION

LIGHTWEIGHT WORKFLOW MODELING

TimeAction
0–3 minDefine process start, end and scope.
3–7 minIdentify participants/pools and responsibility lanes.
7–13 minDraw happy-path tasks and sequence flows.
13–18 minAdd real gateways: XOR/AND/event-based.
18–23 minAdd message/timer/error boundary events and explicit wait states.
23–26 minReview side effects, retries, cancellation and compensation.
26–30 minCheck terminal outcomes, correlation keys, subprocess boundaries and runtime ownership.
38. PRACTICAL WORKSHEET

COPY THIS FOR A REAL PROCESS

BPMN WORKSHEET
=========================================================

PROCESS NAME
→

PURPOSE
→

START EVENT
[ ] none
[ ] message
[ ] timer
[ ] signal
Other:
→

END STATES
1.
2.
3.

PARTICIPANTS / POOLS
1.
2.
3.

LANES / RESPONSIBILITIES
1.
2.
3.

---------------------------------------------------------

HAPPY PATH

1.
2.
3.
4.
5.

---------------------------------------------------------

DECISIONS / GATEWAYS

Gateway:
[ ] XOR
[ ] AND
[ ] OR
[ ] Event-based

Condition/event:
→

Branches:
→

Join behavior:
→

---------------------------------------------------------

WAITS

Human wait:
→
Resume message:
→
Timeout:
→

External callback:
→
Correlation key:
→
Timeout:
→

---------------------------------------------------------

ERRORS

Task:
→

Retryable errors:
→

Permanent errors:
→

Retry count/deadline:
→

Fallback:
→

---------------------------------------------------------

SIDE EFFECTS

Consequential action:
→

operation_id:
→

Can retry safely?
→

Compensation available?
→

Cancellation semantics:
→

---------------------------------------------------------

SUBPROCESSES

Reusable subprocess:
→

Long-running subprocess:
→

---------------------------------------------------------

STATIC CHECK

[ ] every path starts from valid start
[ ] every path reaches end or durable wait
[ ] no sequence flow crosses pools
[ ] all waits have wake-up events
[ ] XOR conditions are exclusive/default exists
[ ] parallel joins cannot deadlock
[ ] consequential retries are idempotent
[ ] timeout/error path exists where needed
[ ] late message handling defined
[ ] diagram maps to real runtime state
39. AI PROMPT TEMPLATE

BPMN-STYLE PROCESS MODELING ASSISTANT

You are assisting with BPMN process modeling.

1. Define process scope, start and terminal outcomes.
2. Identify participants as pools and responsibilities as lanes.
3. Build the happy path using activities and sequence flows.
4. Distinguish:
   - sequence flow inside participant;
   - message flow between participants.
5. Use explicit gateway semantics:
   XOR = one branch,
   AND = all branches,
   OR = one or more,
   event-based = whichever event occurs first.
6. Model waits explicitly with message/timer events.
7. Model human approval as a durable wait state.
8. For long external jobs:
   submit → wait callback → timeout/failure/success.
9. For every task with external side effects:
   define idempotency/operation identity,
   retry class,
   cancellation semantics,
   compensation if available.
10. Add boundary events for timeout/error where material.
11. Do not invent missing SLA, approval rule or business condition;
    mark it as a requirement gap.
12. Check every path reaches:
    terminal outcome
    OR explicit durable wait.
13. If functional decomposition rather than timing is the main question,
    recommend IDEF0 instead.
14. If model is intended to execute,
    map every activity/event to a concrete runtime contract.
40. PRACTICAL DECISION

WHERE BPMN EARNS ITS PLACE

QuestionAnswer
Стоит ли использовать?Да. Для multi-step workflows with waits, events, human handoffs, branching, retries and external participants.
Separate Component?N/A. BPMN is notation/specification; a workflow engine may execute equivalent semantics.
Минимум 80% ценности?Start/end, pools/lanes, tasks, sequence/message flow, XOR/AND/event-based gateways, timers, error/timeout boundaries and explicit human/external waits.
Когда overkill?Simple function decomposition with no meaningful sequence/waits; tiny synchronous call chain that code expresses more clearly.
Trigger?“What happens after this?”, “Who waits?”, “What if approval never arrives?”, “What if two branches run in parallel?”, “How does cancellation work?”.
Как измерить uplift?Fewer stuck workflows, clearer ownership, lower timeout/escalation ambiguity, fewer duplicate side effects and faster implementation/review.
Можно ли использовать AI?Да. AI drafts/normalizes process models; deterministic validators and runtime tests must verify semantics and implementation mapping.
41. DESIGN RULES

THE BPMN RULEBOOK

RULE 01

Start and end explicitly

Every process instance has a lifecycle.

RULE 02

Sequence inside, messages across

Respect participant boundaries.

RULE 03

Use correct gateway semantics

XOR, AND and event-based are not interchangeable diamonds.

RULE 04

Waiting is first-class

Human/external delay must become explicit process state.

RULE 05

Timeouts are process paths

“Eventually” is not an operational contract.

RULE 06

Errors differ from business rejection

Technical failure, negative decision and timeout need separate semantics.

RULE 07

Retry only transient work

Permanent errors and policy blocks should not loop.

RULE 08

Compensation is explicit

External side effects are not automatically reversible.

RULE 09

Executable model must map to runtime state

Diagram, workflow engine, contracts and observability should agree.

42. FINAL MAP

BPMN AS THE PROCESS DYNAMICS LAYER

START
  ↓
DEFINE PROCESS SCOPE
  ↓
WHO PARTICIPATES?

POOL A
POOL B
POOL C

within pool:
  lanes = responsibility

between pools:
  MESSAGE FLOW

within pool:
  SEQUENCE FLOW

────────────────────────────────────────

PROCESS ELEMENTS:

EVENT
  something happens

TASK
  work happens

GATEWAY
  flow decision / synchronization

SUBPROCESS
  grouped process behavior

DATA OBJECT / STORE
  process data context

────────────────────────────────────────

GATEWAYS:

XOR
  exactly one path

AND
  all paths

OR
  one or more

EVENT-BASED
  whichever event happens first

────────────────────────────────────────

WAITING:

human approval
external callback
timer
message
signal

WAIT IS STATE.

A WORKER
DOES NOT NEED TO STAY ALIVE.

────────────────────────────────────────

FAILURE:

service task
  ↓
boundary error
  ├─ transient → bounded retry
  ├─ fallback
  └─ permanent → fail path

timer:
  task waits too long
  ↓
timeout path

business rejection:
  separate from technical error

────────────────────────────────────────

CONSEQUENTIAL ACTION:

prepare exact operation
  ↓
freeze arguments + operation_id
  ↓
approval if required
  ↓
execute once
  ↓
verify
  ↓
if later failure:
  compensation only if defined

────────────────────────────────────────

AI WORKFLOW EXAMPLE:

message start
  ↓
formulate
  ↓
need evidence?
  ├─ no
  └─ yes → retrieve
             ↓
          sufficient?
          ├─ yes
          └─ no → external research
  ↓
generate
  ↓
verify
  ↓
PASS?
  ├─ yes → commit → END
  ├─ revise → revise loop
  └─ high-risk → human wait
                    ├─ approved
                    ├─ rejected
                    └─ timeout

────────────────────────────────────────

WITH OTHER METHODS:

IDEF0
  what functions exist?

BPMN
  how do they unfold over time?

TOC
  where does flow constrain throughput?

KT
  why did a process step deviate?

TRIZ
  how can process conflict be redesigned?

DURABLE WORKFLOW
  how does runtime persist/replay/wake?

QUEUES / BROKER
  how does work/message move?

CONTRACTS
  what exact payload crosses each boundary?

OBSERVABILITY
  what actually happened in each instance?

────────────────────────────────────────

THE CENTRAL BPMN QUESTION:

“WHAT EXACTLY HAPPENS
WHEN THE HAPPY PATH
DOES NOT HAPPEN?”

WHO WAITS?
FOR WHAT?
FOR HOW LONG?
WHAT WAKES THE PROCESS?
WHAT IF THE MESSAGE IS LATE?
WHAT IF THE TASK FAILS?
WHAT IF THE USER REJECTS?
WHAT IF TWO BRANCHES RUN?
WHAT IF ONE SIDE EFFECT
ALREADY COMMITTED?

WHEN THOSE ANSWERS
ARE EXPLICIT,
THE PROCESS
STOPS BEING
A BOX-AND-ARROW STORY
AND BECOMES
AN OPERATIONAL MODEL.

ECC RETROFIT / PRACTICAL HARNESS INTEGRATION

A. Related ECC ideas. Context-as-cache, scoped memory, lifecycle hooks, selective capabilities, feature flags, deterministic enforcement, provider-neutral adapters and eval-gated learning are applied only where relevant to №82 BPMN.

B–E. Existing boundary and placement. The existing conceptual boundary, class METHODOLOGY, default N/A and owner Design-time / Problem Solving remain authoritative. Runtime/control/data/offline placement is unchanged; durable state stays outside model context.

F–H. Hooks and contracts. Use bounded PRE_MODEL/POST_MODEL, PRE_TOOL/POST_TOOL, CHECKPOINT and TASK_COMPLETED events as applicable. Illustrative fields and canonical contracts are defined in NEW_CONTRACTS_SPEC.md; no universal schema is implied.

I–J. Security and evaluation. Host-side schema, permission, secret, budget, idempotency and audit checks take precedence over LLM output. Optional mechanisms require a feature flag and WITH/WITHOUT ablation; measure quality, acceptance, correction, latency, cost, escalations and severe errors.

K–L. Task profiles and cross-references. A TaskProfile selects the relevant skill, tool/context slice, memory scope and enforcement profile independently from FAST/STANDARD/DEEP. See cross-reference map, hook spec and ablation plan. Provider adapters remain outside the core.