perspt-agent 0.6.6

SRBN Orchestrator and Agent logic for Perspt
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
//! Intra-turn commuting tool-call batches (Gate P).
//!
//! Theorem 8 makes the ordering rule precise: for *commuting* calls,
//! arrival order is not an "invented order" — every order yields the same
//! state — so commuting mutators run sequentially in the model's own
//! arrival order, and only identity transitions (reads with precise
//! declared footprints) get true concurrency. A pair of same-turn calls
//! whose footprints do **not** commute, where at least one mutates, is
//! never ordered by the host: the later call is returned to the model as a
//! [`ResidualClass::ToolBatchConflict`] observation so the model can
//! re-sequence it across turns.
//!
//! Provider rate-limit delays live in the transport and never appear here —
//! a throughput wait is not a required serialization (Gate P).

use perspt_sdk::{EffectKind, ProviderToolCall, Resource, StaticCatalog, ToolCatalog};

/// How the planner classified one call of the turn, in arrival order.
#[derive(Debug)]
pub(crate) enum PlannedClass {
    /// Identity transition with a precise footprint: eligible for
    /// concurrent execution after sequential admission.
    ConcurrentRead,
    /// Executed alone in arrival order: mutators (commuting by disjoint
    /// footprints), opaque reads (verifier processes), host-surface tools,
    /// and unknown names (their denial path needs the ordinary flow).
    Sequential,
    /// Footprint collides with an earlier same-turn call and at least one
    /// side mutates: returned as an observation, never ordered.
    Conflict {
        conflicts_with: String,
        resources: Vec<String>,
    },
}

#[derive(Debug)]
pub(crate) struct PlannedCall {
    pub(crate) call: ProviderToolCall,
    pub(crate) class: PlannedClass,
}

/// Pure batch planning over the declared footprints. Greedy in arrival
/// order: each call joins the batch unless it collides with an earlier
/// admitted call.
pub(crate) fn plan_batch(calls: &[ProviderToolCall], catalog: &StaticCatalog) -> Vec<PlannedCall> {
    struct Admitted {
        call_id: String,
        footprint: perspt_sdk::Footprint,
        mutating: bool,
    }
    let mut admitted: Vec<Admitted> = Vec::new();
    let mut planned = Vec::new();
    for call in calls {
        let Some(entry) = catalog.lookup(&call.name) else {
            planned.push(PlannedCall {
                call: call.clone(),
                class: PlannedClass::Sequential,
            });
            continue;
        };
        let footprint = entry.footprint.resolve(&call.arguments, "");
        let mutating = super::candidate_mutating_effect(entry.effect);
        let host = matches!(
            entry.effect,
            EffectKind::ToolSearch | EffectKind::ToolProgram | EffectKind::AskUser
        );
        let opaque_read = !mutating && footprint.reads.contains(&Resource::OpaqueWorkspace);

        let collision = admitted.iter().find(|earlier| {
            (mutating || earlier.mutating) && earlier.footprint.conflicts_with(&footprint)
        });
        if let Some(earlier) = collision {
            let resources: Vec<String> = footprint
                .writes
                .iter()
                .chain(footprint.reads.iter())
                .map(|resource| format!("{resource:?}"))
                .collect();
            planned.push(PlannedCall {
                call: call.clone(),
                class: PlannedClass::Conflict {
                    conflicts_with: earlier.call_id.clone(),
                    resources,
                },
            });
            continue;
        }
        admitted.push(Admitted {
            call_id: call.call_id.clone(),
            footprint,
            mutating,
        });
        planned.push(PlannedCall {
            call: call.clone(),
            class: if !mutating && !host && !opaque_read {
                PlannedClass::ConcurrentRead
            } else {
                PlannedClass::Sequential
            },
        });
    }
    planned
}

use anyhow::{Context as _, Result};

use super::{
    bounded_model_output, candidate_mutating_effect, emit, promote_matching_capability,
    proposal_from, proposal_scope, uncertified_reason, EventLog, LoopContext, LoopEvent, ToolLoop,
    TurnBudget,
};
use crate::realize::ProjectionMismatch;
use perspt_sdk::{CandidateTransition, ToolEntry, TurnOutput};

