Grants: a seat-form read, view or view tool resolves to the assigned claimant when no holder is on record (A-398): the builder's reads of the build seats' steps stayed unresolved and refused
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package grants
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
)
|
||||
|
||||
// A seat-form read resolves to the holder on record, else to the assigned module whose manifest claims the seat (A-398):
|
||||
// on 2026-11-14 the builder's `seat:node-build-go.steps` stayed unresolved while no assignments held the build seat, so
|
||||
// the bus refused it the steps and no build could start.
|
||||
func TestSeatReadsResolveToTheClaimant(t *testing.T) {
|
||||
in := Inputs{
|
||||
Assigned: map[string][]string{"shanks": {"mesh-delivery-builder", "mesh-build-go"}},
|
||||
Manifests: map[string]catalogue.Manifest{
|
||||
"mesh-delivery-builder": {Module: "mesh-delivery-builder"},
|
||||
"mesh-build-go": {Module: "mesh-build-go", Claims: []catalogue.Claim{{Name: "node-build-go"}}},
|
||||
},
|
||||
}
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
holders []catalogue.Held
|
||||
want string
|
||||
}{
|
||||
{"no holder on record: the claimant", nil, "mesh-build-go.steps"},
|
||||
{"a holder on record wins", []catalogue.Held{{Claim: "node-build-go", Node: "ace", Module: "other-build"}}, "other-build.steps"},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
got := resolveSeatReads([]string{"seat:node-build-go.steps"}, withClaimants(c.holders, in))
|
||||
if !slices.Equal(got, []string{c.want}) {
|
||||
t.Fatalf("reads = %v, want [%s]", got, c.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,9 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) {
|
||||
// node-engine's too, read with the manifest each node runs, else the trunk's. Composed, never recorded.
|
||||
holders, passed := holdersAfterPass(in)
|
||||
gaps = append(gaps, passed...)
|
||||
// A seat-form read, view or view tool resolves to the holder on record, else to the assigned module whose manifest claims
|
||||
// the seat (lead answer A-398); holds keep heldWherePlaced's own rule.
|
||||
readHolders := withClaimants(holders, in)
|
||||
values := func(provider, setting string) []any {
|
||||
var vs []any
|
||||
for _, node := range in.Nodes {
|
||||
@@ -104,9 +107,9 @@ func records(in Inputs, union bool) (buscompose.Records, []Gap) {
|
||||
continue
|
||||
}
|
||||
declare := func(m catalogue.Manifest) buscompose.Declared {
|
||||
m.Invokes = slices.Concat(m.Invokes, seatViewTools(m.Consumes, holders))
|
||||
m.Consumes = resolveSeatViews(m.Consumes, holders)
|
||||
m.Reads = resolveSeatReads(m.Reads, holders)
|
||||
m.Invokes = slices.Concat(m.Invokes, seatViewTools(m.Consumes, readHolders))
|
||||
m.Consumes = resolveSeatViews(m.Consumes, readHolders)
|
||||
m.Reads = resolveSeatReads(m.Reads, readHolders)
|
||||
d := declaredFor(m, seats, declarers)
|
||||
if len(in.Placed) > 0 {
|
||||
d.Holds = heldWherePlaced(d.Holds, holders, node, m.Module)
|
||||
@@ -709,6 +712,31 @@ func holdersAfterPass(in Inputs) ([]catalogue.Held, []Gap) {
|
||||
return held, gaps
|
||||
}
|
||||
|
||||
// withClaimants is holders and, for each seat no holder names, the first module assigned to a node (nodes and modules in
|
||||
// order) whose manifest (the trunk's, else the running build of a held module) claims it (lead answer A-398; the operator,
|
||||
// 2026-11-14: who holds a seat follows from the module graph and the assignments). Pure.
|
||||
func withClaimants(holders []catalogue.Held, in Inputs) []catalogue.Held {
|
||||
out := slices.Clone(holders)
|
||||
for _, node := range slices.Sorted(maps.Keys(in.Assigned)) {
|
||||
for _, module := range slices.Sorted(slices.Values(in.Assigned[node])) {
|
||||
m, ok := in.Manifests[module]
|
||||
if !ok {
|
||||
m, ok = in.Held[module]
|
||||
}
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
for _, c := range m.Claims {
|
||||
if slices.ContainsFunc(out, func(h catalogue.Held) bool { return sameSeat(h.Claim, c.Name) }) {
|
||||
continue
|
||||
}
|
||||
out = append(out, catalogue.Held{Claim: c.Name, Scope: c.Scope, Node: node, Module: module})
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// ranEntries is the reader of entries SeatsToPassOn takes (design 47 G §459): the manifest of a fingerprint a node-engine
|
||||
// said it runs, and a module's manifest where none was heard: the trunk's, else the running build of a held module.
|
||||
type ranEntries struct{ in Inputs }
|
||||
|
||||
Reference in New Issue
Block a user