From 763d6a107af5555f730ce5a78192c0dbe394f6b4 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 17 Nov 2026 20:34:49 +0100 Subject: [PATCH] A-476, principle 4: indexer_take_in_pending takes a pending revision in again, and a group A revision whose message is unread or lost, or held for room, has a hand recovery; its description says nothing of an indexer build. Builds: design 47 G A-476 --- .../internal/index/pending.go | 21 +++++++++---------- .../internal/index/pending_test.go | 18 +++++++++------- .../internal/index/pending_tools.go | 10 ++++----- .../internal/index/takein.go | 4 ++-- .../internal/index/unreadcall.go | 2 +- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/pending.go b/modules/mesh-delivery-indexer/internal/index/pending.go index 94b4697a..afddbe4d 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending.go +++ b/modules/mesh-delivery-indexer/internal/index/pending.go @@ -846,12 +846,12 @@ func (ix *Indexer) holdLost(ctx context.Context, ready, lost []PendingEntry, rea } for _, g := range lost { if unread[g.Key] { - ix.logf("take-in: %s (%s#%d) is not taken in and holds its revision, its message is unread for a transport fault: %s; it is read again on the next message heard on the forge and at the start", - g.Key, g.Forge.Repository, g.Forge.Number, reasons[g.Key]) + ix.logf("take-in: %s (%s#%d) is not taken in and holds its revision, its message is unread for a transport fault: %s; it is read again on the next message heard on the forge, at the start, and by %s", + g.Key, g.Forge.Repository, g.Forge.Number, reasons[g.Key], TakeInPendingTool) continue } - ix.logf("take-in: %s (%s#%d) is not taken in and holds its revision, the forge bridge could not give its message: %s; indexer_drop_pending drops it once a later merge of %s covers it", - g.Key, g.Forge.Repository, g.Forge.Number, reasons[g.Key], g.Forge.Repository) + ix.logf("take-in: %s (%s#%d) is not taken in and holds its revision, the forge bridge could not give its message: %s; %s reads it again; indexer_drop_pending drops it once a later merge of %s covers it", + g.Key, g.Forge.Repository, g.Forge.Number, reasons[g.Key], TakeInPendingTool, g.Forge.Repository) } if !ix.sayTakeIn(ctx, t) { return nil @@ -1318,8 +1318,8 @@ func waitOf(entries []PendingEntry, what, behind string) takein.PendingWait { return pw } -// TakeInPendingByHand is the hand take-in (indexer_take_in_pending, ADR 0633 §5, A-476 b): the group gathered so far, named by -// its g. key, is taken in with this indexer and its judge, +// TakeInPendingByHand is the hand take-in (indexer_take_in_pending, ADR 0633 §5, A-476, principle 4): the pending revision (its +// m. key) or the group gathered so far (its g. key) is taken in now with this indexer and its judge, // whatever build it names, for when the group's end never comes. by and why are // said in the journal and on the take-in.taken event. What waited behind it is evaluated again after. func (ix *Indexer) TakeInPendingByHand(ctx context.Context, key, by, why string) TakenIn { @@ -1345,9 +1345,8 @@ func (ix *Indexer) TakeInPendingByHand(ctx context.Context, key, by, why string) take = held } } - default: - r.Answer = fmt.Sprintf("%s names no delivery group: only a group is taken in by hand (a revision is taken in by the indexer itself); indexer_pending names the waits", key) - return r + case len(w.Ready) > 0 && w.Ready[0].Key == key: + take = w.Ready } if len(take) == 0 { r.Answer = fmt.Sprintf("nothing waits under %s: indexer_pending names the waits", key) @@ -1425,8 +1424,8 @@ func (ix *Indexer) DropPending(ctx context.Context, key, by, why string, abandon } if !covered { r.Answer = fmt.Sprintf("%s is not dropped: no later merge of %s, pending or taken in, has %s as an ancestor, so its "+ - "changes would never be taken in (ADR 0633 §5); abandon: true drops it all the same", - key, e.Forge.Repository, e.Forge.Merge) + "changes would never be taken in (ADR 0633 §5); %s reads its message again, or abandon: true drops it all the same", + key, e.Forge.Repository, e.Forge.Merge, TakeInPendingTool) return r } } diff --git a/modules/mesh-delivery-indexer/internal/index/pending_test.go b/modules/mesh-delivery-indexer/internal/index/pending_test.go index 950b0fbf..07792014 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending_test.go +++ b/modules/mesh-delivery-indexer/internal/index/pending_test.go @@ -359,10 +359,10 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633) return n } // The build this program runs is not known (the engine does not answer at its start): nothing waits for it, so the start - // takes the revision in all the same (A-476 b), and a hand ask names only groups. + // takes the revision in all the same (A-476 b), and a hand ask names what waits. next := mk(func(context.Context) (string, error) { return "", errors.New("not yet") }) - if r := next.TakeInPendingByHand(ctx, "m.nothing", "lead@shanks", "a test"); r.Stored || !strings.Contains(r.Answer, "names no delivery group") { - t.Errorf("a hand ask for a revision: %+v", r) + if r := next.TakeInPendingByHand(ctx, "m.nothing", "lead@shanks", "a test"); r.Stored || !strings.Contains(r.Answer, "nothing waits") { + t.Errorf("a hand ask for what does not wait: %+v", r) } if _, _, err := next.TakeInAtStart(ctx); err != nil { t.Fatal(err) @@ -850,8 +850,12 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633) !strings.Contains(r.Answer, "abandon") || len(b.keys()) != 1 { t.Fatalf("a drop nothing covers: %+v, pending %v", r, b.keys()) } - if r := b.ix.DropPending(ctx, takein.PendingKey(3), "lead@shanks", "abandoned", true); !r.Stored || len(b.keys()) != 0 { - t.Fatalf("an abandoned drop: %+v, pending %v", r, b.keys()) + // A pending revision is taken in by the tool, by its key (A-476, principle 4). + if _, _, err := NewPendingAsk(takein.PendingKey(3), "x", "lead@shanks", false, false, time.Unix(0, 0)); err != nil { + t.Fatalf("the ask to take a pending revision in: %v", err) + } + if r := b.ix.TakeInPendingByHand(ctx, takein.PendingKey(3), "lead@shanks", "its message was unread"); !r.Stored || len(b.keys()) != 0 || b.commit(t, "avahi") != sha('d') { + t.Fatalf("hand take-in of a revision: %+v, pending %v, avahi at %s", r, b.keys(), b.commit(t, "avahi")) } // A delivery group gathered is taken in by hand (A-476 b: only a group is). b.ix.Pins = newMem() @@ -870,8 +874,8 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633) // §476, §493: a hand take-in's taken event carries the branch, the source revision it makes and its entries. if len(b.said) >= 1 { got := b.said[0] - if got.Branch != TrunkBranch || got.Source <= 0 || len(got.Entries) != 1 || got.Entries[0].Module != "avahi" || - got.Entries[0].Commit != sha('f') || got.Entries[0].Fingerprint == "" { + if got.Branch != TrunkBranch || got.Source <= 0 || len(got.Entries) != 2 || got.Entries[1].Module != "avahi" || + got.Entries[1].Commit != sha('f') || got.Entries[1].Fingerprint == "" { t.Errorf("hand take-in said branch %q source %d entries %+v: want main, a source revision and avahi at its commit", got.Branch, got.Source, got.Entries) } else if newest, any, _ := newestTrunk(ctx, b.ix.Revisions); !any || got.Revision != newest.Revision { t.Errorf("hand take-in said revision %d, want the revision it made, %d (A-448)", got.Revision, newest.Revision) diff --git a/modules/mesh-delivery-indexer/internal/index/pending_tools.go b/modules/mesh-delivery-indexer/internal/index/pending_tools.go index bec7be46..ba52e019 100644 --- a/modules/mesh-delivery-indexer/internal/index/pending_tools.go +++ b/modules/mesh-delivery-indexer/internal/index/pending_tools.go @@ -75,12 +75,12 @@ func PendingTools(pending, ownBuild Store, ask func(key string, value []byte) (T return answer, nil }}, {Name: TakeInPendingTool, - Description: "Take a delivery group in by hand with the running indexer and its judge (ADR 0633 §5): the group under its g. key " + - "with the members gathered so far, for when its end never comes. Only a group is taken in by hand: a revision is taken in " + - "by the indexer itself. A hand act: who and why are said in the indexer's journal and on the take-in.taken event, which " + - "clears take-in-waits. indexer_pending names the keys.", + Description: "Take in now a pending revision (its m. key), for a merge whose message is unread or lost or that is held " + + "for room, or a delivery group (its g. key) with the members gathered so far, for when its end never comes (ADR 0633 §5). " + + "A hand act: who and why are said in the indexer's journal and on the take-in.taken event, which clears take-in-waits. " + + "indexer_pending names the keys.", Input: map[string]any{"type": "object", "required": []string{"key", "why"}, "properties": map[string]any{ - "key": map[string]any{"type": "string", "description": "the group's key, g., as indexer_pending names it"}, + "key": map[string]any{"type": "string", "description": "the wait's key, m. or g., as indexer_pending names it"}, "why": map[string]any{"type": "string", "description": "why it is taken in by hand, in plain words"}}}, Run: hand(false)}, {Name: DropPendingTool, diff --git a/modules/mesh-delivery-indexer/internal/index/takein.go b/modules/mesh-delivery-indexer/internal/index/takein.go index 5ea1004d..ae21ccc0 100644 --- a/modules/mesh-delivery-indexer/internal/index/takein.go +++ b/modules/mesh-delivery-indexer/internal/index/takein.go @@ -169,11 +169,11 @@ func NewMergeAsk(repository, merge string, sequence uint64, why, by string, at t // drop one pending merge's; abandon drops one no later merge covers. func NewPendingAsk(key, why, by string, drop, abandon bool, at time.Time) (string, []byte, error) { key = strings.TrimSpace(key) - if !(strings.HasPrefix(key, "m.") && drop) && !(strings.HasPrefix(key, "g.") && !drop) { + if !strings.HasPrefix(key, "m.") && !(strings.HasPrefix(key, "g.") && !drop) { if drop { return "", nil, errors.New("name the pending merge to drop by its key, m., as indexer_pending names it") } - return "", nil, errors.New("name the group to take in by its key, g., as indexer_pending names it") + return "", nil, errors.New("name the wait to take in by its key, m. or g., as indexer_pending names it") } if strings.TrimSpace(why) == "" { return "", nil, errors.New("say why (why): a hand act on what waits is said in the journal and on its take-in event") diff --git a/modules/mesh-delivery-indexer/internal/index/unreadcall.go b/modules/mesh-delivery-indexer/internal/index/unreadcall.go index 7d02bd10..d81e49fb 100644 --- a/modules/mesh-delivery-indexer/internal/index/unreadcall.go +++ b/modules/mesh-delivery-indexer/internal/index/unreadcall.go @@ -47,7 +47,7 @@ func (ix *Indexer) unreadFindings(ctx context.Context, entries []PendingEntry) { "A call whose answer is kept is not answered", fmt.Sprintf("The call %s is made again on every transport fault and on the callee's event; it has not been answered since %s. Its last fault: %s.", UnreadCallee, since.UTC().Format(time.RFC3339), e.Value.Unread), "indexer."+mcc.KindCallUnanswered) - f.Needs = "The merge is read again on the next message heard on the forge; " + PendingTool + " shows it unread." + f.Needs = TakeInPendingTool + " reads the merge again now; " + PendingTool + " shows it unread." f.Evidence = []mcseat.Evidence{{At: since.UTC(), Said: e.Value.Unread}} if err := ix.Findings.Write(ctx, f); err != nil { ix.logf("take-in: the finding %s is not written: %v", views.FindingKey(f.Scope, f.ID, f.Kind), err)