Vibescript Showcase

Escalation policy

Build support SLAs with typed severity enums, Duration windows, and structured routing output.

Showcase
Source showcase/support/escalation_policy.vibe
# title: Escalation policy
# category: Vibescript Showcase
# difficulty: Showcase
# summary: Build support SLAs with typed severity enums, Duration windows, and structured routing output.
# description: This example keeps operational policy logic explicit by modeling severity, deadlines, and escalation targets directly in the language.
# tags: support, durations, enums, sla
# vibe: 0.2

enum TicketSeverity
  Low
  High
  Critical
end

def response_window(severity: TicketSeverity) -> duration
  if severity == TicketSeverity::Low
    8.hours
  elsif severity == TicketSeverity::High
    2.hours
  else
    15.minutes
  end
end

def escalation_target(severity: TicketSeverity) -> string
  if severity == TicketSeverity::Low
    "support-queue"
  elsif severity == TicketSeverity::High
    "incident-manager"
  else
    "exec-bridge"
  end
end

def ticket_sla(ticket_id: string, severity: TicketSeverity, opened_at: time) -> hash
  window = response_window(severity)
  target = escalation_target(severity)

  {
    ticket_id: ticket_id,
    severity: severity.name,
    response_window: window.iso8601,
    deadline: window.after(opened_at).format("2006-01-02T15:04:05Z"),
    route_to: target,
    summary: "{{ticket}} routes to {{target}}".template({ ticket: ticket_id, target: target })
  }
end

def run
  opened_at = Time.at(1700200000)

  {
    high: ticket_sla("inc_204", TicketSeverity::High, opened_at),
    critical: ticket_sla("inc_205", TicketSeverity::Critical, opened_at)
  }
end
Output
Press run to execute run from this example.
showcase idiomatic-vibescript support durations enums sla browser-runner