analyze: memoize the resolved Scope by shape in Core (3) #92

Merged
PerishFire merged 1 commit from query-chart into main 2026-07-21 04:27:26 +00:00
Owner
No description provided.
analyze: memoize the resolved Scope by shape in Core (3)
All checks were successful
guard / guard (pull_request) Successful in 29s
920ca92e68
Core gains a Chart beside the Stash: a HashMap<shape, Arc<Scope>> holding
the resolved structure of every query it has analyzed. Distinct from the
Stash by what it caches and how it dies -- Stash holds Packs and is
invalidated by writes; a Scope is a pure function of (plan, query shape)
and the plan is bind-fixed, so a Scope is immortal for the engine
instance and needs no invalidation at all. It ignores the [cache] switch
for the same reason: memoizing a pure function is not a data cache.

The key is query::shape -- the digest with values, sort rank, limit,
after and count elided, so paging and refiltering hit the same Scope.
That forces analyze to split, because analyze was also coercing pred
values, and a key that ignores values must not cache their verdict:

  analyze(plan, tree) -> Scope   structure, cached
  verify(scope, tree) -> ()      values, run before every execution

analyze keeps everything the shape determines (unit and field and bond
resolution, sort field, like-wants-text, nested field kind); verify does
the value work (kind.fit, and the id parse behind has). Everything the
shape does NOT capture stays in verify -- that is the invariant the split
rests on, so sort's field name is in the key while its rank is not.

nest_kind loses its plan and takes the target Unit the caller already
holds. query::run consumes a &Scope instead of analyzing.

tests/query/chart: keys pins the key semantics (same shape across values
and paging, distinct across field, op, link, sort field, root and nested
field); cells, bonds and sorts warm the cache and then prove a bad value
is still refused on the second call. Neutering verify fails cells, bonds
and the pre-existing cast and run -- the tests are load-bearing.

guard clean, 43 tests green on sqlite and on real postgres.
PerishFire deleted branch query-chart 2026-07-21 04:27:26 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
PerishLab/keel!92
No description provided.