mesh-delivery-contracts: the build seats' part types Fetch, the toolchain, the artifacts, the check's levels and a step's result, and marks the times date-time; fixtures for a check ask and the three kinds of result (ADR 0634 §6; issue 1966)

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
2026-11-05 14:55:35 +01:00
parent c183f170cc
commit f2c61815f8
13 changed files with 1243 additions and 740 deletions
+130 -96
View File
@@ -187,26 +187,27 @@ func DecodeToolchainsByNodeLanguageValue(raw []byte) (ToolchainsByNodeLanguageVa
return v, nil
}
// BuildAnswerArtifactsItem is a type of the contract.
type BuildAnswerArtifactsItem struct {
Artifact string `json:"artifact"`
Digest string `json:"digest"`
Reference string `json:"reference,omitempty"`
}
// BuildAnswerToolchain is a type of the contract.
type BuildAnswerToolchain struct {
Language string `json:"language"`
Recipe string `json:"recipe"`
Version string `json:"version"`
// AskArtifact is one artifact of a build ask: built from the fetched tree, or copied from an upstream pin.
type AskArtifact struct {
Artifact string `json:"artifact"`
From string `json:"from,omitempty"`
Seat string `json:"seat,omitempty"`
Version string `json:"version,omitempty"`
}
// BuildAnswer is a type of the contract.
type BuildAnswer struct {
Artifacts []BuildAnswerArtifactsItem `json:"artifacts"`
Imports []string `json:"imports,omitempty"`
OutOfStep []string `json:"out-of-step,omitempty"`
Toolchain *BuildAnswerToolchain `json:"toolchain,omitempty"`
Artifacts []BuiltArtifact `json:"artifacts"`
Imports []string `json:"imports,omitempty"`
OutOfStep []string `json:"out-of-step,omitempty"`
Toolchain *ToolchainUsed `json:"toolchain,omitempty"`
}
// BuiltArtifact is one artifact a build made: its digest and the reference it was published under.
type BuiltArtifact struct {
Artifact string `json:"artifact"`
Digest string `json:"digest"`
Reference string `json:"reference,omitempty"`
}
// Capacity is how many steps the node runs at once.
@@ -229,56 +230,10 @@ type Capacity struct {
Why string `json:"why"`
}
// CheckAnswerLevelsItemDigestNeedsItem is a type of the contract.
type CheckAnswerLevelsItemDigestNeedsItem struct {
Needs []string `json:"needs,omitempty"`
Package string `json:"package,omitempty"`
}
// CheckAnswerLevelsItemDigestPackagesItem is a type of the contract.
type CheckAnswerLevelsItemDigestPackagesItem struct {
Digest string `json:"digest"`
Package string `json:"package"`
}
// CheckAnswerLevelsItemDigest is a type of the contract.
type CheckAnswerLevelsItemDigest struct {
Beside []string `json:"beside,omitempty"`
JudgedBy string `json:"judged_by,omitempty"`
Level string `json:"level,omitempty"`
Needs []CheckAnswerLevelsItemDigestNeedsItem `json:"needs,omitempty"`
Packages []CheckAnswerLevelsItemDigestPackagesItem `json:"packages,omitempty"`
WithoutTests []string `json:"without_tests,omitempty"`
}
// CheckAnswerLevelsItemKeptItem is a type of the contract.
type CheckAnswerLevelsItemKeptItem struct {
Digest string `json:"digest,omitempty"`
Package string `json:"package,omitempty"`
Tests int64 `json:"tests,omitempty"`
}
// CheckAnswerLevelsItemUnmetItem is a type of the contract.
type CheckAnswerLevelsItemUnmetItem struct {
Needs []string `json:"needs,omitempty"`
Package string `json:"package,omitempty"`
}
// CheckAnswerLevelsItem is a type of the contract.
type CheckAnswerLevelsItem struct {
Digest *CheckAnswerLevelsItemDigest `json:"digest,omitempty"`
Judged string `json:"judged,omitempty"`
Kept []CheckAnswerLevelsItemKeptItem `json:"kept,omitempty"`
Level string `json:"level"`
Tests []any `json:"tests,omitempty"`
Unmet []CheckAnswerLevelsItemUnmetItem `json:"unmet,omitempty"`
}
// CheckAnswer is a type of the contract.
type CheckAnswer struct {
// what the build module fetches: the repository, commit and directory, as the indexer states it
Fetch any `json:"fetch"`
Levels []CheckAnswerLevelsItem `json:"levels,omitempty"`
Fetch Fetch `json:"fetch"`
Levels []LevelAnswer `json:"levels,omitempty"`
}
// ComposeAnswer is a type of the contract.
@@ -289,6 +244,77 @@ type ComposeAnswer struct {
Verdict any `json:"verdict,omitempty"`
}
// FetchBesideItem is a type of the contract.
type FetchBesideItem struct {
Commit string `json:"commit"`
Repository string `json:"repository"`
}
// Fetch is what a build module's fetch tool is asked: the repository and the full commit, the pull request's ref when only its head carries the commit, the trunk commit to merge onto for a merge preview, the module's directory and named paths, the mesh packages to build against, and the sibling repositories placed beside.
type Fetch struct {
// the trunk commit a merge preview merges onto
Base string `json:"base,omitempty"`
// the sibling repositories placed beside the fetched tree
Beside []FetchBesideItem `json:"beside,omitempty"`
// the full commit
Commit string `json:"commit"`
// the module's directory in the repository ("." for its root), with paths
Dir string `json:"dir,omitempty"`
// the version (a full commit) of each mesh package to build against, by its module path
Packages map[string]string `json:"packages,omitempty"`
// the paths the module names, relative to dir
Paths []string `json:"paths,omitempty"`
// the pull request's ref, when only its head carries the commit
Ref string `json:"ref,omitempty"`
// <owner>/<name>
Repository string `json:"repository"`
}
// LevelAnswerDigestNeedsItem is a type of the contract.
type LevelAnswerDigestNeedsItem struct {
Needs []string `json:"needs,omitempty"`
Package string `json:"package,omitempty"`
}
// LevelAnswerDigestPackagesItem is a type of the contract.
type LevelAnswerDigestPackagesItem struct {
Digest string `json:"digest"`
Package string `json:"package"`
}
// LevelAnswerDigest is a type of the contract.
type LevelAnswerDigest struct {
Beside []string `json:"beside,omitempty"`
JudgedBy string `json:"judged_by,omitempty"`
Level string `json:"level,omitempty"`
Needs []LevelAnswerDigestNeedsItem `json:"needs,omitempty"`
Packages []LevelAnswerDigestPackagesItem `json:"packages,omitempty"`
WithoutTests []string `json:"without_tests,omitempty"`
}
// LevelAnswerKeptItem is a type of the contract.
type LevelAnswerKeptItem struct {
Digest string `json:"digest,omitempty"`
Package string `json:"package,omitempty"`
Tests int64 `json:"tests,omitempty"`
}
// LevelAnswerUnmetItem is a type of the contract.
type LevelAnswerUnmetItem struct {
Needs []string `json:"needs,omitempty"`
Package string `json:"package,omitempty"`
}
// LevelAnswer is one level of a check ask: the digest's answer, the kept verdicts taken, one test result per test step run, and the packages the node could not test.
type LevelAnswer struct {
Digest *LevelAnswerDigest `json:"digest,omitempty"`
Judged string `json:"judged,omitempty"`
Kept []LevelAnswerKeptItem `json:"kept,omitempty"`
Level string `json:"level"`
Tests []any `json:"tests,omitempty"`
Unmet []LevelAnswerUnmetItem `json:"unmet,omitempty"`
}
// Pause is whether the node takes no new ask.
type Pause struct {
// when (RFC 3339 time)
@@ -308,10 +334,9 @@ type Step struct {
Owner string `json:"owner,omitempty"`
Phase string `json:"phase,omitempty"`
// when (RFC 3339 time)
PhaseAt string `json:"phase-at,omitempty"`
Reason string `json:"reason,omitempty"`
// what the step answered
Result any `json:"result,omitempty"`
PhaseAt string `json:"phase-at,omitempty"`
Reason string `json:"reason,omitempty"`
Result *StepResult `json:"result,omitempty"`
// when (RFC 3339 time)
Started string `json:"started"`
// running, passed, failed or refused
@@ -322,37 +347,20 @@ type Step struct {
What string `json:"what,omitempty"`
}
// StepAskBuildArtifactsItem is a type of the contract.
type StepAskBuildArtifactsItem struct {
Artifact string `json:"artifact"`
From string `json:"from,omitempty"`
Seat string `json:"seat,omitempty"`
Version string `json:"version,omitempty"`
}
// StepAskBuildToolchain is a type of the contract.
type StepAskBuildToolchain struct {
Language string `json:"language"`
Recipe string `json:"recipe"`
Version string `json:"version"`
}
// StepAskBuild is a type of the contract.
type StepAskBuild struct {
Artifacts []StepAskBuildArtifactsItem `json:"artifacts"`
// what the build module fetches: the repository, commit and directory, as the indexer states it
Fetch any `json:"fetch,omitempty"`
Fp string `json:"fp,omitempty"`
Module string `json:"module"`
Path string `json:"path,omitempty"`
Publish bool `json:"publish,omitempty"`
Toolchain *StepAskBuildToolchain `json:"toolchain,omitempty"`
Artifacts []AskArtifact `json:"artifacts"`
Fetch *Fetch `json:"fetch,omitempty"`
Fp string `json:"fp,omitempty"`
Module string `json:"module"`
Path string `json:"path,omitempty"`
Publish bool `json:"publish,omitempty"`
Toolchain *ToolchainUsed `json:"toolchain,omitempty"`
}
// StepAskCheck is a type of the contract.
type StepAskCheck struct {
// what the build module fetches: the repository, commit and directory, as the indexer states it
Fetch any `json:"fetch"`
Fetch Fetch `json:"fetch"`
Kept bool `json:"kept,omitempty"`
Levels []string `json:"levels"`
Packages []string `json:"packages,omitempty"`
@@ -363,9 +371,8 @@ type StepAskCheck struct {
// StepAskCompose is a type of the contract.
type StepAskCompose struct {
Dir string `json:"dir"`
// what the build module fetches: the repository, commit and directory, as the indexer states it
Fetch any `json:"fetch"`
Dir string `json:"dir"`
Fetch Fetch `json:"fetch"`
Package string `json:"package"`
Reader string `json:"reader,omitempty"`
// the compose-candidate request
@@ -392,6 +399,26 @@ type StepAsk struct {
V int64 `json:"v,omitempty"`
}
// StepResult is what a step answered, by the kind of ask: a build's artifacts, toolchain, imports and out-of-step modules; a check's fetch and levels; a compose's built, key and verdict; a declined ask's declined, needs and lacks. The fields of the kinds do not meet, so one layout holds the four.
type StepResult struct {
Artifacts []BuiltArtifact `json:"artifacts,omitempty"`
Built bool `json:"built,omitempty"`
// the holder declined the ask: its node lacks what the ask needs
Declined bool `json:"declined,omitempty"`
Fetch *Fetch `json:"fetch,omitempty"`
Imports []string `json:"imports,omitempty"`
Key string `json:"key,omitempty"`
// what the holder's node lacks of it
Lacks []string `json:"lacks,omitempty"`
Levels []LevelAnswer `json:"levels,omitempty"`
// what the declined ask needs
Needs []string `json:"needs,omitempty"`
OutOfStep []string `json:"out-of-step,omitempty"`
Toolchain *ToolchainUsed `json:"toolchain,omitempty"`
// the compose-candidate verdict (the composer's own layout)
Verdict any `json:"verdict,omitempty"`
}
// Toolchain is the toolchain a node reports.
type Toolchain struct {
// when (RFC 3339 time)
@@ -404,6 +431,13 @@ type Toolchain struct {
Version string `json:"version"`
}
// ToolchainUsed is the toolchain a build was made with: the language, the installed version and the build module's recipe.
type ToolchainUsed struct {
Language string `json:"language"`
Recipe string `json:"recipe"`
Version string `json:"version"`
}
// CurrentInput is what current takes.
type CurrentInput struct {
}