Part II — Intermediate Development · Chapter 11 · Lesson 4 of 6 · 5 min read
Lesson 4: Permission Manifests, Archives, Installation, and Auditing
Lesson level: Intermediate
Purpose: Learn how a package declares the capabilities it needs, how it is packed into an archive, how installation applies those declarations, and how to audit what is installed.
Release note: commands, field names, and syntax in this lesson are illustrative. Verify them against your installed v0.63 release before relying on them.
Learning objectives
By the end of this lesson, you should be able to:
- Declare the capabilities a package needs in a permission manifest.
- Explain what an archive contains and why its contents must be reviewable.
- Install a package while enforcing the permissions it declared.
- Audit installed packages for unexpected capabilities.
- Apply least privilege to dependencies.
4.1 Why packages declare permissions
Chapter 8 introduced capabilities as explicit grants. A package is code that runs inside your application, so it should state which capabilities it needs before you install it. A declaration lets a reviewer compare what a package claims with what it does.
4.2 The permission manifest
A permission manifest lists the capabilities a package requests. In the running example, input_checks only validates values and should request nothing, while a hypothetical audit_export package writes a file and requests file access.
[permissions]
file_write = ["reports/"]
http = false
process = false
Each entry names a capability and its scope. Absent entries mean the capability is denied.
4.3 Reading a manifest critically
| Request | Question to ask | Red flag |
|---|---|---|
| file_write | Which directories, and why? | Whole-disk access for a validation library |
| http | Which hosts? | Unrestricted network for a pure calculation package |
| process | Why launch programs? | Almost never justified for a rules library |
| none | Does behavior match the claim? | Code that needs a capability it did not declare |
4.4 Declared versus granted permissions
A declaration is a request, not a grant. The host or project policy decides what to grant. If a package requests more than policy allows, installation should stop rather than silently reduce the request.
[policy]
allow = ["file_write:reports/"]
deny = ["process", "http"]
4.5 What an archive contains
A package archive bundles the source files, the manifest, the permission manifest, and metadata into one distributable file. The archive is what a registry stores and what an installer downloads.
| Entry | Purpose |
|---|---|
| pea.toml | Package name, version, and dependencies |
| permissions section | Requested capabilities |
| src/ | Module source files |
| README and license | Documentation and terms |
| Checksum file | Integrity record, covered in Lesson 5 |
4.6 Building and inspecting an archive
pea package
pea package --list
Inspect the file list before publishing. Test data, credentials, and editor files should not be included. A reviewer should be able to read every entry.
4.7 Excluding files deliberately
Keep an explicit include or exclude rule so the archive does not depend on whatever happens to be in the directory. This also keeps archives reproducible, which Lesson 2 required for builds.
4.8 Installing a package
pea install
pea install --locked
Installation reads the manifest and lock, fetches each archive, compares its permission request with project policy, and places the code in the project. With --locked, the installer refuses to change the lock.
4.9 Installation steps in order
- Resolve each dependency from the lock.
- Download the archive from its recorded source.
- Verify integrity evidence (Lesson 5).
- Compare requested permissions with policy.
- Unpack into the project dependency area.
- Record what was installed.
4.10 Failing safely
If any step fails, installation should leave the project unchanged and report which package and which check failed. A half-installed dependency tree is hard to reason about.
| Failure | Likely cause | Response |
|---|---|---|
| Permission denied by policy | Package requests more than allowed | Review the package; adjust policy only with justification |
| Archive does not match lock | Source changed or lock is stale | Investigate before updating |
| Missing source | Mirror or host unreachable | Retry or use the mirror |
4.11 Auditing installed packages
pea audit
pea audit --permissions
pea tree
An audit lists installed packages with versions, sources, and requested permissions. Run it before a release and after any dependency change.
4.12 Worked example
The order_rules project depends on input_checks and the development dependency test_helpers. A new release of input_checks adds an HTTP request.
pea audit --permissions
input_checks 1.3.0 requests: http = ["telemetry.example.com"]
The audit shows a new capability that the project policy denies. The team keeps version 1.2.x, records the reason, and asks the maintainer why a validation library needs network access.
4.13 Least privilege for dependencies
- Grant only what a package declares and policy allows.
- Prefer packages that request nothing.
- Scope file access to specific directories.
- Treat a new permission in an update as a review trigger.
4.14 Recording audit evidence
Save the audit output with the release record. It shows which packages, versions, sources, and permissions shipped, and it supports later investigation.
4.15 Continuous integration checks
pea install --locked
pea audit --permissions
Run both commands on every change so a new dependency or permission fails the build before it merges.
4.16 Common mistakes
| Mistake | Consequence | Fix |
|---|---|---|
| Granting permissions to make an install pass | Silent privilege growth | Review the request first |
| Never auditing updates | New capabilities go unnoticed | Audit on every dependency change |
| Publishing without listing the archive | Secrets or test data shipped | Inspect the file list |
| Broad file scopes | A bug can touch unrelated files | Scope to specific directories |
4.17 Guided practice
- Write a permission manifest for a package that writes one report file.
- Write a policy that allows that request and denies everything else.
- List the contents of an archive and mark any entry that should be excluded.
- Run an audit and identify packages that request a capability.
4.18 Hands-on lab
Build an archive for input_checks, inspect its contents, install it into order_rules under a deny-by-default policy, then simulate an update that adds a permission request and observe the failure.
Deliverable: the archive file list, the policy, the audit output before and after the update, and a short review decision.
4.19 Review questions
- Why should a package declare permissions?
- What is the difference between a request and a grant?
- What should an archive file list be checked for?
- At which installation step are permissions compared with policy?
- Why should a new permission in an update trigger review?
4.20 Applied challenge
Design a dependency review checklist for a team. It must cover permission requests, archive contents, source type, and audit evidence, and say who approves an exception.
Lesson summary
- Permission manifests make a package state the capabilities it needs.
- Archives bundle reviewable contents for distribution.
- Installation enforces policy and fails safely.
- Audits record what shipped and expose new capabilities.
Transition to Lesson 5
Permissions describe what a package may do. Lesson 5 covers checksums, signatures, trusted keys, and registry policy: how you know the archive is the one the publisher intended.
Lesson status: Ready for review.