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
//! **The fleet pane between frames** (bl-a43a): the three words its five acts
//! are composed from, the last receipt in the op's own name, and the two reads
//! that stand while it is open.
//!
//! # It is the tuning pane's shape, and every one of its seven ops names a workspace
//!
//! `fleet`, `disband`, `arm`, `disarm`, `scan`, `science` and `work-diff` all
//! carry a workspace, so the pane's subject is the **aimed workspace**: it opens on
//! a row, its reads are asked of that workspace while it stands, and it is retired
//! when the aim moves (`super::tuning`, and `Model::aim_at`). Nothing about it
//! is the queue's shape, which is what tells it from the ball pane next door —
//! that one is two widths and this one is one.
//!
//! # It holds three words because three of its acts carry one
//!
//! A cap is a number, a project is a name and a model is a name; none of the
//! three is derivable from anything on the glass, so each is a box, and the
//! control that spends one stands down until it has something to spend
//! (§4.20's enablement rule: the parameter is missing, not the subject).
//!
//! **The boxes are bound to these fields and never to a copy** (`crate::ui::
//! fleet`, and the tuning editor before it): a draft is what the pane holds,
//! so an edit is a write to it and there is no second value for the two to
//! disagree about.
//!
//! # The receipt is read by the OP and never by the reply
//!
//! `fleet`, `disband`, `arm` and `disarm` answer with the same `armed` kind,
//! and the two families it spans are the fleet loop and the alignment monitor.
//! So [`Armed`] carries the op the poster stamped the frame with
//! (`crate::state::Said::Receipt`) and the flag the server sent, and the pane
//! says both. A seat that read *which family* off the reply would be guessing
//! between two settings on two carriers.
//!
//! **Nothing here holds the loop's STATE**, and that is deliberate: whether a
//! loop is running is on the `board` answer, in the ball pane (DESIGN §4.31).
//! A second copy of it here would be a second authority, and the receipt below
//! is an event rather than a state — what happened when the operator pressed
//! the control, said once.
use super::{Aim, Model};
use crate::reply::diff::Diff;
use crate::reply::science::Attempt;
/// **The fleet pane, while it is open**: the words its acts are composed from,
/// and the last thing an act answered.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Fleet {
/// **The workspace it was opened on**, held rather than followed — the
/// unmaking's arrangement (§4.20), and for a sharper form of its reason:
/// these acts start drones and spend money in one workspace, so a gesture
/// composed against whatever the aim happens to be at the moment of the
/// click would be a control that moved under the operator. The pane is
/// retired when the aim moves, so the two can never disagree — and holding
/// it is what makes that a fact rather than a promise.
pub at: Aim,
/// Whose ready balls the loop should run. `fleet` requires it and nothing
/// on this pane can derive it, so it is typed.
pub project: String,
/// How many at once. A number, which is why `fleet` is a door and not a
/// row (`crate::verbs::fleet`).
pub cap: u64,
/// The cheap model the monitor is pinned to.
pub model: String,
/// **How many candidates a spread asks for** (§4.36). A stepper for the
/// cap's reason and floored at two for a sharper one: upstream reads 1 and
/// 0 as *materialize nothing and hand back the ordinary claim binding*,
/// which is a start and not a fan.
pub spread: u64,
/// What each of those candidates is for. A start with no goal is a driver
/// launched for nothing, and n of them is n.
pub goal: String,
/// The delivery subject one acceptance carries, verbatim — balls tags it
/// with the handle, and that tag is the only acceptance mark there is.
pub summary: String,
/// What the last of the four standing acts answered.
pub said: Option<Armed>,
}
/// **One receipt, in the op's own name.** The op is the poster's stamp and the
/// flag is the server's; this seat joins them and classifies neither.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Armed {
pub op: String,
pub armed: bool,
}
impl Model {
/// **Open the fleet pane on the aimed workspace**, or do nothing with nothing
/// aimed at: every one of its seven ops carries a workspace, so a pane
/// opened unaimed would be a screen of controls with nowhere to fire.
///
/// The cap opens at one rather than at zero. Zero is a loop that spawns
/// nothing and still reaps, which upstream refuses to spell as a cap at
/// all — `disband` is that — so it is not a value this box should be able
/// to send.
pub fn begin_fleet(&mut self) {
if let Some(at) = self.aim.clone() {
self.fleet = Some(Fleet {
at,
project: String::new(),
cap: 1,
model: String::new(),
spread: 2,
goal: String::new(),
summary: String::new(),
said: None,
});
}
}
/// **Close it.** The two reads' answers stay, for the reason the roles do:
/// the next open is about the same workspace, and the standing read replaces
/// them anyway.
pub fn close_fleet(&mut self) {
self.fleet = None;
}
/// **The pane and its two answers go with the workspace they are about** —
/// called by the act that moves the aim.
pub(super) fn retire_fleet(&mut self) {
self.fleet = None;
self.attempts = None;
self.work = None;
}
/// **Spend one of the five acts**, composed against the aimed workspace. It is
/// one door because all five are the same gesture with a different verb:
/// the caller names the envelope, and the aim is read here so no control
/// holds a second opinion about which workspace it is firing at.
pub fn post_fleet(&mut self, envelope: serde_json::Value) {
self.outbox.push(super::Posted::act(envelope));
}
/// **Spend one of the candidate acts**, ADDRESSED down the channel the
/// pane stands on (§4.30's ruling, §4.36's first customer).
///
/// `deliver` and `retire` name no workspace anywhere in their envelopes —
/// their subject is a ball in a project on one server — so the poster
/// would otherwise fan them over every channel this box holds, accepting
/// one candidate on every server the operator is a client of. A seat that
/// no longer holds the channel composes nothing, which is the honest
/// reading: there is nothing left to address.
pub fn post_candidate(&mut self, envelope: serde_json::Value) {
let Some(down) = self.channel() else {
return;
};
self.outbox.push(super::Posted::act(envelope).down(down));
}
/// File the receipt four ops share, under the op that earned it.
pub(super) fn armed(&mut self, op: &str, armed: bool) {
if let Some(fleet) = self.fleet.as_mut() {
fleet.said = Some(Armed {
op: op.to_owned(),
armed,
});
}
}
/// File the attempts.
pub(super) fn scienced(&mut self, rows: Vec<Attempt>) {
self.attempts = Some(rows);
}
/// File what changed.
pub(super) fn worked(&mut self, rows: Vec<Diff>) {
self.work = Some(rows);
}
}
#[cfg(test)]
mod tests;