The Last Application · Part V — Technical Appendices

Chapter 20 — Workflows: Process, Agentic, and Hybrid

6 min read

A workflow is not a second product. It is a typed object in GG whose payload is itself a graph of steps. This chapter gives that graph a mathematics covering process (BPM-class), agentic orchestration, hybrid composition, runs, and loops.

Workflow as an object in GG

Definition 20.1 (Workflow object). A workflow is an object wVw \in V with schema in the workflow family and payload containing a workflow graph WW. Write wWw \hookrightarrow W.

Definition 20.2 (Workflow graph).

W=(N,A,κ,μ,n0)W = (N, A, \kappa, \mu, n_0)

where:

  • NN is a finite set of nodes (steps).
  • AN×NA \subseteq N \times N is a finite set of arcs (control-flow edges), each optionally gated by a predicate γ:Data{0,1}\gamma: \mathsf{Data} \to \{0,1\}.
  • κ:NK\kappa: N \to K assigns a kind from a finite kind alphabet KK.
  • μ:NMeta\mu: N \to \mathsf{Meta} assigns finite metadata (forms, adapters, orchestration, waits, …).
  • n0Nn_0 \in N is the entry node.

Kind alphabet (representative).

K    {start,end,collect,decision,gateway,human,agent,tool,transform,integration,subprocess,wait,timer}.K \;\supseteq\; \{\mathsf{start},\, \mathsf{end},\, \mathsf{collect},\, \mathsf{decision},\, \mathsf{gateway},\, \mathsf{human},\, \mathsf{agent},\, \mathsf{tool},\, \mathsf{transform},\, \mathsf{integration},\, \mathsf{subprocess},\, \mathsf{wait},\, \mathsf{timer}\}.

Catalog facet. A workflow object also carries a facet tag

facet(w){process,agentic,hybrid}\mathsf{facet}(w) \in \{\mathsf{process},\, \mathsf{agentic},\, \mathsf{hybrid}\}

used for authoring and cataloguing. Facet is not a second graph format: both process and agentic workflows are instances of Definition 20.2.

Run state

Definition 20.3 (Run). A run is a tuple

ρ=(w,s,tok,D,H)\rho = (w,\, s,\, \mathsf{tok},\, D,\, H)

where:

  • ww identifies the workflow object,
  • s{running,waiting,completed,failed,cancelled}s \in \{\mathsf{running},\, \mathsf{waiting},\, \mathsf{completed},\, \mathsf{failed},\, \mathsf{cancelled}\} is status,
  • tokN\mathsf{tok} \subseteq N is the set of active tokens (marking),
  • DD is a finite run data map (keys to values),
  • HH is a finite history of step events.

Definition 20.4 (Waiting modes). When s=waitings = \mathsf{waiting}, a mode

m{waiting_human,waiting_ide,waiting_external,waiting_timer}m \in \{\mathsf{waiting\_human},\, \mathsf{waiting\_ide},\, \mathsf{waiting\_external},\, \mathsf{waiting\_timer}\}

records which external agency must resume the run.

Firing a step

Definition 20.5 (Step effect). Firing node nn in run ρ\rho against product graph GG produces:

  1. An optional product mutation Δn=Prop(n,G,D)\Delta_n = \mathrm{Prop}(n, G, D),
  2. An updated data map DD',
  3. A next marking tok\mathsf{tok}',
  4. A status ss' (possibly waiting).

The product update, when present, is always through Chapter 19:

Gδ(G,Δn)only if I(G,Δn)=1.G \leftarrow \delta(G, \Delta_n) \quad \text{only if } I(G, \Delta_n) = 1.

A step that would violate integrity does not commit; the run records failure or routes to repair according to WW.

Definition 20.6 (Sequential advance). On an ordinary arc (n,n)(n, n') with gate γ\gamma:

tok=(tok{n}){n}iff γ(D)=1.\mathsf{tok}' = (\mathsf{tok} \setminus \{n\}) \cup \{n'\} \quad \text{iff } \gamma(D) = 1.

Process (BPM-class) structure

Process workflows emphasize business control flow.

Definition 20.7 (Decision). If κ(n)=decision\kappa(n) = \mathsf{decision}, metadata supplies a finite branch map

β:KeysN\beta: \mathsf{Keys} \rightharpoonup N

and a key extraction k=key(D)k = \mathrm{key}(D). The successor is β(k)\beta(k) when defined; otherwise a default or failure arc.

Definition 20.8 (Gateway). A gateway node implements AND/OR split or join. For a parallel split with successors n1,,nkn_1, \ldots, n_k:

tok=(tok{n}){n1,,nk}.\mathsf{tok}' = (\mathsf{tok} \setminus \{n\}) \cup \{n_1, \ldots, n_k\}.

For a join of predecessors p1,,pkp_1, \ldots, p_k, the gateway fires when {p1,,pk}arrived\{p_1, \ldots, p_k\} \subseteq \mathsf{arrived}, then emits a single successor token.

Definition 20.9 (Human / collect / integration).

  • collect\mathsf{collect} — binds a form schema; completion writes fields into DD and may seal secrets into a vault handle (never into chat).
  • human\mathsf{human} — sets m=waiting_humanm = \mathsf{waiting\_human}; resume requires an authorized actor.
  • integration\mathsf{integration} — invokes a sealed connector; effects outside GG are mediated by handles recorded in DD and events.

Definition 20.10 (Domain of a step). The write-domain dom(n)V\mathrm{dom}(n) \subseteq V is the set of product objects nn may modify. Two steps na,nbn_a, n_b are write-disjoint when

write(na)dom(nb)=        write(nb)dom(na)=.\mathrm{write}(n_a) \cap \mathrm{dom}(n_b) = \emptyset \;\;\wedge\;\; \mathrm{write}(n_b) \cap \mathrm{dom}(n_a) = \emptyset.

Proposition 20.1 (Parallel safety). If a parallel split fires write-disjoint steps and each child proposal is validated, the merged mutation

Δ=ΔaΔb\Delta = \Delta_a \cup \Delta_b

may be validated atomically; under write-disjointness, δ(G,Δa)\delta(G, \Delta_a) then δ(G,Δb)\delta(G', \Delta_b) coincides with δ(G,Δ)\delta(G, \Delta) when both orders pass II.

Proof sketch. Disjoint writes imply commuting updates on GG; integrity on the merge is the conjunction of local typing/referential obligations plus shared structural constraints. \square

Agentic structure

Agentic substance lives inside agent nodes, not as a parallel BPM of specialists.

Definition 20.11 (Orchestration). If κ(n)=agent\kappa(n) = \mathsf{agent}, metadata may include an orchestration

O=(P,Ag,H,J,B)O = (P,\, \mathcal{Ag},\, H_{\leftrightarrow},\, J,\, B)

where:

  • P{single,pipeline,supervisor,swarm}P \in \{\mathsf{single},\, \mathsf{pipeline},\, \mathsf{supervisor},\, \mathsf{swarm}\} is the pattern,
  • Ag={a1,,am}\mathcal{Ag} = \{a_1, \ldots, a_m\} is a finite set of specialist agents (roles, tools, prompts as data),
  • HAg×AgH_{\leftrightarrow} \subseteq \mathcal{Ag} \times \mathcal{Ag} is the handoff relation (who may call whom),
  • JJ is a finite set of interrupt points (HITL mid-orchestration),
  • BB is a budget (step cap, token cap, time cap).

Definition 20.12 (Agentic step as an operator). Executing nn with orchestration OO induces a finite interaction trace

τ=(ai1,,ai),B\tau = (a_{i_1}, \ldots, a_{i_\ell}), \quad \ell \le B

and a proposal Δn=Prop(τ,G,D)\Delta_n = \mathrm{Prop}(\tau, G, D). Interrupts pause with m=waiting_humanm = \mathsf{waiting\_human} or m=waiting_idem = \mathsf{waiting\_ide} when an IDE-capable agent node is declared.

Definition 20.13 (IDE-capable node). A node may declare ideCapable=true\mathsf{ideCapable} = \mathsf{true}. Then the run may enter m=waiting_idem = \mathsf{waiting\_ide}; an external IDE agent fetches a task, performs work, and submits a result that resumes ρ\rho — still through Prop\mathrm{Prop} and II, never as an ungated side channel.

Axiom 20.1 (One audit trail). Whether the muscle of an agent step is hosted inference, an IDE agent, or an external executor, the run ρ\rho and product mutations Δ\Delta remain the system of record. Executors are pluggable; WW and ρ\rho are not.

Hybrid

Definition 20.14 (Hybrid workflow). facet(w)=hybrid\mathsf{facet}(w) = \mathsf{hybrid} when WW contains both BPM-class control nodes (collect, gateway, human, integration, …) and at least one agent node (possibly with OO). Formally:

nN:  κ(n){collect,human,gateway,integration}        nN:  κ(n)=agent.\exists\, n \in N:\; \kappa(n) \in \{\mathsf{collect},\, \mathsf{human},\, \mathsf{gateway},\, \mathsf{integration}\} \;\;\wedge\;\; \exists\, n' \in N:\; \kappa(n') = \mathsf{agent}.

