GT1 gate-wants-in-order: the gate keeps want-revision on an entry and reads a wanted with the contract's decoder

A wanted at a want-revision below the one held for that node and module changes nothing; a wanted with a field
the contract does not know is applied, the field left unread; a wanted with no want-revision is the earlier form,
applied as before and leaving the held revision unchanged. The mover type's entry carries want-revision.

Builds: design 47 H §832 5., H-A-832, H-A-842, H-A-839, H-A-865 (issue 1984 AC-832g, AC-824f)
This commit is contained in:
2026-11-27 02:59:08 +01:00
parent ae8f070916
commit 25c4c52396
4 changed files with 48 additions and 8 deletions
@@ -198,6 +198,9 @@ type RecordEntry struct {
Module string `json:"module"`
Fingerprint string `json:"fingerprint"`
Node string `json:"node,omitempty"`
// WantRevision is the revision of the want's key the entry was written from; a want at a lower one for the same node
// and module changes nothing (design 47 H §832 5.).
WantRevision int64 `json:"want-revision,omitempty"`
}
// EntryKey is the key of an entry: its module, its fingerprint and its node.
@@ -92,8 +92,8 @@ func decodeWait(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
}
func decodeWanted(body json.RawMessage, _ time.Time) ([]StepOutcome, error) {
var w wants.WantedEvent
if err := strictly(body, &w); err != nil {
w, _, err := wants.DecodeWantedEvent(body)
if err != nil {
return nil, err
}
if w.Module == "" || w.Node == "" {
@@ -326,7 +326,12 @@ func (h *Holder) wantWritten(w wants.WantedEvent) error {
if r == nil || r.Ended != nil {
return nil
}
if err := h.Records.AddEntry(r, RecordEntry{Module: w.Module, Fingerprint: w.Fp, Node: w.Node}); err != nil {
for _, e := range r.Entries {
if e.Module == w.Module && e.Node == w.Node && w.WantRevision > 0 && e.WantRevision > w.WantRevision {
return nil
}
}
if err := h.Records.AddEntry(r, RecordEntry{Module: w.Module, Fingerprint: w.Fp, Node: w.Node, WantRevision: w.WantRevision}); err != nil {
return err
}
at := h.Now().UTC()
@@ -103,6 +103,21 @@ func TestARecordFollowsItsPipelineToTheMachines(t *testing.T) {
if _, ok := r.Entries[EntryKey("app", "f", "novox")]; ok {
t.Fatal("a removed want is an entry")
}
// Design 47 H2b §832 5. (1984/AC-832g, H-A-832, H-A-842): a want at a want-revision below the one held for that node and
// module changes nothing, a repeat of an applied body writes nothing new, and a field the contract does not know is
// left unread.
for _, w := range []string{
`{"v":1,"node":"ace","module":"app","fp":"f","pipeline":"main.1","source":1,"revision":12,"want-revision":9,"future":1}`,
`{"v":1,"node":"ace","module":"app","fp":"f2","pipeline":"main.1","source":1,"revision":12,"want-revision":8}`,
} {
hear(t, c, "mesh-wants.wanted.x.app", "", w)
}
if e, ok := r.Entries[EntryKey("app", "f", "ace")]; !ok || e.WantRevision != 9 {
t.Fatalf("the want at want-revision 9 is %+v: applied with its unknown field unread", e)
}
if _, ok := r.Entries[EntryKey("app", "f2", "ace")]; ok {
t.Fatal("a want at want-revision 8, below the 9 held, is an entry")
}
hear(t, c, "node-engine.running.ace.app", "ace", `{"v":1,"at":"2026-11-20T03:05:00Z","module":"app","node":"ace","fingerprint":"f","healthy":true}`)
hear(t, c, "node-engine.running.g14.app", "g14", `{"v":1,"at":"2026-11-20T03:05:00Z","module":"app","node":"g14","fingerprint":"f","healthy":true}`)
if o := r.Outcomes[OutcomeKey("app", "f", "g14", StepRunning)]; o.Outcome != OutcomeRunning || r.Ended != nil || len(*ended) != 0 {
@@ -112,6 +127,11 @@ func TestARecordFollowsItsPipelineToTheMachines(t *testing.T) {
if r.Ended == nil || r.Ended.Why != WhyAllRun || len(*ended) != 1 {
t.Fatalf("the record ended %+v, said %v", r.Ended, *ended)
}
// A tier-late said after the running changes nothing (1984/AC-832g).
hear(t, c, "mesh-wants.pipeline-wanted.main.1", "", `{"v":1,"pipeline":"main.1","branch":"main","source":1,"outcome":"tier-late","not-running":[{"module":"app","machines":["ace"]}]}`)
if r.Ended == nil || r.Ended.Why != WhyAllRun || len(*ended) != 1 {
t.Fatalf("the record ended %+v, said %v: a tier-late after the running changes nothing", r.Ended, *ended)
}
if got, _ := h.Records.ByKey("main", 1); got != r {
t.Fatal("the record read by its key is not the one the gate keeps")
}
@@ -405,20 +425,28 @@ func TestARecordsEndCountIsSaidAtEachEndAndAHigherPipelineEndReopensIt(t *testin
// GATE-5/AC (design 47 H §738, §751; H-A-75, H-A-89 (3), (4)): a pipeline-ended not passed ends the record failed naming
// the pipeline's why, and pipeline-wanted tier-late ends it failed naming the movers and machines not running.
func TestARecordEndsFailedOnAPipelineNotPassedOrATierLate(t *testing.T) {
for _, tc := range []struct{ name, key, body, why string }{
for _, tc := range []struct{ name, key, body, why, then string }{
{"pipeline failed", "mesh-pipeline-runner.pipeline-ended.main.1",
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","outcome":"failed","why":"build failed","movers":[{"module":"app","fingerprint":"f","tier":1,"steps":[{"step":"build","status":"required","outcome":"failed"}]}]}`,
"failed: build failed"},
"failed: build failed", ""},
{"pipeline cancelled, no why", "mesh-pipeline-runner.pipeline-ended.main.1",
`{"v":1,"branch":"main","source":1,"pipeline":"main.1","outcome":"cancelled","movers":[]}`,
"failed: the pipeline main.1 ended cancelled"},
"failed: the pipeline main.1 ended cancelled", ""},
{"tier late", "mesh-wants.pipeline-wanted.main.1",
`{"v":1,"pipeline":"main.1","branch":"main","source":1,"outcome":"tier-late","not-running":[{"module":"app","machines":["g14","ace"]}]}`,
"failed: a tier is late: not running app on ace, g14"},
"failed: a tier is late: not running app on ace, g14", ""},
// 1984/AC-824f: a running after a tier-late leaves the record failed.
{"running after tier late", "mesh-wants.pipeline-wanted.main.1",
`{"v":1,"pipeline":"main.1","branch":"main","source":1,"outcome":"tier-late","not-running":[{"module":"app","machines":["ace"]}]}`,
"failed: a tier is late: not running app on ace",
`{"v":1,"pipeline":"main.1","branch":"main","source":1,"outcome":"running"}`},
} {
t.Run(tc.name, func(t *testing.T) {
_, c, r, ended := pipelineBed(t)
hear(t, c, tc.key, "", tc.body)
if tc.then != "" {
hear(t, c, tc.key, "", tc.then)
}
if r.Ended == nil || r.Ended.Why != tc.why || len(*ended) != 1 {
t.Fatalf("the record ended %+v, said %v; want %q", r.Ended, *ended, tc.why)
}
+5 -1
View File
@@ -258,6 +258,9 @@
},
"ended": {
"type": "object"
},
"want-revision": {
"type": "integer"
}
},
"operations": [
@@ -280,7 +283,8 @@
"key",
"module",
"fingerprint",
"node"
"node",
"want-revision"
],
"into": "entries",
"key": "key",