PeaBox Lab › PeaLang › Learn › Chapter 11 › Lesson 4

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:

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

RequestQuestion to askRed flag
file_writeWhich directories, and why?Whole-disk access for a validation library
httpWhich hosts?Unrestricted network for a pure calculation package
processWhy launch programs?Almost never justified for a rules library
noneDoes 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.

EntryPurpose
pea.tomlPackage name, version, and dependencies
permissions sectionRequested capabilities
src/Module source files
README and licenseDocumentation and terms
Checksum fileIntegrity 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

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.

FailureLikely causeResponse
Permission denied by policyPackage requests more than allowedReview the package; adjust policy only with justification
Archive does not match lockSource changed or lock is staleInvestigate before updating
Missing sourceMirror or host unreachableRetry 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

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

MistakeConsequenceFix
Granting permissions to make an install passSilent privilege growthReview the request first
Never auditing updatesNew capabilities go unnoticedAudit on every dependency change
Publishing without listing the archiveSecrets or test data shippedInspect the file list
Broad file scopesA bug can touch unrelated filesScope to specific directories

4.17 Guided practice

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

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

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.

← Previous Next →