task-0230 Investigation — Nightly Summary Cache Does Not Complete

Finding

The nightly standard-POS task is dominated by combinatorial traversal and N+1 metadata queries. A single long Bilbo reporting query is not required to reproduce the failure.

Production Evidence

Controlled Reproduction

A production runner replaced KPI execution with a process-local function returning NA. It performed no KPI/API work and created no cache rows.

Even with KPI execution removed, one blank-context Branch Effectiveness Summary build exceeded a 45-second timeout. Before cancellation it had:

The largest repeated query groups were:

CEO, COO, CEO of Food Service, Branch Effectiveness, Floor Manager, and Warehouse Manager roots all exceeded five seconds in the same KPI-disabled probe. The summary graph contains nested summaries but no direct cycle in current production data.

Why Existing Safeguards Are Insufficient

Conclusion

The observed “hang” is an effectively unbounded batch. Long individual KPI queries may add cost, but optimizing one query cannot make the current traversal reliable. The fix must first bound and deduplicate the worklist, remove presentation-only rendering from cache warming, and extend timeout/observability coverage.

No production data, code, cron configuration, or task setting was changed during this investigation.