cli: add safe UTF-8 and supplied-buffer hex/base64 std modules
This commit is contained in:
42 files changed
+2807
-14
No files matched your search
@@ -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 branch implementation | compiler-pinned, closed registry; qualified enum types/constructors/patterns; no package lookup |
|
||||
| Built-in standard imports and enum types | STD-0/1a/2a branch implementation | compiler-pinned, closed registry; five modules; 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 |
|
||||
@@ -49,12 +49,13 @@ SQL/database clients, Redis/Kafka, ORMs, application authentication, gRPC/protob
|
||||
| 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-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 | done (branch implementation; RFC Proposed) | bounded copy/search, split composition and recoverable arithmetic for u64/usize | 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-2a | done (branch implementation; RFC Proposed) | UTF-8 next/validate and supplied-buffer hex/base64 | STD-1a/1b | malformed text and insufficient capacity are explicit, output unchanged on returned errors; independent vectors and boundary cases pass |
|
||||
| STD-2b | todo | formatting into supplied buffers | STD-2a | minimal explicit format contract, no implicit heap, capacity/empty/maximal scalar tests and caller example |
|
||||
| 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-1b/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/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 |
|
||||
| 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 |
|
||||
@@ -89,3 +90,9 @@ Run the same required checks as bootstrap. Endian fixtures include independent L
|
||||
Eight further pure functions reuse existing primitives: `std.bytes.copy` and `find_slice`, plus checked add/sub/mul for `u64` and `usize`. Copy reuses `WriteResult`; three additional ordinary Copy enums represent substring matches and arithmetic results. Wrapping remains an operator. Splitting composes a search with explicit caller-bounded slice operations; no borrowed aggregate, iterator, cursor, compiler/runtime change or hidden allocation is added.
|
||||
|
||||
The preserved invariant is shared-read/exclusive-write access only within the supplied slices, no escaping borrows and no mutation on short output. Existing verifier/call/alias/enum rules and interpreter behavior suffice. Valid/rejected source fixtures and hand-written AIR twins cover the contracts; current diagnostics and AIR format 0 are unchanged. Tests include all 81 input/output length pairs through eight, disjoint split borrows, overlapping and empty short-output aliases, 428 search cases, seven split cases and 320 independently computed arithmetic operand pairs exercised through both widths. The interpreter's numeric vectors use its default `air64`; library usize limits are computed with target-width wrapping subtraction. RFC 0018 records the final repository checks and complexity measurements. STD-2 can now start with UTF-8 and supplied-buffer encodings.
|
||||
|
||||
## STD-2a verification
|
||||
|
||||
Six functions and six ordinary result enums add UTF-8 next/validate and supplied-buffer hex/Base64 to the closed registry. UTF-8 returns a scalar plus consumed bytes; caller offsets carry iteration state. Hex accepts both ASCII letter cases and emits lowercase; Base64 accepts canonical padded standard text with zero unused bits. Decode validates all input before capacity/mutation, so malformed input wins over insufficient output and every returned error preserves the destination. Size guards avoid intermediate overflow.
|
||||
|
||||
All algorithms are safe source using existing verifier/runtime rules, fixed frame storage and explicit slice borrows. No borrow escapes, owner/resource is consumed, heap allocation is hidden, AIR meaning changes or authority is granted. Valid/rejected examples, stable existing diagnostics, deterministic interpreter tests and compatibility are specified in spec 16 §2.5–§2.7 and RFC 0019. The registry embeds three additional modules without a resolver or dependency extension. Tests cover independent Python scalar/byte vectors, UTF-8 boundaries/truncation/surrogates, all input byte values, canonical pad bits, every relevant capacity, late invalid bytes, output suffixes, disjoint same-allocation buffers, namespace collisions and hand-written AIR equivalence. Formatting remains STD-2b; this increment does not mark the original whole text/formatting task complete.
|
||||
Reference in new issue
Block a user