The Plan Fortune Teller
The Plan Fortune Teller: reads your graph's palm - depth, fan-in, roots, breadth - and tells its fortune. Every fortune is a real structural fact wearing a mystic's robe; the entertainment is a delivery mechanism for the diagnosis.
Plans & Graphs
Round 7
Matz
exit 0
bundle exec ruby examples/plan_fortune.rb
a real captured run
THE PLAN FORTUNE TELLER the seeker presents a plan of 8 tasks... the teller studies graph[:stats] (the palm never lies): * You begin in many places at once, child of parallelism - your mornings are wide (4 roots). * Beware: all rivers flow through one gate (fan-in 4). When that gate falters, all waters still. * I see a long road, 5 stations deep, in a caravan of only 8. More than half your journey walks single file - latency stalks you, and the critical path knows your name. * All ends in a single scroll (1 leaf). Tidy. The ancestors approve of plans that know what they produce. cross my palm with a refactor and return: the fortune about the long road is a real diagnosis - see refactor_receipts.rb for the cure, and three_shapes.rb to choose your next incarnation.
source
# frozen_string_literal: true # The Plan Fortune Teller: reads your graph's palm - depth, fan-in, # roots, breadth - and tells its fortune. Every fortune is a real # structural fact wearing a mystic's robe; the entertainment is a # delivery mechanism for the diagnosis. # # bundle exec ruby examples/plan_fortune.rb # # Runs offline. The stars are graph[:stats]. require class="s">"bundler/setup" require class="s">"agentic" def step(name) Agentic:class="y">:Task.new(description: name, agent_spec: {class="s">"name" => name, class="s">"instructions" => class="s">"toil"}) end # A seeker arrives with their plan orchestrator = Agentic:class="y">:PlanOrchestrator.new gather = 4.times.map { |i| step(class="s">"gather-#{i}") } sift = step(class="s">"sift") weigh = step(class="s">"weigh") judge = step(class="s">"judge") scribe = step(class="s">"scribe") gather.each { |t| orchestrator.add_task(t) } orchestrator.add_task(sift, gather) orchestrator.add_task(weigh, [sift]) orchestrator.add_task(judge, [weigh]) orchestrator.add_task(scribe, [judge]) # --- the reading -------------------------------------------------------------- graph = orchestrator.graph stats = graph[class="y">:stats] roots = graph[class="y">:dependencies].count { |_, deps| deps.empty? } leaves = graph[class="y">:dependencies].keys.count { |id| graph[class="y">:edges].none? { |e| e[class="y">:from] == id } } tasks = graph[class="y">:tasks].size fortunes = [] fortunes << if roots >= 4 class="s">"You begin in many places at once, child of parallelism - " \ class="s">"your mornings are wide (#{roots} roots)." else class="s">"You begin cautiously (#{roots} root#{(roots == 1) ? "class="s">" : "sclass="s">"}) - " \ class="s">"the fates smile on those who fan out." end fortunes << if stats[class="y">:max_fan_in] >= 4 class="s">"Beware: all rivers flow through one gate (fan-in #{stats[class="y">:max_fan_in]}). " \ class="s">"When that gate falters, all waters still." else class="s">"Your joinings are modest (fan-in #{stats[class="y">:max_fan_in]}) - no single " \ class="s">"gate holds your fate." end fortunes << if stats[class="y">:max_depth] > tasks / 2 class="s">"I see a long road, #{stats[class="y">:max_depth]} stations deep, in a caravan of " \ class="s">"only #{tasks}. More than half your journey walks single file - " \ class="s">"latency stalks you, and the critical path knows your name." else class="s">"Your road is short for your numbers (depth #{stats[class="y">:max_depth]} of " \ class="s">"#{tasks}) - swiftness favors you." end fortunes << if leaves == 1 class="s">"All ends in a single scroll (1 leaf). Tidy. The ancestors approve of " \ class="s">"plans that know what they produce." else class="s">"Your plan ends in #{leaves} places - be sure someone reads them all." end puts class="s">"THE PLAN FORTUNE TELLER" puts puts class="s">" the seeker presents a plan of #{tasks} tasks..." puts class="s">" the teller studies graph[class="y">:stats] (the palm never lies):" puts fortunes.each { |fortune| puts class="s">" * #{fortune}" } puts puts class="s">" cross my palm with a refactor and return: the fortune about the" puts class="s">" long road is a real diagnosis - see refactor_receipts.rb for" puts class="s">" the cure, and three_shapes.rb to choose your next incarnation."