Queries. A query is a value type that caches the archetypes matching its description and refreshes incrementally (new archetypes only). Iteration locks the world for its duration, so structural calls made from a callback fail with STRUCTURE_LOCKED and the callback must use a command_buffer instead.
What a query matches: archetypes containing every bit of with and none of without; with a non-empty changed mask a chunk is visited only when one of the listed columns changed after sinceVersion. optional and writes record what a view's pack reads when present and what it writes; the query itself does not consult them. Stamping follows the constness of the span a chunk_view hands out, and Debug write validation uses the bound system's system_desc.
Matching archetypes a query stores inline before it touches the heap. A view built per system run (the documented context.view<...>().for_each idiom, system.h) therefore allocates nothing while it matches at most this many archetypes; beyond that the first refresh of each new query allocates once.