W12.5: the three build modules answer kept-artifact with the domain SDK's judgement (issue 1966)
Design 47 lines 1888-1906 at b229f5c4 (test 60): the verb sits in every build seat's definition. Its judgement (what may be kept, the kept builds a node holds, the three refusals) is shared code of one domain's modules, so it is the domain SDK's (sdk/buildstep KeptArtifact, ADR 0634 §2): mesh-build-go keeps its store, sweep and tools and drops its own copy of the judgement and its table; mesh-build-node and mesh-build-image keep no build and answer over none, so a module claiming no oci-artifact-registry is refused and the holder is answered not kept. Their manifests serve the verb and invoke seat:mesh-catalog.module, which the judgement asks. Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ (Joined from 42d364fe.) Builds: design 47 G §271, §464 (BLD9) Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -87,7 +87,7 @@ func (m *Module) Puller(steps []StepTool, source buildstep.AskSource) *buildstep
|
||||
|
||||
// SeatTools are the seat's verbs on this node (ADR 0525 §10).
|
||||
func (m *Module) SeatTools(p *buildstep.Puller) []stdio.Tool {
|
||||
return append(buildstep.SeatTools(Seat, "Node", p), m.stepsTool())
|
||||
return append(buildstep.SeatTools(Seat, "Node", p), m.stepsTool(), m.keptArtifactVerb())
|
||||
}
|
||||
|
||||
// StepEndTool ends one step left running (issue 1890); the module's steps state is the one it reads and writes.
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"git.novox.be/novox/mesh-catalog/modules/mesh-build-go/buildstep"
|
||||
sdkstep "git.novox.be/novox/mesh-delivery/sdk/buildstep"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
)
|
||||
|
||||
const askCommit = "0123456789abcdef0123456789abcdef01234567"
|
||||
@@ -123,13 +124,31 @@ func TestManifestTakesTheBuildCapacity(t *testing.T) {
|
||||
t.Error("no settings file")
|
||||
}
|
||||
m0 := &Module{Node: "ace", Capacity: func() int { return 0 }}
|
||||
served := map[string]bool{}
|
||||
served := map[string]stdio.Tool{}
|
||||
for _, tool := range m0.SeatTools(m0.Puller(nil, buildstep.NewFakeAsks())) {
|
||||
served[tool.Name] = true
|
||||
served[tool.Name] = tool
|
||||
}
|
||||
for _, verb := range []string{"current", "pause", "resume"} {
|
||||
if !served[Seat+"."+verb] {
|
||||
for _, verb := range []string{"current", "pause", "resume", "kept-artifact"} {
|
||||
if _, ok := served[Seat+"."+verb]; !ok {
|
||||
t.Errorf("%s.%s is not served", Seat, verb)
|
||||
}
|
||||
}
|
||||
// Design 47 lines 1888-1906 (test 60): kept-artifact is the domain SDK's judgement over no kept build here: the
|
||||
// store's holder is not kept, any other module claims no oci-artifact-registry.
|
||||
m0.Call = func(key string, body any) (json.RawMessage, error) {
|
||||
mod, _ := body.(map[string]any)["module"].(string)
|
||||
man := `{"module":"` + mod + `"}`
|
||||
if mod == "holder" {
|
||||
man = `{"module":"holder","claims":[{"name":"oci-artifact-registry","scope":"mesh"}]}`
|
||||
}
|
||||
return json.RawMessage(`{"module":{"module":"` + mod + `","manifest":` + man + `}}`), nil
|
||||
}
|
||||
for mod, refused := range map[string]string{"holder": "not kept", "web": "claims no oci-artifact-registry"} {
|
||||
if v, ok := served[Seat+".kept-artifact"]; ok {
|
||||
out, _ := v.Run(map[string]any{"module": mod, "fp": "fp1", "digest": strings.Repeat("a", 64)})
|
||||
if a, _ := out.(sdkstep.KeptArtifactAnswer); a.Refused != refused || !strings.Contains(a.Words, mod) {
|
||||
t.Errorf("kept-artifact of %s answered %+v, want refused %q", mod, out, refused)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
// **The artifact store's holder takes its own new build even when its seat is the one broken** (novox/hq design 47,
|
||||
// lines 1888-1906 at b229f5c4; test 60; milestone 47/G W12.5, issue 1966): the verb kept-artifact sits in every build
|
||||
// seat's definition, so this module serves it too. It keeps no build of its own: its answer is the domain SDK's
|
||||
// judgement (sdk/buildstep KeptArtifact, ADR 0634 §2) over no kept build, so a module that claims no
|
||||
// oci-artifact-registry is refused as such and the store's holder is answered not kept here. Who may call it is the
|
||||
// seat definition's (the node-engines alone), granted by the grants part (ADR 0666 §20): this module checks no caller.
|
||||
|
||||
import (
|
||||
seat "git.novox.be/novox/mesh-delivery/contracts/go/seats/nodebuildnode"
|
||||
sdkstep "git.novox.be/novox/mesh-delivery/sdk/buildstep"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
)
|
||||
|
||||
// keptArtifact is the verb kept-artifact's answer for in: this node keeps no build.
|
||||
func (m *Module) keptArtifact(in seat.KeptArtifactInput) sdkstep.KeptArtifactAnswer {
|
||||
return sdkstep.KeptArtifact(in.Module, in.Fp, in.Digest, nil, "", func(module string) (bool, error) {
|
||||
call := m.Call
|
||||
if call == nil {
|
||||
call = stdio.Ask
|
||||
}
|
||||
raw, err := call(sdkstep.CatalogModuleVerb, map[string]any{"module": module})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return sdkstep.ClaimsStoreOf(module, raw)
|
||||
})
|
||||
}
|
||||
|
||||
// keptArtifactVerb serves `<seat>.kept-artifact`.
|
||||
func (m *Module) keptArtifactVerb() stdio.Tool {
|
||||
return stdio.Tool{Name: Seat + "." + seat.VerbKeptArtifact,
|
||||
Description: "Where the build this node kept for the artifact store's holder (the holder of " + sdkstep.StoreSeat +
|
||||
") is. This build module keeps none: it refuses a module that claims no " + sdkstep.StoreSeat +
|
||||
" and answers the holder's build not kept here, naming the module.",
|
||||
Input: map[string]any{"type": "object", "required": []string{"module", "fp", "digest"}, "properties": map[string]any{
|
||||
"module": map[string]any{"type": "string", "description": "the module, the holder of " + sdkstep.StoreSeat},
|
||||
"fp": map[string]any{"type": "string", "description": "its build's fingerprint"},
|
||||
"digest": map[string]any{"type": "string", "description": "the artifact's sha256, 64 lowercase hex digits"}}},
|
||||
Run: func(args map[string]any) (any, error) {
|
||||
str := func(k string) string { s, _ := args[k].(string); return s }
|
||||
return m.keptArtifact(seat.KeptArtifactInput{Module: str("module"), Fp: str("fp"), Digest: str("digest")}), nil
|
||||
}}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func TestManifestKeepsItsStatesClaimsItsBuildSeatAndDeclaresItsHealthTool(t *tes
|
||||
if want := []string{"keys", "pauses", "steps", "toolchains"}; !slices.Equal(states, want) {
|
||||
t.Errorf("state = %v, want %v", states, want)
|
||||
}
|
||||
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || !slices.Equal(m.Claims[0].Serves, []string{"current", "drop", "pause", "resume", "steps"}) {
|
||||
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || !slices.Equal(m.Claims[0].Serves, []string{"current", "drop", "pause", "resume", "steps", "kept-artifact"}) {
|
||||
t.Errorf("claims = %v, want the seat %s alone", m.Claims, Seat)
|
||||
}
|
||||
if !slices.Contains(m.Tools, HealthTool) {
|
||||
|
||||
Reference in New Issue
Block a user