The gate consumes the seat git's merge-called and, per watched branch its members name, writes source.<branch> once by compare-and-set keyed by the call, numbered one above the branch's newest; opens that revision's record keyed <branch>.<source> with the call, by and account in its trace; says record-opened on record-opened.<call> and source-moved on source-moved.<branch>.<source>. The take-in.taken writes its movers into the record read by its key, and a take-in with no mover ends it as nothing to deliver. The verb groups, the record's pins and pins-stated, forge-made and the emitted transition go. One commit for both subtasks: the record's opening is the handler's second half and neither compiles alone against the contracts. Builds: design 47 H §737, §738 (a take-in with no movers ends its record), §749 (the pins are the indexer's), §764 (the gate: the source moved on take-in.taken, the verb groups); H-A-13, H-A-19, H-A-24, H-A-25, H-A-28, H-A-29, H-A-33, H-A-47 (the start writes through the seed's path, no record), H-A-48 (pins, pins-stated, transition, members <repository>@<number>), H-A-76 (Q-G1: the say-again carries the value's heads, start false) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
91 lines
3.4 KiB
Go
91 lines
3.4 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
|
|
)
|
|
|
|
type sayerFake struct{ said []seat.Owed }
|
|
|
|
func (f *sayerFake) Say(o seat.Owed) error { f.said = append(f.said, o); return nil }
|
|
|
|
// A-39: every change of a record owes a note line and the delivery view for each member pull request, and a comment only
|
|
// when the record ends failed or held.
|
|
func TestARecordsChangesOweTheNoteTheViewAndWhenFailedOrHeldAComment(t *testing.T) {
|
|
at := time.Date(2026, 11, 11, 21, 0, 0, 0, time.UTC)
|
|
head := strings.Repeat("1", 40)
|
|
setup := func(t *testing.T) (*Holder, *Records, *Record, *sayerFake) {
|
|
rs := &Records{Ledger: newLedgerFake(t), Now: func() time.Time { return at }}
|
|
f := &sayerFake{}
|
|
h := &Holder{Now: func() time.Time { return at }, Owed: f, Records: rs}
|
|
rs.Changed = h.recordChanged
|
|
r, _, err := rs.Open(opening("main", 47, map[string]string{"novox/app@7": head}))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := rs.AddEntry(r, RecordEntry{Module: "mesh-x", Fingerprint: "src2:f1", Node: "ace"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return h, rs, r, f
|
|
}
|
|
count := func(f *sayerFake, act string) (n int) {
|
|
for _, o := range f.said {
|
|
if o.Act == act {
|
|
n++
|
|
}
|
|
}
|
|
return
|
|
}
|
|
t.Run("an outcome applied says the note and the view, no comment", func(t *testing.T) {
|
|
_, rs, r, f := setup(t)
|
|
if _, err := rs.Outcome(r, RecordOutcome{Module: "mesh-x", Fingerprint: "src2:f1", Node: "ace", Step: "build", Outcome: OutcomeBuilt, Why: "built it"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(f.said) != 2 || count(f, seat.OwedActNote) != 1 || count(f, seat.OwedActView) != 1 {
|
|
t.Fatalf("said %+v", f.said)
|
|
}
|
|
for _, o := range f.said {
|
|
if o.Repository != "novox/app" || o.Number != 7 || o.Head != head {
|
|
t.Fatalf("act %+v", o)
|
|
}
|
|
if _, ok := r.Acts[o.ID]; !ok {
|
|
t.Fatalf("act %s not kept in the record", o.ID)
|
|
}
|
|
if o.Act == seat.OwedActNote && (o.Line != "2026-11-11T21:00:00Z record "+r.Instance+": mesh-x on ace build built (built it)" || o.Commit != head) {
|
|
t.Fatalf("note %+v", o)
|
|
}
|
|
if o.Act == seat.OwedActView && !strings.Contains(o.Text, r.Instance) {
|
|
t.Fatalf("view %q", o.Text)
|
|
}
|
|
}
|
|
// the same outcome again changes nothing and owes nothing
|
|
if _, err := rs.Outcome(r, RecordOutcome{Module: "mesh-x", Fingerprint: "src2:f1", Node: "ace", Step: "build", Outcome: OutcomeBuilt, Why: "built it"}); err != nil || len(f.said) != 2 {
|
|
t.Fatalf("said again: %v %d", err, len(f.said))
|
|
}
|
|
})
|
|
t.Run("a record ended failed says a comment naming why; ended healthy says none", func(t *testing.T) {
|
|
_, rs, r, f := setup(t)
|
|
if _, err := rs.Outcome(r, RecordOutcome{Module: "mesh-x", Fingerprint: "src2:f1", Node: "ace", Step: "build", Outcome: OutcomeFailed, Why: "tests red"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := rs.End(r, "never runs", "operator"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if count(f, seat.OwedActComment) != 1 || count(f, seat.OwedActNote) != 2 || count(f, seat.OwedActView) != 2 {
|
|
t.Fatalf("said %+v", f.said)
|
|
}
|
|
for _, o := range f.said {
|
|
if o.Act == seat.OwedActComment && (!strings.Contains(o.Text, "tests red") || !strings.Contains(o.Text, "never runs")) {
|
|
t.Fatalf("comment %q", o.Text)
|
|
}
|
|
}
|
|
_, rs, r, f = setup(t)
|
|
if err := rs.End(r, "by hand", "operator"); err != nil || count(f, seat.OwedActComment) != 0 || count(f, seat.OwedActNote) != 1 {
|
|
t.Fatalf("%v said %+v", err, f.said)
|
|
}
|
|
})
|
|
}
|