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 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 ¶
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.
Variables ¶
This section is empty.
Functions ¶
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: `version --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 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.
Types ¶
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 Report ¶
type Report struct {
Origin string `json:"origin"`
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"`
NewVersion string `json:"new_version,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 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 legal redirect targets.
func (*Updater) Apply ¶
Apply completes the chosen update: prove the target file is abcd's by provenance (its digest appears in a published release's checksums.txt), download the tag's asset, verify it against the same release's manifest, and swap atomically. It never leaves a partial file: verification happens before anything at the target path is touched. The old version is DERIVED — the release whose manifest matches the on-disk bytes — never read from the running binary, which may not be the file being replaced.