Go client integration
The root Go module neuroplast.io/engram depends only on the Go standard library (Go 1.24+). Import it to poll a channel, verify OpenSSH manifest signatures against pinned Ed25519 keys, and download integrity-checked artifacts.
go get neuroplast.io/engram
Check for updates and download
Pin the public signing key in your binary using sshsig.ParseAllowedSigners from neuroplast.io/engram/sshsig, then create an engram.Client:
keys, err := sshsig.ParseAllowedSigners([]byte(pinnedSigners))
if err != nil {
return err
}
c := &engram.Client{
Base: "https://pkg.example.org",
Project: "acme",
Channel: "stable",
Keys: keys,
}
m, err := c.Latest(ctx, acceptedSeq) // nil, nil when nothing newer exists
if err != nil || m == nil {
return err
}
a, ok := m.Find("acme", runtime.GOOS, runtime.GOARCH)
if !ok {
return fmt.Errorf("no artifact for %s/%s", runtime.GOOS, runtime.GOARCH)
}
data, err := c.Download(ctx, m, a) // checks size and SHA-256 against manifest
Latest fetches the unsigned head, downloads builds/<commit>/manifest and manifest.sig, verifies the signature against Keys, confirms Project, Channel, and Commit, and rejects any signed seq lower than acceptedSeq with engram.ErrRollback.
Client methods
| Method | Purpose | Signed / verified |
|---|---|---|
Latest(ctx, accepted) |
Resolve head to a verified manifest newer than accepted (0 for first install) |
Yes (signature, binding, seq > accepted) |
Manifest(ctx, commit) |
Fetch and verify a specific 40-hex commit directly, bypassing head |
Yes (signature, binding) |
Download(ctx, m, a) |
Fetch an artifact of a verified manifest and check exact byte size and SHA-256 | Yes (via signed manifest) |
Probe(ctx, m, a, local) |
Verify local artifact bytes ([]byte) match the manifest, then check CDN HEAD and first/last 64 KiB via Range |
Yes (via signed manifest) |
Head(ctx) |
Fetch head without verifying any manifest |
No (advisory only) |
HeadIfChanged(ctx, etag) |
Conditional GET head with If-None-Match; returns nil head on HTTP 304 |
No (advisory only) |
Journal(ctx) |
Fetch and parse the full append-only channel journal | No (advisory only) |
Use Manifest(ctx, myCommit) to check whether a specific commit is live on a channel without polling head. Use Journal(ctx) to inspect scrap reasons (ReasonBroken, ReasonSecurity, ReasonMistake) or expire records as status information for users; never act on unsigned journal records beyond checking for a newer signed build.
Private channels and error handling
Set Client.Token to send Authorization: Bearer <token> on every HTTP request for a private channel:
c := &engram.Client{
Base: "https://pkg.example.org",
Project: "acme",
Channel: "preview",
Keys: keys,
Token: token,
}
| Sentinel error | Cause |
|---|---|
engram.ErrNotLive |
Server returned HTTP 404 or 403: commit was never published on this channel, expired, or was scrapped |
engram.ErrRollback |
Channel offered a signed seq lower than accepted |
engram.ErrUnauthorized |
Server returned HTTP 401: channel is private and no valid token was sent |
engram.ErrVersion |
File header declares an unsupported engram format version |
For embedded self-updating binaries and thin launchers, see In-place updates (enboot) and Package launchers (enlaunch).