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:
1 parent
c7bcea294e
commit
571cc6e362
9 files changed
+199
-83
No files matched your search
@@ -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) |
|
||||
| `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>` |
|
||||
| `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) |
|
||||
| `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 |
|
||||
| `tasks` | reserved | 3 | `ownership` | structured task scopes, spawn/join/cancel, `Send`/`Share` |
|
||||
|
||||
|
||||
@@ -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 |
|
||||
|---|---|---|---|
|
||||
| `clock.read` | `clock.read` | none | — |
|
||||
| `fs.read` | `fs.read` | absolute path prefix | `prefix` (RFC 0007) |
|
||||
| `fs.write` | `fs.write` | absolute path prefix | `prefix` (RFC 0007) |
|
||||
| `fs.read` | `fs.read` | absolute path prefix | `prefix` |
|
||||
| `fs.write` | `fs.write` | absolute path prefix | `prefix` |
|
||||
| `io.read` | `io.read` | none | — |
|
||||
| `io.write` | `io.write` | none | — |
|
||||
| `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 |
|
||||
|---|---|
|
||||
| `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
|
||||
|
||||
|
||||
@@ -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
|
||||
fs.open_read
|
||||
fs.open_write
|
||||
fs.read
|
||||
fs.write
|
||||
fs.write_all
|
||||
fs.sync
|
||||
fs.close
|
||||
```
|
||||
`c` = capability operand, `b` = borrowed resource operand, results are `@ok` parameters.
|
||||
|
||||
## Console / generic I/O
|
||||
### Console (`io.*`)
|
||||
|
||||
```text
|
||||
io.stdout_write
|
||||
io.stderr_write
|
||||
```
|
||||
| Intrinsic | Operands | `@ok` | Effect |
|
||||
|---|---|---|---|
|
||||
| `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
|
||||
net.socket
|
||||
net.bind
|
||||
net.listen
|
||||
net.accept
|
||||
net.connect
|
||||
net.recv
|
||||
net.send
|
||||
net.close
|
||||
```
|
||||
### Files (`fs.*`)
|
||||
|
||||
## 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
|
||||
clock.monotonic
|
||||
clock.wall
|
||||
random.fill
|
||||
```
|
||||
| Intrinsic | Operands | `@ok` | Effect |
|
||||
|---|---|---|---|
|
||||
| `fs.open_read` | `c: cap<fs.read>`, `path` | `f: file<read>` | `fs.read` |
|
||||
| `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
|
||||
task.spawn
|
||||
task.join
|
||||
task.cancel
|
||||
thread.spawn
|
||||
thread.join
|
||||
```
|
||||
### TCP (`net.*`)
|
||||
|
||||
## Synchronization
|
||||
Addresses are `slice<u8>` text `host:port` with a numeric IPv4 host (format 0).
|
||||
|
||||
```text
|
||||
mutex.create
|
||||
mutex.lock
|
||||
mutex.unlock
|
||||
rwlock.create
|
||||
rwlock.read
|
||||
rwlock.write
|
||||
channel.create
|
||||
channel.send
|
||||
channel.recv
|
||||
```
|
||||
| Intrinsic | Operands | `@ok` | Effect |
|
||||
|---|---|---|---|
|
||||
| `net.listen` | `c: cap<net.listen>`, `addr` | `l: listener` | `net.listen` |
|
||||
| `net.accept` | `b: mut<listener>` | `s: stream` | `net.listen` |
|
||||
| `net.connect` | `c: cap<net.connect>`, `addr` | `s: stream` | `net.connect` |
|
||||
| `net.recv` | `b: mut<stream>`, `buf: slice_mut<u8>` | `n: usize` (0 = peer closed) | `net.read` |
|
||||
| `net.send_all` | `b: mut<stream>`, `bytes: slice<u8>` | — | `net.write` |
|
||||
| `net.close_stream` | `s: stream` (consumed) | — | — |
|
||||
| `net.close_listener` | `l: listener` (consumed) | — | — |
|
||||
|
||||
## Atomics
|
||||
All network operations block the calling execution unit (Phase 3 adds `thread.block` handling and task-aware I/O).
|
||||
|
||||
```text
|
||||
atomic.load
|
||||
atomic.store
|
||||
atomic.exchange
|
||||
atomic.fetch_add
|
||||
atomic.fetch_sub
|
||||
atomic.compare_exchange
|
||||
atomic.fence
|
||||
```
|
||||
### Clock and random (infallible)
|
||||
|
||||
## 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
|
||||
heap.alloc
|
||||
heap.free
|
||||
region.create
|
||||
region.alloc
|
||||
region.reset
|
||||
region.destroy
|
||||
island.create
|
||||
island.alloc
|
||||
island.freeze
|
||||
```
|
||||
### Narrowing forms
|
||||
|
||||
| Kind | Form | Argument | Result |
|
||||
|---|---|---|---|
|
||||
| `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 |
|
||||
|
||||
## Registry rules
|
||||
|
||||
- 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`.
|
||||
- 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.
|
||||
Reference in new issue
Block a user