Skip to content

Bugs đã biết ​

DANH SÁCH BUGS CẦN FIX

Các bugs dưới đây đã được phát hiện qua code review. Cần fix trước khi refactor hoặc viết lại.

BUG-01: totalOfficialNormalCost luôn = 0 ​

File: workforcePlanningEngine.ts — layer5_calculateOutput() (line ~980-1096)

Vấn đề: totalOfficialNormalCost được khai báo nhưng không bao giờ tăng trong allocation loop. Chỉ OT cost, temp cost, và night surcharge được tính.

Hậu quả: costBreakdown.officialNormalCost luôn = 0, totalCost bị báo thấp hơn thực tế.

Fix: Thêm vào loop:

typescript
totalOfficialNormalCost += (alloc.picker.officialRegular + alloc.packer.official.totalOfficial) 
  * avgCostPerHour * effectiveHours;

BUG-02: dailyBacklogByChannel overwrite thay vì accumulate ​

File: workforcePlanningEngine.ts — layer5_calculateOutput() (line ~1032)

Vấn đề: Trong per-shift loop, dailyBacklogByChannel[ch] dùng = thay vì +=.

Hậu quả: Daily backlog breakdown chỉ phản ánh shift cuối cùng, không phải tổng trong ngày.

Fix: Đổi = → += cho: dailyBacklogByChannel, dailyBacklogByCarrier, dailyBacklogByCustomer.


BUG-03: Legacy allocation chạy khi không cần ​

File: workforcePlanningEngine.ts — layer4_allocateStaff() (line ~856-866)

Vấn đề: else branch chạy khi packStillNeeded === 0 && pickStillNeeded === 0 — tính temp slots khi không cần temp workers.

Hậu quả: Không ảnh hưởng kết quả (output = 0) nhưng gây confusing code path. Dead code.


BUG-04: config.isHoliday luôn = false ​

File: workforcePlanningEngine.ts — runWorkforcePlan() (line ~1123)

Vấn đề: config.isHoliday = false hardcoded. Comment nói "Would come from holiday calendar in production".

Hậu quả: Ngày lễ: OT cost bị tính thấp, labor law compliance warnings bị thiếu.


BUG-05: Silent failure trong SelfImprover rollback ​

File: self_improver.py — _rollback() (line ~536-547)

Vấn đề: Nếu suggestion_id không tìm thấy trong _applied_changes, method trả về silently. check_and_rollback() vẫn return True.

Hậu quả: Auto-rollback tuyên bố thành công nhưng thực tế config vẫn bị modified.

Tài liệu liên quan ​

BoxMe Forecast — Tài liệu kỹ thuật nội bộ