The checking program answers only the head seat definitions the reader does not hold as they are (issue 1921, milestone 47/G, review round 1 finding 3)

The whole heads' list is 342 KB for this group, over the 256 KiB a run's answer
may be. The checker hands the program its reader's seat-to-digest list (5.6 KB)
and lays the answer, the new or changed definitions, over its own list.

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
2026-11-07 03:17:56 +01:00
parent df56af0765
commit 112ca63f38
4 changed files with 98 additions and 5 deletions
@@ -3,6 +3,7 @@ package main
import (
"bytes"
"encoding/json"
"io/fs"
"os"
"path/filepath"
"reflect"
@@ -138,7 +139,39 @@ func TestTheCheckingProgramAnswersTheVerdictOfItsFacts(t *testing.T) {
a.Verdict.Failures[1].Words != "novox/x#3 has files in conflict: go.mod" || a.Verdict.Machines[0] != "laptop" || a.Verdict.Levels[buildstep.LevelUnit].Run != 3 {
t.Errorf("%s: the verdict %+v, want %+v", name, a.Verdict, want)
}
} // Review round 1 of milestone 47/B0: the module graph's cycle rule is the program's (ADR 0603 §2, ADR 0656 §5), over the
}
// Review finding 3 of milestone 47/G: the heads of a real group carry every seat definition the reader holds, unchanged
// (this repository's own contracts, laid as its head): the answer leaves them all to the checker's list and stays
// within the bound a run's answer is written under (buildstep.RunInputBound), where the whole list would not.
t.Run("heads carrying every definition the reader holds unchanged answer none of them, within the bound", func(t *testing.T) {
real := under{prefix: "novox/mesh-delivery", fs: os.DirFS("../../../..")}
group := rules.Facts{V: rules.FactsVersion, Members: []rules.Member{{Repository: "novox/mesh-delivery", Head: "h"}}}
whole, err := rules.SeatsOf(real, group)
if err != nil || len(whole.Seats) < 10 {
t.Fatalf("the repository's own definitions: %d, %v", len(whole.Seats), err)
}
group.SeatDigests = map[string]string{}
for _, raw := range whole.Seats {
var d struct{ Seat string }
_ = json.Unmarshal(raw, &d)
group.SeatDigests[d.Seat] = rules.SeatDigest(raw)
}
same, err := rules.SeatsOf(real, group)
answer, _ := json.Marshal(same)
if err != nil || len(same.Seats) != 0 || same.Same != len(whole.Seats) || len(answer) > buildstep.RunInputBound {
t.Errorf("unchanged heads answer %d definitions (%d the same), %d bytes; want none, all %d the same, within %d: %v",
len(same.Seats), same.Same, len(answer), len(whole.Seats), buildstep.RunInputBound, err)
}
// One definition the heads change is answered alone.
for seat := range group.SeatDigests {
group.SeatDigests[seat] = "changed"
break
}
if one, err := rules.SeatsOf(real, group); err != nil || len(one.Seats) != 1 {
t.Errorf("one changed definition: answered %d, %v", len(one.Seats), err)
}
})
// Review round 1 of milestone 47/B0: the module graph's cycle rule is the program's (ADR 0603 §2, ADR 0656 §5), over the
// edges the running checker gathers. A cycle the change makes fails; one the trunk has among the same modules is noted.
web, mail := rules.Edge{From: "web", To: "mail", Kind: rules.EdgeAwaits}, rules.Edge{From: "mail", To: "web", Kind: rules.EdgeAwaits}
only := func(e rules.Edge, where string) rules.Edge { e.Only = where; return e }
@@ -165,3 +198,19 @@ func TestTheCheckingProgramAnswersTheVerdictOfItsFacts(t *testing.T) {
}
}
}
// under is a directory laid at a repository's path of the heads, as the build node lays a head.
type under struct {
prefix string
fs fs.FS
}
func (u under) Open(name string) (fs.File, error) {
if name == u.prefix {
return u.fs.Open(".")
}
if rest, ok := strings.CutPrefix(name, u.prefix+"/"); ok {
return u.fs.Open(rest)
}
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
}