Merge remote-tracking branch 'origin/main' into feat/delivery-watch
mesh/repo-check head ac79e29319ee merged into trunk 5939bbdefe5a — pass: its merge-check.sh passed
mesh/merge-gate head ac79e29319ee merged into trunk 5939bbdefe5a — pass: group feat/delivery-watch composed: every machine composes with the change as it d…
mesh/delivery delivered
mesh/delivery-group group feat/delivery-watch delivered: every member is delivered

# Conflicts:
#	cmd/mesh-controller/doctor.go
This commit is contained in:
2026-10-19 00:53:02 +02:00
17 changed files with 990 additions and 16 deletions
+4 -2
View File
@@ -462,7 +462,9 @@ func EnsureLeaseBucket(ctx context.Context, js jetstream.JetStream) error {
}
// HaveBucketConfig is the options of the have bucket (novox/hq ADR 0429 §1): delivery.HaveHistory revisions of each
// key, no age, a value under a kilobyte (a have is JSON of about 500 bytes), 64 MiB on disk like the assignments.
// key, no age, 64 MiB on disk like the assignments. A module's have is JSON of about 500 bytes, but a node's own key
// carries its whole facts (its profile among them), several kilobytes on a desktop: a value is as large as the chain's
// buckets take, since a value is never cut (novox/hq ADR 0408 §6, issue 1162).
func HaveBucketConfig() jetstream.KeyValueConfig {
return jetstream.KeyValueConfig{
Bucket: delivery.HaveBucket,
@@ -470,7 +472,7 @@ func HaveBucketConfig() jetstream.KeyValueConfig {
"own facts) (novox/hq ADR 0429, design 47): written by each machine's node-engine under its own node's keys " +
"alone, never by the controller; read by the delivery view and the watchman",
History: delivery.HaveHistory,
MaxValueSize: 4 << 10,
MaxValueSize: ChainValueBytes,
MaxBytes: 64 << 20,
Storage: jetstream.FileStorage,
}
+9
View File
@@ -104,3 +104,12 @@ func TestAModuleReadingHaveAssignmentsAndBuildsReadsAndWritesNone(t *testing.T)
}
}
}
// A node's own key carries its whole facts (its profile among them), several kilobytes on a desktop: the have
// bucket takes any value the chain's buckets take, since a value is never cut (novox/hq ADR 0408 §6, issue 1162).
// 1162/AC1
func TestTheHaveBucketTakesAValueAsLargeAsTheChains(t *testing.T) {
if got := HaveBucketConfig().MaxValueSize; got != ChainValueBytes {
t.Fatalf("the have bucket takes values up to %d bytes, the chain's up to %d", got, ChainValueBytes)
}
}
+10
View File
@@ -84,6 +84,16 @@ func (i *Inventory) AloneMerges(ctx context.Context) ([]BatchedMerge, error) {
return i.chainAloneMerges(ctx, c)
}
// WaitingMerges is every merge no plan answers that is not walked alone: kept, and waiting for something else to
// happen to it (a first merge into a repository, waiting for mesh-delivery's word on it, issue 1146).
func (i *Inventory) WaitingMerges(ctx context.Context) ([]BatchedMerge, error) {
c, err := i.theChain(ctx)
if err != nil {
return nil, err
}
return i.chainWaitingMerges(ctx, c)
}
// AnswerMerge moves a merge to the plan that answers it now; an empty plan with alone leaves it waiting to
// be walked on its own commit.
func (i *Inventory) AnswerMerge(ctx context.Context, repository, commit, plan string, alone bool) error {
+16
View File
@@ -452,6 +452,22 @@ func (i *Inventory) chainAloneMerges(ctx context.Context, c *chain.Chain) ([]Bat
return out, nil
}
// chainWaitingMerges is every merge no plan answers that waits and is not walked alone, the newest first.
func (i *Inventory) chainWaitingMerges(ctx context.Context, c *chain.Chain) ([]BatchedMerge, error) {
w, err := i.chainWinners(ctx, c)
if err != nil {
return nil, err
}
var out []BatchedMerge
for _, h := range w {
if h.m.Waiting && !h.m.Alone {
out = append(out, batchedOf(h))
}
}
sortMerges(out, true)
return out, nil
}
// pendingMerge is a merge added to a plan that is not saved yet: carried until that plan's save writes it.
type pendingMerge struct {
plan string
+33
View File
@@ -0,0 +1,33 @@
package inventory
import (
"context"
"testing"
"time"
)
// A merge no plan answers waits, and is listed as waiting until it is answered where it is kept (novox/hq issue 1146):
// what a first merge into a new repository does while it waits for mesh-delivery's word.
func TestAMergeNoPlanAnswersIsListedWaitingUntilItIsAnswered(t *testing.T) {
inv, c := anInventoryOnTheChain(t)
ctx := context.Background()
now := time.Now().UTC()
if added, err := inv.chainAddMerge(ctx, c, BatchedMerge{Repository: "novox/mesh-delivery", Branch: "main", Commit: "c1",
Merged: now, Heard: now}); err != nil || !added {
t.Fatalf("added %v, %v", added, err)
}
waiting, err := inv.chainWaitingMerges(ctx, c)
if err != nil || len(waiting) != 1 || waiting[0].Commit != "c1" {
t.Fatalf("waiting %+v, %v", waiting, err)
}
move := []MergeMove{{Repository: "novox/mesh-delivery", Commit: "c1", Plan: WaitingRecord}}
if err := inv.chainSavePlans(ctx, c, nil, move); err != nil {
t.Fatal(err)
}
if waiting, err = inv.chainWaitingMerges(ctx, c); err != nil || len(waiting) != 0 {
t.Fatalf("answered, it still waits: %+v, %v", waiting, err)
}
if _, known, err := inv.chainMergeOf(ctx, c, "novox/mesh-delivery", "c1"); err != nil || !known {
t.Fatalf("an answered merge is no longer kept: %v %v", known, err)
}
}