balancer-lite-lua.dlog 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # balancer-lite-lua.dlog — Deployment Log
  2. ## 2026-09-04 Initial Prototype
  3. ### What
  4. Created new workspace project `balancer-lite-lua/` for OpenWrt 22.03 Lua 5.1 port of
  5. balancer-lite's hysteresis watchdog, flap detection, signed webhook outbox, and retention store.
  6. Thin-layer only (~800–1000 LOC) — composes with mwan3/netifd rather than replacing them.
  7. ### Commit
  8. `09fad45` — "Initial Lua 5.1 prototype for OpenWrt 22.03"
  9. ### Files
  10. - `src/balancerlite/state.lua` — 8-state hysteresis machine (INIT, WAN_A/B_PRIMARY, SWITCHING_TO_A/B, DEGRADED, BOTH_DOWN)
  11. - `src/balancerlite/probes.lua` — ICMP/TCP/DNS health checks via ping/nc/nslookup subprocesses
  12. - `src/balancerlite/store.lua` — JSONL append-only event log + compaction
  13. - `src/balancerlite/outbox.lua` — Signed webhook retry queue with exponential backoff + circuit breaker
  14. - `src/balancerlite/sha256.lua` — SHA-256/HMAC-SHA256 via `openssl dgst` CLI
  15. - `src/balancerlite/config.lua` — UCI config file parser
  16. - `src/balancerlite/main.lua` — procd-compatible poll loop daemon
  17. - `src/balancerlite/json.lua` — Pure-Lua JSON encoder (JSON.stringify only)
  18. - `etc/init.d/balancerlite` — procd init script
  19. - `etc/config/balancerlite` — UCI config example
  20. - `Makefile` — lint + test targets
  21. - `tests/state.lua` — 8 state machine tests (all passing)
  22. - `tests/sha256.lua` — SHA-256 + HMAC-SHA256 test vectors (all passing)
  23. - `MEMORY.md`, `README.md`
  24. ### Test Results
  25. ```
  26. lua5.1 tests/state.lua → PASS: state (8/8 tests)
  27. lua5.1 tests/sha256.lua → PASS: sha256 (3/3 vectors)
  28. ```
  29. All modules pass `luac5.1 -p` (parse check).
  30. ### Verification Commands
  31. ```sh
  32. cd /root/.openclaw/workspace/balancer-lite-lua
  33. make test # runs all tests
  34. make lint # runs luac5.1 -p on all modules
  35. ```
  36. ### Remote
  37. `https://git3.techno-world.net/lrosales/balancer-lite-lua.git`
  38. ⚠️ Repo does not exist yet on git3 — creation via Gogs API returned 401.
  39. Manual repo creation needed on https://git3.techno-world.net first.
  40. ### Notes
  41. - HMAC-SHA256 uses `openssl dgst -hmac` CLI (openssl-util package on OpenWrt 22.03)
  42. - No lua-crypto dependency; no raw sockets; all probes via subprocess
  43. - State machine verified against Go source: 8 states, same transition logic
  44. - SWITCHING_TO_* are one-drive-cycle intermediate states
  45. - BOTH_DOWN transitions directly to stable primary (no intermediate)
  46. - BOTH_DOWN clears switch_times (flap detection not counted during all-down)
  47. - DEGRADED entry: flap check counts #record_switch calls; needs `flap_threshold` of them
  48. ### Remaining Work
  49. 1. Create empty repo on git3.techno-world.net, then `git push -u origin master`
  50. 2. Write `src/balancerlite/routing.lua` (policy routing via `ip` commands)
  51. 3. Write `src/balancerlite/wg.lua` (WireGuard endpoint re-point via `wg set`)
  52. 4. Write `balancerlite-ctl` CLI tool (status/events/switch/compact)
  53. 5. Runtime test on `openwrt-testbed`