agentic examples

The Lightning Talks

The Lightning Talks: five speakers, five minutes each, one GONG. The lightning talk is conference culture's greatest API: a hard timeout with applause. Speakers are tasks on a single-track stage (concurrency 1 - there is one podium); each presents slide by slide; and the gong is checked BETWEEN slides, because you can't interrupt a slide mid-sentence but you absolutely can decline to show the next one. Run over and the gong takes the mic, politely, in front of everyone. The …

Testing & Verification Round 18 Akira Matsuda exit 0

source on github

bundle exec ruby examples/lightning_talks.rb

a real captured run

THE LIGHTNING TALKS (a hard timeout with applause)

  speaker       talk                                       slides       outcome
  a_matz_uda    Pagination Considered Wonderful            8/8          applause (41ms, under time)
  gem_hoarder   My Gem Has 0 Downloads: a Love Story       9/9          applause (46ms, under time)
  dr_rambles    A Brief History of Everything (pt. 1/40)   8/30         GONG at 52ms - slide 8, mid-gesture
  ci_arsonist   How I Broke CI in 3 Languages              7/7          applause (43ms, under time)
  ractor_fan    Waiting for Ractor: a Musical              8/8          applause (41ms, under time)

  referee: session ran 228ms against a worst-case budget of
  250ms; every gong landed within one slide of the limit.

  the design notes are conference-tested: the timeout is checked at
  SLIDE boundaries, not mid-slide - cooperative cancellation at safe
  points, which is also how you cancel anything that holds state.
  the gong is enforced by the STAGE, not the speaker (dr_rambles
  believed sincerely in slide 30). and the schedule composes: five
  bounded talks make one bounded session, which is why LT sessions
  are the only conference block that never runs late. a five-minute
  limit with a gong is worth forty minutes of speaker discipline -
  timeboxes beat promises, in talks and in tasks.

source

# frozen_string_literal: true

# The Lightning Talks: five speakers, five minutes each, one GONG.
# The lightning talk is conference culture's greatest API: a hard
# timeout with applause. Speakers are tasks on a single-track stage
# (concurrency 1 - there is one podium); each presents slide by
# slide; and the gong is checked BETWEEN slides, because you can't
# interrupt a slide mid-sentence but you absolutely can decline to
# show the next one. Run over and the gong takes the mic, politely,
# in front of everyone. The session ends on time. Sessions END ON
# TIME. This is the entire technology.
#
#   bundle exec ruby examples/lightning_talks.rb
#
# Runs offline; exits 1 unless the rambler was gonged, the punctual
# finished, and the session respected the schedule.

require class="s">"bundler/setup"
require class="s">"agentic"

Agentic.logger.level = class="y">:fatal

def mono = Process.clock_gettime(Process:class="y">:CLOCK_MONOTONIC)

LIMIT = 0.05 # class="s">"five minutes" (conference seconds are small)
TALKS = [
  {speaker: class="s">"a_matz_uda", title: class="s">"Pagination Considered Wonderful", slides: 8, pace: 0.005},
  {speaker: class="s">"gem_hoarder", title: class="s">"My Gem Has 0 Downloads: a Love Story", slides: 9, pace: 0.005},
  {speaker: class="s">"dr_rambles", title: class="s">"A Brief History of Everything (pt. 1/40)", slides: 30, pace: 0.006},
  {speaker: class="s">"ci_arsonist", title: class="s">"How I Broke CI in 3 Languages", slides: 7, pace: 0.006},
  {speaker: class="s">"ractor_fan", title: class="s">"Waiting for Ractor: a Musical", slides: 8, pace: 0.005}
].freeze

orchestrator = Agentic:class="y">:PlanOrchestrator.new(concurrency_limit: 1) # one podium
session_opened = mono
outcomes = {}
previous = nil
TALKS.each do |talk|
  task = Agentic:class="y">:Task.new(description: talk[class="y">:title], agent_spec: {class="s">"name" => talk[class="y">:speaker], class="s">"instructions" => class="s">"present"})
  orchestrator.add_task(task, previous ? [previous] : [], agent: ->(_t) {
    started = mono
    shown = 0
    talk[class="y">:slides].times do
      break if mono - started >= LIMIT # THE GONG (checked between slides)
      sleep(talk[class="y">:pace])
      shown += 1
    end
    finished = mono - started
    gonged = shown < talk[class="y">:slides]
    outcomes[talk[class="y">:speaker]] = {shown: shown, of: talk[class="y">:slides], took: finished, gonged: gonged}
    gonged ? class="y">:gonged_with_dignity : class="y">:thunderous_applause
  })
  previous = task
end
orchestrator.execute_plan
session_length = mono - session_opened

puts class="s">"THE LIGHTNING TALKS (a hard timeout with applause)"
puts
puts format(class="s">"  %-13s %-42s %-12s %s", class="s">"speaker", class="s">"talk", class="s">"slides", class="s">"outcome")
TALKS.each do |talk|
  o = outcomes[talk[class="y">:speaker]]
  outcome = o[class="y">:gonged] ? class="s">"GONG at #{(o[class="y">:took] * 1000).round}ms - slide #{o[class="y">:shown]}, mid-gesture" : class="s">"applause (#{(o[class="y">:took] * 1000).round}ms, under time)"
  puts format(class="s">"  %-13s %-42s %-12s %s", talk[class="y">:speaker], talk[class="y">:title], class="s">"#{o[class="y">:shown]}/#{o[class="y">:of]}", outcome)
end
puts

# --- the referee: the schedule is sacred --------------------------------------------
failures = []
failures << class="s">"dr_rambles escaped the gong" unless outcomes[class="s">"dr_rambles"][class="y">:gonged]
punctual = TALKS.reject { |t| t[class="y">:speaker] == class="s">"dr_rambles" }
failures << class="s">"a punctual speaker was gonged" if punctual.any? { |t| outcomes[t[class="y">:speaker]][class="y">:gonged] }
failures << class="s">"the gong was late" if outcomes.values.any? { |o| o[class="y">:took] > LIMIT + 0.02 }
budget = TALKS.size * LIMIT
failures << class="s">"session overran its worst case" if session_length > budget + 0.05

puts class="s">"  referee: session ran #{(session_length * 1000).round}ms against a worst-case budget of"
puts class="s">"  #{(budget * 1000).round}ms; every gong landed within one slide of the limit."
puts
puts class="s">"  the design notes are conference-tested: the timeout is checked at"
puts class="s">"  SLIDE boundaries, not mid-slide - cooperative cancellation at safe"
puts class="s">"  points, which is also how you cancel anything that holds state."
puts class="s">"  the gong is enforced by the STAGE, not the speaker (dr_rambles"
puts class="s">"  believed sincerely in slide 30). and the schedule composes: five"
puts class="s">"  bounded talks make one bounded session, which is why LT sessions"
puts class="s">"  are the only conference block that never runs late. a five-minute"
puts class="s">"  limit with a gong is worth forty minutes of speaker discipline -"
puts class="s">"  timeboxes beat promises, in talks and in tasks."
exit(failures.empty? ? 0 : 1)