Files
mesh-catalog/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/gate.go
T
jschoubben d901c6c19d GATE-2: the gate's groups from branch names and its pull request states go
A merge call is the delivery's group from H1, so the gate no longer keeps deliveries
and groups from the seat git's pull events, reads no open pull request at its start,
and answers deliveries and show from the records alone. The verb groups stays,
answered from the records, until the seat mesh-delivery's definition drops it.

Builds: design 47 H §764 (the gate: the groups from a branch name, its states deliveries and groups, its consumption of pull-updated, pull-merged and pull-closed, its start reconciliation); H-A-28

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
2026-11-20 02:36:11 +01:00

93 lines
3.2 KiB
Go

package main
import (
"sync"
"time"
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
)
// The holder of the seat mesh-delivery (novox/hq ADR 0239, to-be 47): from milestone G's delivery it keeps no merge states
// and asks no Approve per merge (design 47 G §172, §431, §592, §593, §613). What it keeps is the delivery records
// (record.go), the source revision per watched branch (merges.go) and what it owes the forge. It merges nothing.
// Seat is the seat the gate holds.
const Seat = "mesh-delivery"
// Holder is the seat's holder.
type Holder struct {
// Settings reads the operator's values (settings.go); nil keeps every default.
Settings func() Settings
Now func() time.Time
Logf func(format string, a ...any)
// Forge is the seat git's reads (sourcestart.go).
Forge ForgeReads
// Catalog reads the seat mesh-catalog's registrations (sourcestart.go); startMu keeps one start of the sources at a time.
Catalog Registered
startMu sync.Mutex
Source SourceStore
// Owed says what the gate owes the forge as the seat's event owed (owed.go).
Owed OwedSayer
// Records keeps the delivery records on the gate's ledger (record.go, ADR 0656 §7); nil keeps none.
Records *Records
// Consumer applies the step events to the records (consumer.go); nil applies none.
Consumer *StepConsumer
// SaySeat says an event of the seat mesh-delivery (recordevents.go); nil says none.
SaySeat SeatSay
// Findings is the gate's one held writer of its own findings (findings.go); nil writes none.
Findings FindingWriter
// Say says a condition to the operator, and Conditions keeps which the gate raised (conditions.go); nil says none.
Say func(c oc.Condition) error
Conditions ConditionStore
// said is what Conditions keeps, read at the first look; sayFailures the looks in a row a condition could not be said.
// Touched by React alone.
said map[string]string
sayFailures int
mu sync.Mutex
started time.Time
refusals []string
// tried counts the owed effects tried since this owner started, by how each ended (novox/hq issue 407).
tried owedTries
// reactMu keeps one React at a time; poke asks for a look (react.go); wanted is when the next is wanted, and its timer.
reactMu sync.Mutex
poke chan struct{}
wanted lookWanted
}
// owedTries is how many owed effects were tried since this owner started, and when the last was.
type owedTries struct {
done, failed, givenUp int
last time.Time
}
// The word this owner signs its acts with.
const byOwner = "mesh-delivery"
func (h *Holder) init() {
if h.Now == nil {
h.Now = func() time.Time { return time.Now().UTC() }
}
if h.Logf == nil {
h.Logf = func(string, ...any) {}
}
h.poke = make(chan struct{}, 1)
h.started = h.Now()
}
// Refuse keeps a refusal from outside the lock.
func (h *Holder) Refuse(err error) {
h.mu.Lock()
defer h.mu.Unlock()
h.refuse(err)
}
// refuse keeps a refusal, said, for the status; under the lock.
func (h *Holder) refuse(err error) {
h.Logf("[mesh-delivery] %v", err)
h.refusals = append(h.refusals, h.Now().Format(time.RFC3339)+" "+err.Error())
if len(h.refusals) > 50 {
h.refusals = h.refusals[len(h.refusals)-50:]
}
}