rfc: 0010 capability grants in aji.toml (Proposed)
Manifest [capabilities] uses the --grant model (parameter = kind[:scope]); the manifest requests and the operator grants via aji run --manifest; command-line grants replace manifest entries per parameter; strict TOML subset.
This commit is contained in:
1 parent
b00bac5937
commit
27fa98f39d
1 file changed
+71
@@ -0,0 +1,71 @@
|
||||
# RFC 0010: Capability Grants in `aji.toml`
|
||||
|
||||
Status: Proposed
|
||||
Scope: package manifest (spec 12), instantiation (spec 05 §10.2)
|
||||
Language version: 0.1
|
||||
Supersedes: —
|
||||
|
||||
## Motivation
|
||||
|
||||
Spec 12 shows a `[capabilities]` section in `aji.toml`, but its illustrative form (`filesystem = ["read", "write"]`, `network = false`) predates RFC 0006: it grants by kind, cannot scope, and cannot give two parameters of the same kind different authority. Instantiation now binds grants by `@main` parameter name. The manifest should use the same model, so that a program's required authority is written down once, reviewed with the code, and reproduced exactly on every run.
|
||||
|
||||
## Principles
|
||||
|
||||
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.
|
||||
|
||||
## Format
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "file-copy"
|
||||
version = "0.1.0"
|
||||
entry = "src/main.air" # path relative to the manifest
|
||||
|
||||
[capabilities]
|
||||
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.
|
||||
|
||||
## Command line
|
||||
|
||||
```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.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Replaces the illustrative manifest of spec 12 §1. The repository's own `aji.toml` (the specification package) moves its `[metadata]` keys to string values and keeps no `[capabilities]`.
|
||||
|
||||
## Spec integration
|
||||
|
||||
On acceptance: spec 12 §1 (manifest format, strict parsing), spec 05 §10.2 (grants from a manifest, operator precedence), `reference/capabilities.md` (instantiation section).
|
||||
|
||||
## Alternatives considered
|
||||
|
||||
- **Manifest grants applied automatically** (whenever an `aji.toml` sits next to the module): installing or cloning would grant authority. Rejected.
|
||||
- **Grants by kind** (spec 12's illustration): cannot scope or distinguish parameters; superseded by RFC 0006.
|
||||
- **Command-line grants may only narrow manifest grants**: would need a general notion of "narrower" per kind and would stop an operator from relocating a scope; the operator already holds the authority. Rejected.
|
||||
- **A full TOML parser**: much larger than the needed subset and a source of ambiguity; the subset can grow later.
|
||||
|
||||
## Unresolved questions
|
||||
|
||||
- Whether the run record should name the source of each grant (manifest or command line) for audit (proposed: not in format 0).
|
||||
Reference in new issue
Block a user