Vibescript Showcase
On-call handoff
Package on-call handoffs with typed coverage enums, shift durations, and deterministic reminder times.
Source
showcase/operations/on_call_handoff.vibe
# title: On-call handoff
# category: Vibescript Showcase
# difficulty: Showcase
# summary: Package on-call handoffs with typed coverage enums, shift durations, and deterministic reminder times.
# description: This example treats operational scheduling as a first-class domain, which is where Vibescript's time-aware features start to pay off.
# tags: operations, durations, enums, on-call
# vibe: 0.2
enum CoverageLevel
Primary
Secondary
Commander
end
def shift_length(level: CoverageLevel) -> duration
if level == CoverageLevel::Primary
8.hours
elsif level == CoverageLevel::Secondary
12.hours
else
24.hours
end
end
def handoff_packet(service: string, level: CoverageLevel, started_at: time) -> hash
length = shift_length(level)
ends_at = length.after(started_at)
{
service: service,
level: level.name,
starts_at: started_at.format("2006-01-02T15:04:05Z"),
ends_at: ends_at.format("2006-01-02T15:04:05Z"),
reminder_at: 30.minutes.ago(ends_at).format("2006-01-02T15:04:05Z"),
summary: "{{service}} {{level}} handoff".template({ service: service, level: level.name })
}
end
def run
started_at = Time.at(1701100000)
{
primary: handoff_packet("payments-api", CoverageLevel::Primary, started_at),
commander: handoff_packet("payments-api", CoverageLevel::Commander, started_at)
}
end
Output
Press run to execute run from this example.