# ADR 0011 — Module registry and distribution

**Status:** accepted. **Date:** 2026-12-03.

## Context
External developers need to create, test, publish and install modules with versioning, signing,
provenance and verified compatibility. Signed packages already existed (ADR 0009)
(`module:pack`, `module:verify`, `module:add`); what was missing was discovery, version resolution, controlled publishing,
version yanking and framework upgrades.

## Alternatives considered
- **npm (public or private registry)**: mature distribution, but it resolves JavaScript dependencies, not module
  contracts; it runs install scripts; its signature (npm provenance) proves the origin of the build, not local trust
  in the publisher; modules would become dependencies in `node_modules`, outside architectural validation.
- **A dedicated registry server with an API and a database**: rich search and permissions, but one more service to operate and secure.
- **Git as the registry** (per-module tags): no index, no per-package integrity, no version yanking.

## Decision
- **Static registry**: `index.json` (format 1), `packages/<id>/<id>-<version>.tgz` and `keys/<fingerprint>.pem`.
  It works from a directory, a file share, object storage or any HTTPS host; `registry:serve`
  provides a read-only server with a token for internal use.
- **Publishing** only to directory registries, with a signed package, a human approval bound to the file hash
  (`module.publish`), immutable versions and dependencies already published.
- **Installation** picks the highest non-yanked version compatible with the installed Fellow; it checks dependencies
  (FW-REG-001), integrity against the index (FW-REG-002), the signature against **locally trusted** keys and
  consistency between the manifest and the index. Registry keys are never trusted implicitly: `registry:trust`
  is interactive and checks the fingerprint.
- **Lockfile** `fellow.lock.json` records the version, integrity, signer and registry of each installed module.
- **Provenance** (repository without credentials, commit, dirty tree, tool version) goes in the package's signed
  manifest, covered by the signature.
- **Yanking** (`module:yank`) marks the version in the index with a reason; it does not remove the file, so as not to break
  existing installations.
- **Framework upgrades** through `upgrade:check`/`upgrade`: they rewrite only project files (`fellow` ranges of
  local modules, `@fellowframework/*` dependencies, installed skills); registry modules are reported (FW-UPG-001).
- **Templates** `web`, `saas` and `module` in `fellow new`, all of which pass `fellow check` when generated.

## Risks
- A signature proves origin, not safety: a trusted module runs with the application's database role. Mitigation:
  explicit per-key trust, architectural validation after installing, documentation of the security model.
- Compromise of the publisher's private key. Partial mitigation: human approval on publishing; key
  revocation in the index is still missing (reassess when there is a public registry).
- A static registry has no concurrency control between publishers: the index write is atomic, but two
  simultaneous publications can lose an entry. Acceptable for registries with a single publisher or serialized CI.

## Evidence
`packages/cli/tests/registry.test.ts` and `templates.test.ts`: publishing, approving, catalog, installation with and without
trust, lockfile, incompatible and yanked versions, tampering detected, HTTP registry with a token, the full
module template flow and upgrade codemods.

## Conditions for reassessment
A public registry with many publishers (requires key revocation, namespaces and a write service);
a need for search/statistics; adoption of Sigstore or an equivalent as the ecosystem standard.
