cli: add safe owning general-key hash sets

Add std.hashset with explicit pure hash/equality policies and complete
owning keys. Duplicate/full insert returns the original input, while
remove/pop and nonempty free preserve explicit resource ownership.

Reuse safe HashMap storage and failure/peak/refund accounting. Integrate
normative contracts, RFC, references, complexity measurements, CLI/profile
checks and independent Copy/owner set traces.

Validation: 973 conformance cases; runtime set GC and schedule stress;
unit/Quick Reference, formatting, hosted smoke, 53 CLI checks, 106 source
coverage constructs and bundle generation.
This commit is contained in:
dev committed 2026-10-07 11:14:53 +03:00
1 parent 7743f515c5
commit 4716cda0f1
43 files changed
+2696 -7

No files matched your search

+1 -1
View File
@@ -141,4 +141,4 @@ Lowering layers (P6A-3/4), each with accepted (golden AIR), rejected (`E7xxx`) a
| P6-9 | todo | Port reference programs and examples to `.aji` | P6-5 | `tests/programs/`, `examples/` | exit criterion passes |
| P6-10 | todo | Phase exit review | all | plan status | exit criterion passes |
The [standard-library track](standard-library.md) implements thirteen compiler-pinned modules and qualified standard enum names. STD-3/RFC 0021 completes P6-3 on the branch with explicit manifest source mapping, acyclic linking, direct qualified names, imported struct literals and task workers. Dependency fetching/resolution is separate package work; STD-4/RFC 0022 completes explicit generics and structural constraints on the branch. STD-5/RFC 0023 adds whole-value linear structs/enums/fixed arrays, complete unpack/match, explicit exchange and ownership-preserving allocation failure through all layers (spec 15 §16). STD-6a/b/RFC 0024 resolves Q-036 with initialized buffer<T> and safe std.vec, explicit growth, returned failure ownership and draining (spec 15 §17). STD-6c/RFC 0025 adds safe owning Deque with existing source primitives. STD-6d.1/RFC 0026 adds pure std.hash; STD-6d.2/RFC 0028 adds safe owning U64Map<V> after the explicit error_values prerequisite (RFC 0027). STD-6d.3/RFC 0029 adds explicit static function parameters for general hash/equality/order operations with existing AIR calls/workers. STD-6d.4/RFC 0030 implements the general owning-key std.hashmap contract; its final GC/stress validation remains in progress (Q-037). Remaining sets/heaps are STD-6d. Existing `from`-returns remain unimplemented (Q-034). These increments do not complete Phase 6.
The [standard-library track](standard-library.md) implements fourteen compiler-pinned modules and qualified standard enum names. STD-3/RFC 0021 completes P6-3 on the branch with explicit manifest source mapping, acyclic linking, direct qualified names, imported struct literals and task workers. Dependency fetching/resolution is separate package work; STD-4/RFC 0022 completes explicit generics and structural constraints on the branch. STD-5/RFC 0023 adds whole-value linear structs/enums/fixed arrays, complete unpack/match, explicit exchange and ownership-preserving allocation failure through all layers (spec 15 §16). STD-6a/b/RFC 0024 resolves Q-036 with initialized buffer<T> and safe std.vec, explicit growth, returned failure ownership and draining (spec 15 §17). STD-6c/RFC 0025 adds safe owning Deque with existing source primitives. STD-6d.1/RFC 0026 adds pure std.hash; STD-6d.2/RFC 0028 adds safe owning U64Map<V> after the explicit error_values prerequisite (RFC 0027). STD-6d.3/RFC 0029 adds explicit static function parameters for general hash/equality/order operations with existing AIR calls/workers. STD-6d.4/RFC 0030 implements the general owning-key std.hashmap contract; its final GC/stress validation remains in progress (Q-037). STD-6d.5/RFC 0031 implements general owning std.hashset with duplicate input return; its conformance, GC/schedule, CLI and documentation checks pass. BinaryHeap remains STD-6d. Existing `from`-returns remain unimplemented (Q-034). These increments do not complete Phase 6.
+10 -2
View File
@@ -20,7 +20,7 @@ Without external source dependencies, Aji should support ordinary CLI tools, sto
|---|---|---|
| Scalars, structs/enums, slices/arrays, explicit borrows | implemented | pure fixed-storage algorithms can start now |
| Heap/regions, I/O, files, TCP, clock/random, structured tasks/channels/mutex | implemented primitives | wrappers can reuse them, but their presence does not imply the complete APIs below |
| Built-in standard imports and enum types | STD-0/1a/2a/2b branch implementation | compiler-pinned, closed registry; eleven modules; qualified enum types/constructors/patterns; no package lookup |
| Built-in standard imports and enum types | STD-0/1a/2a/2b branch implementation | compiler-pinned, closed registry; fourteen modules; qualified enum types/constructors/patterns; no package lookup |
| General modules/imported struct literals | STD-3 branch implementation (P6-3; RFC Proposed) | explicit manifest mapping, direct qualified names, ordinary verifier |
| User generics/structural constraints | STD-4 branch implementation (P6-4; RFC Proposed) | needed for reusable `Vec<T>`, `HashMap<K,V>`, option/result |
| `linear_aggregates` | STD-5 branch implementation (RFC Proposed) | whole-value owning structs/enums/fixed arrays; initialized buffer<T>/std.vec implemented by STD-6a/b |
@@ -57,12 +57,13 @@ SQL/database clients, Redis/Kafka, ORMs, application authentication, gRPC/protob
| STD-6a | done (branch implementation; RFC 0024 Proposed) | dynamic initialized buffer<T> storage/drain contract (Q-036) | STD-4/5 | vertical allocate/grow/push/pop/view/free; allocation failures preserve state, returned owners consumed; no hidden destruction |
| STD-6b | done (branch implementation; RFC 0024 Proposed) | safe std.vec for Copy/owners/files/channel endpoints | STD-6a | explicit reserve, bounded push, moving pop/replace, empty-only free; deterministic and failure/cleanup tests |
| STD-6c | done (branch implementation; RFC 0025 Proposed) | safe std.deque for Copy/owners/files/endpoints | STD-6a/b | bounded ring, both ends, failure-preserving explicit growth, complete resource transfer and empty-only free |
| STD-6d | todo (hash and numeric-key map done; general keys, sets and heaps remain) | HashMap, HashSet, BinaryHeap | STD-6a/b/c | safe collection contracts, including HashMap<Key, Own<Value>>, recoverable failures and explicit draining |
| STD-6d | in progress (maps/set implemented; heap and final general-map GC remain) | HashMap, HashSet, BinaryHeap | STD-6a/b/c | safe collection contracts, including HashMap<Key, Own<Value>>, recoverable failures and explicit draining |
| STD-6d.1 | done (branch implementation; RFC 0026 Proposed) | pure std.hash: FNV-1a 64 / CRC32C, fresh/extend | STD-1b | four safe functions, exact byte/chunk conventions, independent public vectors and CLI/profile checks |
| STD-6d.2a | done (branch implementation; RFC 0027 Proposed) | pure built-in error construction prerequisite | STD-6d.1 | vertical error_values feature, no authority/effect/resource changes; preflight allocation validation |
| STD-6d.2 | done (numeric-key branch implementation; RFC 0028 Proposed) | U64Map<V> first; general HashMap<K,V> key policy Q-037 | STD-6d.1 | safe map with ownership/failure/collision tests and error_values prerequisite (RFC 0027); general-key gate remains open |
| STD-6d.3 | done (branch implementation; RFC 0029 Proposed) | explicit static hash/equality/order functions | STD-4 | exact callable contracts, ordinary AIR calls/workers and nominal operation identity; general collections remain required |
| STD-6d.4 | implementation validated; final GC/stress in progress (RFC 0030 Proposed) | general owning HashMap<K,V,H,E> | STD-6d.3 | dense complete entries, Copy probe indices, exact equality and returned key/value ownership |
| STD-6d.5 | done (branch implementation; RFC 0031 Proposed) | general owning HashSet<K,H,E> | STD-6d.4 | exact membership, duplicate/full input ownership, moving extraction and empty-only free |
| STD-7 | todo | concrete I/O adapters, buffered I/O and lexical paths | STD-1b/2a/2b; STD-3 for public types | short reads, EOF, capacity and write failures covered; paths never grant filesystem authority |
| STD-8 | todo | filesystem gaps, args/env capability RFC, time/random distinctions and structured log | STD-3/7; vertical runtime feature where needed | CLI/storage milestone examples work in deterministic and hosted profiles; all authority is granted at entry |
| STD-9 | todo | independent integration application and API review | STD-6/7/8 | integration gate; public application is not private benchmark material |
@@ -144,3 +145,10 @@ STD-6d.1/RFC 0026 adds safe std.hash with four byte-only fresh/continuation oper
## General operation-selection prerequisite
STD-6d.3/RFC 0029 implements explicitly bound static functions with exact typed/effect contracts, forwarding, generic function arguments, nominal operation identity and named workers. It reuses ordinary AIR and preserves direct-import visibility, capability inputs, ownership and task loans. Source/AIR positives/rejections, recursive/cyclic contracts, GC/scheduler stress, CLI/profile/provenance checks and documentation budgets are recorded in the RFC. General HashMap/HashSet storage/API remains Q-037; BinaryHeap and STD-7 are still required.
## General owning set verification
STD-6d.5/RFC 0031 implements safe HashSet<K,H,E> over the general map, with nine explicit operations. Duplicate insertion preserves every stored entry/bucket and returns the exact incoming key, including its resources; full does likewise for new keys. Remove/pop transfer complete stored keys, and nonempty free returns the whole set. Allocation, failure rollback, peak/refund accounting and dense pop order follow the map. No new language syntax, verifier/runtime state, diagnostic, AIR feature or trusted boundary is added.
All 973 conformance cases pass, including 26 set cases. Runtime fixtures pass collection before every instruction; the shared lookup fixture passes 12 seeds under quanta 1, 2, 7 and its own quantum. Independent Python set/representative oracles cover 80 operations across Copy/owning traces and check membership after each operation. Byte-buffer/file keys, exact duplicate-table preservation, returned owners, allocation failure/refunds/peaks and rejected leaks/moves/aliases/loans/policies/non-Share contents are covered. Unit/Quick Reference, formatting, hosted smoke, 53 CLI/profile/package/source/AIR checks, 106/106 source coverage constructs and bundle generation pass. RFC 0031 records documentation growth. The separate general-map full GC/stress process remains pending; BinaryHeap is the next collection increment, followed by STD-7 I/O/path.