Documentation
¶
Overview ¶
Package update implements the core of `abcd update` (itd-130 / spc-32): a user-invoked fetch/verify/swap for the PATH-installed binary. It is adr-38 tier 2 — the verb's documented meaning IS the fetch; nothing here runs implicitly — and it completes a chosen update (tier 3): the tag is named before anything is replaced, the asset is verified against the same release's checksums.txt AND against the SLSA build provenance release.yml signed for it (provenance.go), and the swap is atomic in the target's directory. The transport is pinned: no proxy, no CA overrides from the environment, redirects only onto the release origin's own hosts, every hop re-checked under the urlguard policy. Transport-agnostic (adr-23): everything returns a structured Report; the CLI renders it.
Index ¶
- Constants
- func CheckStaged(path, sum string) error
- func CommitStaged(target string, st Staged, keepAs string) error
- func KeptPath(target string) string
- func NextStep(t ahoy.UpdateTarget) string
- func NextStepHere() string
- func ReadKept(keepAs string) ([]byte, error)
- func ReleaseProvenanceForTest(apiBase string, trustedRootJSON []byte) (func(tag string, digest []byte) (string, error), error)
- func RestoreKept(target, keepAs string, data []byte) (string, error)
- func TooNew(what string, got, want int) error
- func UpdatedLine(from, to string) string
- func VerifyKept(keepAs, tag string) ([]byte, error)
- func VerifyReleaseProvenance(tag string, digest []byte) (string, error)
- type Action
- type FetchedRelease
- type NoVerdictError
- type Ownership
- type Refusal
- type ReleaseAssets
- type Report
- type SelfTarget
- type Staged
- type Updater
- func (u *Updater) Apply(target, tag string, progress io.Writer) (Report, error)
- func (u *Updater) Candidate(current string) (tag string, newer bool, err error)
- func (u *Updater) FetchVerified(tag string, progress io.Writer) (FetchedRelease, error)
- func (u *Updater) ResolveTag(requested string) (string, error)
- func (u *Updater) StageRelease(target, tag string, progress io.Writer) (Staged, error)
Constants ¶
const RemedyPluginUpdate = "take a plugin update in the host (e.g. /plugin update abcd)"
RemedyPluginUpdate is the way out of every refusal whose cause is a binary the plugin install owns: the plugin-root refusal here, and the stale-binary note the CLI appends to an unknown command (iss-2608230943088357). One string, so the two surfaces cannot drift apart.
const ShapeSourceBuild = "source-build"
ShapeSourceBuild is the refusal of a build that claims no release tag.
const UpdatedFormat = "abcd updated from %s to %s"
UpdatedFormat is the one wording of the line every binary swap prints when it completes: `abcd update`'s receipt and hooks/bootstrap.sh's success notice both lead with it, and the session check uses it for the one swap whose output nobody sees (the ruling CJ1b, dcn-2609300000000011). The bootstrap is POSIX sh and cannot import it, so TestBootstrapUpdateLineIsTheSharedWording holds the script's printf literal to this constant.
Variables ¶
This section is empty.
Functions ¶
func CheckStaged ¶ added in v0.17.0
CheckStaged holds the file at path to sum and to being a regular file, immediately before it is run or swapped.
func CommitStaged ¶ added in v0.17.0
CommitStaged swaps the staged file into place keeping the previous one at keepAs, after reading the staging file's digest again: the proof ran on the same account, so what was verified is not taken to be what stands there now. A digest that differs removes the file and swaps nothing.
func KeptPath ¶ added in v0.17.0
KeptPath is the name the previous binary is kept under, beside target.
func NextStep ¶ added in v0.7.1
func NextStep(t ahoy.UpdateTarget) string
NextStep renders the one line naming how the classified install is brought forward — the answer `abcd update` itself would give. The swappable shape is pointed at the verb; every other shape is pointed at the mechanism that owns its binary, taken verbatim from Plan's refusal so the remedy text lives in exactly one place. This is the canonical "what do I run next" primitive: `update --check` and every schema-too-new refusal render through it (itd-130 / iss-2609012111168872).
func NextStepHere ¶ added in v0.7.1
func NextStepHere() string
NextStepHere classifies the install that answers to `abcd` on this machine and renders NextStep for it. Disk only: the walk reads PATH and the plugin root and touches no network (adr-38), so it is safe inside an error path.
func ReadKept ¶ added in v0.17.0
ReadKept reads the kept copy, refusing anything but a regular file at that name.
func ReleaseProvenanceForTest ¶ added in v0.14.1
func ReleaseProvenanceForTest(apiBase string, trustedRootJSON []byte) (func(tag string, digest []byte) (string, error), error)
ReleaseProvenanceForTest builds the same check against an attestations endpoint a test serves and a fixed Sigstore trusted root, so a caller's tests can hold their wiring to recorded real bundles without the network. Never used by the shipping binary.
func RestoreKept ¶ added in v0.17.0
RestoreKept puts data, the kept copy's bytes as they were checked, back over target, empties the kept name, and returns the digest for the install record.
func TooNew ¶ added in v0.7.1
TooNew is the canonical schema-too-new refusal: an artefact stamped with a schema this binary does not know yet. The frame is stable ("<what> schema vN; this abcd knows up to vM — update abcd: ...") and the tail names the command for this install shape, so the message ends in something the user can type rather than the verbless "upgrade" it used to end in.
func UpdatedLine ¶ added in v0.12.0
UpdatedLine renders UpdatedFormat. The caller sanitises both tags: they are read off an HTTP response or a record on disk.
func VerifyKept ¶ added in v0.17.0
VerifyKept reads the kept copy and holds it to the release it was: its own build claim must name tag and the build provenance for exactly those bytes must verify. What cannot be verified, offline included, is refused. The bytes it returns are the ones it verified.
func VerifyReleaseProvenance ¶ added in v0.14.1
VerifyReleaseProvenance verifies one release asset's SLSA build provenance by its sha256 and returns the verified signer identity: the check Apply runs before a swap, for a verb that promotes a release asset it did not download itself. ahoy install runs it before promoting the plugin's cached release binary to the PATH copy (iss-2610120617515834), so both verbs hold a release binary to one primitive. The client is built per call, only when a promotion needs it, and like ReleaseAssets' it ignores the proxy and CA overrides without unsetting them: it runs inside another verb's process, which the updater's process-wide scrub would change under it. The network it touches is GitHub's attestations API and the Sigstore TUF repository, keyed by the digest of a release already chosen: it discovers nothing (adr-38 tier 3).
Types ¶
type FetchedRelease ¶ added in v0.16.0
FetchedRelease is a release binary downloaded and verified, before anything is written: its bytes, the sha256 checksums.txt names for them, and the signer of the build provenance that names them.
type NoVerdictError ¶ added in v0.17.0
type NoVerdictError struct{ Err error }
NoVerdictError is a failure that says nothing about the release: a network fault, a status other than not-found, a body cut short, a trusted root that could not be fetched, a staging file that could not be written. A drive tries again at its next check, where a verdict on the release takes that release off the table for the run. Its text is the fault alone, without what the caller wrapped it in.
func (*NoVerdictError) Error ¶ added in v0.17.0
func (e *NoVerdictError) Error() string
func (*NoVerdictError) Unwrap ¶ added in v0.17.0
func (e *NoVerdictError) Unwrap() error
Unwrap lets a caller still read the fault underneath.
type Ownership ¶ added in v0.8.0
type Ownership string
Ownership names the proof that the file about to be replaced is abcd's own. There are three, and only the first depends on anything a forge still serves — which is why the other two exist (iss-2609012000222546): release objects are deletable, and an ownership proof that rests on them stops proving the day they are deleted, stranding an install with no way forward.
const ( // OwnedByManifest: the file's digest appears in a published release's // checksums.txt. The strongest proof and the only one that also dates the // file, so it is tried first — but it dies with the release object. OwnedByManifest Ownership = "release-manifest" // OwnedByRunningExecutable: the file IS the executable this process is // running from. Nothing else can be: the code asking the question was // loaded out of those very bytes, so the file is abcd by construction and // no forge object is consulted to know it. OwnedByRunningExecutable Ownership = "running-executable" // OwnedByPathEntry: ~/.abcd.noindex/path-entry records this exact file as the copy // abcd installed, and the bytes still hash to what was recorded. Local, // written at install time by every install route, and equally independent // of what the forge still serves. OwnedByPathEntry Ownership = "path-entry-record" )
type Refusal ¶
type Refusal struct {
Shape string `json:"shape"`
Detail string `json:"detail"`
Remedy string `json:"remedy"`
}
Refusal is a named no: the shape that refused, why, and the remedy. Every refusal is loud and names its way out (the itd-130 dispatch contract).
func Plan ¶
func Plan(t ahoy.UpdateTarget) *Refusal
Plan maps the resolved PATH target onto the spc-32 dispatch table: only a regular file outside a package manager's tree proceeds; every other shape is a refusal naming the mechanism that owns it.
type ReleaseAssets ¶ added in v0.11.0
type ReleaseAssets struct {
// contains filtered or unexported fields
}
ReleaseAssets fetches named assets of one repository's releases under the updater's transport policy: the pinned origin, https only, the urlguard address policy, GitHub's own asset hosts as the only legal redirects, and the proxy and CA overrides ignored by its own client. It is the fetcher `abcd launch`'s parity diff reads a previous release's payload archive and checksums.txt through, and only when the operator asks for it (adr-38 tier 2). It verifies nothing itself: the caller checks the archive against the release's own checksums.
func NewReleaseAssets ¶ added in v0.11.0
func NewReleaseAssets(origin string) (*ReleaseAssets, error)
NewReleaseAssets builds the fetcher for the repository at origin, an https://github.com/<owner>/<repo> address.
func (*ReleaseAssets) EnvIgnored ¶ added in v0.11.0
func (a *ReleaseAssets) EnvIgnored() []string
EnvIgnored names the transport-override variables that were set when the fetcher was built and that its client does not honour.
func (*ReleaseAssets) FetchReleaseAsset ¶ added in v0.11.0
FetchReleaseAsset downloads one asset of tag. found is false, with no error, when the release or the asset does not exist; url is what was requested.
type Report ¶
type Report struct {
Origin string `json:"origin,omitempty"`
Tag string `json:"tag,omitempty"`
Asset string `json:"asset,omitempty"`
Digest string `json:"digest,omitempty"`
TargetPath string `json:"target_path,omitempty"`
OldVersion string `json:"old_version,omitempty"`
OldDigest string `json:"old_digest,omitempty"`
NewVersion string `json:"new_version,omitempty"`
Ownership Ownership `json:"ownership,omitempty"`
// AttestedBy is the signer identity of the build provenance the swapped
// binary verified against: the release workflow's certificate SAN.
AttestedBy string `json:"attested_by,omitempty"`
Action Action `json:"action"`
EnvIgnored []string `json:"env_ignored,omitempty"`
Refusal *Refusal `json:"refusal,omitempty"`
}
Report is the update receipt: origin, tag, digest, and what happened. It prints in both TTY and piped modes — silence is only ever about progress.
type SelfTarget ¶ added in v0.17.0
SelfTarget is the running file as a drive reads it once at its start: its resolved path, the release its own build claims, and why it never self-updates, nil when it may.
func ResolveSelfTarget ¶ added in v0.17.0
func ResolveSelfTarget() SelfTarget
ResolveSelfTarget judges the running file. Nothing on the network, and nothing a stage can write but the file's own kind, which is read before any stage starts.
type Staged ¶ added in v0.17.0
Staged is a release's verified bytes at the staging name beside the target.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater fetches and applies releases from one pinned origin.
func NewGitHubUpdater ¶
func NewGitHubUpdater() *Updater
NewGitHubUpdater builds the updater as it ships: the pinned origin, the full urlguard policy, and GitHub's own asset hosts as the only other hosts a download may reach.
func NewSelfUpdater ¶ added in v0.17.0
func NewSelfUpdater() *Updater
NewSelfUpdater is the updater a running drive asks through: NewGitHubUpdater's origin, policy and checks, over a client that holds the transport overrides out without unsetting them. A drive goes on to start git, gh and every agent, which need the person's proxy, so the process-wide scrub `abcd update` makes in its own short life would change what they run on.
func (*Updater) Apply ¶
Apply completes the chosen update: prove the target file is abcd's, download the tag's asset, verify it against the release's own manifest, and swap atomically. It never leaves a partial file: verification happens before anything at the target path is touched.
Ownership is proven by whichever of the three proofs answers first (see Ownership). The published-digest proof is tried first because it also DATES the file — the old version is derived from the release whose manifest matches the on-disk bytes, never read from the running binary, which may not be the file being replaced. It is not, however, the only proof, and must not be: release objects are deletable, and when the 2026-08-30 cleanup removed every manifest older than v0.6.9 this refused every install it had previously vouched for and sent the user to delete their only abcd (iss-2609012000222546). The two local proofs cannot be revoked from off the machine; a file they carry has no derivable version, so the receipt names it an unpublished build and reports its digest.
func (*Updater) Candidate ¶ added in v0.17.0
Candidate asks the origin for its latest release, one request, and reports whether it is a newer stable release than current.
func (*Updater) FetchVerified ¶ added in v0.16.0
FetchVerified downloads tag's binary for this platform and checks it the way Apply checks a swap and the README's install line checks a first install: against the release's own checksums.txt, then against the build provenance the release workflow signed and the release the bytes claim (verifyRelease). It writes nothing; the caller writes the bytes. It is the fetch `ahoy install` makes on a yes to the question naming the download (itd-2610240823055889), where there is no file at the target for Apply to prove abcd's.
func (*Updater) ResolveTag ¶
ResolveTag validates an explicit tag, or resolves `releases/latest` when none is given — the one discovery this verb performs, and only because the user typed the verb (adr-38 tier 2).