fathom.FleetEngine¶
fathom.FleetEngine
¶
Manages multiple session-scoped Engines backed by a shared :class:FactStore.
Fleet-scoped facts (those whose template has scope="fleet") are
visible across all sessions via :meth:sync_fleet_facts. Every method
that addresses a session takes its id and raises KeyError for an id
with no session.
Known limitation: fleet retraction does not propagate. FleetEngine has no
retract method and never calls :meth:FactStore.subscribe, and
:meth:sync_fleet_facts only ever asserts. A fact removed from the shared
store (explicitly, or by Redis TTL expiry) therefore stays in the working
memory of every session that already synced it. To drop it from a session,
rebuild that session with :meth:replace_session and sync it again.
Source code in src/fathom/fleet.py
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 | |
sessions
property
¶
Return the mapping of session IDs to Engine instances.
create_session(session_id)
¶
Create and return an isolated :class:Engine for session_id.
The engine is loaded from the configured rules path and stored internally so it can be retrieved later.
Raises:
| Type | Description |
|---|---|
FleetError
|
session_id already has a session. Use
:meth: |
Source code in src/fathom/fleet.py
replace_session(session_id)
¶
Discard session_id's engine and return a freshly loaded one.
The new engine starts with empty working memory; call
:meth:sync_fleet_facts to pull the fleet state back in.
Raises:
| Type | Description |
|---|---|
KeyError
|
session_id has no session. |
Source code in src/fathom/fleet.py
remove_session(session_id)
¶
Forget session_id's engine.
Raises:
| Type | Description |
|---|---|
KeyError
|
session_id has no session. |
assert_fact(session_id, template, data)
async
¶
Assert a fact into session_id, routing fleet-scoped facts to the store.
Returns the assigned fact_id for fleet-scoped templates, or None
for session-scoped templates. The store receives the fact as the
engine accepted it, defaults applied and values coerced, so
:meth:query filters match the values this session's rules see.
Raises:
| Type | Description |
|---|---|
KeyError
|
if session_id has no associated Engine. |
ValidationError
|
if the template is not registered on that Engine. |
Source code in src/fathom/fleet.py
sync_fleet_facts(session_id)
async
¶
Pull fleet-scoped facts from the :class:FactStore into session_id.
Queries the fact store for every fleet-scoped template and asserts matching facts into the session's working memory. A fact the session rejects is logged and skipped, so one malformed row in the shared store cannot stop the rest of the fleet state from syncing.
Raises:
| Type | Description |
|---|---|
KeyError
|
session_id has no session. |
Source code in src/fathom/fleet.py
query(template, fact_filter=None)
async
¶
Query the shared :class:FactStore for facts matching template.
Raises:
| Type | Description |
|---|---|
ValidationError
|
fact_filter names a template or slot the rules do not declare. The store would match a null-valued unknown key against every row. |