DMC-14: a state put answers its bucket's fill beside its revision

mesh/state.put answers {"revision", "fill": {"count", "bytes", "max_bytes"}}, buscalls.Fill's
form, read from the bound stream's info once per put, since the key-value put answers no figures;
a bundle's prune reads it from the put.

Builds: design 47 H2 DMC-14, H-A-350, H-A-386
This commit is contained in:
2026-11-22 00:12:23 +01:00
parent a1c12af8b2
commit ec3fe34afc
3 changed files with 48 additions and 11 deletions
@@ -7,6 +7,8 @@ import (
"testing"
"time"
"git.novox.be/novox/mesh-sdk/go/buscalls"
"github.com/novox/mesh-tools/node-tools/internal/bus"
"github.com/novox/mesh-tools/node-tools/internal/launch"
mt "github.com/novox/mesh-tools/node-tools/internal/meshtest"
@@ -71,16 +73,26 @@ func TestAKeysHistoryIsEveryValueKeptOldestFirst(t *testing.T) {
owner, reader, _ := historyBuses(t)
before := time.Now().Add(-time.Second)
var revisions []uint64
for _, v := range []string{`{"state":"open"}`, `{"state":"fixing"}`, `{"state":"resolved"}`} {
// each put answers the bucket's fill with its revision, buscalls.Fill's form (design 47 H2 DMC-14, H-A-386): the messages
// kept (every value of the key, the bucket keeping 8), their bytes, and no cap (0)
var bytes uint64
for i, v := range []string{`{"state":"open"}`, `{"state":"fixing"}`, `{"state":"resolved"}`} {
raw, err := ask(owner, "put", map[string]any{"state": "issues", "key": "502", "value": json.RawMessage(v)})
if err != nil {
t.Fatal(err)
}
var r struct {
Revision uint64 `json:"revision"`
Revision uint64 `json:"revision"`
Fill *buscalls.Fill `json:"fill"`
}
_ = json.Unmarshal(raw, &r)
revisions = append(revisions, r.Revision)
if r.Fill == nil || r.Fill.Count != uint64(i+1) || r.Fill.Bytes <= bytes || r.Fill.MaxBytes != 0 {
t.Errorf("put %d answered %s, want its revision and the fill of %d messages, more bytes than %d, no cap", i, raw, i+1, bytes)
}
if r.Fill != nil {
bytes = r.Fill.Bytes
}
}
if _, err := ask(owner, "put", map[string]any{"state": "issues", "key": "503", "value": 1}); err != nil {
t.Fatal(err)