cli: add recoverable endian APIs and qualified std enums

This commit is contained in:
dev committed 2026-10-06 15:12:55 +03:00
1 parent 10a370471b
commit a2ca293506
45 files changed
+1205 -89

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 std bootstrap implements a closed two-module import subset (`STD-0`, [plan](standard-library.md)); P6-3 remains open for general user modules, imported types and dependency resolution. P6-4 remains open for generics. No full Phase 6 task is marked complete by that subset.
The std bootstrap and endian increment implement a closed two-module import subset and qualified standard enum types/constructors/patterns (`STD-0/1a`, [plan](standard-library.md)). P6-3 remains open for general user modules, imported struct literals and dependency resolution. P6-4 remains open for generics. No full Phase 6 task is marked complete by that subset.
+12 -5
View File
@@ -20,8 +20,8 @@ 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 | this bootstrap increment | compiler-pinned, closed registry; no package lookup |
| General modules/imported types | P6-3 pending | needed before publishing owning collection types |
| Built-in standard imports and enum types | STD-0/1a branch implementation | compiler-pinned, closed registry; qualified enum types/constructors/patterns; no package lookup |
| General modules/imported struct literals | P6-3 pending | needed before publishing owning collection types |
| User generics/structural constraints | P6-4 pending | needed for reusable `Vec<T>`, `HashMap<K,V>`, option/result |
| `linear_aggregates` | reserved, unscheduled | independent vertical RFC/phase gate for owners/resources in containers |
| Extended filesystem, IPv6/DNS, args/env, TLS/crypto | not promised by current runtime | audit each primitive, authority, error and profile model before implementation |
@@ -47,13 +47,14 @@ SQL/database clients, Redis/Kafka, ORMs, application authentication, gRPC/protob
| ID | Status | Work | Depends | Done when |
|---|---|---|---|---|
| STD-0 | done (branch implementation; RFC Proposed) | bootstrap spec, source std, closed imports, conformance, documentation and complexity measurement | existing source frontend | bootstrap exit criterion above and required repository checks pass |
| STD-1 | todo | endian u16/u32/u64, bounded copy/split/search, checked arithmetic API decisions | STD-0 | contracts define short-input/output failure, no partial mutation, empty and maximal values; fixtures and rejected alias examples pass |
| STD-2 | todo | UTF-8 validation/iteration, hex/base64 and formatting into supplied buffers | STD-1 | malformed text and insufficient capacity are explicit; no implicit heap; standard vectors and boundary cases pass |
| STD-1a | done (branch implementation; RFC Proposed) | endian u16/u32/u64 and qualified standard enum results | STD-0 | recoverable short-input/output failure, no partial mutation; all short lengths, empty/maximal values, fixtures and rejected alias examples pass |
| STD-1b | todo | bounded copy/split/search, checked arithmetic API decisions | STD-1a | contracts define capacity/overflow failure, no partial mutation, empty inputs and aliasing; independent fixtures pass |
| STD-2 | todo | UTF-8 validation/iteration, hex/base64 and formatting into supplied buffers | STD-1a/1b | malformed text and insufficient capacity are explicit; no implicit heap; standard vectors and boundary cases pass |
| STD-3 | todo | general modules and imported type names (P6-3) | STD-0 | deterministic resolution, collisions/cycles and diagnostics specified and covered |
| STD-4 | todo | source generics (P6-4), constraints and option/result | STD-3 | deterministic specialization and rejected constraint examples; source/AIR budgets measured |
| STD-5 | todo | independent `linear_aggregates` RFC and vertical implementation phase | STD-3/4 for its source surface | spec → AIR → verifier → interpreter → source/lowering → Quick Reference → AIR/source tests; linear elements consumed on every path |
| STD-6 | todo | buffer, Vec, Deque, HashMap, HashSet, BinaryHeap | STD-4/5 | allocate/grow/remove/free contracts, allocation failure leaves documented state, linear elements survive moves and are consumed; no hidden destruction |
| STD-7 | todo | concrete I/O adapters, buffered I/O and lexical paths | STD-1/2; STD-3 for public types | short reads, EOF, capacity and write failures covered; paths never grant filesystem authority |
| STD-7 | todo | concrete I/O adapters, buffered I/O and lexical paths | STD-1b/2; 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 |
| STD-10 | todo | IPv4/IPv6/TCP/DNS contracts and runtime gaps; task/channel helpers | STD-9 | bounded service fixtures, deterministic scheduling and schedule stress pass |
@@ -76,3 +77,9 @@ Required: `zig build`, `zig build test`, `zig build conformance`, `zig fmt --che
The bootstrap does not add ownership or concurrency semantics. Preserved invariant: shared slices only read, exclusive slices only write, no borrow escapes or resource is consumed. Existing borrow/bounds transfer functions and interpreter rules apply; valid and rejected source fixtures exercise that boundary. Existing `E7001`, `E7002`, `E7005`, `E7006`, `E2101`, `T0002` suffice. AIR format 0 remains unchanged and existing programs without imports lower identically.
Bootstrap result: nine APIs implemented; full conformance, unit/Quick Reference, formatting and source coverage checks pass. Hosted file/stdin/TCP smoke tests and evaluation harness self-tests pass (22 tests; one environment-dependent skip). The documented example returns 42 with no grants; invalid clamp bounds report `std/math.aji:20`. RFC 0016 remains Proposed for owner review. Token growth (cl100k): Quick Reference +4.8%; source bundle excluding AIR +6.6%; AIR unchanged.
## STD-1a verification
Twelve additional endian functions and four ordinary Copy enums lower to existing AIR. The invariant remains: no access outside the supplied slice, no escaping borrow, no hidden allocation, and no mutation on insufficient output capacity. The capacity branch precedes every access. Existing verifier/interpreter rules and diagnostics apply; valid/rejected source examples and hand-written AIR fixtures exercise payload typing and read behavior. AIR format 0 is unchanged. Qualified standard enum names implement only a closed-registry subset of STD-3; user modules, imported struct literals, dependencies and generics remain open.
Run the same required checks as bootstrap. Endian fixtures include independent LE/BE byte vectors, every short length, zero/maximal values, every bit, nonzero offsets, extra input/output bytes, returned enum records, compound types, name collisions, exhaustive matches and forbidden mutable aliasing. RFC 0017 records final checks and complexity measurements.