hfinstall

package
v0.209.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hfinstall is the HyperFrames step of the composition lane (ADR 0059) as one implementation: the version read that status and the runner agree on, and the install a deploy runs.

The installed HyperFrames is a record with a floor, never an exact version (ADR 0099). The harness installs the newest release npm resolves, stages and verifies it, swaps it in with the previous tree kept for a rollback, and records {version, installed_at} in installed.json. The runner (render/compose-hyperframes.mjs) and capability status refuse only a CLI that is absent or older than the floor in setup/floors.json.

Index

Constants

View Source
const SetupPackageName = "offload-harness-hyperframes"

SetupPackageName is the name the committed setup/hyperframes/package.json carries. A directory whose package.json names anything else is not a harness install, and Install refuses to write into it.

Variables

This section is empty.

Functions

func AtLeast

func AtLeast(have, floor string) bool

AtLeast reports whether have is the floor or newer, comparing the numeric parts (a pre-release tag on an equal or newer core does not lower it). An empty floor is always met; an unreadable have is below any floor.

func Check

func Check(runner, dir string) error

Check reports nil when the install under dir has the CLI and a version at or above the floor beside the runner, and otherwise the reason every composition on this box defers CLI_MISSING. A newer release than any this code has seen is not a problem.

func FloorFor

func FloorFor(runner string) string

FloorFor reads the floor from setup/floors.json beside the runner's repo root (<runner dir>/../setup/floors.json), the file the runner itself reads. "" when the tree does not carry it: no floor is then enforced, presence only.

func FloorFromJSON

func FloorFromJSON(floorsJSON []byte) (string, error)

FloorFromJSON reads the HyperFrames floor ("hyperframes".harness) from the bytes of setup/floors.json. "" with a nil error means the file names no floor.

func InstalledVersion

func InstalledVersion(dir string) (string, error)

InstalledVersion reads the version of the HyperFrames package installed under dir — the same file the runner reads (node_modules/hyperframes/package.json).

func RecordInstalled

func RecordInstalled(path, version string, at time.Time) error

RecordInstalled writes {version, installed_at} under components.hyperframes.current of the installed.json at path (schema 2: current carries the version as its id). Every other key is kept as found; a missing file is created; a flat schema-1 entry (components.hyperframes as a bare version string) is replaced by the record. The file is replaced by rename.

func Verify

func Verify(ctx context.Context, run Runner, node, npm, runner, dir string) (browserPath, version string, err error)

Verify checks an install whose node_modules are in place under dir: `npm rebuild esbuild` (the one postinstall the CLI needs), then the runner's own `browser` op (ensure + path, under its scrubbed env, so the browser is the one THIS release resolves) and its `version` op (ok and at_floor). It returns the browser path the release resolved and the installed version. run nil = exec; npm empty = "npm". Install runs it on a swapped-in tree; `update` runs it on the staged generation before that generation can go live.

Types

type Options

type Options struct {
	Dir          string // hyperframes_dir: where node_modules/hyperframes lives
	Runner       string // the resolved compose_script
	Node         string // the node executable every render script runs under
	Npm          string // npm; empty = found on PATH (with Node's directory first)
	PackageJSON  []byte
	Floor        string // minimum acceptable version ("" = none known)
	ManifestPath string // installed.json to record {version, installed_at} in ("" = do not record)
	Log          io.Writer
	Run          Runner           // nil = exec
	Now          func() time.Time // nil = time.Now
}

Options for Install. PackageJSON is the committed setup/hyperframes/package.json (its hyperframes dependency is "latest"), embedded in the binary so a node without a repository checkout can install. Floor is the minimum version from setup/floors.json.

type Result

type Result struct {
	Dir          string `json:"dir"`
	Version      string `json:"version"`
	Reinstalled  bool   `json:"reinstalled"`
	PreviousTree string `json:"previous_tree,omitempty"`
	BrowserPath  string `json:"browser_path"`
	Floor        string `json:"floor,omitempty"`
}

Result is what Install verified, all of it read back rather than assumed.

func Install

func Install(ctx context.Context, o Options) (Result, error)

Install brings the install under o.Dir to the newest release npm resolves without ever leaving the node worse off than it found it:

  • It refuses before touching anything when o.Dir holds something that is not a harness install.
  • An installed tree that npm accepts (`npm ls`), that holds the CLI entry and the committed package.json, and that is at or above the registry's latest, is kept (a newer hand-placed build is never downgraded); its signatures are audited again. An unreachable registry keeps a healthy tree at or above the floor.
  • Anything else is rebuilt in a staging directory inside o.Dir: `npm install --ignore-scripts` (resolving dist-tags.latest; npm verifies each tarball against the registry's integrity field) and `npm audit signatures` (FATAL) run there, the staged package's version is read back and checked against the floor, so a failure leaves the live tree exactly as it was. Only a verified tree is swapped in; the replaced one is kept as node_modules.prev for a rollback.
  • `npm rebuild esbuild` (the one postinstall the CLI needs) and the runner's own `browser` (ensure + path, under its scrubbed env) and `version` ops run on the swapped-in tree; when one fails, the previous tree and its package.json are put back.
  • The installed version and time are recorded in installed.json.

type Runner

type Runner func(ctx context.Context, dir string, env []string, name string, args ...string) (string, error)

Runner executes one command in dir and returns its STDOUT; a failure's error carries the tail of its stderr. Injectable so the step order and every failure path are unit-tested without npm, node or a network.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL