19 lines
2.7 KiB
Markdown
19 lines
2.7 KiB
Markdown
# Executable Aji examples
|
|
|
|
These examples use the implemented `.aji` syntax. Build with `zig build`, then run from the repository root. Each command supplies a deterministic fuel budget and the capabilities its program requests.
|
|
|
|
| Example | Demonstrates | Command |
|
|
|---|---|---|
|
|
| [hello.aji](hello.aji) | Explicit stdout authority | `zig-out/bin/aji run --fuel 100000 --grant stdout=io.write examples/hello.aji` |
|
|
| [file_copy.aji](file_copy.aji) | Borrowed files and explicit close | `zig-out/bin/aji run --fuel 100000 --grant fs_read=fs.read:/in --grant fs_write=fs.write:/out --vfs '/in/data.txt=some text' examples/file_copy.aji` |
|
|
| [parallel_map.aji](parallel_map.aji) | Disjoint mutable loans to two scoped tasks; returns 204 | `zig-out/bin/aji run --fuel 100000 examples/parallel_map.aji` |
|
|
| [channel_transfer.aji](channel_transfer.aji) | Move an Island through a bounded channel; returns 42 | `zig-out/bin/aji run --fuel 100000 --grant heap=mem.alloc:256 examples/channel_transfer.aji` |
|
|
| [atomic_publish.aji](atomic_publish.aji) | Explicit release/acquire publication, including a read before join; returns 42 | `zig-out/bin/aji run --fuel 100000 examples/atomic_publish.aji` |
|
|
| [append_log.aji](append_log.aji) | Bounded records, checked offsets and recoverable I/O; returns 19 | `zig-out/bin/aji run --fuel 100000 --grant fs_write=fs.write:/out examples/append_log.aji` |
|
|
|
|
The journal example creates a new file, replacing previous contents. Its wire format is a 16-byte little-endian header (u32 payload length, u32 payload-only CRC32C, u64 byte offset), followed by the payload. A failed write poisons the Log and blocks further appends; closing the file remains explicit. Header integrity, atomic durable records and recovery are outside this demonstration. The 16 MiB limit is an explicit guard; source `requires`/`ensures` support remains P6-6.
|
|
|
|
[modules/](modules/aji.toml) demonstrates explicit module inputs: `zig-out/bin/aji run --fuel 100000 --manifest examples/modules/aji.toml`. [packages/hello/](packages/hello/aji.toml) runs a source entry with manifest grants: `zig-out/bin/aji run --fuel 100000 --manifest examples/packages/hello/aji.toml`. Its retained `main.air` is an execution counterpart, rather than the package entry.
|
|
|
|
[std/](std/) contains eighteen examples for the compiler-pinned standard modules. `python3 tests/hosted/examples.py --stress 200` checks and runs every standalone example and both packages, verifies journal bytes independently, injects a partial host write, and compares concurrent source/AIR runs over schedule seeds. The five larger [reference programs](../tests/conformance/source/programs/) run with their AIR counterparts through `zig build conformance -- --filter source/programs --stress 200`.
|