C1: the gate and the forge hold no branch name; the trunk is the asked branch, a default is the repository's

Builds: design 47 G §428, §507, A-93

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 22:18:25 +01:00
parent a6ce8dcbd6
commit 0aa5d6637c
6 changed files with 47 additions and 35 deletions
@@ -283,10 +283,10 @@ func tools(h *Holder, l *listening) []stdio.Tool {
{Name: "delivery_status",
Description: "Whether this owner works: how many delivery records are open and ended, what is owed to the forge and not yet " +
"answered, how many owed effects were tried since it started (done, failed and tried again, given up) and when the last " +
"was, whether its events arrive, the last refusals, and source.main as the gate's bucket source holds it.",
"was, whether its events arrive, the last refusals, and the source revision of every branch the gate's bucket source holds.",
Run: func(map[string]any) (any, error) {
out := h.Status(l.get())
out["source-main"] = h.SourceMain()
out["source"] = h.SourceAll()
return out, nil
}},
}
@@ -16,9 +16,6 @@ import (
// (switch.go, §613), never written; `source` is the gate's source revision per watched branch (§15, §291), served by the verb
// `source` below.
// MergeBranch is the trunk branch each repository's merge branch names in a source key.
const MergeBranch = "main"
// changeAttempts is how often a lost compare-and-set is read and applied again before it is said.
const changeAttempts = 10
@@ -155,7 +152,7 @@ func (kvSource) Branches() ([]string, error) {
// SourceRevision is the seat's verb source (§690): given a branch, every repository that branch's source key names, its
// trunk branch and head, the group that moved it last and its revision, or why it cannot be read; given none, `branches`,
// the branch of each source key the gate keeps. A key names each repository's merge branch only (MergeBranch). Outside the lock.
// the branch of each source key the gate keeps. The trunk of each repository is the branch asked, the key's own (§428, §507). Outside the lock.
func (h *Holder) SourceRevision(branch string) seat.SourceAnswer {
if h.Source == nil {
return seat.SourceAnswer{Error: "no source bucket"}
@@ -179,24 +176,8 @@ func (h *Holder) SourceRevision(branch string) seat.SourceAnswer {
}
out := seat.SourceAnswer{Branch: branch, Group: held.Group, Revision: int64(revision)}
for repository, head := range held.Heads {
out.Repositories = append(out.Repositories, seat.SourceHead{Repository: repository, Trunk: MergeBranch, Head: head})
out.Repositories = append(out.Repositories, seat.SourceHead{Repository: repository, Trunk: branch, Head: head})
}
sort.Slice(out.Repositories, func(i, j int) bool { return out.Repositories[i].Repository < out.Repositories[j].Repository })
return out
}
// SourceMain is source.main as the bucket source holds it, read and never written: its group and each repository's trunk
// head, or why it cannot be read. Outside the lock.
func (h *Holder) SourceMain() map[string]any {
if h.Source == nil {
return map[string]any{"error": "no source bucket"}
}
held, _, err := h.Source.Read(MergeBranch)
switch {
case err != nil:
return map[string]any{"error": err.Error()}
case held == nil:
return map[string]any{"heads": map[string]string{}, "says": "source.main is not written yet"}
}
return map[string]any{"group": held.Group, "heads": held.Heads}
}
@@ -84,3 +84,22 @@ func TestTheGateStatesItsPinsThenSaysPinsStated(t *testing.T) {
t.Fatalf("%d %v %+v", n, err, events)
}
}
// Design 47 G §428, §507: no part's code holds a branch's name; the trunk of each repository a source revision names is the
// branch whose key was read, and delivery_status says every branch's source, not one fixed branch's.
func TestTheSourceAnswerNamesTheBranchItWasAskedAndStatusSaysEveryBranch(t *testing.T) {
src := &branchSource{}
for _, b := range []string{"release", "feat"} {
_, _ = src.Set(b, func(*Source) (Source, bool) {
return Source{Group: "g-" + b, Heads: map[string]string{"novox/app": "c1"}}, true
})
}
h := &Holder{Now: time.Now, Source: src}
got := h.SourceRevision("release")
if len(got.Repositories) != 1 || got.Repositories[0].Trunk != "release" {
t.Fatalf("the trunk is the asked branch: %+v", got.Repositories)
}
if all, ok := h.SourceAll()["branches"].([]seat.SourceAnswer); !ok || len(all) != 2 {
t.Fatalf("status says every branch's source: %+v", h.SourceAll())
}
}
@@ -8,14 +8,6 @@ import (
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
)
// The holders the gate reads or hears, by the names their modules go by (the gate's own constants, one per reader: the
// manifest's reads and consumes name them).
const (
tellerModule = "mesh-delivery-teller"
viewModule = "mesh-delivery-view"
forgeBridgeModule = "mesh-delivery-forge-bridge"
)
// The values the gate keeps in the seat mesh-delivery's states. The seat's types are the layout and meshdeliveryclient
// holds their rules and codecs; Source, Owed and Answer are used as they are, and the three whose seat form differs from the
// form the gate works in (a pull request that holds its head, the router's ask as bytes, a turn's times as plain times)