Hybrid is the product claim in one sentence: business process and agentic judgment share one governed graph and one run.

Loops (governed iteration)

Definition 20.15 (Loop). A loop is a subgraph pattern with a distinguished decision node nn_\ell carrying

L=(id,b,passKey,proves)L_\ell = (\mathsf{id},\, b,\, \mathsf{passKey},\, \mathsf{proves})

where bNb \in \mathbb{N} is a fail budget and passKey\mathsf{passKey} names a boolean in DD set by a deterministic verifier (not by model self-assessment).

Branches:

passif D[passKey]=true,failif D[passKey]=false    c<b,exhaustedif D[passKey]=false    cb,\begin{aligned} \mathsf{pass} &\quad\text{if } D[\mathsf{passKey}] = \mathsf{true}, \\ \mathsf{fail} &\quad\text{if } D[\mathsf{passKey}] = \mathsf{false} \;\wedge\; c < b, \\ \mathsf{exhausted} &\quad\text{if } D[\mathsf{passKey}] = \mathsf{false} \;\wedge\; c \ge b, \end{aligned}

with counter cc incremented on each fail. Exhaustion routes to HITL.

Formal reading. A loop is δ\delta with an explicit validate stage: body proposes, verify evaluates a predicate V(G,D){0,1}V(G, D) \in \{0,1\}, pass commits onward, fail repairs, exhausted escalates.

Composition of workflows

Definition 20.16 (Subprocess). If κ(n)=subprocess\kappa(n) = \mathsf{subprocess}, metadata references another workflow ww^\dagger. Firing nn spawns a child run ρ\rho^\dagger whose completion writes outputs into DD and returns a token to the parent.

Definition 20.17 (Sequential composition of workflows). wa;wbw_a ; w_b is the workflow that runs wbw_b after waw_a completes, either by arc or by subprocess. Product mutations accumulate as

Gi+1=δ(Gi,Δi)G_{i+1} = \delta(G_i, \Delta_i)

along the run.

Definition 20.18 (Intent composition, informal). When two product intents share typed structure and the same gated store, their composition is the pushout of their subgraphs in GG (shared identifiers glue). When they do not share GG, composition degenerates to integration by convention — outside R(S)R(S).

Soundness obligations

ObligationStatement
Graph SoTWW lives in GG; runtime does not keep a shadow process definition
Gated effectsEvery product write uses δ\delta and II
Parallel safetyParallel tokens respect write-disjointness or merged validate
Agentic enclosureSpecialists live in OO, not as ungated side graphs
Loop honestyPass/fail from deterministic VV, not model self-grade
Waiting integrityResume from human/IDE/external re-enters the same ρ\rho

The point

Process and agentic work are one mathematics: workflow graphs, markings, gated mutations. Hybrid is their conjunction. Loops are governed δ\delta. Architecture chapters next place these objects among pillars and projections.