Iterator Element Ownership Protocol
6 sections
Overview
Establish one backend-neutral iterator-yield contract: every element yielded by IterState::next() transfers exactly one logical owner credit to the consumer. A consumer either transfers that credit onward or discharges its exact cleanup obligation; an adapter that discards an element discharges the same obligation. AIMS freezes those owner, transfer, and cleanup events in the shared executable artifact before any physical executor selects storage or instructions.
Planned
6 sections
Sources: Increment on Yield
Every source iterator's next_* function yields owned (+1 RC) elements
Adapters: Decrement on Discard
Adapters that discard elements (filter, skip) call elem_dec_fn; adapters that pass through or produce inherit correct ownership
Consumers: Decrement After Use
Every consumer function receives elem_dec_fn and calls it after consuming each element
Current Compiled Projection: Parameter Plumbing
The LLVM adapter faithfully binds the current compiled counter plan's elem_inc_fn and elem_dec_fn actions to the frozen logical iterator ownership contract
AIMS: Logical Element Ownership Contract
AIMS freezes one backend-neutral owner-credit transfer and exact downstream cleanup/transfer obligation for every iterator yield
Verification Matrix
Full consumer x adapter x type test matrix with leak checking