RefusedCycle, with its running-version break and its path search, moves from the indexer's internal/index into mesh-delivery-sdk/graph, so the assigner's validate step reads the same rule the indexer's take-in does; the indexer calls the shared function. The rule's table test moves with it; the indexer keeps its test of the trunk catalogues against the shared rule. Builds: design 47 H §745; lead answers H-A-34, H-A-104 (2) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
49 lines
2.9 KiB
Go
49 lines
2.9 KiB
Go
package graph
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
|
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
|
)
|
|
|
|
// A-326, A-333 (design 47 G §49, §51): a cycle through a build module's own inputs is broken at its running version and
|
|
// allowed, as are a cycle of package edges alone and a cycle of delivery edges alone; any other cycle with a build edge is
|
|
// refused, naming every artifact on it (design 47 H-A-104: the rule both the indexer and the validate step read).
|
|
func TestACycleWithABuildEdgeIsRefusedUnlessABuildSeatsRunningVersionBreaksIt(t *testing.T) {
|
|
builder := meshcatalog.CatalogEntry{Module: "mesh-build-go", Artifacts: []meshcatalog.Artifact{{Ref: "mesh-build-go:files", Language: "go"}},
|
|
Acts: []meshcatalog.ActingRule{{Seat: "node-build-go", Step: seatdef.StepBuild, On: "go"}}}
|
|
handActs := meshcatalog.CatalogEntry{Module: "mesh-hand-acts", Artifacts: []meshcatalog.Artifact{{Ref: "mesh-hand-acts:tools", Language: "go"}},
|
|
Edges: []meshcatalog.Edge{{Kind: 3, From: "mesh-build-go:files", To: "mesh-hand-acts:tools", Word: "toolchains", Why: "go"}}}
|
|
trunkCycle := builder
|
|
trunkCycle.Edges = []meshcatalog.Edge{{Kind: 6, From: "mesh-hand-acts:tools", To: "mesh-build-go:files", Word: "seat:mesh-hand-acts.hand-act"}}
|
|
a := meshcatalog.CatalogEntry{Module: "a", Artifacts: []meshcatalog.Artifact{{Ref: "a:go", Language: "go"}},
|
|
Edges: []meshcatalog.Edge{{Kind: 1, From: "b:go", To: "a:go", Word: "packages"}}}
|
|
b := meshcatalog.CatalogEntry{Module: "b", Artifacts: []meshcatalog.Artifact{{Ref: "b:go", Language: "go"}},
|
|
Edges: []meshcatalog.Edge{{Kind: 1, From: "a:go", To: "b:go", Word: "packages"}}}
|
|
noSeat := trunkCycle
|
|
noSeat.Acts = nil
|
|
verbsOnly := meshcatalog.CatalogEntry{Module: "c", Artifacts: []meshcatalog.Artifact{{Ref: "c:go"}}, Edges: []meshcatalog.Edge{{Kind: 6, From: "d:go", To: "c:go"}}}
|
|
verbsBack := meshcatalog.CatalogEntry{Module: "d", Artifacts: []meshcatalog.Artifact{{Ref: "d:go"}}, Edges: []meshcatalog.Edge{{Kind: 4, From: "c:go", To: "d:go"}}}
|
|
for _, c := range []struct {
|
|
name string
|
|
entries []meshcatalog.CatalogEntry
|
|
want []meshcatalog.ArtifactRef
|
|
}{
|
|
{"the trunk catalogue's cycle through a build module's own inputs", []meshcatalog.CatalogEntry{trunkCycle, handActs}, nil},
|
|
{"two artifacts each needing the other's new package, package edges alone", []meshcatalog.CatalogEntry{a, b}, nil},
|
|
{"the same cycle from a module that holds no build seat", []meshcatalog.CatalogEntry{noSeat, handActs},
|
|
[]meshcatalog.ArtifactRef{"mesh-build-go:files", "mesh-hand-acts:tools", "mesh-build-go:files"}},
|
|
{"a cycle of delivery edges alone", []meshcatalog.CatalogEntry{verbsOnly, verbsBack}, nil},
|
|
} {
|
|
entries := map[string]meshcatalog.CatalogEntry{}
|
|
for _, e := range c.entries {
|
|
entries[e.Module] = e
|
|
}
|
|
if got := RefusedCycle(entries); !slices.Equal(got, c.want) {
|
|
t.Errorf("%s: refused %v, want %v", c.name, got, c.want)
|
|
}
|
|
}
|
|
}
|