From 2df32b78921bdb5967dd2210a059ba6f6a180dc9 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 23:03:08 +0100 Subject: [PATCH 001/111] T1: the teller's ask-again for want of room goes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The channel holds no room to wait for (A-424): a refusal for want of room is said as any refusal is, and its waiting, its bound of refusals and their tests go. The wait for asks the router did not take stays. Builds: design 47 H2 §813 (10) --- .../cmd/mesh-delivery-teller/assignerasks.go | 2 +- .../mesh-delivery-teller/assignerasks_test.go | 17 +- .../cmd/mesh-delivery-teller/ends.go | 8 +- .../mesh-delivery-teller/integration_test.go | 72 ------ .../cmd/mesh-delivery-teller/room_test.go | 233 ------------------ .../cmd/mesh-delivery-teller/teller.go | 105 ++------ .../cmd/mesh-delivery-teller/teller_test.go | 6 +- .../cmd/mesh-delivery-teller/unheard_test.go | 99 ++++++++ 8 files changed, 136 insertions(+), 406 deletions(-) delete mode 100644 modules/mesh-delivery-teller/cmd/mesh-delivery-teller/room_test.go create mode 100644 modules/mesh-delivery-teller/cmd/mesh-delivery-teller/unheard_test.go diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks.go index 93f8dc4c1..e97463615 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks.go @@ -17,7 +17,7 @@ import ( // teller only filled them from an answer given in the view, so an ask nobody opened the view for reached nobody: on // 2026-10-25 seven modules stayed held on every machine and the operator was never asked. Now the teller raises each on the // operator channel as it raises the gate's merge asks: as the asker mesh-delivery-teller, once per router id, through the same -// records, the same wait for room and the same warrants. The operator's answer, from the phone or from the view, is written +// records, the same wait and the same warrants. The operator's answer, from the phone or from the view, is written // under the ask's own key in the bucket answers, which the assigner reads (mesh-delivery-assigner pass.go answeredWith); none // of these asks needs proof of who answered (mesh-sdk go/delivery AskNeedsProof). diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks_test.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks_test.go index 86022dfc7..0b3680d7c 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks_test.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/assignerasks_test.go @@ -154,27 +154,14 @@ func TestAnAssignerAskAnsweredInTheViewOrTakenAwayIsTakenBack(t *testing.T) { } } -// 1906/H1: an assigner ask refused for want of room waits and is asked again when another of the teller's asks ends; a refusal for -// its words is said as a condition about a delivery ask. -func TestAnAssignerAskWaitsForRoomAndARefusalIsSaidAsADeliveryAsk(t *testing.T) { +// 1906/H1: an assigner ask refused for its words is said as a condition about a delivery ask. +func TestAnAssignerAskRefusedIsSaidAsADeliveryAsk(t *testing.T) { anAssignerAskWrittenAgainAfterBeingTakenAwayIsAskedAgainUnderANewAsking(t) b := newBed(t) assigner, _ := withView(b) - _, first := b.holdOf(t, 1, 1) key, value, ask := holdAsk(t) assigner[key] = value b.t.OnAssignerAsk(key) - b.refuse(t, ask.ID, roomRefusal) - b.deliver(t, warrantFor(first, "keep")) - got := b.askedIDs() - if len(got) != 3 || got[2] != ask.ID { - t.Fatalf("asks = %v, want the assigner's %s asked again", got, ask.ID) - } - - b = newBed(t) - assigner, _ = withView(b) - assigner[key] = value - b.t.OnAssignerAsk(key) b.refuse(t, ask.ID, "the ask has no headline") if len(b.conds) != 1 || b.conds[0].Subject.Scope != "delivery" || strings.Contains(b.conds[0].Explanation, "merge") { t.Errorf("conditions = %+v", b.conds) diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/ends.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/ends.go index 65273455c..353efcba0 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/ends.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/ends.go @@ -13,7 +13,7 @@ import ( ) // EndAsk ends one ask of the teller's by hand (the tool teller_end_ask, issue 774): an ask open at the router is cancelled -// there and marked ended here, and one waiting for room is dropped from the wait, so it is asked no more under that router +// there and marked ended here, and one waiting to be asked again is dropped from the wait, so it is asked no more under that router // id. The ask is named by its router id or by the key of the gate's or the assigner's asks it was asked for (then its latest // asking). An ask that is neither open nor waiting is said so and left: it holds no place at the router. The gate's or the // assigner's key is not the teller's to take away: a later asking of it, under a new router id, is asked as any. @@ -37,7 +37,7 @@ func (t *Teller) EndAsk(ask, why, by string) ends.Result { if ws, rec, err := t.waiting(); err == nil && rec != nil { if i := slices.IndexFunc(ws, func(x waitingAsk) bool { return x.ID == id }); i >= 0 { if t.keepWaiting(slices.Delete(ws, i, i+1), rec) != nil { - r.Says = "the ask " + id + " waits for room, and the wait could not be written: it is not ended" + r.Says = "the ask " + id + " waits to be asked again, and the wait could not be written: it is not ended" return r } waited = true @@ -51,7 +51,7 @@ func (t *Teller) EndAsk(ask, why, by string) ends.Result { if !open(k) { r.Ended = waited if waited { - r.Says = "the ask " + id + " waited for room at the router: it is dropped from the wait and asked no more" + r.Says = "the ask " + id + " waited to be asked again: it is dropped from the wait and asked no more" } else { r.Says = "the ask " + id + " is not open (answered, lapsed or ended already): it holds no place at the router, and nothing is done" } @@ -65,7 +65,7 @@ func (t *Teller) EndAsk(ask, why, by string) ends.Result { } t.markHand(key, id) r.Ended = true - r.Says = "the ask " + id + " is cancelled at the router, which frees its place; the next ask waiting for room is asked when the router says it ended" + r.Says = "the ask " + id + " is cancelled at the router, which frees its place" t.logf("%s: the ask %s is ended by hand, by %s: %s", key, id, by, why) return r } diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/integration_test.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/integration_test.go index 304549ddb..d8d2289d2 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/integration_test.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/integration_test.go @@ -489,78 +489,6 @@ func TestTellerCarriesAnAskAndWritesTheAnswer(t *testing.T) { // 1343/AC1, AC2 } } -// TestTellerAsksAgainAnAskRefusedForWantOfRoom starts the program against the bus: the router (the test) refuses the assigner's -// ask for want of room, as the live router did on 2026-10-21 (issue 1610), and then says another of the teller's asks -// lapsed; the refused ask is on the seat's work queue again, which the bus's duplicate window would have dropped under its -// first message id (1610/AC1 on the real bus). -func TestTellerAsksAgainAnAskRefusedForWantOfRoom(t *testing.T) { // 1610/AC1 - t.Cleanup(nowIs(time.Now().UTC())) - b := startFull(t) - b.place(t) - assigner := b.as(t, "n1.mesh-delivery-assigner") - broker := filepath.Join(t.TempDir(), "broker") - cred, _ := json.Marshal(process.Account{URL: b.srv.ClientURL(), Node: "n1", Module: "mesh-delivery-teller", User: "n1.mesh-delivery-teller", Password: "pw"}) - if err := os.WriteFile(broker, cred, 0o600); err != nil { - t.Fatal(err) - } - env := map[string]string{"MESH_BROKER_FILE": broker} - logs := &syncBuffer{} - rn := startRunner(b.ctx, func(c context.Context) error { return run(c, func(k string) string { return env[k] }, logs) }) - t.Cleanup(func() { rn.finish(t, 10*time.Second) }) - kv, err := assigner.KeyValue(b.ctx, assignerAsks) - if err != nil { - t.Fatal(err) - } - seat, err := b.js.Stream(b.ctx, "SEAT_OPERATOR_CHANNEL") - if err != nil { - t.Fatal(err) - } - b.listening(t) - // lastAsk waits for the seat's queue to hold an ask newer than seq under id, and gives its sequence. - lastAsk := func(id string, after uint64) uint64 { - t.Helper() - for deadline := time.Now().Add(10 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) { - raw, err := seat.GetLastMsgForSubject(b.ctx, seatAsk) - if err != nil || raw.Sequence <= after { - continue - } - var a oc.Ask - if json.Unmarshal(raw.Data, &a) == nil && a.ID == id { - return raw.Sequence - } - } - t.Fatalf("the ask %s is not on the seat's queue after sequence %d\n%s", id, after, logs.String()) - return 0 - } - say := func(w oc.Warrant) { - t.Helper() - raw, _ := json.Marshal(w) - if err := b.ctl.Publish(seatDecided, raw); err != nil { - t.Fatal(err) - } - } - - key, value, held := holdAskAt(t, 1, 1) - if _, err := kv.Put(b.ctx, key, value); err != nil { - t.Fatal(err) - } - first := lastAsk(held.ID, 0) - say(oc.Warrant{Ask: held.ID, Asker: tellerModule, Outcome: occ.OutcomeRefused, Words: roomRefusal, At: occ.FormatTime(now)}) - for deadline := time.Now().Add(10 * time.Second); !strings.Contains(logs.String(), "for want of room"); time.Sleep(50 * time.Millisecond) { - if time.Now().After(deadline) { - t.Fatalf("the refusal was not heard\n%s", logs.String()) - } - } - key2, value2, ga2 := holdAskAt(t, 2, 1) - if _, err := kv.Put(b.ctx, key2, value2); err != nil { - t.Fatal(err) - } - second := lastAsk(ga2.ID, first) - // The other ask lapses at the router: there is room, and the refused ask is asked again. - say(oc.Warrant{Ask: ga2.ID, Asker: tellerModule, Outcome: occ.OutcomeExpired, At: occ.FormatTime(now), AskDigest: occ.Digest(ga2)}) - lastAsk(held.ID, second) -} - // TestTellerFillsAnAskFromTheViewsAnswerOnce starts the program against the bus with the permissions above: the assigner's // fixture hold ask is written, then the view's answer under `.view`; the answer is under the ask's own key, once // (rewriting the view's answer does not write a second), and a view answer under a key that is no assigner's (a merge's) fills nothing diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/room_test.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/room_test.go deleted file mode 100644 index 4747126b1..000000000 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/room_test.go +++ /dev/null @@ -1,233 +0,0 @@ -package main - -import ( - "encoding/json" - occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" - oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" - "strings" - "testing" -) - -// roomRefusal is the router's words when an asker already holds occ.MostOpen open asks, as the live router said them to -// the teller on 2026-10-21 at 11:21:08 local (novox journal of mesh-delivery-teller.service: "the router refused the ask -// merge-design_61_print_and_scan-8cc11c5b8c32-d916c290f50f: its asker already has 3 open asks"; mesh-catalog -// modules/messenger cmd/messenger/asks.go:529-531). -const roomRefusal = "its asker already has 3 open asks" - -// refuse is the router's refusal of an ask: it keeps no record of a refused ask (asks.go refuseAsk only tells its asker), -// so the id may be asked again. -func (b *bed) refuse(t *testing.T, id, words string) { - t.Helper() - delete(b.seenIDs, id) - delete(b.records, id) - b.deliver(t, oc.Warrant{Ask: id, Asker: tellerModule, Outcome: occ.OutcomeRefused, Words: words, At: occ.FormatTime(now)}) -} - -// expire is the router's word that an ask of the teller's lapsed with nobody's answer: one of its asks ended. -func (b *bed) expire(t *testing.T, ask oc.Ask) { - t.Helper() - b.deliver(t, oc.Warrant{Ask: ask.ID, Asker: tellerModule, Outcome: occ.OutcomeExpired, At: occ.FormatTime(now), AskDigest: occ.Digest(ask)}) -} - -// askedIDs is the router ids of every ask the bus carried, in order. -func (b *bed) askedIDs() []string { - var out []string - for _, p := range b.askedOf(oc.AcceptSubjectAsk(tellerModule)) { - var a struct { - ID string `json:"id"` - } - _ = json.Unmarshal(p.body, &a) - out = append(out, a.ID) - } - return out -} - -// The live fault of issue 1610: asks open, one refused by the router for want of room, and the operator then answers one of the -// open. The refused is asked again, under its own router id and a new bus message id, and nothing is said as a fault. -func TestAnAskRefusedForWantOfRoomIsAskedAgainWhenAnotherEnds(t *testing.T) { // 1610/AC1 - b := newBed(t) - _, first := b.holdOf(t, 1, 1) - key2, second := b.holdOf(t, 2, 1) - b.refuse(t, second.ID, roomRefusal) - if len(b.conds) != 0 { - t.Errorf("a refusal for want of room is said as a fault before it was asked again: %+v", b.conds) - } - if got := b.askedIDs(); len(got) != 2 { - t.Fatalf("asked %v before room came", got) - } - b.deliver(t, warrantFor(first, "keep")) - got := b.askedIDs() - if len(got) != 3 || got[2] != second.ID { - t.Fatalf("asks = %v, want the refused %s asked again once the first was answered", got, second.ID) - } - pubs := b.askedOf(oc.AcceptSubjectAsk(tellerModule)) - if pubs[2].id == pubs[1].id { - t.Errorf("asked again under the bus message id %s of its first asking: the bus drops it as a duplicate", pubs[2].id) - } - if len(b.busDropped) != 0 || len(b.dropped) != 0 || len(b.conds) != 0 { - t.Errorf("bus dropped %v, router dropped %v, conditions %+v", b.busDropped, b.dropped, b.conds) - } - // Taken this time: an answer to it writes the answer as for any ask. - b.deliver(t, warrantFor(second, "keep")) - if _, ok := b.answers.written[answerKey(key2)]; !ok { - t.Errorf("the answer to the ask asked again was not written; logs:\n%s", b.logs.String()) - } - // And it is asked no more: its answer ends its wait. - _, third := b.holdOf(t, 3, 1) - b.expire(t, third) - if got := b.askedIDs(); len(got) != 4 || got[3] == second.ID { - t.Errorf("asks after the answer = %v, want only the third asked", got) - } -} - -func TestAnAskRefusedForWantOfRoomIsNotAskedAgainOnceTheAssignerMovedOn(t *testing.T) { // 1610/AC2 - b := newBed(t) - _, first := b.holdOf(t, 1, 1) - key, gone := b.holdOf(t, 2, 1) - b.refuse(t, gone.ID, roomRefusal) - // Taken away by the assigner (the hold lifted) before room came. - delete(b.assigner, key) - b.t.OnAssignerAskGone(key) - key3, g3 := b.holdOf(t, 3, 1) - b.refuse(t, g3.ID, roomRefusal) - // Rewritten by the assigner under its next asking before room came: the later asking is asked under its own id, and the - // refused earlier asking is not asked again. - _, v3b, g3b := holdAskAt(t, 3, 2) - b.assigner[key3] = v3b - b.t.OnAssignerAsk(key3) - before := len(b.askedIDs()) - if ids := b.askedIDs(); ids[before-1] != g3b.ID { - t.Fatalf("asks = %v, want the next asking %s asked", ids, g3b.ID) - } - b.deliver(t, warrantFor(first, "keep")) - b.expire(t, g3b) - if after := b.askedIDs()[before:]; len(after) != 0 { - t.Errorf("asked again %v, which the assigner no longer asks", after) - } -} - -func TestAnAskRefusedForWantOfRoomTooOftenIsSaidAsACondition(t *testing.T) { // 1610/AC3 - b := newBed(t) - _, held := b.holdOf(t, 1, 1) - for i := 0; i < mostRoomRefusals; i++ { - if len(b.conds) != 0 { - t.Fatalf("a condition after %d refusals: %+v", i, b.conds) - } - b.refuse(t, held.ID, roomRefusal) - _, other := b.holdOf(t, 2+i, 1) - b.expire(t, other) - } - var again int - for _, id := range b.askedIDs() { - if id == held.ID { - again++ - } - } - if again != mostRoomRefusals { - t.Errorf("asked %d times, want %d (once, and again after each refusal but the last)", again, mostRoomRefusals) - } - asked := len(b.askedIDs()) - if len(b.conds) != 1 || b.conds[0].State != occ.StateRaised || !strings.Contains(b.conds[0].Summary, "open asks") { - t.Fatalf("conditions = %+v", b.conds) - } - _, last := b.holdOf(t, 8, 1) - b.expire(t, last) - if len(b.askedIDs()) != asked+1 { - t.Errorf("asked again after the bound: %v", b.askedIDs()) - } -} - -func TestAnAskWaitingForRoomIsAskedAgainAtStart(t *testing.T) { // 1610/AC4 - b := newBed(t) - key, held := b.holdOf(t, 1, 1) - b.refuse(t, held.ID, roomRefusal) - // The teller starts again: a new teller on the same buckets, and the watch hands over the key it holds. - b2 := newBed(t) - b2.store, b2.answers, b2.assigner = b.store, b.answers, b.assigner - b2.client.State = b.store - b2.t.Store, b2.t.Answers, b2.t.Assigner = b.store, b.answers, b.assigner - b2.t.OnAssignerAsk(key) - if len(b2.askedIDs()) != 0 { - t.Fatalf("asked before the watch handed over its keys: %v", b2.askedIDs()) - } - b2.t.OnCurrent() - if got := b2.askedIDs(); len(got) != 1 || got[0] != held.ID { - t.Errorf("asks at start = %v, want %s asked again", got, held.ID) - } -} - -func TestAnAskRefusedForItsWordsIsSaidAtOnceAndNotAskedAgain(t *testing.T) { // 1610/AC5 - b := newBed(t) - _, first := b.holdOf(t, 1, 1) - _, bad := b.holdOf(t, 2, 1) - b.refuse(t, bad.ID, "its words carry an address, which may not leave the mesh") - if len(b.conds) != 1 { - t.Fatalf("conditions = %+v", b.conds) - } - b.deliver(t, warrantFor(first, "keep")) - if got := b.askedIDs(); len(got) != 2 { - t.Errorf("asks = %v: an ask refused for its words was asked again", got) - } -} - -// restart is a new teller on the same buckets and the same bus (its message ids still in the bus's duplicate window), and -// the router's records as they stand; the watch hands over the assigner's keys, then says it has handed over all. -func (b *bed) restart(t *testing.T) *bed { - t.Helper() - n := newBed(t) - n.store, n.answers, n.assigner, n.records, n.msgIDs, n.seenIDs = b.store, b.answers, b.assigner, b.records, b.msgIDs, b.seenIDs - n.client.State = b.store - n.t.Store, n.t.Answers, n.t.Assigner = b.store, b.answers, b.assigner - for key := range b.assigner { - n.t.OnAssignerAsk(key) - } - n.t.OnCurrent() - return n -} - -// Review of 38116fe0 (reviewer-1610): an ask asked again whose refusal the teller never heard (it was away; the router's -// warrants come on a plain subscription) is asked again at the next start: the router keeps no record of a refused ask, -// so no record there means it was not taken. -func TestAnAskAskedAgainWhoseRefusalWasMissedIsAskedAgainAtStart(t *testing.T) { // 1610/AC4 - b := newBed(t) - _, held := b.holdOf(t, 2, 1) - b.refuse(t, held.ID, roomRefusal) - _, other := b.holdOf(t, 3, 1) - b.deliver(t, warrantFor(other, "keep")) - b.records[other.ID] = `{"state":"chosen"}` - if got := b.askedIDs(); got[len(got)-1] != held.ID { - t.Fatalf("asks = %v, want %s asked again", got, held.ID) - } - // Refused again, and the teller does not hear it: the router forgets it. - delete(b.seenIDs, held.ID) - delete(b.records, held.ID) - n := b.restart(t) - got := n.askedIDs() - if len(got) != 1 || got[0] != held.ID { - t.Fatalf("asks after the start = %v, want %s asked again; logs:\n%s", got, held.ID, n.logs.String()) - } - if len(n.busDropped) != 0 { - t.Errorf("the bus dropped %v as a duplicate", n.busDropped) - } -} - -// The same for a first asking: kept open by the teller, its refusal never heard, and no record at the router. -func TestAFirstAskingWhoseRefusalWasMissedIsAskedAgainAtStart(t *testing.T) { // 1610/AC4 - b := newBed(t) - _, held := b.holdOf(t, 1, 1) - delete(b.seenIDs, held.ID) // refused for room, unheard: the router keeps no record of it - delete(b.records, held.ID) - n := b.restart(t) - got := n.askedIDs() - if len(got) != 1 || got[0] != held.ID { - t.Fatalf("asks after the start = %v, want %s asked again; logs:\n%s", got, held.ID, n.logs.String()) - } - if len(n.busDropped) != 0 { - t.Errorf("the bus dropped %v as a duplicate", n.busDropped) - } - // An ask the router holds (it took the one asked again) is not asked again. - m := n.restart(t) - if got := m.askedIDs(); len(got) != 0 { - t.Errorf("an ask the router holds was asked again: %v", got) - } -} diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller.go index b990a67ea..70fe114d7 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller.go @@ -67,8 +67,8 @@ type Teller struct { // Say publishes a condition to the operator (mesh.seat.operator-channel.accept.condition.). Say func(c oc.Condition) error Logf func(format string, args ...any) - // Publish is the bus the asker publishes on, used to ask again an ask the router refused for want of room under a bus - // message id of its own (the bus drops a second message under an id it holds). + // Publish is the bus the asker publishes on, used to ask again an ask the router did not take under a bus message id + // of its own (the bus drops a second message under an id it holds). Publish func(subject string, body any, id string) error // Answered says an answer written under an ask's key as the event answered (ADR 0596 §2: the owner says what it // wrote; a reader hears it and asks the tool teller_answers, never the bucket). Nil says nothing. @@ -198,8 +198,8 @@ func (t *Teller) catchUp(id string) { if w == nil { if state == "" { // The router holds no record of an ask the teller holds open: it refused it (a refused ask is not kept) while - // the teller was away and did not hear it, or has not read it yet. It waits for room, and is asked again at the - // start or at the next end; the router drops a second ask under an id it holds (review of 38116fe0). + // the teller was away and did not hear it, or has not read it yet. It waits, and is asked again at the start or + // at the next end; the router drops a second ask under an id it holds (review of 38116fe0). t.unheard(id) } return @@ -286,8 +286,8 @@ func (t *Teller) sayAnswered(key, askID string, answer []byte) error { // Said is what the teller does with what became of a warrant: a good answer clears the condition of its ask; a warrant // that does not hold, or that the router refused, is said as a condition (ADR 0437 §9). Nothing is written for either. -// An ask the router refused for want of room is not said: it waits, and is asked again when one of the teller's asks -// ends (issue 1610). +// The channel holds no room to wait for (design 47 G A-424), so a refusal for want of room is said as any refusal is +// (design 47 H2 §813 (10)). func (t *Teller) Said(h occ.Handled, w oc.Warrant, err error) { t.mu.Lock() defer t.mu.Unlock() @@ -301,12 +301,6 @@ func (t *Teller) said(h occ.Handled, w oc.Warrant, err error) { // §638): the ask is closed as any ended ask is, so the teller treats it as the ended ask it was (as before §638). h = occ.Recorded } - if w.Outcome == occ.OutcomeRefused && forWantOfRoom(w.Words) { - if h == occ.Recorded { - t.roomRefused(w) - } - return // a second word of the same refusal is no end of an ask - } t.saidOnce(h, w, err) if h == occ.Recorded { if s, rec, _ := t.seenOf(w.Ask); rec != nil && isAssignerKey(s.Key) { @@ -404,41 +398,27 @@ func (t *Teller) clear(askID string) { _ = t.Store.Delete(condKey(id)) } -// Room at the router (issue 1610; design 47 G A-424 took the limit away). The router held at most three open asks of one asker and refused another at once -// in words, keeping no record of it (mesh-catalog modules/messenger cmd/messenger/asks.go:524-531, refuseAsk), so the -// same router id may be asked again. Merges come in bursts: on 2026-10-21 at 11:21 a fourth merge ask was refused so, and -// nothing asked it again, so the operator was never asked. Now an ask refused for want of room waits in the record -// `room`, and each time one of the teller's asks ends at the router (a warrant of any outcome: the room it held is free) -// the first that waits is asked again, under its own router id and a bus message id of its own (the bus drops a second -// message under an id it holds). It is asked again at most mostRoomRefusals times; refused that often it is said as a -// condition, as any refusal is. An ask the assigner took away or asked again under a newer asking meanwhile, or one already -// answered, is the assigner's no more, and is dropped from the wait. The teller holds no timer: an end, and its start, are the -// events that ask again. +// The asks the router did not take (issue 1610; design 47 G A-424 took the router's limit of open asks away, and design 47 +// H2 §813 (10) the teller's asking again for want of room). An ask the teller holds open and the router holds no record of +// (it was not taken, or its refusal was not heard) waits in the record `room`, and is asked again at the next end of one of +// the teller's asks and at the start, under its own router id and a bus message id of its own (the bus drops a second +// message under an id it holds). An ask the assigner took away or asked again under a newer asking meanwhile, or one +// already answered, is the assigner's no more, and is dropped from the wait. The teller holds no timer: an end, and its +// start, are the events that ask again. -// mostRoomRefusals is how many times an ask is refused for want of room before it is said as a condition and asked no -// more: each refusal follows an end of another ask, so it is that many asks answered while this one could not be asked. -const mostRoomRefusals = 6 - -// roomRecord is the key of the asks that wait for room, in the order they were refused. +// roomRecord is the key of the asks that wait to be asked again, in the order they were met. const roomRecord = "room" -// waitingAsk is one ask that waits for room: the ask key it was asked for, its router id, how often the router refused -// it for want of room, and whether it is asked again and its word not yet heard. +// waitingAsk is one ask that waits to be asked again: the ask key it was asked for, its router id, and whether it is asked +// again and its word not yet heard. type waitingAsk struct { - Key string `json:"key"` - ID string `json:"id"` - Refusals int `json:"refusals"` - Asked bool `json:"asked,omitempty"` + Key string `json:"key"` + ID string `json:"id"` + Asked bool `json:"asked,omitempty"` // Tries is how many times it was asked again: each time under a bus message id of its own, also across a start. Tries int `json:"tries,omitempty"` } -// forWantOfRoom says whether a refusal's words are the router's for an asker that already holds its most open asks -// ("its asker already has 3 open asks", asks.go:530). -func forWantOfRoom(words string) bool { - return strings.Contains(words, "already has") && strings.Contains(words, "open asks") -} - func (t *Teller) now() time.Time { if t.Now != nil { return t.Now() @@ -469,45 +449,12 @@ func (t *Teller) keepWaiting(ws []waitingAsk, prior *stdio.StateEntry) error { _, err = t.Store.Update(roomRecord, ws, prior.Revision) } if err != nil { - t.logf("the record of the asks waiting for room could not be kept: %v", err) + t.logf("the record of the asks waiting to be asked again could not be kept: %v", err) } return err } -// roomRefused keeps an ask the router refused for want of room waiting, or, refused that way mostRoomRefusals times, -// says it as a condition and drops it. -func (t *Teller) roomRefused(w oc.Warrant) { - ws, rec, err := t.waiting() - if err != nil { - t.logf("%v", err) - return - } - i := slices.IndexFunc(ws, func(x waitingAsk) bool { return x.ID == w.Ask }) - if i < 0 { - s, _, _ := t.seenOf(w.Ask) - ws = append(ws, waitingAsk{Key: s.Key, ID: w.Ask}) - i = len(ws) - 1 - } - ws[i].Refusals++ - ws[i].Asked = false - n := ws[i].Refusals - if n >= mostRoomRefusals { - ws = slices.Delete(ws, i, i+1) - if t.keepWaiting(ws, rec) != nil { - return - } - t.logf("the router refused the ask %s for want of room %d times (%s): it is asked no more, and said", w.Ask, n, w.Words) - t.raise(w.Ask, assignerWords.unaskedHeadline, fmt.Sprintf("the router refused it %d times for want of room: %s", n, w.Words)) - return - } - if t.keepWaiting(ws, rec) != nil { - return - } - t.logf("the router refused the ask %s for want of room (%s): it waits, and is asked again when one of the teller's asks ends (refused %d of at most %d times)", - w.Ask, w.Words, n, mostRoomRefusals) -} - -// endWait drops an ask from the wait once the router said it ended otherwise than for want of room. +// endWait drops an ask from the wait once the router said it ended. func (t *Teller) endWait(id string) { ws, rec, err := t.waiting() if err != nil || rec == nil { @@ -521,7 +468,7 @@ func (t *Teller) endWait(id string) { } // OnCurrent is the watch of the assigner's asks having handed over every key it holds now, at the teller's start: an ask that -// waited for room while the teller was away is asked again (the asks that held the room may have ended meanwhile). +// waited while the teller was away is asked again. // // An ask asked again whose word the teller did not hear (the router's warrants come on a plain subscription) waits once // more when the router holds no record of it: the router keeps none of a refused ask (review of 38116fe0). Up to @@ -569,7 +516,7 @@ func (t *Teller) OnCurrent() { t.askWaiting() } -// unheard puts an ask the teller holds open and the router holds no record of in the wait for room, once. +// unheard puts an ask the teller holds open and the router holds no record of in the wait, once. func (t *Teller) unheard(id string) { ws, rec, err := t.waiting() if err != nil { @@ -611,17 +558,17 @@ func (t *Teller) askWaiting() { } a, why := t.stillAsked(x) if why != "" { - t.logf("%s: the ask %s, waiting for room, is not asked again: %s", x.Key, x.ID, why) + t.logf("%s: the ask %s, waiting, is not asked again: %s", x.Key, x.ID, why) ws, changed = slices.Delete(ws, i, i+1), true continue } ws[i].Tries, changed = x.Tries+1, true if err := t.askAgain(a, fmt.Sprintf("%s.again-%d", a.ID, ws[i].Tries)); err != nil { - t.logf("%s: the ask %s, waiting for room, could not be asked again, and waits for the next end: %v", x.Key, x.ID, err) + t.logf("%s: the ask %s, waiting, could not be asked again, and waits for the next end: %v", x.Key, x.ID, err) return } ws[i].Asked = true - t.logf("%s: the ask %s is asked of the operator again (refused %d times for want of room)", x.Key, x.ID, x.Refusals) + t.logf("%s: the ask %s is asked of the operator again (try %d)", x.Key, x.ID, ws[i].Tries) i++ } } diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller_test.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller_test.go index f64c4a384..b968f229c 100644 --- a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller_test.go +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/teller_test.go @@ -381,7 +381,7 @@ func TestAWarrantThatDoesNotHoldWritesNoAnswerAndRaisesTheCondition(t *testing.T } // design 47 G §653, A-172: the teller carries no merge ask. A router ask it holds under a key that is no assigner key (a merge -// ask kept before the Approve per merge went) answers nothing, and a merge ask waiting for room is dropped from the wait. +// ask kept before the Approve per merge went) answers nothing, and a merge ask waiting to be asked again is dropped from the wait. func TestAMergeAskOfBeforeTheApprovePerMergeWentAnswersNothingAndWaitsNoMore(t *testing.T) { b := newBed(t) _, _, ask := holdAskAt(t, 1, 1) @@ -396,7 +396,9 @@ func TestAMergeAskOfBeforeTheApprovePerMergeWentAnswersNothingAndWaitsNoMore(t * if ws, rec, _ := b.t.waiting(); rec != nil || len(ws) != 0 { t.Fatalf("the wait holds %v", ws) } - b.refuse(t, ask.ID, roomRefusal) // it waits for room, as a merge ask did + if err := b.t.keepWaiting([]waitingAsk{{Key: mergeKey, ID: ask.ID}}, nil); err != nil { // it waits, as a merge ask did + t.Fatal(err) + } b.deliver(t, warrantFor(ask, "keep")) if len(b.answers.written) != 0 { t.Errorf("a merge ask was answered: %v", b.answers.written) diff --git a/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/unheard_test.go b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/unheard_test.go new file mode 100644 index 000000000..f74399178 --- /dev/null +++ b/modules/mesh-delivery-teller/cmd/mesh-delivery-teller/unheard_test.go @@ -0,0 +1,99 @@ +package main + +import ( + "encoding/json" + occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" + oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" + "testing" +) + +// roomRefusal is the router's words when an asker already holds occ.MostOpen open asks, as the live router said them to +// the teller on 2026-10-21 at 11:21:08 local (novox journal of mesh-delivery-teller.service: "the router refused the ask +// merge-design_61_print_and_scan-8cc11c5b8c32-d916c290f50f: its asker already has 3 open asks"; mesh-catalog +// modules/messenger cmd/messenger/asks.go:529-531). +const roomRefusal = "its asker already has 3 open asks" + +// refuse is the router's refusal of an ask: it keeps no record of a refused ask (asks.go refuseAsk only tells its asker), +// so the id may be asked again. +func (b *bed) refuse(t *testing.T, id, words string) { + t.Helper() + delete(b.seenIDs, id) + delete(b.records, id) + b.deliver(t, oc.Warrant{Ask: id, Asker: tellerModule, Outcome: occ.OutcomeRefused, Words: words, At: occ.FormatTime(now)}) +} + +// askedIDs is the router ids of every ask the bus carried, in order. +func (b *bed) askedIDs() []string { + var out []string + for _, p := range b.askedOf(oc.AcceptSubjectAsk(tellerModule)) { + var a struct { + ID string `json:"id"` + } + _ = json.Unmarshal(p.body, &a) + out = append(out, a.ID) + } + return out +} + +// A refusal is said at once and the ask is not asked again, also one for want of room: the channel holds no room to wait +// for (design 47 G A-424), and the teller's asking again for it went (design 47 H2 §813 (10)). +func TestAnAskRefusedIsSaidAtOnceAndNotAskedAgain(t *testing.T) { // 1610/AC5, H2 §813 (10) + for _, words := range []string{"its words carry an address, which may not leave the mesh", roomRefusal} { + b := newBed(t) + _, first := b.holdOf(t, 1, 1) + _, bad := b.holdOf(t, 2, 1) + b.refuse(t, bad.ID, words) + if len(b.conds) != 1 { + t.Fatalf("%s: conditions = %+v", words, b.conds) + } + b.deliver(t, warrantFor(first, "keep")) + if got := b.askedIDs(); len(got) != 2 { + t.Errorf("%s: asks = %v: a refused ask was asked again", words, got) + } + } +} + +// restart is a new teller on the same buckets and the same bus (its message ids still in the bus's duplicate window), and +// the router's records as they stand; the watch hands over the assigner's keys, then says it has handed over all. +func (b *bed) restart(t *testing.T) *bed { + t.Helper() + n := newBed(t) + n.store, n.answers, n.assigner, n.records, n.msgIDs, n.seenIDs = b.store, b.answers, b.assigner, b.records, b.msgIDs, b.seenIDs + n.client.State = b.store + n.t.Store, n.t.Answers, n.t.Assigner = b.store, b.answers, b.assigner + for key := range b.assigner { + n.t.OnAssignerAsk(key) + } + n.t.OnCurrent() + return n +} + +// An ask kept open by the teller whose refusal it never heard (it was away; the router's warrants come on a plain +// subscription) is asked again at the next start: the router keeps no record of a refused ask, so no record there means it +// was not taken (review of 38116fe0); asked again and missed again, it is asked again at the start after. +func TestAnAskingWhoseRefusalWasMissedIsAskedAgainAtStart(t *testing.T) { // 1610/AC4 + b := newBed(t) + _, held := b.holdOf(t, 1, 1) + delete(b.seenIDs, held.ID) // refused for room, unheard: the router keeps no record of it + delete(b.records, held.ID) + n := b.restart(t) + got := n.askedIDs() + if len(got) != 1 || got[0] != held.ID { + t.Fatalf("asks after the start = %v, want %s asked again; logs:\n%s", got, held.ID, n.logs.String()) + } + if len(n.busDropped) != 0 { + t.Errorf("the bus dropped %v as a duplicate", n.busDropped) + } + // Asked again, and its refusal missed once more: the router forgets it, and the next start asks it again. + delete(n.seenIDs, held.ID) + delete(n.records, held.ID) + m := n.restart(t) + if got := m.askedIDs(); len(got) != 1 || got[0] != held.ID { + t.Fatalf("asks after the second start = %v, want %s asked again; logs:\n%s", got, held.ID, m.logs.String()) + } + // An ask the router holds (it took the one asked again) is not asked again. + o := m.restart(t) + if got := o.askedIDs(); len(got) != 0 { + t.Errorf("an ask the router holds was asked again: %v", got) + } +} -- 2.54.0 From ff7db337206de8fa78e91ee57c5251e9a1913f5b Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 23:11:10 +0100 Subject: [PATCH 002/111] G1, D0: seat readers decode tolerantly and say their form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seat generator gives every value, event and answer the wire field form (left out while 1) and a tolerant decoder answering the form it read; each contract carries its forms and a digest of its fields, and the compare fails a definition whose fields changed while its form did not. Every delivery seat is regenerated, and the readers take the form. Builds: design 47 H2 §780; H-A-352 --- .../mesh-delivery-assigner/asksform_test.go | 2 +- .../internal/versions/names.go | 6 +- .../clients/meshcatalogclient/catalog_test.go | 6 +- .../go/clients/meshdeliveryclient/gate.go | 4 +- .../clients/meshdeliveryclient/gate_test.go | 5 +- .../go/clients/meshwantsclient/wants.go | 6 +- .../go/clients/meshwantsclient/wants_test.go | 16 +- .../seats/containerimageregistry/contract.go | 224 +++++++- .../go/seats/git/contract.go | 319 ++++++++++- .../go/seats/gopackageregistry/contract.go | 111 ++++ .../go/seats/meshartifactsweep/contract.go | 85 ++- .../go/seats/meshbuilds/contract.go | 82 ++- .../go/seats/meshcatalog/contract.go | 528 ++++++++++++----- .../go/seats/meshdelivery/contract.go | 220 ++++++-- .../go/seats/meshdeliveryview/contract.go | 131 ++--- .../go/seats/meshpipelinerunner/contract.go | 480 ++++++++++++---- .../go/seats/meshwants/contract.go | 529 ++++++++++++------ .../go/seats/nodebuildgo/contract.go | 287 +++++++--- .../go/seats/nodebuildimage/contract.go | 287 +++++++--- .../go/seats/nodebuildnode/contract.go | 287 +++++++--- .../go/seats/npmpackageregistry/contract.go | 111 ++++ .../go/seats/ociartifactregistry/contract.go | 202 ++++++- .../seats/containerimageregistry/index.d.ts | 16 + .../parts/registry.d.ts | 10 + .../ts/seats/git/index.d.ts | 50 ++ .../gopackageregistry/parts/registry.d.ts | 10 + .../ts/seats/meshartifactsweep/index.d.ts | 4 + .../ts/seats/meshbuilds/index.d.ts | 10 + .../ts/seats/meshcatalog/index.d.ts | 56 ++ .../ts/seats/meshdelivery/index.d.ts | 22 + .../ts/seats/meshdeliveryview/index.d.ts | 2 + .../ts/seats/meshpipelinerunner/index.d.ts | 56 ++ .../ts/seats/meshwants/index.d.ts | 44 ++ .../seats/nodebuildgo/parts/build-step.d.ts | 14 + .../nodebuildimage/parts/build-step.d.ts | 14 + .../seats/nodebuildnode/parts/build-step.d.ts | 14 + .../npmpackageregistry/parts/registry.d.ts | 10 + .../ts/seats/ociartifactregistry/index.d.ts | 12 + .../ociartifactregistry/parts/registry.d.ts | 10 + .../internal/index/branch_builds.go | 4 +- .../internal/index/branch_builds_test.go | 2 +- .../internal/index/run_inputs.go | 2 +- .../internal/index/toolchains_values.go | 2 +- .../internal/index/versions.go | 2 +- .../cmd/mesh-delivery-pipeline-tools/queue.go | 2 +- .../internal/pipeline/moverkeys.go | 2 +- .../internal/pipeline/moverkeys_test.go | 2 +- .../internal/pipeline/queue.go | 4 +- .../internal/pipeline/read.go | 4 +- modules/mesh-delivery-sdk/seatgen/form.go | 181 ++++++ modules/mesh-delivery-sdk/seatgen/gogen.go | 21 +- modules/mesh-delivery-sdk/seatgen/load.go | 8 +- modules/mesh-delivery-sdk/seatgen/states.go | 14 +- .../mesh-delivery-sdk/seatgen/states_test.go | 63 ++- modules/mesh-delivery-sdk/seatgen/types.go | 8 +- .../mesh-delivery-view/internal/view/view.go | 2 +- 56 files changed, 3659 insertions(+), 946 deletions(-) create mode 100644 modules/mesh-delivery-sdk/seatgen/form.go diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/asksform_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/asksform_test.go index 675498415..e9c79f510 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/asksform_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/asksform_test.go @@ -68,7 +68,7 @@ func TestTheAssignersAsksAreTheSeatMeshWantsAsks(t *testing.T) { if err != nil { t.Fatal(err) } - if v, err := meshwants.DecodeAsksByHoldModuleFingerprintValue(raw); err != nil || v.Asking != 2 { + if v, _, err := meshwants.DecodeAsksByHoldModuleFingerprintValue(raw); err != nil || v.Asking != 2 { t.Errorf("the ask %s is not the seat's Ask: %+v, %v", raw, v, err) } } diff --git a/modules/mesh-delivery-builder/internal/versions/names.go b/modules/mesh-delivery-builder/internal/versions/names.go index 4eead9177..46a9b9607 100644 --- a/modules/mesh-delivery-builder/internal/versions/names.go +++ b/modules/mesh-delivery-builder/internal/versions/names.go @@ -39,7 +39,7 @@ func NamesIn(s PackagesState) PackageNames { if !found { continue } - v, err := meshcatalog.DecodePackagesByPackageSeriesValue(value) // the indexer's value of a series key (mesh-sdk's contract, J4) + v, _, err := meshcatalog.DecodePackagesByPackageSeriesValue(value) // the indexer's value of a series key (mesh-sdk's contract, J4) if err != nil || v.Package != built { continue } @@ -56,7 +56,7 @@ func NamedModule(key string, value []byte) (module, name string, ok bool) { if !isSeriesKey(key) { return "", "", false } - v, err := meshcatalog.DecodePackagesByPackageSeriesValue(value) + v, _, err := meshcatalog.DecodePackagesByPackageSeriesValue(value) if err != nil || v.Name == "" { return "", "", false } @@ -99,7 +99,7 @@ func Carriers(s PackagesState) func(ctx context.Context, name string) ([]Built, if !found { continue } - v, err := meshcatalog.DecodePackagesByPackageSeriesValue(value) + v, _, err := meshcatalog.DecodePackagesByPackageSeriesValue(value) if err != nil || v.Name != name { continue } diff --git a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go index 44bc27f51..8bebbd58d 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshcatalogclient/catalog_test.go @@ -213,10 +213,10 @@ func TestTakeInBodiesAndNoneYetAreTheSeatsTypes(t *testing.T) { } // design 47 H-A-48: the indexer stamps no source revision on a module; the take-in's commit names it, so a module value and an -// entry's inputs carrying src or fp-src are not the seat's. +// entry's inputs carrying src or fp-src are not the seat's: a reader leaves them unread (design 47 H2 §780). func TestNoSourceStamps(t *testing.T) { - if _, err := seat.DecodeModulesByModuleValue([]byte(`{"v":1,"repository":"mesh-sdk","commit":"` + hex64("a")[:40] + `","manifest":"` + hex64("b") + `","path":"go","src":41,"fp-src":41}`)); err == nil { - t.Error("a module value carrying src and fp-src is read") + if v, form, err := seat.DecodeModulesByModuleValue([]byte(`{"v":1,"repository":"mesh-sdk","commit":"` + hex64("a")[:40] + `","manifest":"` + hex64("b") + `","path":"go","src":41,"fp-src":41}`)); err != nil || v.Repository != "mesh-sdk" || form != 1 { + t.Errorf("a module value carrying src and fp-src is not read past them: %+v %d %v", v, form, err) } var in seat.EntryInputs dec := json.NewDecoder(strings.NewReader(`{"src":41,"fp-src":41}`)) diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate.go b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate.go index 055d93984..6da281fc4 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate.go +++ b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate.go @@ -58,7 +58,7 @@ func DecodeSource(data []byte) (seat.SourceByBranchValue, error) { if err := keys.CheckVersion(data); err != nil { return seat.SourceByBranchValue{}, err } - s, err := seat.DecodeSourceByBranchValue(data) + s, _, err := seat.DecodeSourceByBranchValue(data) if err != nil { return s, fmt.Errorf("meshdeliveryclient: a source does not fit its shape: %w", err) } @@ -80,7 +80,7 @@ func DecodeOwed(data []byte) (seat.OwedByRepositoryNumberHeadActValue, error) { if err := keys.CheckVersion(data); err != nil { return seat.OwedByRepositoryNumberHeadActValue{}, err } - o, err := seat.DecodeOwedByRepositoryNumberHeadActValue(data) + o, _, err := seat.DecodeOwedByRepositoryNumberHeadActValue(data) if err != nil { return o, fmt.Errorf("meshdeliveryclient: an owed value does not fit its shape: %w", err) } diff --git a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate_test.go b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate_test.go index c9cf3499b..50613698d 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient/gate_test.go @@ -140,7 +140,8 @@ func TestGateValuesRefuseWhatTheirRulesRefuse(t *testing.T) { if _, err := DecodeSource([]byte(`{"v":2,"source":1,"call":"c","heads":{"a":"b"}}`)); !errors.Is(err, keys.ErrUnknownVersion) { t.Errorf("another version: %v", err) } - if _, err := DecodeSource([]byte(`{"v":1,"source":1,"call":"c","heads":{"a":"b"},"extra":1}`)); err == nil { - t.Error("an unknown field decodes") + // design 47 H2 §780: a reader leaves a field it does not know unread. + if s, err := DecodeSource([]byte(`{"v":1,"source":1,"call":"0123456789abcdef","heads":{"a":"b"},"extra":1}`)); err != nil || s.Source != 1 { + t.Errorf("an unknown field is not read past: %+v %v", s, err) } } diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go index 5d7f8e6b8..21f87b008 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go @@ -233,7 +233,7 @@ func DecodeWant(data []byte) (Want, error) { if err := keys.CheckVersion(data); err != nil { return Want{}, err } - w, err := seat.DecodeWantsByWantNodeModuleValue(data) + w, _, err := seat.DecodeWantsByWantNodeModuleValue(data) if err != nil { return Want{}, fmt.Errorf("wants: value does not fit its shape: %w", err) } @@ -272,7 +272,7 @@ func DecodeNodeWant(data []byte) (NodeWant, error) { if err := keys.CheckVersion(data); err != nil { return NodeWant{}, err } - w, err := seat.DecodeWantsByWantNodeNodeValue(data) + w, _, err := seat.DecodeWantsByWantNodeNodeValue(data) if err != nil { return NodeWant{}, fmt.Errorf("wants: a node's own want does not fit its shape: %w", err) } @@ -298,7 +298,7 @@ func DecodeHeld(data []byte) (Held, error) { if err := keys.CheckVersion(data); err != nil { return Held{}, err } - h, err := seat.DecodeWantsByHeldModuleFingerprintValue(data) + h, _, err := seat.DecodeWantsByHeldModuleFingerprintValue(data) if err != nil { return Held{}, fmt.Errorf("wants: value does not fit its shape: %w", err) } diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go index c967aace7..9a0d4a17d 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go @@ -76,17 +76,18 @@ func TestWantsAreWhatTheEarlierCodecWrote(t *testing.T) { t.Errorf("%s: written", name) } } - // design 47 H §750, H-A-37: a want names no digest, rule or newest; the earlier fields are refused. + // design 47 H §750, H-A-37: a want names no digest, rule or newest; a reader leaves the earlier fields unread + // (design 47 H2 §780). for _, old := range []string{`"composed":"` + c + `"`, `"parts":{"x:image":"` + d + `"}`, `"rule":3`, `"newest":"` + b + `"`, `"kept-on":"n1"`} { - if _, err := DecodeWant([]byte(`{"v":1,"fp":"` + a + `",` + old + `}`)); err == nil { - t.Errorf("a want naming %s is read", old) + if w, err := DecodeWant([]byte(`{"v":1,"fp":"` + a + `",` + old + `}`)); err != nil || w.Fp != a { + t.Errorf("a want naming %s is not read past it: %+v %v", old, w, err) } } if _, err := DecodeWant([]byte(`{"fp":"` + a + `","self":true}`)); !errors.Is(err, keys.ErrUnknownVersion) { t.Errorf("no version: %v", err) } - if _, err := DecodeWant([]byte(`{"v":1,"fp":"` + a + `","self":true,"extra":1}`)); err == nil { - t.Error("an unknown field is read") + if w, err := DecodeWant([]byte(`{"v":1,"fp":"` + a + `","self":true,"extra":1}`)); err != nil || !w.Self { + t.Errorf("an unknown field is not read past (design 47 H2 §780): %+v %v", w, err) } }) t.Run("node want and hold", func(t *testing.T) { @@ -108,8 +109,9 @@ func TestWantsAreWhatTheEarlierCodecWrote(t *testing.T) { t.Errorf("%s: written", name) } } - if _, err := DecodeNodeWant([]byte(`{"v":1,"composed":"` + c + `","fp":"` + a + `"}`)); err == nil { - t.Error("a fingerprint in a node's own want is read") + // design 47 H2 §780: a fingerprint is no field of a node's own want, and a reader leaves it unread. + if back, err := DecodeNodeWant([]byte(`{"v":1,"composed":"` + c + `","fp":"` + a + `"}`)); err != nil || back.Composed != c { + t.Errorf("a node's own want naming a fingerprint is not read past it: %+v %v", back, err) } raw, err = EncodeHeld(Held{Node: "anchor", Words: "unhealthy"}) if err != nil { diff --git a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go index 80739294f..bad679dd6 100644 --- a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go @@ -4,15 +4,27 @@ package containerimageregistry import ( - "bytes" "encoding/json" - "errors" "strings" ) // Seat is the seat's name. const Seat = "container-image-registry" +// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): +// a reader of a value of another form says "form N, this reader knows M". +const Form = 1 + +// FormRegistry is the form of what the part registry adds. +const FormRegistry = 1 + +// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition +// whose fields changed while its forms did not (design 47 H2 §780). +const ( + generatedForms = "1 registry:1" + generatedFieldsDigest = "63651a5f06aa41743b7c77ff25bed94a2b3ad6bcc39ac9f15ffcd51ff55a3c9d" +) + const ( VerbPublish = "publish" VerbPublishPart = "publish-part" @@ -102,18 +114,13 @@ func ParseHoldsBySeatNameDigestKey(key string) (string, string, string, bool) { return v0, v2, v4, true } -// DecodeHoldsBySeatNameDigestValue reads one value of the state holds under the form "..", refusing a field HoldsBySeatNameDigestValue does not know and any text after the value. -func DecodeHoldsBySeatNameDigestValue(raw []byte) (HoldsBySeatNameDigestValue, error) { +// DecodeHoldsBySeatNameDigestValue reads one value of the state holds under the form ".." as another part wrote it: a field HoldsBySeatNameDigestValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeHoldsBySeatNameDigestValue(raw []byte) (HoldsBySeatNameDigestValue, int, error) { var v HoldsBySeatNameDigestValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // WindowsByCallerKey is the key of one value of the state windows under the form "". @@ -133,18 +140,13 @@ func ParseWindowsByCallerKey(key string) (string, bool) { return v0, true } -// DecodeWindowsByCallerValue reads one value of the state windows under the form "", refusing a field WindowsByCallerValue does not know and any text after the value. -func DecodeWindowsByCallerValue(raw []byte) (WindowsByCallerValue, error) { +// DecodeWindowsByCallerValue reads one value of the state windows under the form "" as another part wrote it: a field WindowsByCallerValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeWindowsByCallerValue(raw []byte) (WindowsByCallerValue, int, error) { var v WindowsByCallerValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // Artifact is one published thing, as every registry event and answer names it. @@ -182,6 +184,8 @@ type Hold struct { By string `json:"by,omitempty"` // the digest Digest string `json:"digest"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the module holding the seat Holder string `json:"holder"` // the name @@ -216,6 +220,8 @@ type Outcome struct { Digest string `json:"digest"` // the build's fingerprint Fingerprint string `json:"fingerprint,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the module holding the seat that said it Holder string `json:"holder"` // what it is @@ -296,6 +302,8 @@ const ( // PublishAnswer is what publish answers. type PublishAnswer struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the digest is held already: nothing to send; the outcome follows as an event Held bool `json:"held,omitempty"` // the digests of the parts the holder lacks, to send by publish-part @@ -322,6 +330,8 @@ type PublishPartInput struct { type PublishPartAnswer struct { // the part is whole and its bytes match its digest Complete bool `json:"complete,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the part Part string `json:"part"` // the chunks of the part held so far @@ -340,6 +350,8 @@ type VersionsInput struct { // VersionsAnswer is what versions answers. type VersionsAnswer struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the name Name string `json:"name"` // newest first @@ -369,6 +381,8 @@ const ( // RemoveAnswer is what remove answers. type RemoveAnswer struct { Artifact *Artifact `json:"artifact,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // it stays whole, its tag and its bytes: the store cannot remove the tag alone while another tag names its digest (reason, tags) Kept bool `json:"kept,omitempty"` // why it was kept: shared-digest, another tag names its digest @@ -398,6 +412,8 @@ type MirrorInput struct { type MirrorAnswer struct { // the digest stored Digest string `json:"digest"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the reference the seat answers Reference string `json:"reference"` } @@ -418,6 +434,8 @@ type TagsAnswerTagsItem struct { // TagsAnswer is what tags answers. type TagsAnswer struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the image Name string `json:"name"` // every tag @@ -436,6 +454,8 @@ type HoldInput struct { // HoldAnswer is what hold answers. type HoldAnswer struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // it is held Held bool `json:"held"` // when the hold began, RFC 3339 @@ -454,6 +474,8 @@ type ReleaseInput struct { // ReleaseAnswer is what release answers. type ReleaseAnswer struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // a hold was let go; false when there was none Released bool `json:"released"` } @@ -466,6 +488,8 @@ type ListInput struct { // ListAnswer is what list answers. type ListAnswer struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // each repository named, in order of its name Repositories []Repository `json:"repositories"` } @@ -492,9 +516,11 @@ type ReleasedEvent = Hold type HoldsBySeatNameDigestValue struct { By string `json:"by"` Digest string `json:"digest"` - Kind string `json:"kind"` - Name string `json:"name"` - Seat string `json:"seat"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` + Kind string `json:"kind"` + Name string `json:"name"` + Seat string `json:"seat"` // when (RFC 3339 time) Since string `json:"since"` Why string `json:"why,omitempty"` @@ -515,6 +541,8 @@ type WindowsByCallerValue struct { Closed string `json:"closed,omitempty"` // retired nodes dropped by hand Dropped []WindowsByCallerValueDroppedItem `json:"dropped,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the nodes holding it open Holding []string `json:"holding,omitempty"` LastHolding []string `json:"last_holding,omitempty"` @@ -526,3 +554,149 @@ type WindowsByCallerValue struct { // of each node holding the window, why it holds it Why map[string]string `json:"why,omitempty"` } + +// DecodePublishAnswer reads a PublishAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePublishAnswer(raw []byte) (PublishAnswer, int, error) { + var v PublishAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodePublishPartAnswer reads a PublishPartAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePublishPartAnswer(raw []byte) (PublishPartAnswer, int, error) { + var v PublishPartAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeVersionsAnswer reads a VersionsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeVersionsAnswer(raw []byte) (VersionsAnswer, int, error) { + var v VersionsAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeRemoveAnswer reads a RemoveAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeRemoveAnswer(raw []byte) (RemoveAnswer, int, error) { + var v RemoveAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeMirrorAnswer reads a MirrorAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeMirrorAnswer(raw []byte) (MirrorAnswer, int, error) { + var v MirrorAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeTagsAnswer reads a TagsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeTagsAnswer(raw []byte) (TagsAnswer, int, error) { + var v TagsAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeHoldAnswer reads a HoldAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeHoldAnswer(raw []byte) (HoldAnswer, int, error) { + var v HoldAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeReleaseAnswer reads a ReleaseAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeReleaseAnswer(raw []byte) (ReleaseAnswer, int, error) { + var v ReleaseAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeListAnswer reads a ListAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeListAnswer(raw []byte) (ListAnswer, int, error) { + var v ListAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodePublishedEvent reads a PublishedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePublishedEvent(raw []byte) (PublishedEvent, int, error) { + var v PublishedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeRefusedEvent reads a RefusedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeRefusedEvent(raw []byte) (RefusedEvent, int, error) { + var v RefusedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeRemovedEvent reads a RemovedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeRemovedEvent(raw []byte) (RemovedEvent, int, error) { + var v RemovedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeKeptEvent reads a KeptEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeKeptEvent(raw []byte) (KeptEvent, int, error) { + var v KeptEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeHeldEvent reads a HeldEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeHeldEvent(raw []byte) (HeldEvent, int, error) { + var v HeldEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeReleasedEvent reads a ReleasedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeReleasedEvent(raw []byte) (ReleasedEvent, int, error) { + var v ReleasedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// formRead is the form a value says on the wire: 1 when it says none, or is no object. +func formRead(raw []byte) int { + var f struct { + Form int `json:"form"` + } + if json.Unmarshal(raw, &f) != nil || f.Form < 1 { + return 1 + } + return f.Form +} diff --git a/modules/mesh-delivery-contracts/go/seats/git/contract.go b/modules/mesh-delivery-contracts/go/seats/git/contract.go index e5ba278d1..60fe8348a 100644 --- a/modules/mesh-delivery-contracts/go/seats/git/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/git/contract.go @@ -4,9 +4,7 @@ package git import ( - "bytes" "encoding/json" - "errors" "strings" "time" ) @@ -14,6 +12,17 @@ import ( // Seat is the seat's name. const Seat = "git" +// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): +// a reader of a value of another form says "form N, this reader knows M". +const Form = 1 + +// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition +// whose fields changed while its forms did not (design 47 H2 §780). +const ( + generatedForms = "1" + generatedFieldsDigest = "76d91e80e3c40c239af4ab4ea133e72f3757b17fbbf98452cb53cbe15f343a57" +) + const ( VerbPull = "pull" VerbBranch = "branch" @@ -129,18 +138,13 @@ func ParseFailedStepsByModuleFingerprintStepKey(key string) (string, string, str return v0, v2, v4, true } -// DecodeFailedStepsByModuleFingerprintStepValue reads one value of the state failed-steps under the form "..", refusing a field FailedStepsByModuleFingerprintStepValue does not know and any text after the value. -func DecodeFailedStepsByModuleFingerprintStepValue(raw []byte) (FailedStepsByModuleFingerprintStepValue, error) { +// DecodeFailedStepsByModuleFingerprintStepValue reads one value of the state failed-steps under the form ".." as another part wrote it: a field FailedStepsByModuleFingerprintStepValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeFailedStepsByModuleFingerprintStepValue(raw []byte) (FailedStepsByModuleFingerprintStepValue, int, error) { var v FailedStepsByModuleFingerprintStepValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // CallsByCallCallKey is the key of one value of the state calls under the form "call.". @@ -164,18 +168,13 @@ func ParseCallsByCallCallKey(key string) (string, bool) { return v1, true } -// DecodeCallsByCallCallValue reads one value of the state calls under the form "call.", refusing a field CallsByCallCallValue does not know and any text after the value. -func DecodeCallsByCallCallValue(raw []byte) (CallsByCallCallValue, error) { +// DecodeCallsByCallCallValue reads one value of the state calls under the form "call." as another part wrote it: a field CallsByCallCallValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeCallsByCallCallValue(raw []byte) (CallsByCallCallValue, int, error) { var v CallsByCallCallValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // Call is one merge call, written before its first merge and updated as each member merges (design 47 H §766). @@ -184,7 +183,9 @@ type Call struct { Account string `json:"account"` At time.Time `json:"at"` // the caller as who@node - By string `json:"by"` + By string `json:"by"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` Members []CallMember `json:"members"` // merge-called was said for it Said bool `json:"said"` @@ -242,7 +243,9 @@ type FailedStep struct { Commits []string `json:"commits"` // the build-input fingerprint the step failed at Fingerprint string `json:"fingerprint"` - Module string `json:"module"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` + Module string `json:"module"` // the run that failed it: the runner's pipeline key Run string `json:"run"` // why it failed, as the runner's step-ended said @@ -369,6 +372,8 @@ type MergeCalled struct { By string `json:"by"` // the merge call, 16 lowercase hex characters made once per call Call string `json:"call"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // one per landed member Members []MergeCalledMembersItem `json:"members"` // one per member not merged after every member was judged (design 47 H §767) @@ -390,8 +395,10 @@ type PullAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` - Merging *Merging `json:"merging,omitempty"` - Pull *Pull `json:"pull,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` + Merging *Merging `json:"merging,omitempty"` + Pull *Pull `json:"pull,omitempty"` } // BranchInput is what branch takes. @@ -407,6 +414,8 @@ type BranchAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // a commit, its full 40-hex sha Head string `json:"head,omitempty"` Repository string `json:"repository,omitempty"` @@ -421,6 +430,8 @@ type OpenPullsAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // every open pull request; said empty when none is open, so an answer that lacks it is never read as none Pulls []OpenPull `json:"pulls"` } @@ -442,6 +453,8 @@ type TagsAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // another page exists More bool `json:"more,omitempty"` // the page @@ -473,6 +486,8 @@ type TreesAnswer struct { ErrorKind ErrorKind `json:"error-kind,omitempty"` // directory to {path: blob id} Files map[string]map[string]string `json:"files,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // directory to {path: object id} Paths map[string]map[string]string `json:"paths,omitempty"` // the root tree's hash @@ -502,6 +517,8 @@ type FileAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the path Path string `json:"path,omitempty"` // what was read @@ -531,6 +548,8 @@ type ContainsAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the other In string `json:"in,omitempty"` } @@ -552,6 +571,8 @@ type StatusesAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the newest of each context Statuses []Status `json:"statuses,omitempty"` } @@ -588,6 +609,8 @@ type StatusAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the id was already held on the pull request or the note, so nothing was done again Held bool `json:"held,omitempty"` // the act's id, as the caller gave it @@ -613,6 +636,8 @@ type CommentAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the id was already held on the pull request or the note, so nothing was done again Held bool `json:"held,omitempty"` // the act's id, as the caller gave it @@ -638,6 +663,8 @@ type ViewAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the id was already held on the pull request or the note, so nothing was done again Held bool `json:"held,omitempty"` // the act's id, as the caller gave it @@ -663,6 +690,8 @@ type NoteAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the id was already held on the pull request or the note, so nothing was done again Held bool `json:"held,omitempty"` // the act's id, as the caller gave it @@ -696,6 +725,8 @@ type MergePullAnswer struct { // why the forge could not answer, or refused: set alone with error-kind, and a caller reads it as a failure, never as none Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // each member's outcome, in the order named Members []MemberOutcome `json:"members,omitempty"` } @@ -715,6 +746,8 @@ type TagAnswer struct { // why the forge could not write it: set alone with error-kind Error string `json:"error,omitempty"` ErrorKind ErrorKind `json:"error-kind,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the forge holds the tag at that commit now Performed bool `json:"performed,omitempty"` // the tag, as asked @@ -732,6 +765,8 @@ type PullUpdatedEvent struct { // its head branch Branch string `json:"branch"` Change *Change `json:"change,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // a commit, its full 40-hex sha Head string `json:"head"` // the pull request's number @@ -753,6 +788,8 @@ type PullMergedEvent struct { // its head branch Branch string `json:"branch"` Change *Change `json:"change,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // a commit, its full 40-hex sha Head string `json:"head"` // the head's statuses by context, their states; absent when they could not be read @@ -779,6 +816,8 @@ type PullClosedEvent struct { Base string `json:"base"` // its head branch Branch string `json:"branch"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // a commit, its full 40-hex sha Head string `json:"head"` // the pull request's number @@ -801,6 +840,8 @@ type ForgePullEvent struct { Base string `json:"base,omitempty"` // its head branch Branch string `json:"branch,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // its head commit Head string `json:"head,omitempty"` // the merge commit @@ -823,6 +864,8 @@ type ForgeStatusEvent struct { Context string `json:"context"` // what it says Description string `json:"description,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the repository, / Repository string `json:"repository"` // who set it @@ -833,6 +876,8 @@ type ForgeStatusEvent struct { // ForgeDeleteEvent is the body of the event forge-delete. type ForgeDeleteEvent struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the deleted branch or tag Ref string `json:"ref"` // branch or tag @@ -847,6 +892,8 @@ type ForgeDeleteEvent struct { type RepoWritableEvent struct { // the account that writes it now Account string `json:"account"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the repository, / Repository string `json:"repository"` } @@ -855,6 +902,8 @@ type RepoWritableEvent struct { type BranchMovedEvent struct { At *time.Time `json:"at,omitempty"` Branch string `json:"branch"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the head the webhook said, a commit's full 40-hex sha; read again by branch Head string `json:"head,omitempty"` // the repository, / @@ -869,3 +918,221 @@ type FailedStepsByModuleFingerprintStepValue = FailedStep // CallsByCallCallValue is one value of the state calls under the key call.. type CallsByCallCallValue = Call + +// DecodePullAnswer reads a PullAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePullAnswer(raw []byte) (PullAnswer, int, error) { + var v PullAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeBranchAnswer reads a BranchAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeBranchAnswer(raw []byte) (BranchAnswer, int, error) { + var v BranchAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeOpenPullsAnswer reads a OpenPullsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeOpenPullsAnswer(raw []byte) (OpenPullsAnswer, int, error) { + var v OpenPullsAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeTagsAnswer reads a TagsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeTagsAnswer(raw []byte) (TagsAnswer, int, error) { + var v TagsAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeTreesAnswer reads a TreesAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeTreesAnswer(raw []byte) (TreesAnswer, int, error) { + var v TreesAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeFileAnswer reads a FileAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeFileAnswer(raw []byte) (FileAnswer, int, error) { + var v FileAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeContainsAnswer reads a ContainsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeContainsAnswer(raw []byte) (ContainsAnswer, int, error) { + var v ContainsAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeStatusesAnswer reads a StatusesAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeStatusesAnswer(raw []byte) (StatusesAnswer, int, error) { + var v StatusesAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeStatusAnswer reads a StatusAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeStatusAnswer(raw []byte) (StatusAnswer, int, error) { + var v StatusAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeCommentAnswer reads a CommentAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeCommentAnswer(raw []byte) (CommentAnswer, int, error) { + var v CommentAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeViewAnswer reads a ViewAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeViewAnswer(raw []byte) (ViewAnswer, int, error) { + var v ViewAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeNoteAnswer reads a NoteAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeNoteAnswer(raw []byte) (NoteAnswer, int, error) { + var v NoteAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeMergePullAnswer reads a MergePullAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeMergePullAnswer(raw []byte) (MergePullAnswer, int, error) { + var v MergePullAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeTagAnswer reads a TagAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeTagAnswer(raw []byte) (TagAnswer, int, error) { + var v TagAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodePullUpdatedEvent reads a PullUpdatedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePullUpdatedEvent(raw []byte) (PullUpdatedEvent, int, error) { + var v PullUpdatedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodePullMergedEvent reads a PullMergedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePullMergedEvent(raw []byte) (PullMergedEvent, int, error) { + var v PullMergedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodePullClosedEvent reads a PullClosedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePullClosedEvent(raw []byte) (PullClosedEvent, int, error) { + var v PullClosedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeForgePullEvent reads a ForgePullEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeForgePullEvent(raw []byte) (ForgePullEvent, int, error) { + var v ForgePullEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeForgeStatusEvent reads a ForgeStatusEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeForgeStatusEvent(raw []byte) (ForgeStatusEvent, int, error) { + var v ForgeStatusEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeForgeDeleteEvent reads a ForgeDeleteEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeForgeDeleteEvent(raw []byte) (ForgeDeleteEvent, int, error) { + var v ForgeDeleteEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeRepoWritableEvent reads a RepoWritableEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeRepoWritableEvent(raw []byte) (RepoWritableEvent, int, error) { + var v RepoWritableEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeBranchMovedEvent reads a BranchMovedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeBranchMovedEvent(raw []byte) (BranchMovedEvent, int, error) { + var v BranchMovedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeMergeCalledEvent reads a MergeCalledEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeMergeCalledEvent(raw []byte) (MergeCalledEvent, int, error) { + var v MergeCalledEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// formRead is the form a value says on the wire: 1 when it says none, or is no object. +func formRead(raw []byte) int { + var f struct { + Form int `json:"form"` + } + if json.Unmarshal(raw, &f) != nil || f.Form < 1 { + return 1 + } + return f.Form +} diff --git a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go index eb534618a..9329709ff 100644 --- a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go @@ -3,9 +3,27 @@ // Package gopackageregistry is the contract of the seat "go-package-registry", defined whole (seats/go-package-registry/seat.json): The mesh's Go modules: Go's module proxy protocol's read side, and publishing over the bus. package gopackageregistry +import ( + "encoding/json" +) + // Seat is the seat's name. const Seat = "go-package-registry" +// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): +// a reader of a value of another form says "form N, this reader knows M". +const Form = 1 + +// FormRegistry is the form of what the part registry adds. +const FormRegistry = 1 + +// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition +// whose fields changed while its forms did not (design 47 H2 §780). +const ( + generatedForms = "1 registry:1" + generatedFieldsDigest = "b80afb127966ec05c9c822eab0ab43488e6ee0a9d0f43cb1334e4fa32f07bb35" +) + const ( VerbPublish = "publish" VerbPublishPart = "publish-part" @@ -83,6 +101,8 @@ type Outcome struct { Digest string `json:"digest"` // the build's fingerprint Fingerprint string `json:"fingerprint,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the module holding the seat that said it Holder string `json:"holder"` // what it is @@ -155,6 +175,8 @@ const ( // PublishAnswer is what publish answers. type PublishAnswer struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the digest is held already: nothing to send; the outcome follows as an event Held bool `json:"held,omitempty"` // the digests of the parts the holder lacks, to send by publish-part @@ -181,6 +203,8 @@ type PublishPartInput struct { type PublishPartAnswer struct { // the part is whole and its bytes match its digest Complete bool `json:"complete,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the part Part string `json:"part"` // the chunks of the part held so far @@ -199,6 +223,8 @@ type VersionsInput struct { // VersionsAnswer is what versions answers. type VersionsAnswer struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the name Name string `json:"name"` // newest first @@ -228,6 +254,8 @@ const ( // RemoveAnswer is what remove answers. type RemoveAnswer struct { Artifact *Artifact `json:"artifact,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // it stays whole, its tag and its bytes: the store cannot remove the tag alone while another tag names its digest (reason, tags) Kept bool `json:"kept,omitempty"` // why it was kept: shared-digest, another tag names its digest @@ -260,3 +288,86 @@ type GoPackageRegistryForm struct { // the read side's address URL string `json:"url"` } + +// DecodePublishAnswer reads a PublishAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePublishAnswer(raw []byte) (PublishAnswer, int, error) { + var v PublishAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodePublishPartAnswer reads a PublishPartAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePublishPartAnswer(raw []byte) (PublishPartAnswer, int, error) { + var v PublishPartAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeVersionsAnswer reads a VersionsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeVersionsAnswer(raw []byte) (VersionsAnswer, int, error) { + var v VersionsAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeRemoveAnswer reads a RemoveAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeRemoveAnswer(raw []byte) (RemoveAnswer, int, error) { + var v RemoveAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodePublishedEvent reads a PublishedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePublishedEvent(raw []byte) (PublishedEvent, int, error) { + var v PublishedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeRefusedEvent reads a RefusedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeRefusedEvent(raw []byte) (RefusedEvent, int, error) { + var v RefusedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeRemovedEvent reads a RemovedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeRemovedEvent(raw []byte) (RemovedEvent, int, error) { + var v RemovedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeKeptEvent reads a KeptEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeKeptEvent(raw []byte) (KeptEvent, int, error) { + var v KeptEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// formRead is the form a value says on the wire: 1 when it says none, or is no object. +func formRead(raw []byte) int { + var f struct { + Form int `json:"form"` + } + if json.Unmarshal(raw, &f) != nil || f.Form < 1 { + return 1 + } + return f.Form +} diff --git a/modules/mesh-delivery-contracts/go/seats/meshartifactsweep/contract.go b/modules/mesh-delivery-contracts/go/seats/meshartifactsweep/contract.go index 8aa87d219..928422ba8 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshartifactsweep/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshartifactsweep/contract.go @@ -3,11 +3,25 @@ // Package meshartifactsweep is the contract of the seat "mesh-artifact-sweep", defined whole (seats/mesh-artifact-sweep/seat.json): no description. package meshartifactsweep -import "time" +import ( + "encoding/json" + "time" +) // Seat is the seat's name. const Seat = "mesh-artifact-sweep" +// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): +// a reader of a value of another form says "form N, this reader knows M". +const Form = 1 + +// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition +// whose fields changed while its forms did not (design 47 H2 §780). +const ( + generatedForms = "1" + generatedFieldsDigest = "15ff15679b43316c05f50583f7ed5e367eac2ba26003374b05a94f5107857a92" +) + const ( VerbArtifacts = "artifacts" VerbHeld = "held" @@ -47,6 +61,8 @@ type ArtifactsGone struct { Event string `json:"event"` // the key's fingerprint Fingerprint string `json:"fingerprint"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // every reference of the key the store does not hold, sorted Gone []string `json:"gone"` // the builder's done key @@ -80,6 +96,8 @@ type HeldInput struct { // HeldAnswer is what held answers. type HeldAnswer struct { + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the references the store answered 404 for Gone []string `json:"gone"` // the references the store holds @@ -127,3 +145,68 @@ type ImagesAnswer = map[string]any // ArtifactsGoneEvent is the body of the event artifacts-gone. type ArtifactsGoneEvent = ArtifactsGone + +// DecodeArtifactsAnswer reads a ArtifactsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeArtifactsAnswer(raw []byte) (ArtifactsAnswer, int, error) { + var v ArtifactsAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeHeldAnswer reads a HeldAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeHeldAnswer(raw []byte) (HeldAnswer, int, error) { + var v HeldAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeCollectAnswer reads a CollectAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeCollectAnswer(raw []byte) (CollectAnswer, int, error) { + var v CollectAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeMirrorsAnswer reads a MirrorsAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeMirrorsAnswer(raw []byte) (MirrorsAnswer, int, error) { + var v MirrorsAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeImagesAnswer reads a ImagesAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeImagesAnswer(raw []byte) (ImagesAnswer, int, error) { + var v ImagesAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeArtifactsGoneEvent reads a ArtifactsGoneEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeArtifactsGoneEvent(raw []byte) (ArtifactsGoneEvent, int, error) { + var v ArtifactsGoneEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// formRead is the form a value says on the wire: 1 when it says none, or is no object. +func formRead(raw []byte) int { + var f struct { + Form int `json:"form"` + } + if json.Unmarshal(raw, &f) != nil || f.Form < 1 { + return 1 + } + return f.Form +} diff --git a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go index 10c632d2d..009dd68f4 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go @@ -3,11 +3,25 @@ // Package meshbuilds is the contract of the seat "mesh-builds", defined whole (seats/mesh-builds/seat.json): The builder's seat: it says each artifact it published and each agreed toolchain, and answers a module's reserved version. Held once for the mesh (design 47 G section 52, section 307). package meshbuilds -import "time" +import ( + "encoding/json" + "time" +) // Seat is the seat's name. const Seat = "mesh-builds" +// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): +// a reader of a value of another form says "form N, this reader knows M". +const Form = 1 + +// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition +// whose fields changed while its forms did not (design 47 H2 §780). +const ( + generatedForms = "1" + generatedFieldsDigest = "4001613559208a0a99ed933d22eefad947365f8bcd6ba091dc4edb5e869d4798" +) + const ( VerbReserved = "reserved" VerbPublished = "published" @@ -94,6 +108,8 @@ type PackagePublished struct { Dependencies []Dependency `json:"dependencies,omitempty"` // the published artifact's digest Digest string `json:"digest"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the module Module string `json:"module"` // the catalog revision number of that branch the build was made from, the indexer's count (design 47 H-A-218, H-A-220); absent from a reservation made before the field @@ -112,6 +128,8 @@ type StepEnded struct { Ended *time.Time `json:"ended,omitempty"` // each entry the step built, by module and fingerprint Entries []BuildEntry `json:"entries"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the ask's id ID string `json:"id"` // the node the builder ran it on, as in the subject @@ -180,6 +198,8 @@ type ToolchainAgreed struct { At *time.Time `json:"at,omitempty"` // each digest the nodes reporting the agreed version report, as it stood when the version was agreed, with those nodes (design 47 G section 472, section 495) Digests []ToolchainAgreedDigestsItem `json:"digests"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the language whose agreed toolchain changed Language string `json:"language"` V int64 `json:"v"` @@ -210,6 +230,8 @@ type ReservedAnswer struct { Artifacts []ReservedAnswerArtifactsItem `json:"artifacts,omitempty"` // a name no entry carries, or a version neither reserved nor released, naming which; set alone (design 47 G 582, 679) Error string `json:"error,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // the module Module string `json:"module,omitempty"` // true when the version is released: the catalog holds it, and artifacts are the ones its release recorded with their digests; false when it is reserved (design 47 G 582, 679) @@ -234,6 +256,8 @@ type PublishedAnswer struct { At *time.Time `json:"at,omitempty"` // the published artifact's digest, when published; absent for a release kept before the digest was kept (design 47 H-A-331) Digest string `json:"digest,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` // true when the artifact built at the fingerprint is published; a number a take-over withdrew is never published (design 47 H-A-331) Published bool `json:"published"` // the version it is published at, MAJOR.MINOR.PATCH, when published @@ -251,3 +275,59 @@ type ToolchainAgreedEvent = ToolchainAgreed // StepEndedEvent is the body of the event step-ended. type StepEndedEvent = StepEnded + +// DecodeReservedAnswer reads a ReservedAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeReservedAnswer(raw []byte) (ReservedAnswer, int, error) { + var v ReservedAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodePublishedAnswer reads a PublishedAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePublishedAnswer(raw []byte) (PublishedAnswer, int, error) { + var v PublishedAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodePackagePublishedEvent reads a PackagePublishedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePackagePublishedEvent(raw []byte) (PackagePublishedEvent, int, error) { + var v PackagePublishedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeToolchainAgreedEvent reads a ToolchainAgreedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeToolchainAgreedEvent(raw []byte) (ToolchainAgreedEvent, int, error) { + var v ToolchainAgreedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// DecodeStepEndedEvent reads a StepEndedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeStepEndedEvent(raw []byte) (StepEndedEvent, int, error) { + var v StepEndedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + +// formRead is the form a value says on the wire: 1 when it says none, or is no object. +func formRead(raw []byte) int { + var f struct { + Form int `json:"form"` + } + if json.Unmarshal(raw, &f) != nil || f.Form < 1 { + return 1 + } + return f.Form +} diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index 1ad5e63d5..1c98e0ade 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -4,9 +4,7 @@ package meshcatalog import ( - "bytes" "encoding/json" - "errors" "strings" "time" ) @@ -14,6 +12,17 @@ import ( // Seat is the seat's name. const Seat = "mesh-catalog" +// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): +// a reader of a value of another form says "form N, this reader knows M". +const Form = 1 + +// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition +// whose fields changed while its forms did not (design 47 H2 §780). +const ( + generatedForms = "1" + generatedFieldsDigest = "5a5f6106fe9ee419cc10e40c34f4e901b9ee9215033079381243d04d898e5c7c" +) + const ( VerbModules = "modules" VerbModule = "module" @@ -132,18 +141,13 @@ func ParseManifestsByDigestKey(key string) (string, bool) { return v0, true } -// DecodeManifestsByDigestValue reads one value of the state manifests under the form "", refusing a field ManifestsByDigestValue does not know and any text after the value. -func DecodeManifestsByDigestValue(raw []byte) (ManifestsByDigestValue, error) { +// DecodeManifestsByDigestValue reads one value of the state manifests under the form "" as another part wrote it: a field ManifestsByDigestValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeManifestsByDigestValue(raw []byte) (ManifestsByDigestValue, int, error) { var v ManifestsByDigestValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // ModulesByModuleKey is the key of one value of the state modules under the form "". @@ -163,18 +167,13 @@ func ParseModulesByModuleKey(key string) (string, bool) { return v0, true } -// DecodeModulesByModuleValue reads one value of the state modules under the form "", refusing a field ModulesByModuleValue does not know and any text after the value. -func DecodeModulesByModuleValue(raw []byte) (ModulesByModuleValue, error) { +// DecodeModulesByModuleValue reads one value of the state modules under the form "" as another part wrote it: a field ModulesByModuleValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeModulesByModuleValue(raw []byte) (ModulesByModuleValue, int, error) { var v ModulesByModuleValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // CandidatesByGroupKey is the key of one value of the state candidates under the form "". @@ -194,18 +193,13 @@ func ParseCandidatesByGroupKey(key string) (string, bool) { return v0, true } -// DecodeCandidatesByGroupValue reads one value of the state candidates under the form "", refusing a field CandidatesByGroupValue does not know and any text after the value. -func DecodeCandidatesByGroupValue(raw []byte) (CandidatesByGroupValue, error) { +// DecodeCandidatesByGroupValue reads one value of the state candidates under the form "" as another part wrote it: a field CandidatesByGroupValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeCandidatesByGroupValue(raw []byte) (CandidatesByGroupValue, int, error) { var v CandidatesByGroupValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // PredefinedByListKey is the key of one value of the state predefined under the form "list". @@ -224,18 +218,13 @@ func ParsePredefinedByListKey(key string) bool { return true } -// DecodePredefinedByListValue reads one value of the state predefined under the form "list", refusing a field PredefinedByListValue does not know and any text after the value. -func DecodePredefinedByListValue(raw []byte) (PredefinedByListValue, error) { +// DecodePredefinedByListValue reads one value of the state predefined under the form "list" as another part wrote it: a field PredefinedByListValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePredefinedByListValue(raw []byte) (PredefinedByListValue, int, error) { var v PredefinedByListValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // PackagesByModuleKey is the key of one value of the state packages under the form "". @@ -255,18 +244,13 @@ func ParsePackagesByModuleKey(key string) (string, bool) { return v0, true } -// DecodePackagesByModuleValue reads one value of the state packages under the form "", refusing a field PackagesByModuleValue does not know and any text after the value. -func DecodePackagesByModuleValue(raw []byte) (PackagesByModuleValue, error) { +// DecodePackagesByModuleValue reads one value of the state packages under the form "" as another part wrote it: a field PackagesByModuleValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePackagesByModuleValue(raw []byte) (PackagesByModuleValue, int, error) { var v PackagesByModuleValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // PackagesByPackageSeriesKey is the key of one value of the state packages under the form ".". @@ -291,18 +275,13 @@ func ParsePackagesByPackageSeriesKey(key string) (string, string, bool) { return v0, v2, true } -// DecodePackagesByPackageSeriesValue reads one value of the state packages under the form ".", refusing a field PackagesByPackageSeriesValue does not know and any text after the value. -func DecodePackagesByPackageSeriesValue(raw []byte) (PackagesByPackageSeriesValue, error) { +// DecodePackagesByPackageSeriesValue reads one value of the state packages under the form "." as another part wrote it: a field PackagesByPackageSeriesValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodePackagesByPackageSeriesValue(raw []byte) (PackagesByPackageSeriesValue, int, error) { var v PackagesByPackageSeriesValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // CatalogRevisionsByBranchRevisionKey is the key of one value of the state catalog-revisions under the form ".". @@ -329,18 +308,13 @@ func ParseCatalogRevisionsByBranchRevisionKey(key string) (string, string, bool) return v0, v2, true } -// DecodeCatalogRevisionsByBranchRevisionValue reads one value of the state catalog-revisions under the form ".", refusing a field CatalogRevisionsByBranchRevisionValue does not know and any text after the value. -func DecodeCatalogRevisionsByBranchRevisionValue(raw []byte) (CatalogRevisionsByBranchRevisionValue, error) { +// DecodeCatalogRevisionsByBranchRevisionValue reads one value of the state catalog-revisions under the form "." as another part wrote it: a field CatalogRevisionsByBranchRevisionValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeCatalogRevisionsByBranchRevisionValue(raw []byte) (CatalogRevisionsByBranchRevisionValue, int, error) { var v CatalogRevisionsByBranchRevisionValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // CatalogRevisionsByCandidateGroupHeadsKey is the key of one value of the state catalog-revisions under the form "candidate..". @@ -371,18 +345,13 @@ func ParseCatalogRevisionsByCandidateGroupHeadsKey(key string) (string, string, return v1, v3, true } -// DecodeCatalogRevisionsByCandidateGroupHeadsValue reads one value of the state catalog-revisions under the form "candidate..", refusing a field CatalogRevisionsByCandidateGroupHeadsValue does not know and any text after the value. -func DecodeCatalogRevisionsByCandidateGroupHeadsValue(raw []byte) (CatalogRevisionsByCandidateGroupHeadsValue, error) { +// DecodeCatalogRevisionsByCandidateGroupHeadsValue reads one value of the state catalog-revisions under the form "candidate.." as another part wrote it: a field CatalogRevisionsByCandidateGroupHeadsValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeCatalogRevisionsByCandidateGroupHeadsValue(raw []byte) (CatalogRevisionsByCandidateGroupHeadsValue, int, error) { var v CatalogRevisionsByCandidateGroupHeadsValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // CatalogRevisionsByEntryDigestKey is the key of one value of the state catalog-revisions under the form "entry.". @@ -406,18 +375,13 @@ func ParseCatalogRevisionsByEntryDigestKey(key string) (string, bool) { return v1, true } -// DecodeCatalogRevisionsByEntryDigestValue reads one value of the state catalog-revisions under the form "entry.", refusing a field CatalogRevisionsByEntryDigestValue does not know and any text after the value. -func DecodeCatalogRevisionsByEntryDigestValue(raw []byte) (CatalogRevisionsByEntryDigestValue, error) { +// DecodeCatalogRevisionsByEntryDigestValue reads one value of the state catalog-revisions under the form "entry." as another part wrote it: a field CatalogRevisionsByEntryDigestValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeCatalogRevisionsByEntryDigestValue(raw []byte) (CatalogRevisionsByEntryDigestValue, int, error) { var v CatalogRevisionsByEntryDigestValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // RegistrationsByModuleKey is the key of one value of the state registrations under the form "". @@ -437,18 +401,13 @@ func ParseRegistrationsByModuleKey(key string) (string, bool) { return v0, true } -// DecodeRegistrationsByModuleValue reads one value of the state registrations under the form "", refusing a field RegistrationsByModuleValue does not know and any text after the value. -func DecodeRegistrationsByModuleValue(raw []byte) (RegistrationsByModuleValue, error) { +// DecodeRegistrationsByModuleValue reads one value of the state registrations under the form "" as another part wrote it: a field RegistrationsByModuleValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeRegistrationsByModuleValue(raw []byte) (RegistrationsByModuleValue, int, error) { var v RegistrationsByModuleValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // RegistrationHistoryByModuleVersionKey is the key of one value of the state registration-history under the form ".". @@ -475,18 +434,13 @@ func ParseRegistrationHistoryByModuleVersionKey(key string) (string, string, boo return v0, v2, true } -// DecodeRegistrationHistoryByModuleVersionValue reads one value of the state registration-history under the form ".", refusing a field RegistrationHistoryByModuleVersionValue does not know and any text after the value. -func DecodeRegistrationHistoryByModuleVersionValue(raw []byte) (RegistrationHistoryByModuleVersionValue, error) { +// DecodeRegistrationHistoryByModuleVersionValue reads one value of the state registration-history under the form "." as another part wrote it: a field RegistrationHistoryByModuleVersionValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeRegistrationHistoryByModuleVersionValue(raw []byte) (RegistrationHistoryByModuleVersionValue, int, error) { var v RegistrationHistoryByModuleVersionValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // VersionsByModuleVersionKey is the key of one value of the state versions under the form ".". @@ -511,18 +465,13 @@ func ParseVersionsByModuleVersionKey(key string) (string, string, bool) { return v0, v2, true } -// DecodeVersionsByModuleVersionValue reads one value of the state versions under the form ".", refusing a field VersionsByModuleVersionValue does not know and any text after the value. -func DecodeVersionsByModuleVersionValue(raw []byte) (VersionsByModuleVersionValue, error) { +// DecodeVersionsByModuleVersionValue reads one value of the state versions under the form "." as another part wrote it: a field VersionsByModuleVersionValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeVersionsByModuleVersionValue(raw []byte) (VersionsByModuleVersionValue, int, error) { var v VersionsByModuleVersionValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // BuildEdgesByModuleBranchKey is the key of one value of the state build-edges under the form ".". @@ -547,18 +496,13 @@ func ParseBuildEdgesByModuleBranchKey(key string) (string, string, bool) { return v0, v2, true } -// DecodeBuildEdgesByModuleBranchValue reads one value of the state build-edges under the form ".", refusing a field BuildEdgesByModuleBranchValue does not know and any text after the value. -func DecodeBuildEdgesByModuleBranchValue(raw []byte) (BuildEdgesByModuleBranchValue, error) { +// DecodeBuildEdgesByModuleBranchValue reads one value of the state build-edges under the form "." as another part wrote it: a field BuildEdgesByModuleBranchValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeBuildEdgesByModuleBranchValue(raw []byte) (BuildEdgesByModuleBranchValue, int, error) { var v BuildEdgesByModuleBranchValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil + return v, formRead(raw), nil } // InputsByTimeDigestKey is the key of one value of the state inputs under the form "