pub struct CompletionSignal {
pub cadence: CadenceType,
pub agents: Vec<String>,
pub overall_completion: f64,
pub step: u64,
}Expand description
Signal when a group of agents reaches a cadence point.
Fields§
§cadence: CadenceTypeThe cadence type reached
agents: Vec<String>Agents that contributed to the signal
overall_completion: f64Overall completion percentage
step: u64Timestamp or step number
Implementations§
Source§impl CompletionSignal
impl CompletionSignal
Sourcepub fn detect_from_group(tasks: &[TaskProgress], step: u64) -> Option<Self>
pub fn detect_from_group(tasks: &[TaskProgress], step: u64) -> Option<Self>
Detect completion signals from a group of task progresses.
Sourcepub fn is_final(&self) -> bool
pub fn is_final(&self) -> bool
Is this a final completion signal?
Examples found in repository?
examples/cadence_demo.rs (line 188)
3fn main() {
4 println!("╔══════════════════════════════════════════════════════════════╗");
5 println!("║ 🎼 Cadence Types & Resolution Demo 🎼 ║");
6 println!("╚══════════════════════════════════════════════════════════════╝");
7 println!();
8
9 // === Section 1: Cadence Types Overview ===
10 println!("━━━ Section 1: The Five Cadence Types ━━━");
11 println!();
12
13 let cadences = [
14 CadenceType::PerfectAuthentic,
15 CadenceType::Plagal,
16 CadenceType::Deceptive,
17 CadenceType::Half,
18 CadenceType::Phrygian,
19 ];
20
21 println!(" {:>20} {:>8} {:>10} {}", "Cadence", "Resolved?", "Strength", "Description");
22 println!(" {} {} {} {}", "────────────────────", "────────", "──────────", "────────────────────────────────────────");
23 for c in &cadences {
24 println!(" {:>20} {:>8} {:>9.0}% {}",
25 format!("{:?}", c),
26 if c.is_resolved() { "✅ Yes" } else { "❌ No" },
27 c.resolution_strength() * 100.0,
28 c.description()
29 );
30 }
31 println!();
32
33 // === Section 2: Progress through cadences ===
34 println!("━━━ Section 2: Task Progress → Cadence Mapping ━━━");
35 println!();
36
37 let progressions = [
38 (0.05, "Just started — confused rummaging"),
39 (0.25, "Getting oriented"),
40 (0.50, "Halfway — the real work begins"),
41 (0.65, "Building momentum"),
42 (0.75, "Almost there... or is it?"),
43 (0.82, "Deceptive! Thought we were done"),
44 (0.90, "Soft landing — we made it"),
45 (0.99, "Perfect completion!"),
46 (1.00, "Definitive resolution"),
47 ];
48
49 println!(" {:>6} {:>20} {:>10} {}", "Prog%", "Cadence", "Strength", "Mood");
50 println!(" {} {} {} {}", "─────", "────────────────────", "──────────", "────────────────────────────────");
51 for (prog, mood) in &progressions {
52 let mut tp = TaskProgress::with_progress("demo", *prog);
53 let cadence = tp.detect_cadence();
54 println!(" {:>5.0}% {:>20} {:>9.0}% {}",
55 prog * 100.0,
56 format!("{:?}", cadence),
57 cadence.resolution_strength() * 100.0,
58 mood
59 );
60 }
61 println!();
62
63 // === Section 3: Chord Progression as Task Flow ===
64 println!("━━━ Section 3: Standard Progression (I → ii → IV → V → I) ━━━");
65 println!();
66
67 let mut tracker = ProgressionTracker::standard();
68 println!(" Mapping task stages to chord functions:");
69 println!();
70
71 let stage_names = [
72 "Task begins — stable start",
73 "Setup phase — gathering resources",
74 "Building — main work in progress",
75 "Climax — approaching completion",
76 "Resolution — task complete!",
77 ];
78
79 println!(" {:>5} {:>12} {:>8} {:>10} {:>6} {}", "Step", "Chord", "Stability", "Tension", "Prog%", "Stage");
80 println!(" {} {} {} {} {} {}", "─────", "────────────", "────────", "──────────", "─────", "────────────────────────────────────");
81
82 for (i, stage) in stage_names.iter().enumerate() {
83 let chord = tracker.advance().unwrap();
84 let cadence = tracker.detect_cadence();
85 println!(" {:>5} {:>12} {:>8.0}% {:>9.0}% {:>5.0}% {}",
86 i + 1,
87 format!("{:?}", chord),
88 chord.stability() * 100.0,
89 chord.tension() * 100.0,
90 tracker.progress_ratio() * 100.0,
91 stage
92 );
93 if let Some(c) = cadence {
94 println!(" └─ Cadence detected: {:?} (strength: {:.0}%)", c, c.resolution_strength() * 100.0);
95 }
96 }
97 println!();
98
99 // === Section 4: Deceptive Progression ===
100 println!("━━━ Section 4: Deceptive Progression (I → IV → V → vi ✗ → IV → V → I) ━━━");
101 println!();
102
103 let mut deceptive = ProgressionTracker::deceptive();
104 let deceptive_labels = [
105 "Start",
106 "Building",
107 "Climax — here it comes!",
108 "WAIT — deceptive! Not done yet!",
109 "Regroup",
110 "Try again",
111 "Finally resolved",
112 ];
113
114 println!(" {:>5} {:>12} {:>10} {}", "Step", "Chord", "Cadence?", "What happened");
115 println!(" {} {} {} {}", "─────", "────────────", "──────────", "─────────────────────────────────");
116 for (i, label) in deceptive_labels.iter().enumerate() {
117 let chord = deceptive.advance().unwrap();
118 let cadence = deceptive.detect_cadence();
119 let cadence_str = cadence.map(|c| format!("{:?}", c)).unwrap_or("—".to_string());
120 let marker = match cadence {
121 Some(CadenceType::Deceptive) => "⚠️",
122 Some(CadenceType::PerfectAuthentic) => "✅",
123 _ => " ",
124 };
125 println!(" {:>5} {:>12} {:>10}{} {}", i + 1, format!("{:?}", chord), cadence_str, marker, label);
126 }
127 println!();
128
129 // === Section 5: Deceptive Resolution Detection ===
130 println!("━━━ Section 5: Detecting Deceptive Resolutions (Task Regressions) ━━━");
131 println!();
132
133 let mut dr = DeceptiveResolution::new(0.05);
134 println!(" Tracking task 'deploy-app' through progress updates:");
135 println!();
136
137 let updates = [
138 (0.10, "Initial setup"),
139 (0.30, "Dependencies installed"),
140 (0.55, "Tests passing"),
141 (0.80, "Deploying to staging"),
142 (0.95, "Looks good!"),
143 (0.60, "💀 Rollback — tests failed in production!"),
144 (0.65, "Fixing the issue"),
145 (0.85, "Re-deploying"),
146 (0.95, "All green now"),
147 (1.00, "Fully deployed ✓"),
148 ];
149
150 let mut prev = 0.0;
151 for (step, (progress, desc)) in updates.iter().enumerate() {
152 let is_deceptive = dr.track("deploy-app", prev, *progress, step as u64);
153 let marker = if is_deceptive { "⚠️ DECEPTIVE REGRESSION!" } else { "" };
154 println!(" Step {:>2}: {:>5.0}% → {:>5.0}% {} {}", step, prev * 100.0, progress * 100.0, desc, marker);
155 prev = *progress;
156 }
157
158 println!();
159 println!(" Total regressions detected: {}", dr.regression_count());
160 println!(" Deceptive tasks: {:?}", dr.deceptive_tasks());
161 println!();
162
163 // === Section 6: Multi-Agent Completion ===
164 println!("━━━ Section 6: Multi-Agent Completion Signals ━━━");
165 println!();
166
167 let mut coord = CadenceCoordinator::new(ProgressionTracker::standard());
168 coord.add_task(TaskProgress::with_progress("frontend", 0.0));
169 coord.add_task(TaskProgress::with_progress("backend", 0.0));
170 coord.add_task(TaskProgress::with_progress("database", 0.0));
171
172 let updates_by_step = [
173 vec![("frontend", 0.2), ("backend", 0.15), ("database", 0.3)],
174 vec![("frontend", 0.5), ("backend", 0.45), ("database", 0.6)],
175 vec![("frontend", 0.8), ("backend", 0.7), ("database", 0.85)],
176 vec![("frontend", 0.95), ("backend", 0.82), ("database", 0.97)],
177 vec![("frontend", 1.0), ("backend", 1.0), ("database", 1.0)],
178 ];
179
180 for (step, updates) in updates_by_step.iter().enumerate() {
181 for (task, progress) in updates {
182 coord.update_task(task, *progress);
183 }
184 if let Some(signal) = coord.check_cadence(step as u64) {
185 println!(" Step {}: Avg={:.0}% | Cadence={:?} | Final={} | Agents={:?}",
186 step, signal.overall_completion * 100.0,
187 signal.cadence,
188 if signal.is_final() { "✅" } else { "..." },
189 signal.agents
190 );
191 }
192 }
193
194 println!();
195 println!("╔══════════════════════════════════════════════════════════════╗");
196 println!("║ Every ending is a new beginning in music 🎶 ║");
197 println!("╚══════════════════════════════════════════════════════════════╝");
198}Trait Implementations§
Source§impl Clone for CompletionSignal
impl Clone for CompletionSignal
Source§fn clone(&self) -> CompletionSignal
fn clone(&self) -> CompletionSignal
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CompletionSignal
impl RefUnwindSafe for CompletionSignal
impl Send for CompletionSignal
impl Sync for CompletionSignal
impl Unpin for CompletionSignal
impl UnsafeUnpin for CompletionSignal
impl UnwindSafe for CompletionSignal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more