mirror of
https://github.com/RightNow-AI/openfang.git
synced 2026-07-30 14:49:10 +00:00
PUT /api/budget casts &Arc<AppState> to *mut KernelConfig and mutates the budget fields through a raw pointer. This is unsound: AppState is shared across Tokio worker threads, so two concurrent PUT /api/budget requests cause a data race on the same memory location. Replace with Arc<tokio::sync::RwLock<BudgetConfig>> stored on AppState, initialized from kernel.config.budget at startup. All readers use .read().await and all writers use .write().await. No unsafe code remains in the budget update path. Fixes: data race / undefined behaviour under concurrent budget updates