Documentation
¶
Index ¶
- Constants
- Variables
- func AcceptedMCPCommand(cmd string) bool
- func Build(ctx context.Context, srcDir, out, goos, goarch, version, commit string) (string, error)
- func BuildCmd(ctx context.Context, ...) (string, error)
- func BuildEnv(base []string, goos, goarch string) []string
- func BuildFlags(version, commit string) []string
- func CIAssetNames(version string) []string
- func CheckAssets(version string, have map[string]string, hashes map[Binary]string, keyless bool) error
- func CheckCI(runs []CheckRun, x string) error
- func CheckCIWalk(x string, chain []Commit, runsFor func(sha string) ([]CheckRun, error)) error
- func CheckHookMatchers(hooks []HookCommand) error
- func CheckManifestVersion(path string, manifest []byte, version string) error
- func CheckPluginVersion(manifest []byte, version string) error
- func CheckScripts(version string, have map[string]string, content map[string][]byte) error
- func CheckSource(srcDir, commit, out string) error
- func CheckTrackedFiles(root string) ([]string, error)
- func ExpectedSums(version string, hashes map[Binary]string, ci map[string]string, keyless bool) string
- func IsDocsPath(p string) bool
- func IsLauncherCommand(cmd string) bool
- func IsMashHook(cmd string) bool
- func MCPCommand(mcp []byte) (command string, args []string, err error)
- func MCPServer(mcp []byte) (command string, args []string, env map[string]string, err error)
- func PinnedEnv(base []string) []string
- func PreviousTag(tags []string, version string) (string, bool)
- func RequiresProofs(version string) bool
- func ScriptNamesFor(version string) []string
- func SumsCINames(version string, keyless bool) []string
- func TagBelow(tag, version string) bool
- type Binary
- type CheckRun
- type Commit
- type HookCommand
- type Target
- type ToolError
Constants ¶
const ( PluginHooks = "plugin/hooks/hooks.json" PluginMCP = "plugin/.mcp.json" )
PluginHooks and PluginMCP are the paths of the plugin's hook and MCP server definitions, relative to the repository root.
const CIApp = "github-actions"
CIApp is the GitHub App whose check runs count: Actions. Another integration can write check runs under any name, so a name alone proves nothing: another app's run is ignored unless it carries a required check's name, which is refused as a spoof.
const EndpointEnvSince = "0.5.6"
EndpointEnvSince is the first mash version configured by MASH_ENDPOINT. A release older than this reads MASH_NAME, MASH_OWNER, MASH_GROUP and MASH_URL, and needs MASH_INSECURE_PLAINTEXT; this version and later refuse to start with MASH_INSECURE_PLAINTEXT set (config.SkipEncryptionFrom).
const HookSince = "0.2.0"
HookSince is the first mash version that has `mash hook`; a release older than this answers it "unknown command", which the plugin's tolerant hook wrapper exists to absorb. It is cmd/mash's pluginMinMash (plugin_hook_test.go).
const LauncherCommand = "${CLAUDE_PLUGIN_ROOT}/scripts/mash"
LauncherCommand is the MCP command of a plugin that runs mash through its bundled launcher script.
const MaxDocsWalk = 50
MaxDocsWalk bounds how many commits the gate walks back from a docs-only candidate to a tested commit.
const MigrationScriptLastVersion = "0.5.9"
MigrationScriptLastVersion is the last release that carries MigrationScriptName.
const MigrationScriptName = "mash-migrate-0.5.5.sh"
MigrationScriptName is the one-time 0.5.5 configuration migration script that releases up to and including MigrationScriptLastVersion carried as a third script (ADR 0152). From 0.5.10 on it is not a release asset (ADR 0181), and scripts/ no longer holds it; the published releases that carry it are still re-verified, so they are still held to it. Every version up to and including 0.5.9 is held to the third script, also those before 0.5.5, which shipped no scripts at all: the check does not tell them apart.
const PluginManifest = "plugin/.claude-plugin/plugin.json"
PluginManifest is the path of the Claude Code plugin manifest, relative to the repository root.
const ProvenanceName = "mash.intoto.jsonl"
ProvenanceName is the provenance asset (the Sigstore bundle) covering the eight binaries, the two scripts and SHA256SUMS.
const SetupPluginManifest = "mash-setup/.claude-plugin/plugin.json"
SetupPluginManifest is the path of the skills-only mash-setup plugin's manifest. It carries the release version too.
const SumsName = "SHA256SUMS"
SumsName is the checksums asset.
const SumsNamespace = "mash-release"
SumsNamespace is the ssh-keygen -Y namespace of SHA256SUMS.sig. It is specific to mash, so a signature this key makes for any other purpose cannot be replayed as a mash release signature.
const SumsSigName = "SHA256SUMS.sig"
SumsSigName is the detached SSH signature of SHA256SUMS (ssh-keygen -Y sign, namespace SumsNamespace). The draft release.yml makes does not carry it: `release-check --assets` adds it. CheckAssets allows it, and the signing step judges it. A keyless release (at or above the cutover) carries none: CheckAssets refuses it there.
const SwitchOnVersion = "0.6.0"
SwitchOnVersion is the switch-on release of the 0.6.0 SDK adoption (REQ-019). 0.6.0 is the SDK move, so it is version 0.6.0. From this version the release gate requires the upgrade-proof receipts (AT-011 and AT-012) and refuses a candidate that has none; below it the receipts are checked only when the maintainer gives them.
const Toolchain = "go1.27.4"
Toolchain is the Go toolchain every release is built with; go.mod's go directive and the workflows pin the same value.
Variables ¶
var PluginManifests = []string{PluginManifest, SetupPluginManifest}
PluginManifests lists every plugin manifest that must name the release version.
var Programs = []string{"mash", "mashctl"}
Programs are the commands a release builds, one binary each per target: cmd/<name> becomes <name>-<os>-<arch>.
var RequiredChecks = []string{"test (linux)", "reproducible"}
RequiredChecks are the check runs ci.yml produces that a candidate must have passed. test (macos) is advisory (ADR 0079): it is produced and visible but not required here. TODO(macos-gate): require it again, with pr-check's needs, when we confirm the macOS runner no longer pauses running jobs.
var Targets = []Target{
{"darwin", "amd64"}, {"darwin", "arm64"}, {"linux", "amd64"}, {"linux", "arm64"},
}
Targets are the four platforms a release builds for, in the order SHA256SUMS lists them (sha256sum's glob order). Each platform carries two binaries, mash and mashctl (see Binaries).
Functions ¶
func AcceptedMCPCommand ¶
AcceptedMCPCommand reports whether an MCP server command is one the gate can check: bare `mash` (the binary on PATH) or the plugin's launcher script.
func Build ¶
Build compiles cmd/mash from srcDir into out for goos/goarch ("" means the host's) with the release flags, CGO off and the pinned toolchain, and returns the binary's SHA-256. The same source built in any directory gives the same hash. It is BuildCmd for the mash program.
func BuildCmd ¶ added in v0.5.6
func BuildCmd(ctx context.Context, srcDir, out, goos, goarch, version, commit, program string) (string, error)
BuildCmd is Build for one of the Programs (cmd/<program>). The flags are the same for every program: the version is stamped into internal/endpoint, which both programs link, and a -X for a variable a program lacks is a no-op.
func BuildEnv ¶ added in v0.5.9
BuildEnv is the environment of a release build for goos/goarch ("" means the host's), for tools that must see what the build sees.
func BuildFlags ¶
BuildFlags are the release build flags. They carry no build tags.
func CIAssetNames ¶ added in v0.3.2
CIAssetNames are the assets release.yml makes that the gate cannot rebuild: the two scripts, each binary's SBOM in Binaries order, then the SLSA provenance. They are attached by name and listed in SHA256SUMS; the gate verifies their contents (the scripts are compared with the repository's, `release-check`; the rest by their attestations).
func CheckAssets ¶
func CheckAssets(version string, have map[string]string, hashes map[Binary]string, keyless bool) error
CheckAssets judges a draft release's assets (name -> GitHub's "sha256:<hex>" digest) against our own fresh builds of the candidate: exactly the eight binaries (mash and mashctl for each target), the two scripts, their eight SBOMs, the SLSA provenance and SHA256SUMS, nothing else; each binary's digest is the hash of our build for that target; the SBOMs and the provenance must be attached (their contents are verified separately, as they cannot be rebuilt); and SHA256SUMS is exactly the file those hashes and the attached digests produce. It names every problem. For a keyless release (at or above the cutover) SHA256SUMS omits the provenance bundle (which stays required to be attached), and a SHA256SUMS.sig is not allowed. An asset whose digest GitHub did not give (empty or absent) is reported as "digest not available" by name, still a refusal, and the empty value is never compared.
func CheckCI ¶
CheckCI requires every required check run to exist and have succeeded, all for commit x. A run for another commit, or two different results under one run id, means the response is not what was asked for and is refused. When a check ran more than once the latest run (highest id) decides. Only CIApp's runs count: a run from another app is ignored unless it carries a required check's name, which is refused as a spoof.
func CheckCIWalk ¶ added in v0.5.7
CheckCIWalk is CheckCIWalkCited without the citation.
func CheckHookMatchers ¶
func CheckHookMatchers(hooks []HookCommand) error
CheckHookMatchers refuses hooks whose matchers stop the plugin's hooks from running on what they exist for: PostToolUse must match every tool ("*" or no matcher), UserPromptSubmit takes no matcher, and each must run a `mash hook` command.
func CheckManifestVersion ¶ added in v0.5.6
CheckManifestVersion is CheckPluginVersion for the manifest at path (named in the error).
func CheckPluginVersion ¶
CheckPluginVersion refuses a plugin manifest whose version is not the release version (N.N.N, no leading v). Claude Code updates an installed plugin only when its manifest version changes.
func CheckScripts ¶ added in v0.5.6
CheckScripts holds the release scripts to the repository: each of ScriptNamesFor(version) must be attached with exactly the digest of the bytes the repository holds at the release commit (content, by name; read with `git show <commit>:scripts/<name>`). A script that differs, or that is missing from either side, is named.
func CheckSource ¶
CheckSource refuses a source tree that is not exactly the candidate: HEAD must be the full commit X, the working tree clean, and the output outside the tree. A release binary stamped X must be built from X.
func CheckTrackedFiles ¶ added in v0.5.9
CheckTrackedFiles lists the files git tracks under root (git ls-files) and returns one message per problem: a file over maxTrackedFileSize that is not in largeFileAllowlist, a file that starts with an executable magic number, or a file with a NUL byte in its first 8 KiB whose extension is not a binary asset. It returns an error when git cannot list root's files (git missing, or root is not a git checkout).
func ExpectedSums ¶
func ExpectedSums(version string, hashes map[Binary]string, ci map[string]string, keyless bool) string
ExpectedSums is the exact SHA256SUMS content for the given per-binary hashes (hex SHA-256 of each binary) and the hex SHA-256 of each CIAssetNames file (ci, by name): the binaries, the two scripts, the SBOMs and the provenance, in that order, as release.yml's draft job lists them. A name missing from ci is left out. A keyless release (at or above the cutover) lists the same names except the provenance bundle: it cannot list itself, as release.yml makes the sums before the job that attests.
func IsDocsPath ¶ added in v0.5.7
IsDocsPath reports whether a repository path is documentation: any *.md file, or any path under docs/ except the four data files the release tooling reads. It is scripts/ci-changes' is_docs, ported; docsonly_test.go runs both over the same table so they cannot drift. Everything else is code: the default is code, so a new top-level path is code.
func IsLauncherCommand ¶
IsLauncherCommand reports whether an MCP server command is the plugin's launcher script.
func IsMashHook ¶
IsMashHook reports whether a hook command runs `mash hook`: directly, or through the plugin's launcher script.
func MCPCommand ¶
MCPCommand is the command and arguments of the plugin's "mash" MCP server.
func MCPServer ¶
MCPServer is MCPCommand and the server's env block too: the plugin launches serve with it (MASH_SPOOL_FROM_START), so a check of serve's behaviour must run it the same way.
func PinnedEnv ¶
PinnedEnv is the environment for running the project's tests from a candidate checkout: the caller's environment with the same ambient Go configuration removed and the same toolchain pinned as a release build (no GOFLAGS, workspace, go env file, GOEXPERIMENT or arch tuning), so the tests that run are the tests in X.
func PreviousTag ¶
PreviousTag is the highest vN.N.N tag strictly below version (N.N.N), ignoring every other tag; false when none.
func RequiresProofs ¶ added in v0.5.10
RequiresProofs reports whether the release gate requires the upgrade proofs for version (N.N.N): true when the version is at or above SwitchOnVersion by numeric comparison (0.10.0 is above 0.6.0, 0.5.10 is below). A version that does not parse as N.N.N is not held to it here; the callers refuse such a version earlier.
func ScriptNamesFor ¶ added in v0.5.10
ScriptNamesFor are the scripts the release of version (N.N.N) carries beside the binaries (ADR 0150), named exactly as the repository's scripts/ files are, in the order SHA256SUMS lists them (after the binaries, before the SBOMs). They are the repository's own files at the release commit, copied unchanged, and are subjects of the provenance attestation like the binaries. They have no SBOM. From 0.5.10 (and for an empty or unparsable version) they are install.sh and mash-local-nats-setup.sh; releases up to and including 0.5.9 carry MigrationScriptName as a third.
func SumsCINames ¶ added in v0.4.0
SumsCINames are the CIAssetNames that SHA256SUMS lists: all of them, or, for a keyless release, all but the provenance bundle.
Types ¶
type Binary ¶ added in v0.5.6
Binary is one release binary: a program (one of Programs) built for a target.
func Binaries ¶ added in v0.5.6
func Binaries() []Binary
Binaries are the eight binaries a release carries: mash for every target, then mashctl for every target, in the order SHA256SUMS lists them.
type CheckRun ¶
type CheckRun struct {
ID int64 `json:"id"`
HeadSHA string `json:"head_sha"`
Name string `json:"name"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
HTMLURL string `json:"html_url"`
App struct {
Slug string `json:"slug"`
} `json:"app"`
}
CheckRun is one GitHub check run on the candidate commit.
func CheckCIWalkCited ¶ added in v0.5.10
func CheckCIWalkCited(x string, chain []Commit, runsFor func(sha string) ([]CheckRun, error)) (cited []CheckRun, at string, above int, err error)
CheckCIWalkCited is CheckCI for a candidate that may be docs-only, and names the runs that decided. If x's required checks passed, it is CheckCI. If they were skipped or never ran, x must change only documentation (IsDocsPath), and so must every commit back along main's first parent until one whose required checks ran and succeeded; that commit decides. A docs-only commit therefore can neither break the gate nor stand in for tests: the code it carries is the tested ancestor's code. A code commit without passing checks, a failed or cancelled run, a spoofed run, or no tested ancestor within MaxDocsWalk is refused. chain lists x first, then its first parents, newest first; runsFor reads one commit's check runs.
type Commit ¶ added in v0.5.7
Commit is one commit of main's first-parent history with the paths it changed against its first parent.
type HookCommand ¶
type HookCommand struct{ Event, Matcher, Command string }
HookCommand is one command of the plugin's hooks.json, with the event that runs it and the "matcher" of its hook group (empty when the group has none).
func HookCommands ¶
func HookCommands(hooks []byte) ([]HookCommand, error)
HookCommands lists the commands hooks.json runs, events in name order, commands in file order, each with its group's matcher.
type Target ¶
type Target struct{ GOOS, GOARCH string }
Target is one build target.
func (Target) CtlAssetName ¶ added in v0.5.6
CtlAssetName is the release asset's name of mashctl for the target.