## 2023-11-20 - O(1) Cycle Detection in Workspace resolving **Learning:** When resolving deep, interdependent variables across sheets, checking a `string[]` stack for cycles using `.includes()` can degrade performance significantly (O(N) lookup repeatedly). Changing the stack representation to a `Set` improves the check to O(1) and substantially drops resolution time from ~180ms to ~0.5ms under load. **Action:** Whenever a unique set of items is tracked primarily for existence checking (like a cycle detection or "visiting" stack), prefer `Set` over `Array` if sequence order is not strictly necessary or if removal by value is possible.