package buildrecord import "time" // BuildRecord is the layout the ended controller's chain wrote (mesh-controller internal/chain/records.go Build, line 91), // the fields a reader outside it read (novox/hq ADR 0437 §4 §5, issue 1223). The controller's record carries more; a decode ignores // what is not here. Path is the module's directory in its repository, as the controller writes it (Build.Path, records.go:100, // set from the build request trimmed of slashes at internal/inventory/chain_requests.go:19); empty for a module whose // manifest is the repository's root. SourceInputs has no json keys of its own: it is written under its Go field names, as the controller // writes it. type BuildRecord struct { ID string `json:"id"` State string `json:"state,omitempty"` Failed string `json:"failed,omitempty"` Repository string `json:"repository"` Ref string `json:"ref,omitempty"` Module string `json:"module,omitempty"` Path string `json:"path,omitempty"` Commit string `json:"commit,omitempty"` At time.Time `json:"at,omitzero"` SourceFingerprint string `json:"source-fingerprint,omitempty"` SourceInputs *SourceInputs `json:"source-inputs,omitempty"` // Made is what the build made (Build.Made, records.go:110); the digest is the tail of an artifact's Reference. Made []Artifact `json:"made,omitempty"` } // Artifact is one thing a build made: mesh-controller internal/chain/records.go Artifact, json keys name, kind and // reference, nothing else (novox/hq ADR 0478 clause 8). type Artifact struct { Name string `json:"name"` Kind string `json:"kind"` Reference string `json:"reference"` } // BuildKey is a build's record under its module, a build that knew none under the request's key: copied from // mesh-controller internal/chain/keys.go:35-40 (BuildKey, with RequestKey at line 42). func BuildKey(module, id string) string { if module == "" { return "req." + id } return module + ".build." + id } // NewestKey is the key of a module's newest build, of any state: copied from mesh-controller internal/chain/keys.go:44. // The key holds no record: its value is the newest build's id as raw bytes (internal/inventory/chain_builds.go:210 and // :546), and the record lives at BuildKey(module, id). The pointer is a hint, checked against that record. func NewestKey(module string) string { return module + ".newest" } // SourceInputs are what the ended controller's source fingerprint (src1) was of, as its build records hold them // (BuildRecord), read and never computed again (novox/hq ADR 0437 §5): the module, the git tree of // its directory, its bases (references, of which only the digest counts), the root tree of each repository its // artifacts read (by artifact), each artifact's toolchain line, and the reason the source does not pin the build // when it does not (a build that resolves packages when built). A context is the value the builder records for it: // a repository's root tree, or for an image that compiles a Go program the `narrow:` hash of the build source it was // handed (mesh-controller internal/builder/builder.go:1146-1156). type SourceInputs struct { Module string Tree string Bases []string Contexts map[string]string Toolchains map[string]string Unpinned string } // IsTrunkBuild is whether the record is a successful build of the trunk that recorded its source inputs: an outcome // (the controller writes no state on one; state asked is a request, records.go:57-59), not failed, and ref "main" or none. A build a delivery plan asked after a merge, or rebuild or build --behind, follows the branch // without naming it, so it carries no ref; a build of any other branch or of a commit names it (issue 1281). func (r BuildRecord) IsTrunkBuild() bool { return r.State == "" && r.Failed == "" && r.SourceInputs != nil && (r.Ref == "" || r.Ref == "main") }