Expand description
Process-local schema cache — 0.7.2.
The planner / review / executor chain already reads
rustio.schema.json on every invocation. What was missing was a
runtime-visible reload: the dashboard and suggestion engine
baked their decisions against the compiled AdminEntry list, so
after rustio schema regenerated the file or after an
ai apply, the admin kept showing stale suggestions until the
operator restarted the server.
This module gives the admin a single refreshable source of truth:
a RwLock<Option<Schema>> behind a OnceLock. The suggestion
engine reads from here; the /admin/schema/reload handler writes
to here; the apply handler writes to here automatically on
success. No restart required.
§Safety
- The cache stores only a parsed
Schema— no handlers, no mutable project state. Reloading a bad file returnsErr; the previous good value stays in the cache. - Reads take a
RwLockread guard. Writes take a write guard and swap the innerOption. A poisoned lock falls back to “cache empty” rather than panic. - The cache is pure data — it cannot cause file writes, DB access, or any side effect.
Structs§
Functions§
- format_
loaded_ at - Formats
loaded_atasYYYY-MM-DD HH:MM:SS UTCfor the dashboard footer. - refresh
- Re-read
rustio.schema.jsonand atomically replace the cached value. Returns the freshly-loaded schema on success; leaves the previous value intact on any error. - refresh_
best_ effort - Like
refreshbut does not surface errors. Used by the apply handler to auto-reload after a successful write; the user-visiblerefreshendpoint returns a clear error on failure. - snapshot
- Snapshot of the currently-cached schema, or
Noneif the file is missing / unreadable / unparsable.