M1: the build modules and the registry say their class and name every store's cap; detected-steps is pruned

Each of the four is core. Every state that named no cap names one, from its
live fill read 2026-11-22 01:4x CET (mesh-broker show, nats_streams on novox):
mesh-build-go steps 16.0 MiB (16,783,695 bytes) -> 128 MiB; mesh-build-node
steps 2.35 MiB (2,463,833 bytes) -> 16 MiB; every other state under 2 MiB ->
8 MiB (largest: distribution holds 1,844,287 bytes, mesh-build-go
detected-steps 868,554, distribution transfers 846,359, findings 668,161, idle
401,736, mesh-build-go pauses 254,366). The Go build module's finding-events is
8 MiB for 7 days. The objects stores already name their caps; none keeps a log.
The Go and Node build modules prune their state detected-steps (each key an
artifact's steps as detected, detected again when gone) at their own writes,
past prune-mark 70 % down to prune-target 50 %, and serve
<module>_state_prune_now and <module>_state_keep; no other state of the four is
prunable (each is truth: running steps, pauses, keys, toolchains, findings,
holds, transfers, windows, mirrors, taken asks).

Builds: design 47 H2 §812, §820; H-A-411 (1), (2), (3), H-A-437
This commit is contained in:
2026-11-22 01:39:49 +01:00
parent 1697b7041c
commit d3d9ff5183
19 changed files with 242 additions and 39 deletions
@@ -0,0 +1,35 @@
package main
import (
"fmt"
"os"
"sync"
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildnode"
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/stateobjects"
)
// ModuleName is this module's name, which its prune tools are named for (stateobjects.PruneTools).
const ModuleName = "mesh-build-node"
// prunedDetected is the state detected-steps, pruned toward its cap at this module's own writes (design 47 H2 §812;
// H-A-411 (2), (3)): past prune-mark of its 8 MiB the oldest keys go down to prune-target, in one journal line. Each key
// is an artifact's steps as detected, which the verb steps detects again when its key is gone. A setting that is no
// percentage is said, and the defaults hold.
var prunedDetected = sync.OnceValue(func() *stdio.PrunedState {
p, err := stdio.PruneSettings()
if err != nil {
fmt.Fprintf(os.Stderr, "the prune of %s keeps its defaults (%d %% to %d %%): %v\n", seat.StateDetectedSteps, stdio.PruneMarkDefault, stdio.PruneTargetDefault, err)
p = stdio.Prune{Mark: stdio.PruneMarkDefault, Target: stdio.PruneTargetDefault}
}
return stdio.State(seat.StateDetectedSteps).Pruned(p)
})
// pruneTools are the module's two prune tools over detected-steps, each written in the hand-act log (H-A-380 (3)).
func pruneTools() []stdio.Tool {
return stateobjects.PruneTools(ModuleName, []stateobjects.Pruning{{Name: seat.StateDetectedSteps, State: prunedDetected()}},
meshhandactsclient.Recorder{Ask: stdio.Ask})
}
@@ -150,7 +150,8 @@ func TestManifestRequiresForgeAccountKeepsKeysAndTakesFilesFromTemplates(t *test
}
keeps := false
for _, s := range m.State {
if s == "keys" {
// Design 47 H2 H-A-411 (2): every state names its cap, 8 MiB.
if e, _ := s.(map[string]any); e["name"] == "keys" && e["max-mib"] == float64(8) {
keeps = true
}
}
@@ -51,7 +51,7 @@ func main() {
SayToolchain: stdio.SeatPublish,
Steps: stdio.State(seat.StateSteps).Put,
ReadSteps: readOf(stdio.State(seat.StateSteps)),
Detected: stdio.State(seat.StateDetectedSteps).Put,
Detected: prunedDetected().Put,
ReadDetected: readOf(stdio.State(seat.StateDetectedSteps)).Get,
ForgetDetected: stdio.State(seat.StateDetectedSteps).Delete,
RecordAct: handActRecorder,
@@ -10,6 +10,7 @@ import (
"strings"
"testing"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/catalogue"
)
@@ -121,10 +122,30 @@ func TestManifestKeepsItsStatesClaimsItsBuildSeatAndDeclaresItsHealthTool(t *tes
if len(m.Claims) != 1 || m.Claims[0].Name != Seat || !slices.Equal(m.Claims[0].Serves, []string{"current", "drop", "pause", "resume", "steps", "kept-artifact", "output", "answer"}) {
t.Errorf("claims = %v, want the seat %s alone", m.Claims, Seat)
}
// Design 47 H2 H-A-411 (2), (3): a core module; its state detected-steps is pruned at its own writes, with the two prune
// tools and the settings prune-mark (70 %) and prune-target (50 %).
if m.Class != catalogue.ClassCore {
t.Errorf("class = %q, want %s", m.Class, catalogue.ClassCore)
}
for _, tool := range []string{ModuleName + "_state_prune_now", ModuleName + "_state_keep"} {
if !slices.Contains(m.Tools, tool) {
t.Errorf("tools = %v lack %s", m.Tools, tool)
}
}
raw, _ := os.ReadFile(filepath.Join(moduleDir, "module.json"))
var doc struct {
Config map[string]struct {
Default json.RawMessage `json:"default"`
} `json:"config"`
}
_ = json.Unmarshal(raw, &doc)
if mark, target := string(doc.Config[stdio.PruneMarkSetting].Default), string(doc.Config[stdio.PruneTargetSetting].Default); mark != "70" || target != "50" {
t.Errorf("prune-mark %s and prune-target %s, want 70 and 50", mark, target)
}
if !slices.Contains(m.Tools, HealthTool) {
t.Errorf("tools = %v lack %s", m.Tools, HealthTool)
}
raw, _ := os.ReadFile(filepath.Join(moduleDir, "module.json"))
raw, _ = os.ReadFile(filepath.Join(moduleDir, "module.json"))
if !strings.Contains(string(raw), `"tool": "`+HealthTool+`"`) {
t.Errorf("runtime-health does not name %s", HealthTool)
}
@@ -305,7 +326,7 @@ func TestManifestRequiresTheStepsStateWithItsObjectsStore(t *testing.T) {
t.Fatal(err)
}
for _, want := range []map[string]any{
{"name": "steps", "storage": "key-value", "template": "state", "options": map[string]any{"ttl-seconds": float64(172800), "objects-max-mib": float64(256)}},
{"name": "steps", "storage": "key-value", "template": "state", "options": map[string]any{"ttl-seconds": float64(172800), "objects-max-mib": float64(256), "max-mib": float64(16)}},
{"name": "outputs", "storage": "object-store", "template": "objects", "options": map[string]any{"max-mib": float64(1024), "max-age-days": float64(7)}},
} {
if !slices.ContainsFunc(doc.Requires, func(r any) bool { return reflect.DeepEqual(r, any(want)) }) {
@@ -117,7 +117,7 @@ func TestANodeThatCannotBeRunRefusesEveryStepAndHealthIsUnhealthy(t *testing.T)
{Name: "short_probe", Run: run},
}, (&Module{}).StepTools()...)
for _, tool := range m.Tools(steps) {
if tool.Name == StatusTool || tool.Name == HealthTool || tool.Name == StepReadTool || tool.Name == StepsReadTool || tool.Name == ToolchainsReadTool || tool.Name == ReleaseTool || tool.Name == StepEndTool {
if strings.HasPrefix(tool.Name, ModuleName+"_state_") || tool.Name == StatusTool || tool.Name == HealthTool || tool.Name == StepReadTool || tool.Name == StepsReadTool || tool.Name == ToolchainsReadTool || tool.Name == ReleaseTool || tool.Name == StepEndTool {
continue
}
var reason string
@@ -43,6 +43,7 @@ func (m *Module) Tools(steps []StepTool) []stdio.Tool {
tools = append(tools, m.ReadTools()...)
tools = append(tools, steprun.StepEndTool(StepEndTool, m.Node, m.stepScan(), m.Held))
tools = append(tools, m.releaseTool())
tools = append(tools, pruneTools()...)
return append(tools,
stdio.Tool{Name: StatusTool,
Description: "What the Node build module is on this machine: the Node version its recipe builds with and the one installed, " +