Function sequant::eval::detail::ordered_skip_closure

Function Documentation

inline container::vector<char> sequant::eval::detail::ordered_skip_closure(CellTable const &table, container::vector<char> seed)

Cache-halt, computed once per evaluation call over the table: the set of cells whose production this call may skip.

A cell is skipped when

  1. it is persistent and the registry already holds it &#8212; it survived from a previous evaluation of this schedule through the persistent value store and was seeded back in (CellRegistry::seed_persistent), so re-producing it would be pure waste (and, for an accumulating Assemble, would corrupt the held value by summing it into itself); or

  2. every consumer of it is itself skipped &#8212; nothing left this call will read it. The consumers of a cell are the consumer cells of every Read whose source is it, plus every Assemble whose production.source is it. The edge is by source cell, not by value: a read names the exact form it consumes and the resolver serves that form and no other, so an in-block partial whose only reader is the Assemble that closes it is dead as soon as that Assemble is &#8212; even though the assembled form of the same value is still read elsewhere.

A cell with no consumer at all is never skipped by rule 2 &#8212; the closure below only ever adds a cell all of whose consumers are skipped, and a cell with no consumer has none to skip. Those cells are the schedule’s own results (validator rule 4 admits a zero-read cell only at the root scope), and rule 1 does reach them: a non-volatile forest root &#8212; a constant term, held by the persistent store from the previous evaluation &#8212; is skipped exactly as any other held persistent cell is, which is the whole point of cache-halt. What the caller then receives for such a root is a private copy of the held value, never the stored buffer itself (see the root results in run_ordered_schedule_pre_results).

Rule 2 is a fixpoint over the table’s dependency edges: skipping a resident persistent composite makes its own prerequisites dead, and so on down. This is the table-side statement of what forest descent does by halting its descent at a cache hit.