cli: add safe owning deque standard module

Embed std.deque with eleven generic operations implemented entirely in
safe Aji over initialized Option<T> buffer slots. Bounded pushes and
moving pops work at both ends; full pushes, out-of-bounds replacements
and nonempty free return ownership to the caller. Explicit reserve
preserves order and all state on allocation failure, charges the old
and new slot capacities at the allocation peak, and rotates whole
values after successful growth. No AIR, verifier or runtime change.

Specify the visible representation invariant, tag-inclusive allocation
accounting and empty-only cleanup. Add RFC 0025, a runnable owning
example, source/CLI conformance and CI coverage. Complete STD-6c;
HashMap, HashSet and BinaryHeap remain STD-6d.

Validation: unit tests and 785 full conformance cases; 28 deque fixtures;
focused collection after every instruction and 12 schedule seeds over
four quanta; 136 source/package/hosted CLI checks; an independent Python
deque oracle for 128 operations and 71 small growth configurations;
93/93 source coverage; Zig formatting, staged whitespace and bundles.

Reference cost: full source excluding AIR grows 52,384 -> 53,993 cl100k
tokens (+3.1%); Quick Reference 7,667 -> 7,747 (+1.0%). AIR stays at
175,736 bytes. Construction/growth still incur interpreter prefix-copy
overhead; no native performance or empirical MCC benefit is claimed.
This commit is contained in:
dev committed 2026-10-07 00:08:42 +03:00
1 parent 4138a52af6
commit 93405f69ce
46 files changed
+1789 -7

No files matched your search

+2
View File
@@ -449,3 +449,5 @@ fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
`ref values = buffer.view(b);` / `mut values = buffer.view(b);` borrow only the prefix. A live child view/task loan blocks shape changes, even a no-op reserve. Read Copy elements; use value.swap to replace linear elements, consuming the returned old value. Full contracts: language/buffers.md.
Import `std.vec` for `Vec<T>` and new/len/capacity/reserve/push/pop/free/get/replace, each explicitly specialized `::<T>`. new/reserve require mem.alloc; push is bounded, get requires Copy, pop returns std.option.Option<T>. Failure variants retain ownership: full(item), out_of_bounds(item), not_empty(vector). Match move on linear results; import std.option to name its variants. Signatures: library/std.md. Inside a specialized generic body, `move name` also accepts complete Copy bindings and retains their availability; monomorphic Copy moves and moves of borrows still reject.
`std.deque` uses the same explicit allocation, returned-ownership and empty-only free contract, with push_front/push_back and pop_front/pop_back. Indices count from the front. Each capacity slot charges Option<T> (tag plus payload); reserve preserves order and needs old+new quota. It uses existing source primitives; signatures and representation invariants stay in library/std.md.