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
@@ -109,3 +109,5 @@ RFC 0022 explicit generics (cl100k, relative to modules): Quick Reference 6,501
RFC 0023 whole-value linear aggregates (cl100k, relative to generics): Quick Reference 6,948 → 7,225 (+4.0%); other source docs 41,086 → 42,364 (+3.1%); full source docs excluding AIR 48,034 → 49,589 (+3.2%). New on-demand `language/linear-aggregates.md` is 1,133 tokens; `library/std.md` is 8,398. AIR grows to 168,336 bytes (+4.7%). Whole unpack/exhaustive match/explicit swap/allocation failure expose ownership without per-field holes, cleanup or new transfer state. Cumulative source growth is approximately +45.9%; Quick Reference remains beyond its 4–6k target. RFC 0023 justifies the added contracts; consolidation remains separate work and no MCC improvement is claimed.
RFC 0024 initialized buffers and safe Vec (cl100k, relative to linear aggregates): Quick Reference 7,225 → 7,667 (+6.1%); other source docs 42,364 → 44,717 (+5.6%); full source excluding AIR 49,589 → 52,384 (+5.6%). New on-demand language/buffers.md is 1,175 tokens; library/std.md is 9,432. AIR grows to 175,736 bytes (+4.4%). Initialized prefixes, explicit reserve, returned failure ownership and empty-only free permit safe resource containers without per-slot verifier state. Cumulative full source growth is +54.2%, with the RFC's owner-review justification; Quick Reference consolidation remains separate work and no empirical MCC improvement is claimed.
RFC 0025 safe owning Deque (cl100k, relative to buffer/Vec): Quick Reference 7,667 → 7,747 (+1.0%); other source docs 44,717 → 46,246 (+3.4%); full source excluding AIR 52,384 → 53,993 (+3.1%). library/std.md is 10,961 tokens; AIR remains 175,736 bytes. Eleven generic safe functions reuse buffer/Option/exchange and existing ownership/borrow rules without semantic or verifier-state growth. Full ring invariants and accounting stay on demand; cumulative full-source growth is +58.9%, with the RFC's owner-review justification and no empirical MCC claim.
+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.
+1 -1
View File
@@ -8,7 +8,7 @@ The other files in `/docs` hold the full rules. Open one only when this page is
| Need | Read |
|---|---|
| built-in bytes/math/text/formatting, option/result and owning Vec, signatures and failure contracts | `/docs/library/std.md` |
| built-in bytes/math/text/formatting, option/result, owning Vec and Deque, signatures and failure contracts | `/docs/library/std.md` |
| initialized buffer storage, explicit growth/drain and child views | `/docs/language/buffers.md` |
| whole-value linear aggregates, unpack, exchange and allocation failure | `/docs/language/linear-aggregates.md` |
| generic declarations/applications, property constraints and specialization limits | `/docs/language/generics.md` |