spec: accept RFC 0007 and integrate I/O and linear resources

- spec 06 §6-§7: feature resources, consumption and verifier rules,
  io_error
- spec 05 §11.1 fallible intrinsic form; spec 07 §8.7 frozen built-in
  enum variants, §8.9 resource types; spec 07a resources and run record
  fields; spec 11 §8 execution profiles, blocked outcome, result channel
- reference/intrinsics.md: formal catalogue; capabilities.md: io_error
  and fs prefix narrowing
- features: resources published, linear_aggregates reserved
This commit is contained in:
dev committed 2026-10-04 13:52:26 +03:00
1 parent c7bcea294e
commit 571cc6e362
9 files changed
+199 -83

No files matched your search

+2
View File
@@ -38,8 +38,10 @@ Declaring `features [capabilities, effects, ownership]` grants no authority. It
| `effects` | published | 2 | — | flat effect checking of `effects [...]` for `call` and `intrinsic` (E3101, spec 05 §9) | | `effects` | published | 2 | — | flat effect checking of `effects [...]` for `call` and `intrinsic` (E3101, spec 05 §9) |
| `heap` | reserved | 2 | `capabilities`, `effects`, `ownership` | `Own<T>`, `own.alloc`, `own.free`, move-only values | | `heap` | reserved | 2 | `capabilities`, `effects`, `ownership` | `Own<T>`, `own.alloc`, `own.free`, move-only values |
| `islands` | reserved | 4 | `capabilities`, `effects`, `ownership`, `regions` | `Island<T>`, `iref<T>`, transfer, freeze, `Frozen<T>` | | `islands` | reserved | 4 | `capabilities`, `effects`, `ownership`, `regions` | `Island<T>`, `iref<T>`, transfer, freeze, `Frozen<T>` |
| `linear_aggregates` | reserved | — | `capabilities`, `effects`, `ownership`, `resources` | resource types as struct fields, enum payloads and array elements; unscheduled |
| `ownership` | published | 1 | — | frame storage `local<T>`, second-class borrows `ref<T>`/`mut<T>`, `from` returns, initialization (spec 07 §8.8, spec 07a, spec 08 §11, §13) | | `ownership` | published | 1 | — | frame storage `local<T>`, second-class borrows `ref<T>`/`mut<T>`, `from` returns, initialization (spec 07 §8.8, spec 07a, spec 08 §11, §13) |
| `regions` | reserved | 2 | `capabilities`, `effects`, `ownership` | `Region`, static generations, region allocation, reset and destroy | | `regions` | reserved | 2 | `capabilities`, `effects`, `ownership` | `Region`, static generations, region allocation, reset and destroy |
| `resources` | published | 2 | `capabilities`, `effects`, `ownership` | linear resources `file<read>`, `file<write>`, `file<append>`, `listener`, `stream`; built-in `io_error`; I/O intrinsics (spec 06 §6–§7, `reference/intrinsics.md`) |
| `sync` | reserved | 3 | `ownership` | `Mutex<T>`, `RwLock<T>`, linear guards | | `sync` | reserved | 3 | `ownership` | `Mutex<T>`, `RwLock<T>`, linear guards |
| `tasks` | reserved | 3 | `ownership` | structured task scopes, spawn/join/cancel, `Send`/`Share` | | `tasks` | reserved | 3 | `ownership` | structured task scopes, spawn/join/cancel, `Send`/`Share` |
+11 -2
View File
@@ -5,8 +5,8 @@ Normative registry of capability kinds for AIR format 0 (spec 05 §10). A kind n
| Kind | Authorizes effects | Scope at instantiation | Narrowing forms | | Kind | Authorizes effects | Scope at instantiation | Narrowing forms |
|---|---|---|---| |---|---|---|---|
| `clock.read` | `clock.read` | none | — | | `clock.read` | `clock.read` | none | — |
| `fs.read` | `fs.read` | absolute path prefix | `prefix` (RFC 0007) | | `fs.read` | `fs.read` | absolute path prefix | `prefix` |
| `fs.write` | `fs.write` | absolute path prefix | `prefix` (RFC 0007) | | `fs.write` | `fs.write` | absolute path prefix | `prefix` |
| `io.read` | `io.read` | none | — | | `io.read` | `io.read` | none | — |
| `io.write` | `io.write` | none | — | | `io.write` | `io.write` | none | — |
| `mem.alloc` | `mem.alloc` | byte budget | `budget` (RFC 0008) | | `mem.alloc` | `mem.alloc` | byte budget | `budget` (RFC 0008) |
@@ -26,6 +26,15 @@ Narrowing forms marked with an RFC are registered when that RFC is accepted; unt
| Enum | Variants | | Enum | Variants |
|---|---| |---|---|
| `cap_error` | `invalid_restriction`, `not_subset`, `unsupported_restriction` | | `cap_error` | `invalid_restriction`, `not_subset`, `unsupported_restriction` |
| `io_error` | `not_found`, `permission_denied`, `already_exists`, `invalid_input`, `no_space`, `broken_pipe`, `connection_refused`, `connection_reset`, `address_in_use`, `address_unavailable`, `timed_out`, `other` |
Variant sets of published built-in enums are frozen (spec 07 §8.7).
## Narrowing forms
| Kind | Form | Argument | `ok` | `err` (`cap_error`) |
|---|---|---|---|---|
| `fs.read`, `fs.write` | `prefix` | `path: slice<u8>`, absolute, no empty/`.`/`..` components | same kind scoped to `path` | `invalid_restriction` if malformed; `not_subset` if not inside the current scope |
## Instantiation ## Instantiation
+51 -76
View File
@@ -1,93 +1,68 @@
# Intrinsic Registry (Draft) # Intrinsic Registry
Intrinsics are verifier-known platform/runtime operations. Each intrinsic requires a formal signature, effects, capabilities, ownership behavior and failure model. Normative catalogue of intrinsics for AIR format 0 (spec 05 §11). Each entry fixes operand types, results, effect, capability, consumption and failure model; behavior per profile is in spec 11 §8. Using an intrinsic needs the feature `capabilities`; intrinsics that mention resource types also need `resources`.
## Filesystem Notation: `c` capability operand, `b` borrowed resource operand. Fallible intrinsics are terminators: results are the parameters of `@ok`, and `@err` receives one `io_error` (spec 06 §7).
```text `c` = capability operand, `b` = borrowed resource operand, results are `@ok` parameters.
fs.open_read
fs.open_write
fs.read
fs.write
fs.write_all
fs.sync
fs.close
```
## Console / generic I/O ### Console (`io.*`)
```text | Intrinsic | Operands | `@ok` | Effect |
io.stdout_write |---|---|---|---|
io.stderr_write | `io.stdout_write` | `c: cap<io.write>`, `bytes: slice<u8>` | — | `io.write` |
``` | `io.stderr_write` | `c: cap<io.write>`, `bytes: slice<u8>` | — | `io.write` |
| `io.stdin_read` | `c: cap<io.read>`, `buf: slice_mut<u8>` | `n: usize` (0 = end of input) | `io.read` |
## Network Writes are all-or-error: on `@ok` every byte was written.
```text ### Files (`fs.*`)
net.socket
net.bind
net.listen
net.accept
net.connect
net.recv
net.send
net.close
```
## Time/random Paths are `slice<u8>` holding an absolute path whose components are not empty, `.` or `..` (otherwise `invalid_input`). A path outside the capability's scope is `permission_denied`.
```text | Intrinsic | Operands | `@ok` | Effect |
clock.monotonic |---|---|---|---|
clock.wall | `fs.open_read` | `c: cap<fs.read>`, `path` | `f: file<read>` | `fs.read` |
random.fill | `fs.create` | `c: cap<fs.write>`, `path` | `f: file<write>` (truncated or new) | `fs.write` |
``` | `fs.open_append` | `c: cap<fs.write>`, `path` | `f: file<append>` (created if missing) | `fs.write` |
| `fs.read` | `b: mut<file<read>>`, `buf: slice_mut<u8>` | `n: usize` (0 = end of file) | `fs.read` |
| `fs.write_all` | `b: mut<file<write>>` or `mut<file<append>>`, `bytes: slice<u8>` | — | `fs.write` |
| `fs.sync` | `b: mut<file<write>>` or `mut<file<append>>` | — | `fs.write` |
| `fs.close` | `f: file<M>` for any mode (consumed on both edges) | — | — |
## Task/thread An error from `fs.close` reports a failed final flush; the file is closed either way.
```text ### TCP (`net.*`)
task.spawn
task.join
task.cancel
thread.spawn
thread.join
```
## Synchronization Addresses are `slice<u8>` text `host:port` with a numeric IPv4 host (format 0).
```text | Intrinsic | Operands | `@ok` | Effect |
mutex.create |---|---|---|---|
mutex.lock | `net.listen` | `c: cap<net.listen>`, `addr` | `l: listener` | `net.listen` |
mutex.unlock | `net.accept` | `b: mut<listener>` | `s: stream` | `net.listen` |
rwlock.create | `net.connect` | `c: cap<net.connect>`, `addr` | `s: stream` | `net.connect` |
rwlock.read | `net.recv` | `b: mut<stream>`, `buf: slice_mut<u8>` | `n: usize` (0 = peer closed) | `net.read` |
rwlock.write | `net.send_all` | `b: mut<stream>`, `bytes: slice<u8>` | — | `net.write` |
channel.create | `net.close_stream` | `s: stream` (consumed) | — | — |
channel.send | `net.close_listener` | `l: listener` (consumed) | — | — |
channel.recv
```
## Atomics All network operations block the calling execution unit (Phase 3 adds `thread.block` handling and task-aware I/O).
```text ### Clock and random (infallible)
atomic.load
atomic.store
atomic.exchange
atomic.fetch_add
atomic.fetch_sub
atomic.compare_exchange
atomic.fence
```
## Memory | Intrinsic | Operands | Result | Effect |
|---|---|---|---|
| `clock.monotonic` | `c: cap<clock.read>` | `u64` nanoseconds | `clock.read` |
| `random.fill` | `c: cap<random.read>`, `buf: slice_mut<u8>` | — | `random.read` |
```text ### Narrowing forms
heap.alloc
heap.free | Kind | Form | Argument | Result |
region.create |---|---|---|---|
region.alloc | `fs.read`, `fs.write` | `prefix` | `path: slice<u8>`, absolute | `ok`: same kind scoped to `path`; `err`: `invalid_restriction` if `path` is malformed, `not_subset` if it is not inside the current scope |
region.reset
region.destroy ## Registry rules
island.create
island.alloc - An unknown name is `E0004`; operands of the wrong type `E1001`; a capability of the wrong kind `E3201`; an effect missing from the caller `E3101`.
island.freeze - Using the fallible form for an infallible intrinsic, or the reverse, is `E1001`; wrong `@ok`/`@err` parameter counts are `E5002`.
``` - Resource operands marked "consumed" are consumed on both edges.
+2 -1
View File
@@ -1,8 +1,9 @@
# RFC 0007: I/O Intrinsics, I/O Errors and Linear Resources # RFC 0007: I/O Intrinsics, I/O Errors and Linear Resources
Status: Proposed (revision 2: owner review applied) Status: Accepted (revision 2, after owner review)
Scope: AIR format 0, feature `resources`; intrinsic and narrowing registries of `capabilities` Scope: AIR format 0, feature `resources`; intrinsic and narrowing registries of `capabilities`
Language version: 0.1 Language version: 0.1
Integrated into: spec 05 §11.1; spec 06 §6–§7; spec 07 §8.7, §8.9; spec 07a; spec 11 §7–§8; `reference/intrinsics.md`, `reference/capabilities.md`, `reference/air-features.md`
Supersedes: — Supersedes: —
Builds on RFC 0005 (borrows) and RFC 0006 (effects, capabilities). Heap allocation and regions follow in RFC 0008 and reuse the linearity rules defined here. Builds on RFC 0005 (borrows) and RFC 0006 (effects, capabilities). Heap allocation and regions follow in RFC 0008 and reuse the linearity rules defined here.
+13
View File
@@ -250,6 +250,19 @@ An effectful operation takes its capability as an explicit operand (§11). If th
This RFC registers no I/O intrinsic yet. RFC 0007 adds the catalogue (console, files, sockets, clock, random) together with the error representation. This RFC registers no I/O intrinsic yet. RFC 0007 adds the catalogue (console, files, sockets, clock, random) together with the error representation.
### 11.1 Fallible intrinsics
Two forms extend RFC 0006 §3:
```text
[%r =] intrinsic <name>(%a…) ; infallible
intrinsic <name>(%a…), ok -> @ok, err -> @err ; fallible: a terminator
```
A fallible intrinsic delivers its results as the parameters of `@ok` (count and types per registry; `E5002`/`E1001`) and a single `io_error` to `@err`. The registry says which form each intrinsic has; using the other form is `E1001`. Resource operands consumed by an intrinsic are consumed on both edges.
The catalogue of intrinsics is [`../reference/intrinsics.md`](../reference/intrinsics.md).
## 12. Runtime ## 12. Runtime
- A capability is represented as an index into a host-owned table of (kind, scope) entries. The index is not observable by the program. - A capability is represented as an index into a host-owned table of (kind, scope) entries. The index is not observable by the program.
+79
View File
@@ -58,3 +58,82 @@ Propagation syntax may exist only if its lowering is explicit and does not intro
Use `Result` for failures callers may reasonably handle. Use `Result` for failures callers may reasonably handle.
Use trap for invariant violations, failed assertions and explicitly trapping primitives. Use trap for invariant violations, failed assertions and explicitly trapping primitives.
## 6. Resources in AIR (feature `resources`)
Decision record: RFC 0007.
Invariants:
1. **Linearity.** A resource value (`file`, `listener`, `stream`) is consumed exactly once on every normal path: by a closing intrinsic, by passing it to a by-value resource parameter or block parameter, or by returning it. It is never used after consumption and never silently dropped.
2. **No implicit release.** No resource is closed by scope exit, by a trap path being taken, or by any hidden action. Paths ending in `trap` end the program; the runtime then releases host resources as part of terminating the execution instance, which is not observable by the program.
3. **Explicit failure.** Every operation that can fail for external reasons delivers either its results or an `io_error` to block parameters. Failure is never a trap and never an exception.
4. **Object capabilities.** An open resource carries the authority it was opened with; operations on it need its effect but no further capability operand. Opening a resource requires a capability.
5. **Determinism.** In the `deterministic` profile every intrinsic has a fully specified result; the same module, grants, inputs and fuel produce the same run record. Profiles never invent results the program did not ask for: a run that can make no further progress ends with the environment outcome `blocked`, not with an I/O error.
Depends on `capabilities`, `effects`, `ownership`.
### 6.1 Types
| Type | Meaning | Accounted size |
|---|---|---|
| `file<read>` | file opened for reading | 8 |
| `file<write>` | file opened for writing (created or truncated) | 8 |
| `file<append>` | file opened for appending | 8 |
| `listener` | listening TCP socket | 8 |
| `stream` | connected TCP stream | 8 |
The mode of a file is part of its type, so using a file in the wrong mode is a verifier error, not a runtime failure: `fs.read` takes `mut<file<read>>`; `fs.write_all` and `fs.sync` take `mut<file<write>>` or `mut<file<append>>`.
Resource types are **linear** and **authority-bearing** (spec 05 §10.1): not copyable (`copy` is `E1001`), not zeroable, not comparable, not serializable.
In format 0, resource types MUST NOT appear as struct fields, enum payloads or array elements; that requires the reserved feature `linear_aggregates` (`E0006` reason `feature_not_declared` without it). They may appear as function parameters, return types, block parameters and as operands of borrow instructions.
### 6.2 Consumption
A resource value is **consumed** by exactly one of:
- a closing intrinsic (`fs.close`, `net.close_stream`, `net.close_listener`). A closing intrinsic consumes the resource **regardless of its result**: on both the `ok` and the `err` edge the resource is dead, and closing it again is `E2002`. After a failed close the state of the underlying host handle is unspecified, so no retry is possible;
- being a `call` argument for a parameter of resource type (ownership moves to the callee);
- being a branch argument (`br`, `cbr`, `switch`, default targets) for a block parameter of resource type;
- `ret`.
Every other operand use of a resource is a **non-consuming use**, which is only permitted through borrows: `borrow.ref %f` / `borrow.mut %f` take a resource SSA value as their root, exactly as for a `local` (RFC 0005), and produce `ref<file>` / `mut<file>`.
### 6.3 Verifier rules
The resource state of each resource value — `owned`, `consumed by close`, `consumed by transfer` — is tracked on every reachable path with the same discipline as borrows (spec 08 §11.4):
| Rule | Code |
|---|---|
| owned resource live at `ret` (other than the returned one) | `E3002` (`resource.leak`) |
| resource state differs between edges into a block | `E3002` |
| resource consumed again after any consumption | `E2002` (`ownership.double_consume`) |
| non-consuming use after consumption by a closing intrinsic | `E3001` (`resource.use_after_consume`) |
| non-consuming use after consumption by transfer | `E2001` (`ownership.use_after_move`) |
| resource consumed while a borrow of it is live | `E2101` |
Resource parameters of the current function are owned by it (they were moved in). Resource block parameters own their argument.
## 7. I/O errors
`io_error` is a built-in enum (spelled without `@`, used with `enum.switch io_error %e, …`):
| Variant | Meaning |
|---|---|
| `not_found` | path or address does not exist |
| `permission_denied` | the host refused, or the path is outside the capability's scope |
| `already_exists` | exclusive creation of an existing path |
| `invalid_input` | malformed path or address (relative path, `.`/`..` component, unparsable address) |
| `no_space` | storage exhausted |
| `broken_pipe` | the peer closed while writing |
| `connection_refused` | nobody listens at the address |
| `connection_reset` | the peer reset the connection |
| `address_in_use` | listen address taken |
| `address_unavailable` | listen or connect address not available to this host |
| `timed_out` | an explicit timeout expired (reserved for timers in Phase 3; no Phase 2 operation produces it) |
| `other` | any host error not listed above |
The mapping from host errors to variants is part of each profile's specification; `other` keeps the set closed. Host error numbers are not part of AIR semantics: a runtime may attach them as diagnostic metadata outside the run record's values, never in a way the program can observe.
**Frozen variant sets.** The variants of a published built-in enum never change: adding one would make an existing exhaustive `enum.switch` without `default` non-exhaustive, turning an accepted module into a rejected one (spec 07 §8.7). This is why `timed_out` is reserved now although nothing produces it yet.
+4 -2
View File
@@ -250,13 +250,15 @@ A change is permitted under `air 0` only if all of the following hold:
3. the change adds instructions, types, diagnostic codes or trap codes; every added construct belongs to a feature registered in [`../reference/air-features.md`](../reference/air-features.md), and the feature's semantics are specified (spec 07a and the relevant spec files) before the feature is published and implemented; 3. the change adds instructions, types, diagnostic codes or trap codes; every added construct belongs to a feature registered in [`../reference/air-features.md`](../reference/air-features.md), and the feature's semantics are specified (spec 07a and the relevant spec files) before the feature is published and implemented;
4. the canonical form (§8.5) of existing constructs is unchanged. 4. the canonical form (§8.5) of existing constructs is unchanged.
A published feature's semantics are immutable. Extending a feature with new semantics is not permitted; register a new feature instead. A published feature's semantics are immutable. In particular the variant set of a published built-in enum never changes, since a new variant would make existing exhaustive `enum.switch` instructions non-exhaustive. Extending a feature with new semantics is not permitted; register a new feature instead.
Any other change to format 0 — a different meaning, typing rule, trap behavior, diagnostic code or canonical spelling for an existing construct — requires a new format version (`air 1`) introduced by an RFC. An implementation that supports several format versions selects the semantics by the module's `air` line; it never mixes them. Any other change to format 0 — a different meaning, typing rule, trap behavior, diagnostic code or canonical spelling for an existing construct — requires a new format version (`air 1`) introduced by an RFC. An implementation that supports several format versions selects the semantics by the module's `air` line; it never mixes them.
### 8.9 Types of the features `effects` and `capabilities` ### 8.9 Types of the features `effects` and `capabilities`
`cap<K>` (feature `capabilities`) is an opaque, copyable, authority-bearing value type; `K` is a registered capability kind ([`../reference/capabilities.md`](../reference/capabilities.md)). Built-in enums such as `cap_error` are spelled without `@`, have registered variants and are used with `enum.switch <builtin> %v, …` like declared enums. Rules: spec 05 §9–§12. `cap<K>` (feature `capabilities`) is an opaque, copyable, authority-bearing value type; `K` is a registered capability kind ([`../reference/capabilities.md`](../reference/capabilities.md)). Built-in enums such as `cap_error` and `io_error` are spelled without `@`, have registered variants and are used with `enum.switch <builtin> %v, …` like declared enums. Rules: spec 05 §9–§12.
Feature `resources`: `file<read>`, `file<write>`, `file<append>`, `listener`, `stream` are linear, authority-bearing resource types (spec 06 §6).
### 8.8 Types and syntax of the features `ownership` and `arrays` ### 8.8 Types and syntax of the features `ownership` and `arrays`
+6 -2
View File
@@ -222,7 +222,11 @@ Rules: spec 05 §9–§12. Decision record: RFC 0006.
| `cap.narrow.<form> %c, %arg…, ok -> @ok, err -> @err` (terminator) | `cap<K>`, form arguments | form registered for `K` (`E3202`); `@ok` has one parameter `cap<K>`, `@err` one parameter `cap_error` (`E5002` count, `E1001` type) | continues at `@ok` with a narrower capability sharing nothing wider than `%c`, or at `@err` with the reason; never traps | | `cap.narrow.<form> %c, %arg…, ok -> @ok, err -> @err` (terminator) | `cap<K>`, form arguments | form registered for `K` (`E3202`); `@ok` has one parameter `cap<K>`, `@err` one parameter `cap_error` (`E5002` count, `E1001` type) | continues at `@ok` with a narrower capability sharing nothing wider than `%c`, or at `@err` with the reason; never traps |
| `[%r =] intrinsic <name>(%a…)` | per registry entry | operand types (`E1001`), capability kind (`E3201`), effect (`E3101`), borrows as for `call`; unknown name `E0004` | forwards to the host through the capability | | `[%r =] intrinsic <name>(%a…)` | per registry entry | operand types (`E1001`), capability kind (`E3201`), effect (`E3101`), borrows as for `call`; unknown name `E0004` | forwards to the host through the capability |
No intrinsic is registered yet (RFC 0007). Effect checking applies to `call` and `intrinsic` in modules that declare `effects` (spec 05 §9.3). Intrinsics have an infallible form (`[%r =] intrinsic …`) and a fallible terminator form (`intrinsic …, ok -> @ok, err -> @err`) (spec 05 §11.1). The catalogue is `reference/intrinsics.md`. Effect checking applies to `call` and `intrinsic` in modules that declare `effects` (spec 05 §9.3).
## Feature `resources`
Resource types and their consumption rules: spec 06 §6. Resources are used through `borrow.ref`/`borrow.mut` (which accept a resource value as root) and consumed by closing intrinsics, by-value resource parameters, resource block parameters and `ret`.
## Run result ## Run result
@@ -238,4 +242,4 @@ No intrinsic is registered yet (RFC 0007). Effect checking applies to `call` and
On a trap it reports `{"status":"trapped", "code":…, "kind":…, "function":…, "block":…, "inst":…}` (spec 01 §6). On a trap it reports `{"status":"trapped", "code":…, "kind":…, "function":…, "block":…, "inst":…}` (spec 01 §6).
When instantiation fails (spec 05 §10.2) the program does not start and the runner reports `{"status":"not_instantiated","reason":…,…}`. When the runner stops execution because an execution limit is exhausted (spec 11 §7), it reports `{"status":"limit_exceeded","kind":"fuel","limit":N,"steps":N}`. This is an outcome of the execution environment, not of the program, and is not a trap. Programs that declare `capabilities` also get `"stdout"` and `"stderr"` (captured output) and `"files"` (files written in the virtual file system) in the record of the `deterministic` profile (spec 11 §8). When the deterministic runtime detects quiescence it reports `{"status":"blocked","kind":"no_future_event",…}` (spec 11 §8). When instantiation fails (spec 05 §10.2) the program does not start and the runner reports `{"status":"not_instantiated","reason":…,…}`. When the runner stops execution because an execution limit is exhausted (spec 11 §7), it reports `{"status":"limit_exceeded","kind":"fuel","limit":N,"steps":N}`. This is an outcome of the execution environment, not of the program, and is not a trap.
+31
View File
@@ -87,6 +87,7 @@ not_instantiated the environment did not start the program (spec 05 §10.2)
returned the program finished returned the program finished
trapped the program failed (T0xxx) trapped the program failed (T0xxx)
limit_exceeded the environment stopped the program limit_exceeded the environment stopped the program
blocked the program can make no further progress (§8)
``` ```
Running without a fuel limit is permitted (for example `aji run program.air`). Conformance, fuzz and stress runs MUST use a fuel limit. Running without a fuel limit is permitted (for example `aji run program.air`). Conformance, fuzz and stress runs MUST use a fuel limit.
@@ -100,3 +101,33 @@ With several tasks, fuel is global: the sum of instructions executed by all task
| fuel | how long the program may execute | | fuel | how long the program may execute |
| schedule budget | how many interleavings schedule exploration examines | | schedule budget | how many interleavings schedule exploration examines |
| quantum | how many instructions a task executes before a forced scheduling point | | quantum | how many instructions a task executes before a forced scheduling point |
## 8. Execution profiles
Decision record: RFC 0007.
The run record gains fields for observable output. `aji run` uses the **deterministic** profile by default; `--profile hosted` uses the real host.
| Aspect | `deterministic` | `hosted` |
|---|---|---|
| stdout / stderr | captured; reported as `"stdout"` / `"stderr"` strings in the run record, which is printed on stdout | the process's real streams; the run record is written to a separate result channel (below) |
| stdin | from `--stdin TEXT` (empty by default) | real stdin |
| files | in-memory file system seeded by `--vfs PATH=TEXT`; files written during the run are reported as `"files"` in the run record | real file system, limited by capability scopes |
| network | in-process loopback: `net.connect` to a listening address of the same run queues a connection that `net.accept` returns; sends are buffered; an operation that would wait for an event that can never occur ends the run with the environment outcome `blocked` (below) | real sockets |
| clock | the number of instructions executed so far (1 ns per instruction) | real monotonic clock |
| random | PRNG seeded by `--seed N` (default 0), algorithm fixed by the spec | host CSPRNG |
**Quiescence.** In the `deterministic` profile, when an operation would wait, no other execution unit can run, and no future deterministic event can complete the wait, the run ends with the environment outcome
```json
{"status":"blocked","kind":"no_future_event","function":"…","block":"…","inst":0}
```
and `aji run` exits with code 7. This is not an `io_error` and not a trap: the program did not ask for a timeout, so none is invented. In the `hosted` profile the same operation simply blocks. A program that needs a timeout states it explicitly (timers and `select`, Phase 3). The outcomes are now:
```text
program outcome: returned, trapped
environment outcome: not_instantiated, limit_exceeded, blocked
```
**Result channel.** In the `hosted` profile the program owns stdout and stderr, so the run record cannot share them unambiguously. The machine-readable record goes to a separate channel: `aji run --profile hosted --result-file PATH` (a `--result-fd N` form may follow; `ajid` has its own control channel). Without `--result-file` the CLI may print a human-readable summary on stderr after the program ends; that summary is not a machine interface.