Files
mesh-delivery/modules/mesh-delivery-indexer/internal/index/unreadcall.go
T
jschoubben b815b54bff G findings4 indexer: the indexer's findings are the seat's generated finding written through views.NewHeldWriter, its assignments followed through the views reader
The indexer's CAS Findings store is the held writer through the small FindingWriter interface (Write, Clear, Held): the
unread-call, accepted-unsaid, seat-definition and out-of-step findings are raised and cleared through it, the unsaid ones
read from Held. followAssignments follows the assigner's assignments through the module's ProcessReader (the reader raises and
clears the first view's finding), the emitter and the family-not-heard finding write through the same writer, and the
view-waits finding of the seat git is written by hand through Write and Clear (A-28). The old resolved words go (A-22).
The integration bed has the findings stream and the test sees finding-written said on it.

Builds: design 47 G A-29, A-26, A-28, A-22, A-3, A-14, A-17, A-30, A-37, A-38, §689, §687, §461
Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-11 22:19:57 +01:00

68 lines
3.5 KiB
Go

package index
import (
"context"
"fmt"
"strings"
"time"
mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
"git.novox.be/novox/mesh-sdk/go/views"
)
// **A merged message unread past five minutes, the forge heard, is a finding** (issue 1966 note 153; novox/hq ADR 0668 §3).
// The indexer's call for a merged message is a kept call: a transport fault leaves the merge unread (Pending.Unread) and
// it is read again after every message heard on the forge (UnreadAgain). A message heard on the forge is the forge bridge
// heard, the callee of that call: so after each one, a merge still unread since meshconditionsclient.CallUnansweredAfter
// or longer is the finding call-unanswered in the indexer's findings, which the condition keeper raises, and a merge no
// longer unread (read, taken in, covered or dropped) clears its finding. While nothing is heard on the forge (the bridge's
// machine away) no finding is written: the merge stays unread and is read again when the forge is heard. No timer.
// UnreadCallee is the call the finding names: the forge bridge's tool for one merged message.
const UnreadCallee = ForgeBridgeModule + ".bridge_merged_message"
// unreadCallID is the finding's id for the pending key: the merge it waits on.
func unreadCallID(key string) string { return "merged-message." + key }
// unreadFindings raises the finding of every merge of entries unread past the bound and clears the finding of every other
// that the finding writer holds (design 47 G §689, A-29).
func (ix *Indexer) unreadFindings(ctx context.Context, entries []PendingEntry) {
if ix.Findings == nil {
return
}
unread := map[string]bool{}
for _, e := range entries {
if e.Value.Unread == "" {
continue
}
id := keyID(unreadCallID(e.Key))
unread[id] = true
since := e.Value.UnreadSince
if since.IsZero() || ix.now().Sub(since) < mcc.CallUnansweredAfter {
continue
}
f := ix.observed(mcc.ScopeCall, unreadCallID(e.Key), mcc.KindCallUnanswered,
fmt.Sprintf("the call %s about %s is unanswered since %s", UnreadCallee, unreadCallID(e.Key), since.UTC().Format(time.RFC3339)),
"A call whose answer is kept is not answered",
fmt.Sprintf("The call %s is made again on every transport fault and on the callee's event; it has not been answered since %s. Its last fault: %s.",
UnreadCallee, since.UTC().Format(time.RFC3339), e.Value.Unread), "indexer."+mcc.KindCallUnanswered)
f.Needs = TakeInPendingTool + " reads the merge again now; " + PendingTool + " shows it unread."
f.Evidence = []mcseat.Evidence{{At: since.UTC(), Said: e.Value.Unread}}
if err := ix.Findings.Write(ctx, f); err != nil {
ix.logf("take-in: the finding %s is not written: %v", views.FindingKey(f.Scope, f.ID, f.Kind), err)
} else {
ix.logf("take-in: %s (%s#%d) is unread since %s and the forge is heard: the finding %s", e.Key, e.Forge.Repository, e.Forge.Number, since.Format("2006-01-02T15:04:05Z07:00"), views.FindingKey(f.Scope, f.ID, f.Kind))
}
}
prefix := keyID(strings.TrimSuffix(unreadCallID(""), ".")) + "."
for _, f := range ix.Findings.Held() {
if f.Scope != mcc.ScopeCall || f.Kind != mcc.KindCallUnanswered || !strings.HasPrefix(f.ID, prefix) || unread[f.ID] {
continue
}
if err := ix.Findings.Clear(ctx, f.Scope, f.ID, f.Kind, "the merge is no longer unread"); err != nil {
ix.logf("take-in: the finding %s is not cleared: %v", views.FindingKey(f.Scope, f.ID, f.Kind), err)
}
}
}