Merge branch 'feat/47-H2-corrections-a' into feat/47-H2-corrections

This commit is contained in:
2026-11-25 19:11:29 +01:00
4 changed files with 34 additions and 14 deletions
@@ -33,6 +33,7 @@ import (
"time"
nodeengine "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
runnerclient "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient"
runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
)
@@ -58,22 +59,13 @@ func decodePipelineStarted(body json.RawMessage, _ time.Time) ([]StepOutcome, er
return nil, namesSource(p.Branch, p.Source, p.Run)
}
// decodeMoverAdded reads a mover-added with the contract's decoder, and refuses one naming none or two of from, caller and
// decodeMoverAdded reads a mover-added with the client's decoder, which refuses one naming none or two of from, caller and
// take-in (design 47 H2 H-A-645).
func decodeMoverAdded(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
m, _, err := runner.DecodeMoverAddedEvent(body)
m, err := runnerclient.MoverAdded(body)
if err != nil {
return nil, err
}
named := 0
for _, given := range []bool{m.From != "", m.Caller != "", m.TakeIn != 0} {
if given {
named++
}
}
if named != 1 {
return nil, fmt.Errorf("a mover-added names exactly one of from, caller and take-in, and this names %d", named)
}
if m.Module == "" || m.Pipeline == "" {
return nil, fmt.Errorf("a mover-added names no module or pipeline")
}
@@ -160,8 +152,8 @@ func (h *Holder) Follow(event string, body json.RawMessage) error {
}
return h.pipelineStarted(p)
case runner.EventMoverAdded:
var m runner.MoverAddedEvent
if err := json.Unmarshal(body, &m); err != nil {
m, err := runnerclient.MoverAdded(body)
if err != nil {
return nil
}
return h.moverAdded(m)
@@ -381,12 +381,19 @@ func TestARecordsEndCountIsSaidAtEachEndAndAHigherPipelineEndReopensIt(t *testin
}
// A mover-added counts its mover in the record its pipeline's key names; one naming none or two of its sources is refused.
hear(t, c, "mesh-pipeline-runner.mover-added.main.1", "", `{"v":1,"pipeline":"main.1","revision":4,"module":"extra","fingerprint":"x","from":"main.1.again.1"}`)
var refusals []string
c.Logf = func(format string, a ...any) { refusals = append(refusals, fmt.Sprintf(format, a...)) }
for _, bad := range []string{
`{"v":1,"pipeline":"main.1","revision":4,"module":"never","fingerprint":"y"}`,
`{"v":1,"pipeline":"main.1","revision":4,"module":"never","fingerprint":"y","from":"a","take-in":3}`,
} {
hear(t, c, "mesh-pipeline-runner.mover-added.main.1", "", bad)
}
// Each is refused by the client's decoder and said (AC-DC2c, H-A-645).
if len(refusals) != 2 || !strings.Contains(refusals[0]+refusals[1], "meshpipelinerunnerclient: mover-added names exactly one of from, caller and take-in, not 0") ||
!strings.Contains(refusals[1], "not 2") {
t.Errorf("the refusals said %q: want the client decoder's, one naming none and one naming two", refusals)
}
if _, ok := r.Entries[EntryKey("extra", "x", "")]; !ok {
t.Errorf("a mover-added counted no mover: %v", r.Entries)
}
+1
View File
@@ -9,6 +9,7 @@ require (
git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery v0.0.0-00010101000000-000000000000
git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner v0.0.0-00010101000000-000000000000
@@ -672,6 +672,20 @@ func TestTheBusModuleRunsWhole(t *testing.T) {
if !ok {
t.Fatal("the bus holds no rc_records_snapshot")
}
// The snapshot store as a keeper before H2 made it: dropping its oldest when full, which the asked form refuses.
old := snap.Config
old.Discard = jetstream.DiscardOld
if _, err := js.UpdateStream(ctx, old); err != nil {
t.Fatal(err)
}
// A message in the history, which the shorter age asked keeps (it is younger than the age).
hist, ok := held("rc_records")
if !ok || hist.Config.MaxAge != 90*24*time.Hour {
t.Fatalf("the history is %+v: want its age 90 days", hist)
}
if _, err := js.Publish(ctx, strings.TrimSuffix(hist.Config.Subjects[0], ">")+"i1", []byte("x")); err != nil {
t.Fatal(err)
}
for i := range 3 {
if _, err := js.Publish(ctx, strings.TrimSuffix(snap.Config.Subjects[0], ">")+fmt.Sprintf("k%d", i), []byte("x")); err != nil {
t.Fatal(err)
@@ -687,7 +701,7 @@ func TestTheBusModuleRunsWhole(t *testing.T) {
}
}
ending := plain
ending.Configuration = map[string]json.RawMessage{"ended-days": json.RawMessage("30"), "max-age-days": json.RawMessage("90")}
ending.Configuration = map[string]json.RawMessage{"ended-days": json.RawMessage("30"), "max-age-days": json.RawMessage("30")}
accepted("rc", 21, ending)
eventually(t, "drifted rc records", saidHas("drifted rc records"))
r := keeper.Request{ID: "rc1", Verb: keeper.VerbRecreate, Module: "rc", Local: "records", Caller: "person.jo", Why: "take the lifetimes", At: time.Now(), AskExpires: time.Now().Add(keeper.AskLasts)}
@@ -713,6 +727,12 @@ func TestTheBusModuleRunsWhole(t *testing.T) {
eventually(t, "recreated rc records", saidHas("recreated rc records"))
snap, _ = held("rc_records_snapshot")
state, _ := held("KV_rc_records_state")
if hist, _ = held("rc_records"); hist.Config.MaxAge != 30*24*time.Hour || hist.State.Msgs != 1 {
t.Errorf("the history holds %d messages (want 1) at the age %s (want 30 days): changed in place to the shorter age", hist.State.Msgs, hist.Config.MaxAge)
}
if snap.Config.Discard != jetstream.DiscardNew {
t.Errorf("the snapshot store still drops its oldest when full (discard %v): the refusal when full turned on in place", snap.Config.Discard)
}
if snap.State.Msgs != 3 || state.State.Msgs != 2 || !snap.Config.AllowMsgTTL || !state.Config.AllowMsgTTL {
t.Errorf("the snapshot store holds %d messages (want 3, AllowMsgTTL %v), the state bucket %d keys (want 2, AllowMsgTTL %v): changed in place",
snap.State.Msgs, snap.Config.AllowMsgTTL, state.State.Msgs, state.Config.AllowMsgTTL)