From 59f9a00c64dd2132f5e7af199f27a75bf0c626b6 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 11 Nov 2026 14:40:50 +0100 Subject: [PATCH] A merge the forge made with no record's merge-pull opens a forge-made delivery record, said once as its transition with why forge-made (milestone 47/G, W11.17e) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The record holds the pull request at its head and has no Approve; the delivery keeps that it was recorded (forge_recorded). Rows in issue 888's test. The test bridge never performs a switched act: the forge bridge decides. Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ (Joined from 674f49ef.) Builds: design 47 G §170 (GATE6) Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ --- .../cmd/mesh-delivery-gate/issue888_test.go | 16 ++++++++ .../cmd/mesh-delivery-gate/merges.go | 38 +++++++++++++++++++ .../cmd/mesh-delivery-gate/model.go | 3 ++ .../cmd/mesh-delivery-gate/ready.go | 1 + 4 files changed, 58 insertions(+) diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/issue888_test.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/issue888_test.go index ab6b42d94..d28d6d1a1 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/issue888_test.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/issue888_test.go @@ -31,6 +31,7 @@ func i888MergedAt(repo string, number int, head, merge string, at time.Time) Pul // 888/AC1: a merge into main the gate did not hand is heard from the forge: source.main holds it, and keeps the others. func TestAMergeHeardOnlyFromTheForgeMovesSourceMain(t *testing.T) { w := newWorld(t) + w.h.Records = &Records{Ledger: newLedgerFake(t), Now: w.h.Now} w.source.main = &Source{V: mdc.Version, Group: "earlier", Heads: map[string]string{i888Other: i888OtherH}} w.h.PullUpdated(pr(i888App, 3, i888Head1, "fix/x", "internal/a.go")) w.settleAll() @@ -52,6 +53,21 @@ func TestAMergeHeardOnlyFromTheForgeMovesSourceMain(t *testing.T) { if len(w.source.moves) != n || n != 1 { t.Fatalf("source.main moved %d then %d times; wanted once", n, len(w.source.moves)) } + // W11.17e: a merge with no record's merge-pull opens a forge-made record at its head, said once as a transition + // with why forge-made. + records, err := w.h.Records.Current() + if err != nil || len(records) != 1 || !records[0].ForgeMade || records[0].Heads[mdc.ApprovedKey(i888App, 3)] != i888Head1 { + t.Fatalf("the forge-made record is %+v (%v)", records, err) + } + var said []map[string]any + for _, e := range w.said { + if e["event-kind"] == "transition" && e["why"] == "forge-made" { + said = append(said, e) + } + } + if len(said) != 1 || said[0]["record"] != records[0].Instance { + t.Fatalf("the forge-made record is said %d times: %v", len(said), said) + } } // 888/AC2: a group the gate merged through the bridge moves source.main once, in finish, though the forge's word of each diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/merges.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/merges.go index 1404f6237..3f32bfb77 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/merges.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/merges.go @@ -652,6 +652,44 @@ func (h *Holder) settleForgeMerges() []func() { return out } +// recordForgeMade opens a forge-made delivery record for every merge into the trunk the forge made with no record's +// merge-pull (design 47 *What the gate owes the forge*): one the gate did not say the merge of, heard as it happened. It +// holds the pull request at its head, has no Approve, and is said as the delivery's transition with why forge-made, once. +// Under the lock; the record is opened outside it. +func (h *Holder) recordForgeMade() []func() { + if h.Records == nil { + return nil + } + var out []func() + for _, d := range h.deliveries { + if d.MergedAs == "" || d.ForgeRecorded || d.LearntLate || gateMerges(d) || d.Number == 0 || d.Base != MergeBranch { + continue + } + id, milestone, heads := d.ID, milestoneOf(d), map[string]string{mdc.ApprovedKey(d.Repository, d.Number): d.Commit} + out = append(out, func() { + r, _, err := h.Records.Open(milestone, heads, true) + h.mu.Lock() + defer h.mu.Unlock() + m := h.deliveries[id] + if err != nil || m == nil || r == nil { + if err != nil { + h.Logf("[mesh-delivery] %s merged at the forge with no record's merge-pull, and its forge-made record cannot be opened yet: %v; asked again in %s", id, err, askAgainAfter) + h.again("a forge-made record, opened for a merge the forge made") + } + return + } + now := h.Now() + body := transitionEvent(m, Transition{At: now, From: m.State, To: m.State, Event: "forge-made", Why: "forge-made"}, time.Time{}) + body["record"] = r.Instance + m.Owed = append(m.Owed, Effect{Kind: EffectEmit, Event: "transition", Line: string(mustJSON(body)), Since: now}) + m.ForgeRecorded = true + h.keep(m) + h.Logf("[mesh-delivery] %s merged at the forge with no record's merge-pull: its forge-made record is %s", id, r.Instance) + }) + } + return out +} + // trunkHead is a full commit id as the forge names a branch's head. var trunkHead = regexp.MustCompile(`^[0-9a-f]{40}$`) diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/model.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/model.go index 37e27c0bd..8f69a2209 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/model.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/model.go @@ -86,6 +86,9 @@ type Delivery struct { // InSource says the merge was looked at for source.main: written there, or left as older than the trunk's head (issue 888). // A merge the gate handed to the bridge on an Approve is moved there by finish instead (merges.go). InSource bool `json:"in_source,omitempty"` + // ForgeRecorded is a merge the forge made with no record's merge-pull whose forge-made record is opened and said + // (merges.go recordForgeMade). + ForgeRecorded bool `json:"forge_recorded,omitempty"` // LearntLate says its merge was learnt after the fact, from its absence among the forge's open pull requests // (settleGone, issue 1275): it moved no trunk here, and it never moves source.main, not even at a catch-up. LearntLate bool `json:"learnt_late,omitempty"` diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/ready.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/ready.go index 442593248..37186e644 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/ready.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/ready.go @@ -313,6 +313,7 @@ func (h *Holder) readyAsks(now time.Time) []func() { asks = append(asks, h.turnWrites()...) // the merge turns, after the holds of this look (ADR 0548 §3) asks = append(asks, h.settleMerges()...) asks = append(asks, h.settleForgeMerges()...) + asks = append(asks, h.recordForgeMade()...) asks = append(asks, h.seedTrunks()...) asks = append(asks, h.withdrawnKeys()...) asks = append(h.cancels, asks...)