///|
/// True when `record_dependency` would attach a static recompute's read to
/// a caller frame instead of to a declared fixed-dependency boundary.
fn Runtime::static_recompute_blocks_dependency_recording(
self : Runtime,
) -> Bool {
let len = self.static_recompute_tracking_floors.length()
len > 0 &&
self.core.tracking.stack.length() <=
self.static_recompute_tracking_floors[len - 1]
}
///|
/// Records a dependency from the currently computing memo to the given cell.
///
/// Called internally by `Input::get` and `Memo::get` when inside a memo's
/// compute function. If no memo is currently computing (tracking stack is
/// empty), this is a no-op.
impl Tracker for Runtime with fn record_dependency(self, dep) {
if self.static_recompute_blocks_dependency_recording() {
abort(
"Tracked reads are unsupported inside static Derived recompute; use peek() or declared fixed-source reads",
)
}
@kernel.record_dep(self.core, dep)
}
///|
/// Pushes a new dependency tracking frame for a memo computation.
///
/// Called internally at the start of a memo's recomputation. All subsequent
/// `get()` calls will be recorded as dependencies until `pop_tracking` is
/// called.
impl Tracker for Runtime with fn push_tracking(self, cell_id) {
@kernel.push_tracking(self.core, cell_id)
}
///|
/// Pops the tracking frame and returns the collected dependencies.
impl Tracker for Runtime with fn pop_tracking(self) {
@kernel.pop_tracking(self.core)
}
///|
/// Pushes a fresh tracking frame for the given cell (Phase 2 API).
fn Runtime::begin_tracking(self : Runtime, cell_id : CellId) -> Unit {
@kernel.push_tracking(self.core, cell_id)
}
///|
/// Pops the tracking frame and returns the collected dependencies and seen set.
fn Runtime::end_tracking(
self : Runtime,
) -> (Array[CellId], @hashset.HashSet[CellId]) {
@kernel.pop_tracking(self.core)
}
///|
/// Updates subscriber links after a cell recomputes with a new dependency set.
fn Runtime::finish_tracking(
self : Runtime,
cell_id : CellId,
old_deps : Array[CellId],
new_deps : Array[CellId],
new_seen : @hashset.HashSet[CellId],
) -> Unit {
@kernel.diff_and_update_subscribers(
self.core,
self.pull,
self.push,
self.datalog,
cell_id,
old_deps,
new_deps,
new_seen~,
)
|> ignore
}
///|
/// Guards a cell read from occurring inside a computation on a different
/// runtime. Centralizes the cross-runtime check that was previously
/// duplicated across Input, Derived (outer), HybridMemo, EagerDerived, Relation,
/// and MapRelation read paths.
fn Runtime::check_cross_runtime(
_self : Runtime,
cell_runtime_id : @incr_types.RuntimeId,
kind : String,
) -> Unit {
@kernel.check_cross_runtime_strict(cell_runtime_id, kind)
}
///|
/// Internal: returns a reference to the top ActiveQuery frame, if any.
fn Runtime::top_active_query(self : Runtime) -> ActiveQuery? {
@kernel.top_active_query(self.core)
}
///|
/// Internal: pops the tracking frame and returns the full ActiveQuery for
/// callers that need staged accumulator state.
fn Runtime::pop_tracking_full(self : Runtime) -> ActiveQuery {
@kernel.pop_tracking_full(self.core)
}