/ workflows / examples / hiring.exs
hiring.exs
 1  # Hiring Workflow Example
 2  #
 3  # This workflow demonstrates hierarchical decision-making
 4  # for hiring a new engineer.
 5  #
 6  # Participants: CTO, CHRO, Senior Architect
 7  #
 8  # Decision Pattern: Hierarchical (escalates based on budget)
 9  
10  alias EchoShared.Workflow.Definition
11  
12  Definition.new(
13    "hiring_engineer",
14    "Complete hiring workflow for engineering position",
15    [:cto, :chro, :senior_architect],
16    [
17      # Step 1: CTO identifies need and creates requisition
18      {:request, :cto, "create_hiring_requisition", %{
19        role: "senior_engineer",
20        department: "engineering",
21        justification: "Team capacity constraint"
22      }},
23  
24      # Step 2: CHRO reviews against budget and headcount
25      {:request, :chro, "review_hiring_request", %{
26        check_budget: true,
27        check_headcount: true
28      }},
29  
30      # Step 3: Conditional - escalate to CEO if over budget
31      {:conditional,
32        fn context -> context[:budget_approved] == false end,
33        {:request, :ceo, "approve_hiring_budget", %{urgency: "medium"}},
34        {:notify, :chro, "Budget pre-approved for hiring"}
35      },
36  
37      # Step 4: CHRO approves requisition
38      {:request, :chro, "approve_hiring_requisition", %{}},
39  
40      # Step 5: CHRO posts job and screens candidates
41      {:notify, :chro, "Job posted and candidate screening in progress"},
42  
43      # Step 6: Pause for candidate applications (simulated delay)
44      {:pause, "Waiting for qualified candidates to apply"},
45  
46      # Step 7: Parallel - Technical interviews
47      {:parallel, [
48        {:request, :cto, "conduct_technical_interview", %{focus: "system_design"}},
49        {:request, :senior_architect, "conduct_technical_interview", %{focus: "architecture"}}
50      ]},
51  
52      # Step 8: Collaborative decision on candidate
53      {:request, :chro, "make_offer_decision", %{
54        input_from: [:cto, :senior_architect]
55      }},
56  
57      # Step 9: Record hiring decision
58      {:decision, %{
59        type: "hiring_approval",
60        mode: :hierarchical,
61        participants: [:chro, :cto, :senior_architect],
62        escalated_to: :ceo
63      }}
64    ],
65    timeout: 1_800_000,  # 30 minutes (excluding pause)
66    metadata: %{
67      category: "human_resources",
68      visibility: "leadership",
69      tags: ["hiring", "hierarchical"]
70    }
71  )