spec: accept RFC 0006 and integrate effects and capabilities

- spec 05 §9-§12: flat effects, checking rule, capability model,
  instantiation by parameter name, lifetime, fallible narrowing,
  intrinsic calls, runtime
- spec 07 §8.9, 07a (cap.narrow, intrinsic, run result), 08 stage
  order, 11 not_instantiated outcome
- new reference/effects.md and reference/capabilities.md (kinds,
  scopes, built-in cap_error)
- features effects and capabilities published
- Q-011, Q-012 resolved
This commit is contained in:
dev committed 2026-10-04 13:36:46 +03:00
1 parent 3fd1513c86
commit fb4338cea6
10 files changed
+245 -13

No files matched your search

+13 -2
View File
@@ -213,9 +213,20 @@ New trap code: `T0008 trap.out_of_bounds`.
- The interpreter represents a borrow as (storage, path) and a slice as (storage, path, offset, length). It performs no alias or liveness checks at runtime: the verifier guarantees them. Bounds checks run exactly where §4 says.
- Behavior is deterministic; storage addresses are never observable.
## Feature `effects` and feature `capabilities`
Rules: spec 05 §9–§12. Decision record: RFC 0006.
| Instruction | Operands → result | Verifier | Runtime |
|---|---|---|---|
| `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 |
No intrinsic is registered yet (RFC 0007). Effect checking applies to `call` and `intrinsic` in modules that declare `effects` (spec 05 §9.3).
## Run result
`aji run` executes the function `@main`, which MUST take no parameters. On return it reports `{"status":"returned","value":V}` where `V` renders the returned value as JSON:
`aji run` executes the function `@main`, whose parameters MUST all be capabilities, bound by name at instantiation (spec 05 §10.2); without the `capabilities` feature it takes no parameters. On return it reports `{"status":"returned","value":V}` where `V` renders the returned value as JSON:
| Type | Rendering |
|---|---|
@@ -227,4 +238,4 @@ New trap code: `T0008 trap.out_of_bounds`.
On a trap it reports `{"status":"trapped", "code":…, "kind":…, "function":…, "block":…, "inst":…}` (spec 01 §6).
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.
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.