What it solves
Risky operations start while RAM, queue, energy or write budgets are already under pressure.
How it works
1Application→2resource snapshot→3LOX Budget policy→4decision
Use it when
Gate an OTA attempt on energy and flash budget
Degrade logging under memory pressure
Prevent MQTT bursts from exhausting queue slots
Enforce flash-write lifetime budgets
Quick Start
#include "loxbudget.h"
static uint32_t mem[(LOXBUDGET_REQUIRED_SIZE(2,2,0)+3u)/4u];
loxbudget_t b; loxbudget_decision_t d;
loxbudget_op_profile_t p=loxbudget_op_profile_default(0);
if (loxbudget_init_simple(&b,mem,sizeof mem,2,2)!=LOXBUDGET_OK) return 1;
(void)loxbudget_set_resource(&b,0,10,LOXBUDGET_RES_REUSABLE);
(void)loxbudget_register_op(&b,&p);
(void)loxbudget_op_set_need(&b,0,0,5);
(void)loxbudget_check(&b,0,&d);
/* Expected: d.action == LOXBUDGET_ALLOW_FULL. */Real scenarios
Gate an OTA attempt on energy and flash budget
A caller-owned admission controller returns an explicit allow, degrade, defer or deny decision before work starts.
Degrade logging under memory pressure
A caller-owned admission controller returns an explicit allow, degrade, defer or deny decision before work starts.
Prevent MQTT bursts from exhausting queue slots
A caller-owned admission controller returns an explicit allow, degrade, defer or deny decision before work starts.
Engineering evidence
- GCC and Clang host CI, Cortex-M0 cross-build, ASan/UBSan and fuzz smoke are listed in the repository verification table
- Tests and optional audit trail cover decision paths
Known limits
- Not a scheduler, allocator, watchdog, logger or RTOS replacement
- Policies and resource measurements are supplied by the application
- The repository makes no safety-certification claim