# 12. Packages and Build ## 1. Manifest A package contains an `aji.toml` manifest. Decision record for capability grants: RFC 0010. 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` or `aji explore --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 = "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. 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`, `aji lower` and `aji report` read a manifest only with explicit `--manifest PATH`, selecting its entry and module inputs without granting program authority. `aji explore --manifest PATH` uses its entry/module inputs and grants with the same override rules as run. 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. ### 1.3 Package source mapping An optional `[modules]` table maps dotted source module names to manifest-relative `.aji` file paths: ```toml [package] name = "record-tool" version = "0.1.0" entry = "src/main.aji" [modules] app.model = "src/model.aji" app.work = "src/work.aji" ``` Mapping keys MUST be ASCII identifier components separated by dots and MUST NOT occupy standard/built-in namespaces (spec 15 §14). Duplicate keys remain manifest errors. With this section present, `entry` is required and MUST name `.aji` source; entry/mapped paths MUST be nonempty portable relative paths with `/` separators and no empty, `.` or `..` component, backslash, colon or NUL. They MUST end in `.aji`. Every directory component and source file MUST be opened without following symlinks, relative to the selected manifest directory; that directory is the operator-selected root. Directory/file handles stay open while descending/reading to avoid substituting an ancestor with a symlink. Nonregular sources MUST be rejected. Unsupported safe no-follow behavior MUST fail rather than silently read outside the package. The loader MUST read entry first, then mapped files in lexicographic module-name order into fixed compilation inputs. All mapped files are explicit build inputs and MUST be readable even if unreachable; only the reachable graph is parsed/linked (spec 15 §14). No source is executed during loading. The manifest is limited to 1 MiB, at most 1,024 mapped modules and the total source snapshot to 64 MiB. Invalid bindings/paths, unavailable files, symlinks, input limits and other I/O errors use the existing usage/I/O error contract (exit 2 before verification); source graph/name/type errors are verification rejection (exit 1, JSON diagnostics). Manifests without `[modules]` retain their entry-loading contract. Commands accept one file or `--manifest PATH`, never both. Check/lower/report never grant program authority; run/explore instantiate only with explicitly selected manifest grants and command-line overrides. No implicit manifest discovery is allowed. ## 2. Reproducibility Given the same: - source; - compiler version; - dependency lock; - target; - feature set; build graph evaluation must be deterministic. ## 3. Build scripts Packages cannot execute arbitrary host code merely because they are dependencies. Any build extension must be explicitly declared, sandboxed and capability-limited. ## 4. Dependencies Dependencies should be content-addressed or lockfile-pinned. The package system should record unsafe/runtime dependencies separately from ordinary safe source dependencies.