Module: Legion::LLM::API::InventoryAdmin
- Extended by:
- Legion::Logging::Helper
- Defined in:
- lib/legion/llm/api/inventory_admin.rb
Overview
Admin endpoint for the inventory. POST /api/llm/inventory/refresh — operator lever ("$1M expiring → bump weight, drain, drop") and manual recovery after a credential rotation. The daemon holds no lane store and no weight engine: each provider publisher recomputes write-time weights from current settings on its own discovery cadence (lex-llm Inventory::WeightReconciler) and re-publishes into the single registry; the selector reads settings through its own generation. The route reports that state honestly — it never claims to have reweighted anything.
Constant Summary collapse
- REFRESH_NOTE =
'lane weights are recomputed by each provider publisher from current ' \ 'settings on its discovery cadence (lex-llm WeightReconciler); the daemon ' \ 'holds no lane store to reweight'
Class Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/legion/llm/api/inventory_admin.rb', line 25 def self.registered(app, **) log.debug('[llm][api][inventory_admin] registering inventory admin routes') app.post '/api/llm/inventory/refresh' do body_raw = request.body&.read body = if body_raw && !body_raw.empty? Legion::JSON.load(body_raw) else {} end scope = body[:scope] || {} log.info("[llm][api][inventory_admin] action=refresh scope=#{scope} result=publisher_driven") json_response(data: { refreshed: false, scope: scope, note: REFRESH_NOTE }) rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: 'llm.api.inventory_admin.refresh') json_error('inventory_refresh_error', e., status_code: 500) end end |