fix(BIZ-42): critical deadlock + major review issues

- Fix #1 (Critical): evaluate_retreat() deadlock — changed _retreat_lock to
  threading.RLock() to allow reentrant acquisition when evaluate_retreat()
  calls get_429_rate() while holding the lock
- Fix #2 (Major): Dashboard queue chart now uses snap.queue.per_priority
  instead of Math.random() mock data
- Fix #3 (Major): structlog uses JSONRenderer instead of ConsoleRenderer
  for JSON-format output as required by acceptance criteria
- Bonus: webui.py _build_snapshot() now async and includes queue data
  with per-priority depth for dashboard consumption

Reviewed-by: 梁思筑 (architect)
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-06-24 12:20:23 +08:00
parent e829a4060b
commit ba5b932f50
4 changed files with 28 additions and 12 deletions
@@ -186,12 +186,13 @@ function updateDashboard(snap) {
];
chartTokens.update();
const mb = (snap.metrics_buffer || {});
const qs = snap.queue || {};
const perPriority = qs.per_priority || {};
chartQueue.data.datasets[0].data = [
Math.round(Math.random() * 5),
Math.round(Math.random() * 10),
Math.round(Math.random() * 15),
Math.round(Math.random() * 20)
perPriority.URGENT || 0,
perPriority.HIGH || 0,
perPriority.NORMAL || 0,
perPriority.LOW || 0
];
chartQueue.update();