impl ToolLoop<'_> {
    /// Route every returned call through the kernel; execute the admitted
    /// ones. Returns the number of admitted mutations.
    pub(super) async fn execute_turn(
        &mut self,
        output: &TurnOutput,
        turn: u32,
        max_mutations: u32,
        context: &mut LoopContext,
        log: &mut EventLog,
        projection: &mut ProjectionMismatch,
    ) -> Result<(u32, bool)> {
        let calls = output.tool_calls().to_vec();
        if calls.is_empty() {
            if let TurnOutput::Text(text) = output {
                context.push_message(
                    perspt_sdk::Message::Assistant {
                        content: text.clone(),
                    },
                    self.recorder,
                    log,
                )?;
            }
            return Ok((0, false));
        }
        // The recall store: every projection page by id and typed key,
        // built only when this turn actually asks for one (Definition 6
        // backing store).
        let recall = calls
            .iter()
            .any(|call| call.name == "context_recall")
            .then(|| super::resident::recall_index(context.conversation()));
        context.push_tool_calls(calls.clone(), self.recorder, log)?;

        let plan = plan_batch(&calls, self.catalog);
        let mut budget = TurnBudget::new(max_mutations);
        let mut deferred: Vec<(ProviderToolCall, ToolEntry)> = Vec::new();
        let mut responses: std::collections::BTreeMap<String, String> = Default::default();
        for planned in &plan {
            self.route_planned(
                planned,
                turn,
                recall.as_ref(),
                &mut budget,
                &mut deferred,
                &mut responses,
                context,
                log,
                projection,
            )
            .await?;
        }

        // Identity transitions run with true concurrency; their events and
        // responses are still emitted in arrival order so the recorded
        // chain stays deterministic (Gate P).
        for (call_id, output) in self.apply_reads_concurrently(&deferred, log).await? {
            responses.insert(call_id, output);
        }
        for call in &calls {
            let response = responses
                .remove(&call.call_id)
                .unwrap_or_else(|| "internal: response missing".into());
            context.push_tool_response(call.call_id.clone(), response, self.recorder, log)?;
        }
        Ok((budget.mutations, budget.immediate_boundary))
    }

    /// Dispatch one planned call by its Gate P class.
    #[allow(clippy::too_many_arguments)]
    async fn route_planned(
        &mut self,
        planned: &PlannedCall,
        turn: u32,
        recall: Option<&super::resident::RecallIndex>,
        budget: &mut TurnBudget,
        deferred: &mut Vec<(ProviderToolCall, ToolEntry)>,
        responses: &mut std::collections::BTreeMap<String, String>,
        context: &mut LoopContext,
        log: &mut EventLog,
        projection: &mut ProjectionMismatch,
    ) -> Result<()> {
        let call = &planned.call;
        emit(
            self.recorder,
            log,
            LoopEvent::ToolCallObserved { call: call.clone() },
        )?;
        match &planned.class {
            PlannedClass::Conflict {
                conflicts_with,
                resources,
            } => {
                let observation =
                    self.conflict_observation(call, conflicts_with, resources, log)?;
                responses.insert(call.call_id.clone(), observation);
            }
            PlannedClass::ConcurrentRead => {
                let entry = self
                    .catalog
                    .lookup(&call.name)
                    .cloned()
                    .expect("planner classified a cataloged read");
                match self
                    .screen_call(call, Some(&entry), budget, log, projection)
                    .await?
                {
                    Some(denial) => {
                        responses.insert(call.call_id.clone(), denial);
                    }
                    None => match self.admit_read(call, &entry, log, projection).await? {
                        Ok(()) => deferred.push((call.clone(), entry)),
                        Err(denial) => {
                            responses.insert(call.call_id.clone(), denial);
                        }
                    },
                }
            }
            PlannedClass::Sequential => {
                let response = self
                    .sequential_call(call, turn, recall, budget, context, log, projection)
                    .await?;
                responses.insert(call.call_id.clone(), response);
            }
        }
        Ok(())
    }

    /// Per-call screening shared by every class: argument validation and
    /// the per-turn call/mutation budgets. `Some(response)` is a recorded
    /// denial.
    async fn screen_call(
        &mut self,
        call: &ProviderToolCall,
        entry: Option<&ToolEntry>,
        budget: &mut TurnBudget,
        log: &mut EventLog,
        projection: &mut ProjectionMismatch,
    ) -> Result<Option<String>> {
        let mutating = entry.is_some_and(|entry| candidate_mutating_effect(entry.effect));
        let invalid = entry
            .and_then(|entry| entry.validate_arguments(&call.arguments).err())
            .map(|error| anyhow::anyhow!(error.to_string()));
        let denial = self.budget_denial(
            budget.calls_seen,
            mutating,
            budget.mutations,
            budget.max_mutations,
        );
        budget.calls_seen = budget.calls_seen.saturating_add(1);
        match (invalid, denial) {
            (Some(reason), _) => {
                self.record_unchecked_proposal(call, entry.expect("validated entry"), log)
                    .await?;
                Ok(Some(self.deny(
                    log,
                    projection,
                    &call.call_id,
                    reason.to_string(),
                    perspt_sdk::ResidualClass::ToolArgumentInvalid,
                )?))
            }
            (None, Some(reason)) => {
                if let Some(entry) = entry {
                    self.record_unchecked_proposal(call, entry, log).await?;
                }
                Ok(Some(self.deny(
                    log,
                    projection,
                    &call.call_id,
                    reason.to_string(),
                    perspt_sdk::ResidualClass::BudgetExhausted,
                )?))
            }
            (None, None) => Ok(None),
        }
    }

    /// The ordinary sequential path: screen, kernel-check, execute, and
    /// post-process the host-surface tools.
    #[allow(clippy::too_many_arguments)]
    async fn sequential_call(
        &mut self,
        call: &ProviderToolCall,
        turn: u32,
        recall: Option<&super::resident::RecallIndex>,
        budget: &mut TurnBudget,
        context: &mut LoopContext,
        log: &mut EventLog,
        projection: &mut ProjectionMismatch,
    ) -> Result<String> {
        let entry = self.catalog.lookup(&call.name).cloned();
        let mutating = entry
            .as_ref()
            .is_some_and(|entry| candidate_mutating_effect(entry.effect));
        if let Some(denial) = self
            .screen_call(call, entry.as_ref(), budget, log, projection)
            .await?
        {
            return Ok(denial);
        }
        let mut response = self
            .check_and_apply(call, recall, log, projection, &mut budget.mutations)
            .await?;
        if call.name == "context_recall" && !response.starts_with("denied:") {
            self.record_recall(call, turn, &response, log)?;
        }
        if call.name == "tool_search" && !response.starts_with("denied:") {
            // The response *is* the executed search result; activate from
            // it instead of running the search a second time.
            if let Ok(specs) = serde_json::from_str::<Vec<perspt_sdk::ToolSpec>>(&response) {
                for spec in specs {
                    context.activate_tool(&spec.name, self.recorder, log)?;
                }
            }
        }
        if call.name == "tool_program" && !response.starts_with("denied:") {
            response = self
                .run_tool_program(call, &response, budget, log, projection)
                .await?;
        }
        if mutating && Self::high_risk(entry.as_ref()) && budget.mutations > 0 {
            budget.immediate_boundary = true;
        }
        Ok(response)
    }

    /// Admit one identity transition for concurrent execution: proposal,
    /// five-clause certification, capability debit. `Err(response)` is a
    /// recorded denial.
    async fn admit_read(
        &mut self,
        call: &ProviderToolCall,
        entry: &ToolEntry,
        log: &mut EventLog,
        projection: &mut ProjectionMismatch,
    ) -> Result<std::result::Result<(), String>> {
        let scope = proposal_scope(call, entry);
        let before = self.executor.checkpoint(&scope).await?;
        let proposal = proposal_from(call, entry, &self.node_id, self.generation, &before.witness);
        emit(
            self.recorder,
            log,
            LoopEvent::ProposalObserved {
                call_id: call.call_id.clone(),
                proposal: proposal.clone(),
            },
        )?;
        self.kernel_state
            .set_witness("__candidate_root", before.witness.state_root.clone());
        let identity = CandidateTransition::new(
            proposal.clone(),
            before.witness.clone(),
            before.witness.clone(),
        );
        let witness = self.certify(&call.call_id, &identity, log)?;
        if let Some(reason) = uncertified_reason(&witness) {
            return Ok(Err(self.deny(
                log,
                projection,
                &call.call_id,
                reason,
                perspt_sdk::ResidualClass::CapabilityDenied,
            )?));
        }
        promote_matching_capability(&mut self.capabilities, &witness)
            .map_err(|error| anyhow::anyhow!("promotion: {error}"))?;
        Ok(Ok(()))
    }

    /// Run every admitted identity transition concurrently, then record
    /// outputs in arrival order.
    async fn apply_reads_concurrently(
        &mut self,
        admitted: &[(ProviderToolCall, ToolEntry)],
        log: &mut EventLog,
    ) -> Result<Vec<(String, String)>> {
        // Every durable intent must be visible before any concurrent effect
        // starts. Recording after `join_all` would erase the crash window the
        // external-effect bracket exists to expose.
        let brackets = admitted
            .iter()
            .map(|(call, entry)| self.open_effect_bracket(call, entry))
            .collect::<Result<Vec<_>>>()?;
        let executor = self.executor;
        let outcomes = futures::future::join_all(
            admitted
                .iter()
                .map(|(call, entry)| executor.apply(call, entry)),
        )
        .await;
        let mut results = Vec::with_capacity(admitted.len());
        let mut first_error = None;
        for (((call, _), bracket), outcome) in admitted.iter().zip(brackets).zip(outcomes) {
            match outcome {
                Ok(outcome) => {
                    if outcome.completed {
                        if let (Some(recorder), Some(key)) = (self.recorder, bracket.as_deref()) {
                            recorder.external_result(
                                key,
                                &serde_json::json!({"mutated": outcome.mutated}),
                            )?;
                        }
                    }
                    let output = bounded_model_output(self.recorder, outcome.output)?;
                    emit(
                        self.recorder,
                        log,
                        LoopEvent::EffectApplied {
                            call_id: call.call_id.clone(),
                            mutated: false,
                            output: output.clone(),
                        },
                    )?;
                    results.push((call.call_id.clone(), output));
                }
                Err(error) => {
                    // All futures have already completed. Continue folding
                    // definitive siblings so their brackets are not left
                    // falsely open, then return the first executor error.
                    if first_error.is_none() {
                        first_error = Some(error);
                    }
                }
            }
        }
        if let Some(error) = first_error {
            return Err(error);
        }
        Ok(results)
    }

    /// Ledger one `context_recall` outcome: a restored page or a typed
    /// miss (Definition 6 recall alphabet).
    fn record_recall(
        &self,
        call: &ProviderToolCall,
        turn: u32,
        response: &str,
        log: &mut EventLog,
    ) -> Result<()> {
        // The recall key: whichever typed argument the call named.
        let page_id = [
            "page_id",
            "path",
            "diagnostic_id",
            "test_id",
            "symbol",
            "provenance_key",
        ]
        .iter()
        .find_map(|field| {
            call.arguments
                .get(field)
                .and_then(serde_json::Value::as_str)
                .filter(|value| !value.is_empty())
        })
        .unwrap_or_default()
        .to_string();
        let event = if response.starts_with("recalled page ") {
            // A typed lookup records the newest restored page's identity.
            let restored = response
                .trim_start_matches("recalled page ")
                .split_whitespace()
                .next()
                .unwrap_or(&page_id)
                .to_string();
            LoopEvent::ContextPageRecalled {
                forest_id: String::new(),
                branch_id: String::new(),
                turn,
                page_id: restored,
            }
        } else {
            LoopEvent::ContextMiss {
                forest_id: String::new(),
                branch_id: String::new(),
                turn,
                key: page_id,
            }
        };
        emit(self.recorder, log, event)
    }

    /// A same-turn footprint collision (Gate P): recorded and returned as
    /// an observation; the call executes nothing and consumes no budget.
    fn conflict_observation(
        &self,
        call: &ProviderToolCall,
        conflicts_with: &str,
        resources: &[String],
        log: &mut EventLog,
    ) -> Result<String> {
        emit(
            self.recorder,
            log,
            LoopEvent::ToolBatchConflict {
                call_id: call.call_id.clone(),
                conflicts_with: conflicts_with.to_string(),
                resources: resources.to_vec(),
            },
        )?;
        Ok(format!(
            "conflict: this call's footprint collides with same-turn call {conflicts_with} \
             (resources: {}); it was not executed and consumed no budget. Re-issue it in a \
             later turn if still needed.",
            resources.join(", ")
        ))
    }

    /// Execute a validated tool program's nested calls, each returning to the
    /// same kernel and budgets as a top-level call. Nested calls run
    /// sequentially in program order (the program author already committed
    /// to that order).
    async fn run_tool_program(
        &mut self,
        call: &ProviderToolCall,
        response: &str,
        budget: &mut TurnBudget,
        log: &mut EventLog,
        projection: &mut ProjectionMismatch,
    ) -> Result<String> {
        let program_calls: Vec<perspt_policy::ToolProgramCall> =
            serde_json::from_str(response).context("decoding tool program result")?;
        let mut nested_results = Vec::new();
        for (nested_ordinal, nested) in program_calls.into_iter().enumerate() {
            let nested_call = ProviderToolCall {
                call_id: format!("{}:{}", call.call_id, nested_ordinal),
                name: nested.tool,
                arguments: nested.arguments,
            };
            emit(
                self.recorder,
                log,
                LoopEvent::ToolCallObserved {
                    call: nested_call.clone(),
                },
            )?;
            let nested_entry = self.catalog.lookup(&nested_call.name).cloned();
            let nested_mutating = nested_entry
                .as_ref()
                .is_some_and(|entry| candidate_mutating_effect(entry.effect));
            let nested_high_risk = Self::high_risk(nested_entry.as_ref());
            let result = match self
                .screen_call(&nested_call, nested_entry.as_ref(), budget, log, projection)
                .await?
            {
                Some(denial) => denial,
                None => {
                    self.check_and_apply(&nested_call, None, log, projection, &mut budget.mutations)
                        .await?
                }
            };
            if nested_mutating && nested_high_risk && budget.mutations > 0 {
                budget.immediate_boundary = true;
            }
            nested_results.push(serde_json::json!({
                "call_id": nested_call.call_id,
                "tool": nested_call.name,
                "result": result,
            }));
        }
        Ok(serde_json::to_string(&nested_results)?)
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    fn catalog() -> StaticCatalog {
        StaticCatalog::with_base(Vec::new()).unwrap()
    }

    fn call(id: &str, name: &str, arguments: serde_json::Value) -> ProviderToolCall {
        ProviderToolCall {
            call_id: id.into(),
            name: name.into(),
            arguments,
        }
    }

    #[test]
    fn same_path_double_edit_is_a_conflict_observation() {
        let plan = plan_batch(
            &[
                call(
                    "e1",
                    "edit_file",
                    serde_json::json!({"path": "a.rs", "old_string": "x", "new_string": "y"}),
                ),
                call(
                    "e2",
                    "edit_file",
                    serde_json::json!({"path": "a.rs", "old_string": "p", "new_string": "q"}),
                ),
            ],
            &catalog(),
        );
        assert!(matches!(plan[0].class, PlannedClass::Sequential));
        let PlannedClass::Conflict { conflicts_with, .. } = &plan[1].class else {
            panic!("second same-path edit must be a conflict");
        };
        assert_eq!(conflicts_with, "e1");
    }

    #[test]
    fn disjoint_path_edits_both_apply_in_arrival_order() {
        let plan = plan_batch(
            &[
                call(
                    "e1",
                    "edit_file",
                    serde_json::json!({"path": "a.rs", "old_string": "x", "new_string": "y"}),
                ),
                call(
                    "e2",
                    "edit_file",
                    serde_json::json!({"path": "b.rs", "old_string": "p", "new_string": "q"}),
                ),
            ],
            &catalog(),
        );
        assert!(matches!(plan[0].class, PlannedClass::Sequential));
        assert!(matches!(plan[1].class, PlannedClass::Sequential));
    }

    #[test]
    fn read_after_write_on_the_same_path_is_a_conflict() {
        let plan = plan_batch(
            &[
                call(
                    "w1",
                    "write_file",
                    serde_json::json!({"path": "a.rs", "content": "x"}),
                ),
                call("r1", "read_file", serde_json::json!({"path": "a.rs"})),
            ],
            &catalog(),
        );
        assert!(matches!(plan[1].class, PlannedClass::Conflict { .. }));
    }

    #[test]
    fn multiple_reads_run_concurrently() {
        let plan = plan_batch(
            &[
                call("r1", "read_file", serde_json::json!({"path": "a.rs"})),
                call("r2", "read_file", serde_json::json!({"path": "a.rs"})),
                call("r3", "grep", serde_json::json!({"query": "fn"})),
            ],
            &catalog(),
        );
        assert!(plan
            .iter()
            .all(|p| matches!(p.class, PlannedClass::ConcurrentRead)));
    }

    #[test]
    fn verifier_processes_stay_sequential_but_never_conflict_with_each_other() {
        let plan = plan_batch(
            &[
                call("t1", "run_test", serde_json::json!({})),
                call("b1", "run_build", serde_json::json!({})),
            ],
            &catalog(),
        );
        assert!(matches!(plan[0].class, PlannedClass::Sequential));
        assert!(matches!(plan[1].class, PlannedClass::Sequential));
    }

    #[test]
    fn unknown_tools_take_the_sequential_denial_path() {
        let plan = plan_batch(
            &[call("u1", "no_such_tool", serde_json::json!({}))],
            &catalog(),
        );
        assert!(matches!(plan[0].class, PlannedClass::Sequential));
    }
}