resolver
resolver
¶
Turning « sur mon PC » into a device id — or refusing to guess.
Spec §22. The assistant hears a phrase, not an identifier. This module is the only place allowed to bridge the two, and its governing rule is that a wrong guess is worse than a question: opening a screen on the wrong machine is confusing, and sending a notification to the wrong one is a small betrayal of trust. So when two devices match equally well, this returns an AMBIGUOUS answer with the candidates rather than picking the first.
The one place it does decide on its own: a single obvious match, or a tie broken by reachability — because "the phone that is on" is what a person means by "my phone" when only one is awake.
Functions:¶
resolve_device
¶
resolve_device(
phrase: str,
devices: Sequence[Mapping[str, Any]],
*,
local_device_id: str = "",
) -> dict[str, Any]
Read phrase against the fleet and say who is meant — or that it is unclear.
Returns one of four outcomes, each with a French sentence the assistant can say verbatim:
LOCAL the user means this machine; do not route anything.
RESOLVED one device, with device.
AMBIGUOUS several plausible, with candidates — ask, do not pick.
UNKNOWN nothing matched, with candidates listing what exists.
Source code in src/diapason/mesh/resolver.py
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 | |
describe_devices
¶
The fleet as the assistant should see it: names, kinds, and whether they are awake. No keys, no addresses — nothing the model needs.