# Installing and verifying

Install binaries from an engram channel using standard Unix tools, verify published channels from CI or a workstation, and check releases manually with `ssh-keygen`. Assumes `engram` is on `PATH` for `engram verify` commands (see [Install](https://engram.neuroplast.io/#install)).

## Install on a workstation

```sh
curl -fsSL https://engram.neuroplast.io/install.sh | sh
```

Installs `engram` to `~/.local/bin` (override with `ENGRAM_BINDIR`), verified against the release key pinned in the script.

## Install in CI or from another channel

[`install.sh`](https://github.com/neuroplastio/engram/blob/main/install.sh) (hosted at `https://pkg.neuroplast.io/engram/install.sh`) downloads a `.tar.gz` artifact from any engram channel, verifies its OpenSSH signature and SHA-256 hash using only `curl`, `ssh-keygen`, `sha256sum` (or `shasum`), and `tar`, and extracts `<name>` into `<dir>`. It requires `ENGRAM_SIGNERS` from the caller so workflows pin the signing key in their own source rather than trusting the artifact server.

In GitHub Actions:

```yaml
- name: Install engram
  env:
    ENGRAM_SIGNERS: release@neuroplast.io namespaces="engram" ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDCsEZcn1tiubvKQzEVs5pJ4QVXoFmSDtO+k6SdetUdf
  run: curl -fsSL https://pkg.neuroplast.io/engram/install.sh | sh -s -- engram ./bin
```

Positional arguments are `[name] [dir]`, defaulting to `engram` and `./bin`.

| Environment variable | Default | Meaning |
| --- | --- | --- |
| `ENGRAM_SIGNERS` | required | OpenSSH `allowed_signers` line(s) pinned by the caller (multiple lines for rotation must share the first line's identity) |
| `ENGRAM_URL` | `https://pkg.neuroplast.io` | Channel base URL |
| `ENGRAM_PROJECT` | `engram` | Project name on the channel |
| `ENGRAM_CHANNEL` | `stable` | Channel name |
| `ENGRAM_COMMIT` | channel `head` | Full 40-character commit to install directly |
| `ENGRAM_TOKEN` | empty | Bearer token for a private channel |

Supported platforms in `install.sh`: Linux (`amd64`, `arm64`, `arm`) and macOS (`amd64`, `arm64`).

## Verify a channel with `engram verify`

`engram verify` checks the manifest signature against a local `allowed_signers` file and confirms that the signed `project`, `channel`, and `commit` match the request:

```sh
engram verify \
  --url https://pkg.example.org \
  --project acme \
  --channel stable \
  --signers allowed_signers
```

| Verification mode | Flag | What it checks |
| --- | --- | --- |
| Manifest only | (default) | Signature, manifest grammar, and `project`/`channel`/`commit` binding |
| Full download | `--fetch` | Downloads every artifact through the server and verifies size and SHA-256 |
| Fast CI probe | `--local <dir>` | Hashes local files in `<dir>` against the manifest, then sends `HEAD` (status and `Content-Length`) and `Range` requests for the first and last 64 KiB of each artifact (~128 KiB per artifact) |

Pass `--commit <40-hex>` to verify a specific commit instead of the current `head`. `--fetch` and `--local` are mutually exclusive.

## Private channels

Private channels restrict HTTP access with a bearer token enforced by the server or CDN (returning HTTP `401` when absent or invalid; see [Private channels](https://engram.neuroplast.io/docs/spec#private-channels)). A token controls read access only; clients still verify signatures and hashes against pinned keys identically to public channels.

`engram verify` and `install.sh` read the token from `ENGRAM_TOKEN` rather than a CLI flag so the secret never appears in `ps` output (`install.sh` passes the header to `curl` on stdin). For manual requests:

```sh
printf 'Authorization: Bearer %s\n' "$ENGRAM_TOKEN" \
  | curl -fsSL -H @- https://pkg.example.org/acme/preview/head
```

## Direct downloads from `latest/`

Every channel mirrors the newest live build's files under `latest/` for stable `curl` URLs:

```sh
curl -fsSLO https://pkg.example.org/acme/stable/latest/acme_linux_amd64.tar.gz
```

Automated updaters and Go clients should read `head` and immutable `builds/<commit>/` paths instead of `latest/` (see [`latest/`](https://engram.neuroplast.io/docs/spec#latest)).

## Manual verification with OpenSSH

Verify any published build without installing `engram`:

```sh
curl -fsSLO https://pkg.example.org/acme/stable/builds/<commit>/manifest
curl -fsSLO https://pkg.example.org/acme/stable/builds/<commit>/manifest.sig
ssh-keygen -Y verify -f allowed_signers -I release@example.org -n engram \
  -s manifest.sig < manifest
sha256sum acme_linux_amd64.tar.gz
```

Confirm that the printed SHA-256 matches the `sha256=` field of the matching `artifact` line in `manifest`, and that `project=`, `channel=`, and `commit=` on the `build` line match what you requested.
