Record the inputs of a build's source fingerprint in its build record (issue 1215)

This commit is contained in:
2026-10-19 11:54:21 +02:00
parent 8da2619920
commit 68088ec782
13 changed files with 204 additions and 16 deletions
+5
View File
@@ -5,6 +5,8 @@ import (
"strconv"
"strings"
"time"
"git.novox.be/novox/mesh-sdk/go/delivery"
)
// Asking a machine to build a module, and hearing what came out.
@@ -410,6 +412,9 @@ type BuildResult struct {
// byte-reproducible. Empty from a builder that predates it, or where the source does not pin the
// build; then only identical artifacts make a rebuild no move.
SourceFingerprint string `json:"source-fingerprint,omitempty"`
// SourceInputs are what SourceFingerprint was computed from (novox/hq ADR 0437 §5, issue 1215), as encoding/json
// writes the SDK's type; also set where the source does not pin the build.
SourceInputs *delivery.SourceInputs `json:"source-inputs,omitempty"`
// Delivery is the how-manyth time the queue handed this ask out (BuildStart.Delivery): more than 1
// says the outcome is from a run started again after an earlier taker left it (novox/hq issue 594).
+35
View File
@@ -0,0 +1,35 @@
package link
import (
"encoding/json"
"reflect"
"testing"
"git.novox.be/novox/mesh-sdk/go/delivery"
)
// 1215/AC4: the builder's result on the wire carries the inputs, under source-inputs, and reads back unchanged.
func TestABuildResultCarriesTheSourceInputs(t *testing.T) {
in := &delivery.SourceInputs{Module: "m", Tree: "t", Bases: []string{"x@sha256:a"},
Contexts: map[string]string{"c": "narrow:1"}, Toolchains: map[string]string{"c": "go sha256:b 01"}, Unpinned: "why"}
raw, err := json.Marshal(BuildResult{ID: "build-1", SourceInputs: in})
if err != nil {
t.Fatal(err)
}
var wire map[string]json.RawMessage
if err := json.Unmarshal(raw, &wire); err != nil || wire["source-inputs"] == nil {
t.Fatalf("the result on the wire has no source-inputs: %s", raw)
}
var back BuildResult
if err := json.Unmarshal(raw, &back); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(back.SourceInputs, in) {
t.Errorf("read back as %+v, not %+v", back.SourceInputs, in)
}
raw, _ = json.Marshal(BuildResult{ID: "build-2"})
wire = nil
if err := json.Unmarshal(raw, &wire); err != nil || wire["source-inputs"] != nil {
t.Errorf("a result with none writes source-inputs: %s", raw)
}
}