The gate consumes the forge bridge's head-moved, keeps in its template state heads each head source.<branch> does not name, and raises head-untaken (scope delivery, id <repository>.<branch>, warning, the operator its resolver) once untaken-bound passes, on its one deadline timer; a later source revision naming the head lets it go and clears the finding. The stalled conditions, their state and the operator-channel use go: the watchman's record-open is the one signal. Builds: design 47 H §740; H-A-27 (head-moved's form, forgemsg), H-A-48 (the stalled conditions go; untaken-bound on the gate's one timer), H-A-81 (warning, resolver operator, no owner) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
86 lines
2.8 KiB
Go
86 lines
2.8 KiB
Go
package main
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
// 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
|
|
// Heads is the state heads of the watchdog (heads.go); nil watches none.
|
|
Heads HeadStore
|
|
|
|
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:]
|
|
}
|
|
}
|