diff --git a/docs/reference/capabilities.md b/docs/reference/capabilities.md index 1462a6f..a5435dc 100644 --- a/docs/reference/capabilities.md +++ b/docs/reference/capabilities.md @@ -40,4 +40,4 @@ Variant sets of published built-in enums are frozen (spec 07 §8.7). ## Instantiation -`aji run --grant =[:]` binds one `@main` capability parameter. Every parameter needs exactly one grant of its kind and every grant must name a parameter (spec 05 §10.2). Scopes: path prefixes are absolute and contain no `.` or `..` components; byte budgets are decimal integers. +`aji run --grant =[:]` binds one `@main` capability parameter. With `aji run --manifest aji.toml`, the manifest's `[capabilities]` entries (`parameter = "kind[:scope]"`) are the grants, each replaced by a `--grant` for the same parameter (spec 12 §1). Every parameter needs exactly one grant of its kind and every grant must name a parameter (spec 05 §10.2). Scopes: path prefixes are absolute and contain no `.` or `..` components; byte budgets are decimal integers. diff --git a/docs/rfcs/0010-manifest-capability-grants.md b/docs/rfcs/0010-manifest-capability-grants.md index 7c89ac9..21719af 100644 --- a/docs/rfcs/0010-manifest-capability-grants.md +++ b/docs/rfcs/0010-manifest-capability-grants.md @@ -1,8 +1,9 @@ # RFC 0010: Capability Grants in `aji.toml` -Status: Proposed +Status: Accepted Scope: package manifest (spec 12), instantiation (spec 05 §10.2) Language version: 0.1 +Integrated into: spec 12 §1; spec 05 §10.2; `reference/capabilities.md` Supersedes: — ## Motivation diff --git a/docs/spec/05-effects-and-capabilities.md b/docs/spec/05-effects-and-capabilities.md index dfc3a80..4f94f56 100644 --- a/docs/spec/05-effects-and-capabilities.md +++ b/docs/spec/05-effects-and-capabilities.md @@ -192,7 +192,7 @@ effects [fs.read, io.write] aji run app.air --grant config=fs.read:/etc/app --grant data=fs.read:/var/data ``` - For packages the same bindings come from `aji.toml` `[capabilities]` (spec 12). + For packages the same bindings come from `aji.toml` `[capabilities]`, applied only when the operator runs `aji run --manifest`; a command-line `--grant` for the same parameter replaces the manifest entry (spec 12 §1). - Before execution the host **instantiates** the program: every capability parameter of `@main` must have exactly one grant whose kind matches, and every grant must name a parameter. Otherwise the program does not start. This is an **environment outcome**, not a trap and not a verifier error; `aji run` exits with code 6 and reports, for the first problem in parameter order: ```json diff --git a/docs/spec/12-packages-and-build.md b/docs/spec/12-packages-and-build.md index dc0273f..4f608cc 100644 --- a/docs/spec/12-packages-and-build.md +++ b/docs/spec/12-packages-and-build.md @@ -2,24 +2,50 @@ ## 1. Manifest -A package contains an `aji.toml` manifest. +A package contains an `aji.toml` manifest. Decision record for capability grants: RFC 0010. -Illustrative manifest: +1. **A manifest requests; the operator grants.** The author of a package writes `[capabilities]`. Authority is granted only when someone explicitly runs the program with that manifest (`aji run --manifest`). Building, verifying or installing never grants anything (spec 05 §6). +2. **Same model as `--grant`.** One entry per `@main` capability parameter: `parameter = "kind[:scope]"`. All instantiation rules apply unchanged (missing, mismatched, unknown, invalid scope; mandatory `mem.alloc` budget in the deterministic profile). +3. **The operator has the last word.** A command-line `--grant P=…` replaces the manifest entry for `P`, for example to point a scope at another directory. It never silently adds parameters: an unknown parameter is still `unknown_parameter`. +4. **Strict parsing.** Unknown sections, unknown keys and duplicate keys are errors, so a typo cannot silently drop or misplace authority. + +### 1.1 Format ```toml [package] -name = "aji-log" +name = "file-copy" version = "0.1.0" - -[target] -os = "linux" -arch = "x86_64" +entry = "src/main.air" # path relative to the manifest [capabilities] -filesystem = ["read", "write"] -network = false +src = "fs.read:/var/data" +dst = "fs.write:/var/out" +heap = "mem.alloc:67108864" +out = "io.write" + +[metadata] # optional, free-form strings; no semantics +purpose = "example" ``` +- `[package]`: `name` and `version` (strings) are required; `entry` (string) is required for `aji run --manifest`. +- `[capabilities]`: keys are `@main` parameter names; values are strings `kind[:scope]` exactly as for `--grant`. +- `[metadata]`: optional table of string values for documentation. +- The accepted syntax is a TOML subset: comments with `#`, `[section]` headers, `key = "string"`. Strings use `"` with the escapes `\"`, `\\`, `\n`. Anything else is a manifest error. + +Further sections (targets, dependencies, build extensions) are added by later phases; until then they are unknown sections and therefore errors. + +### 1.2 Running from a manifest + +```text +aji run --manifest aji.toml [--grant P=KIND[:SCOPE]]... [other run options] +``` + +- The module is the manifest's `entry`; a file argument is not allowed together with `--manifest`. +- Grants are the manifest's `[capabilities]` entries, each replaced by a `--grant` for the same parameter if given. +- `aji check` and `aji report` do not read manifests. + +Manifest errors (unreadable file, syntax, unknown section or key, duplicate key, missing `name`/`version`/`entry`, malformed grant string) are reported before verification as a usage error (exit code 2) with a message naming the line. Structured manifest diagnostics belong to the package tooling of Phase 8. + ## 2. Reproducibility Given the same: