Design decisions

71. TimeTree.run and offline_over zero-step-allocation callbacks (2026-11-21)

  1. Add TimeTree<E>.run<M, R>(self, mark:, apply:, answer:, undo:) -> List<R> and offline_over<E, M, R>(q, items, by:, mark:, apply:, answer:, undo:) -> List<R> in stdlib/timetree.cp, keeping steps() for compatibility. Reason: TimeTree.steps() materialized an O(q + m log q) List<TimeStep> and required callers to maintain a per-event marks: List<Mark> stack. Callback-driven run / offline_over takes one mark() per non-empty segment-tree node, devirtualizes all four callbacks in C++ codegen with zero std::function, and returns [answer(0), ..., answer(q - 1)] directly. On cf2069f (n = 400k, q = 400k), median user time dropped from 1.31s to 1.05s (-20%) and peak RSS dropped from 356 MB to 146 MB (2.44x less memory). Reverse: remove run, run_node, and offline_over from stdlib/timetree.cp and restore tt.steps() in proto/ports/ecnerwala/cf2069f.cp.