ADR 0593 §11: the controller's repository holds nothing that builds once route-proxy moves, so its sibling rule goes; its tests fold into the sibling test, which now uses mesh-sdk's rule. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
112 lines
4.5 KiB
Go
112 lines
4.5 KiB
Go
package check
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
)
|
|
|
|
// BesideRef is a sibling repository a repository's tests read, placed beside the fetched tree as a plain directory (ADR
|
|
// 0484 clause 4). Ref names the pull request's head when the commit is only there.
|
|
type BesideRef struct {
|
|
Repository string `json:"repository"`
|
|
Commit string `json:"commit"`
|
|
Ref string `json:"ref,omitempty"`
|
|
// atTrunk says the sibling was read at its trunk's head, so a move of that trunk puts the verdict out of date and is
|
|
// carried (novox/hq ADR 0548 §6). Never sent: the node-engine at the commit the mesh runs, mesh-sdk at a pin and a
|
|
// group's member at its head do not move with a trunk.
|
|
atTrunk bool
|
|
// runs says the sibling was read at the commit the mesh runs (the node-engine, the indexer's record of mesh-host): a new
|
|
// running commit puts the verdict out of date and is carried (ADR 0548 §6). Never sent.
|
|
runs bool
|
|
}
|
|
|
|
// NodeEngineModule is the module whose running commit the node-engine sibling is read at.
|
|
const NodeEngineModule = nodeEngineModule
|
|
|
|
const (
|
|
catalogueRepository = "novox/mesh-catalog"
|
|
nodeEngineRepo = "novox/mesh-host"
|
|
nodeEngineModule = "mesh-host"
|
|
)
|
|
|
|
// besideRules are the repositories each core repository's tests read, as the tests state it (mesh-sdk go/internal/beside
|
|
// beside.go): the catalogue, the node-engine, the SDK, and the delivery's pinned forge dependencies (mesh-catalog
|
|
// checks/deps). Which commit of each is besideCommit's rule. No repository's tests read the controller, which ended by its
|
|
// unassignment (novox/hq ADR 0590, issue 1126), and its repository is emptied and archived (ADR 0593 §11), so it has no
|
|
// siblings placed either.
|
|
var besideRules = map[string][]string{
|
|
nodeEngineRepo: {catalogueRepository, SDKRepository},
|
|
SDKRepository: {catalogueRepository, nodeEngineRepo},
|
|
catalogueRepository: {SDKRepository},
|
|
"novox/mesh-delivery": {SDKRepository, catalogueRepository},
|
|
}
|
|
|
|
// besideFor are the siblings a pull request's tests read (ADR 0484 clause 4): the node-engine at the commit the mesh runs
|
|
// (the commit of the indexer's module mesh-host, its trunk head when none is known); any other sibling, the catalogue
|
|
// included, at the head of the group's pull request for it when the group holds one, else at its trunk, since a group's
|
|
// check judges each member against the group's heads (ADR 0482 §2, ADR 0573 §4; issue 1126: a judge a group changed was
|
|
// judged against the catalogue's trunk). And first, the change's own repository at the trunk it is merged onto, so a test
|
|
// comparing a shrink-only list with the trunk's copy reads it at $MESH_CHECK_BESIDE/<name> (issue 1887 A12, ADR 0529 §2):
|
|
// that is where a catalogue change's own trunk copy is placed.
|
|
func (j *Examiner) besideFor(ctx context.Context, c *Case, p Pull) ([]BesideRef, error) {
|
|
var heads map[string]string
|
|
if j.Trunks != nil {
|
|
heads = j.Trunks.Heads()
|
|
}
|
|
var out []BesideRef
|
|
if p.Trunk != "" {
|
|
out = append(out, BesideRef{Repository: p.Repository, Commit: p.Trunk})
|
|
}
|
|
for _, repo := range besideRules[p.Repository] {
|
|
switch {
|
|
case repo == nodeEngineRepo:
|
|
commit := ""
|
|
if j.Runs != nil {
|
|
commit = j.Runs.CommitOf(nodeEngineModule)
|
|
}
|
|
atTrunk := false
|
|
if commit == "" {
|
|
commit, atTrunk = heads[repo], true
|
|
}
|
|
if commit != "" {
|
|
// Named in the verdict either way (ADR 0548 §6, issue 568's own example): at the commit the mesh runs, a new
|
|
// running commit puts the verdict out of date; at the trunk, a trunk move does (Checker.besideNow).
|
|
out = append(out, BesideRef{Repository: repo, Commit: commit, atTrunk: atTrunk, runs: !atTrunk})
|
|
}
|
|
default:
|
|
if member := c.member(repo); member != nil {
|
|
out = append(out, BesideRef{Repository: repo, Commit: member.Head, Ref: refOf(member.Number)})
|
|
} else if head := heads[repo]; head != "" {
|
|
out = append(out, BesideRef{Repository: repo, Commit: head, atTrunk: true})
|
|
}
|
|
}
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *Case) member(repository string) *Pull {
|
|
for i := range c.Pulls {
|
|
if c.Pulls[i].Repository == repository {
|
|
return &c.Pulls[i]
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func refOf(number int) string {
|
|
if number <= 0 {
|
|
return ""
|
|
}
|
|
return "refs/pull/" + strconv.Itoa(number) + "/head"
|
|
}
|
|
|
|
// besideAtTrunk are the siblings of refs read at their trunk's head that the case does not merge, by repository: what a
|
|
// verdict names as Beside (ADR 0548 §6).
|
|
func besideAtTrunk(c *Case, refs []BesideRef, into map[string]string) {
|
|
for _, r := range refs {
|
|
if _, merged := c.Trunk[r.Repository]; (r.atTrunk || r.runs) && !merged {
|
|
into[r.Repository] = r.Commit
|
|
}
|
|
}
|
|
}
|