G-10 §479 with §495: view-waits names <owner>.<state>.<branch>; a branch with no revision yet raises none

Builds: design 47 G §479, §495

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
2026-11-11 12:15:55 +01:00
parent eed96854ae
commit 5f1e12a41f
3 changed files with 26 additions and 5 deletions
+2 -2
View File
@@ -82,8 +82,8 @@ func finding(observer, kind, id, summary, headline, explanation string, at time.
// part, the owner and the revision, and clears when the part holds it.
func ViewWaitsFinding(part string, s Status, at time.Time) Finding {
id := part + "." + s.Owner + "." + s.State
summary := fmt.Sprintf("%s waits for %s's view %s since %s and acts on nothing new until it holds it; it holds %s",
part, s.Owner, s.WaitsFor, s.WaitingSince.UTC().Format(time.RFC3339), cmp.Or(s.View, "none"))
summary := fmt.Sprintf("%s waits for the view %s.%s at revision %s since %s and acts on nothing new until it holds it; it holds %s",
part, s.Owner, s.State, s.WaitsFor, s.WaitingSince.UTC().Format(time.RFC3339), cmp.Or(s.View, "none"))
return finding(part, ViewWaitsKind, id, summary,
fmt.Sprintf("%s waits for a view of %s", part, s.Owner),
fmt.Sprintf("%s keeps running what it runs and takes up nothing new until %s's view %s reaches it. Look at %s: is it running, and has it "+
+5 -1
View File
@@ -112,6 +112,10 @@ var waitBound = func(ctx context.Context, d time.Duration) bool {
return ctx.Err() == nil
}
// NoneYet is what a seat's revision verb answers for a branch with no revision yet (design 47 G §479, §495): that view
// is ready and empty, and nothing waits for it.
const NoneYet = "none yet"
// WaitFor says the part waits for view, a revision of the revision view its seat's client names, and acts on nothing
// new until it holds it (Holds): the status says what and since when, and if it still waits for it past WaitsBound,
// RaiseWaits is told (the part writes view-waits, ViewWaitsFinding). Waiting for the view it waits for already changes
@@ -119,7 +123,7 @@ var waitBound = func(ctx context.Context, d time.Duration) bool {
func (f *Follower) WaitFor(ctx context.Context, view string) {
f.mu.Lock()
f.init()
if f.st.WaitsFor == view || view == "" {
if f.st.WaitsFor == view || view == "" || view == NoneYet {
f.mu.Unlock()
return
}
+19 -2
View File
@@ -309,7 +309,7 @@ func TestViews(t *testing.T) {
defer func() { waitBound = kept }()
var raised, cleared, said []Status
var mu sync.Mutex
f := &Follower{Owner: "o", Tool: "o.revision", State: "catalog", Now: now,
f := &Follower{Owner: "o", Tool: "o.revision", State: BranchState("catalog", "trunk"), Now: now,
RaiseWaits: func(s Status) { mu.Lock(); raised = append(raised, s); mu.Unlock() },
ClearWaits: func(s Status) { mu.Lock(); cleared = append(cleared, s); mu.Unlock() },
Said: func(s Status) { mu.Lock(); said = append(said, s); mu.Unlock() }}
@@ -329,10 +329,27 @@ func TestViews(t *testing.T) {
}
mu.Unlock()
fd := ViewWaitsFinding("mesh-delivery-builder", f.Status(), now())
if fd.Kind != ViewWaitsKind || fd.ID != "mesh-delivery-builder.o.catalog" || !strings.Contains(fd.Summary, "waits for o's view trunk.12") ||
if fd.Kind != ViewWaitsKind || fd.ID != "mesh-delivery-builder.o.catalog.trunk" || !strings.Contains(fd.Summary, "waits for the view o.catalog.trunk at revision trunk.12") ||
!strings.Contains(fd.Summary, "it holds trunk.11") {
t.Errorf("finding = %+v", fd)
}
none := &Follower{Owner: "o", Tool: "o.revision", State: BranchState("catalog", "new"), Now: now,
Ask: func(context.Context, string) (Answer, error) { return Answer{V: 1, Owner: "o", State: "catalog.new", At: now()}, nil }}
if err := none.Start(context.Background()); err != nil {
t.Fatal(err)
}
select {
case <-none.Ready():
default:
t.Errorf("a view of a branch with no revision is not ready")
}
if len(none.Values()) != 0 {
t.Errorf("not empty")
}
none.WaitFor(context.Background(), NoneYet) // a branch with no revision yet: ready, empty, nothing awaited (§495)
if s := none.Status(); s.WaitsFor != "" || !s.WaitingSince.IsZero() {
t.Errorf("a view of none yet is awaited: %+v", s)
}
f.Holds("trunk.12")
if s := f.Status(); s.View != "trunk.12" || s.WaitsFor != "" || s.WaitsRaised {
t.Errorf("after holding: %+v", s)