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
//! Which provider/model a turn runs on, given where the session sits in the
//! plan lifecycle (#792).
//!
//! Planning and executing are different jobs and reward different models, so
//! `/plan` can route to one pair and the execution that follows to another.
//! The mapping keys off plan STATE rather than the command that caused it,
//! which is what makes it surface-agnostic: `/execute` on Telegram, the TUI
//! approval, and the agent approving its own plan in prose all converge on
//! `try_approve` and all land in the same state, so all three route the same
//! way with no per-surface code.
//!
//! Everything here is pure. Deciding what the pair SHOULD be is separable from
//! the swap that installs it, and only the decision needs exhaustive tests.
use crateAgentConfig;
use cratePlanModeState;
/// A provider/model change a plan state asks for. Either field may be absent:
/// a provider with no model means that provider's default, and a model with no
/// provider means keep the current provider and swap the model alone.
/// The pair `state` calls for, or `None` to leave the session alone.
///
/// `None` is the important case: it is what an unconfigured install returns for
/// every state, and it must mean no computation, no swap, and behaviour
/// byte-identical to having no feature at all.
/// The provider/model a session was on before a plan-mode override replaced it,
/// paired with what the override installed.
///
/// Both halves are needed. The original is where the session returns once the
/// plan archives. The applied pair is the evidence that the override is still
/// the thing in place: if the user switches provider themselves mid-plan, the
/// current pair no longer matches and restoring would clobber a deliberate
/// pick, so the record is dropped instead.