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
//! **The advertised tool set** (REMOTE §5, bl-4e08): what a tool host presents
//! when it connects, and where the engine keeps it.
//!
//! REMOTE §5: *"A tool host presents its tool set — name, description, input
//! schema — when it connects; the engine writes it into the client's
//! registration (world, file) when it differs from what is stored."* The
//! spelling of that file is decided here and recorded in REMOTE §5:
//!
//! ```text
//! <yog-state-root>/clients/<client>/tools.json the advertised set, one array
//! ```
//!
//! **One document per client, not one per registration.** A tool set is a fact
//! about a *machine* — what that laptop can do — and REMOTE §2 already makes
//! the registration listing the fact about which workspaces see it. Writing the
//! same array under every registration would be one fact stored N times, which
//! is the drift the single-source rule exists to prevent; the roster joins the
//! two by reading the listing it already has.
//!
//! **An element is three facts and nothing more** (bl-4e08): `name`, a single
//! path component so the later load act has an unambiguous handle;
//! `description`, one string; and `input_schema`, the JSON Schema **verbatim**
//! — yog neither validates it nor rewrites it, because it is the tool host's
//! statement to a model and any narrowing here would be yog inventing a
//! contract it does not own.
//!
//! **Names collide inside a client's set and not across clients.** Two
//! `Bash`es in one presentation is a set that cannot be addressed and it is
//! declined, loudly, naming the token; two machines both offering `Bash` is the
//! ordinary case, and disambiguating them belongs to the act that loads one.
use io;
use ;
use ;
use Client;
use cratestr_of;
/// One client's advertised set, under its own registry directory.
pub const TOOLS: &str = "tools.json";
/// One advertised tool (REMOTE §5): the three facts, the JSON Schema carried
/// as the value it arrived as — and the optional fourth fact (REMOTE §5.4's
/// worktree lane, bl-77be): whether the advertising box consents to run this
/// tool at a working directory the invocation names.
///
/// **[`Eq`] is written rather than derived**, because [`Value`] is not `Eq` —
/// it holds `f64`, whose `NaN` is the one value equality is not reflexive over.
/// A schema that came through a JSON decoder cannot hold one: the grammar has
/// no `NaN` literal and `serde_json` refuses to emit one. So equality here is
/// reflexive by construction, and saying so is what lets the whole gesture
/// surface keep the `Eq` its codec round-trip is asserted with.
/// This client's advertised set, on disk.
/// The set as JSON — the **one** spelling, spent by the boundary codec and by
/// the file alike (§8.5's single-source discipline: a stored set and a
/// presented one that were spelled twice would drift within a week).
/// **One element**, spelled once. The set encoder above spends it, and so does
/// the loaded set (`src/tool_host/loaded.rs`, bl-c907), which stores the
/// definition frozen at the load act beside the client it came from — a second
/// spelling of these three keys is exactly the drift this module's doc refuses.
/// Read a set back, strictly — a missing field or a mistyped one refuses with
/// the offending key, exactly as the gesture codec's decode does. An
/// advertisement is an instruction, not an observation.
/// **One element**, read back — [`one`]'s inverse, and the same single spelling
/// the loaded set reads its frozen definitions with.
/// What `client` advertises now. A client that has advertised nothing, whose
/// document cannot be read, or whose document is not a set reads as the **empty
/// set** — the same posture a fresh registration has, so no reader carries a
/// "never advertised" case beside "advertised nothing".
/// Refuse a set that cannot be addressed (REMOTE §5): a name that is not a
/// single path component, or two elements wearing one name. Both name the
/// offending token — a decline an operator can act on.
/// Store `client`'s set, **only when it differs from what is stored** (REMOTE
/// §5). Answers whether it wrote: a re-presentation of an unchanged set is the
/// ordinary case on every reconnect, and rewriting the file each time would
/// make a mtime watcher see a change on every network blip — the very
/// connectivity-rate churn presence is RAM to avoid.