carlos / platform Public

channels digests: round 3 fixes for the no-app evidence (#1634)

Astra and Fable round 3, both READY; fixes applied without another
round under the stopping rule:
- the box reports are folded once per request (remoteFactsFold), not per
  app;
- an app whose record read fails keeps its evidence line;
- a silent report no longer claims an older version; zero reports print
  their own line (copy by Luna);
- tests for incomplete, silent-only and zero-report evidence;
- stale comments from the cut door fixed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 1c0284e1ecb10c85b5a0fa4467c9d11acc442d05 parent 9cbb74e
7 files changed, +55 −16
  • canary_retire_test.go +13 −2
  • channels_digests.go +7 −2
  • internal/console/apidigests.go +14 −6
  • internal/console/remoteinstances.go +14 −2
  • internal/console/remoteinstances_round5_test.go +4 −2
  • internal/release/adopt.go +1 −1
  • internal/status/snapshot.go +2 −1
diff --git a/canary_retire_test.go b/canary_retire_test.go
index 82acd35d9..ec542a8e3 100644
--- a/canary_retire_test.go
+++ b/canary_retire_test.go
@@ -114,6 +114,10 @@ func TestChannelsDigestsPrintsNoAppEvidence(t *testing.T) {
"running": []map[string]any{{"box": "box-a", "channel": "canary/rc", "at": now.Add(-4 * time.Minute).Format(time.RFC3339)}},
"silent": []map[string]any{{"box": "box-b", "at": now.Add(-3 * time.Hour).Format(time.RFC3339)}}},
{"account": "bab", "app": "gone", "complete": true, "boxes": 3},
+ {"account": "bab", "app": "partial", "complete": false, "boxes": 2},
+ {"account": "bab", "app": "quiet", "complete": true, "boxes": 1,
+ "silent": []map[string]any{{"box": "box-c", "at": now.Add(-time.Hour).Format(time.RFC3339)}}},
+ {"account": "bab", "app": "empty", "complete": true, "boxes": 0},
},
})
}))
@@ -128,14 +132,21 @@ func TestChannelsDigestsPrintsNoAppEvidence(t *testing.T) {
fmt.Sprintf(textNoAppRunning, "bab", "old", "box-a", "canary/rc", "4m"),
fmt.Sprintf(textNoAppSilent, "bab", "old", "box-b", "3h"),
fmt.Sprintf(textNoAppNone, "bab", "gone", 3),
+ fmt.Sprintf(textNoAppIncomplete, "bab", "partial"),
+ fmt.Sprintf(textNoAppSilent, "bab", "quiet", "box-c", "1h"),
+ fmt.Sprintf(textNoAppNoReports, "bab", "empty"),
textNoAppSnapshot,
} {
if !strings.Contains(out.String(), want) {
t.Fatalf("listing lacks %q:\n%s", want, out.String())
}
}
- if strings.Contains(out.String(), fmt.Sprintf(textNoAppNone, "bab", "old", 3)) {
- t.Fatalf("an app a box runs was also said to run nowhere:\n%s", out.String())
+ // An app a box runs, an incomplete read, a box that cannot say and no
+ // reports at all never read as "no box reports running it".
+ for _, app := range []string{"old", "partial", "quiet", "empty"} {
+ if strings.Contains(out.String(), " bab/"+app+": no box reports running it") {
+ t.Fatalf("%s was said to run nowhere:\n%s", app, out.String())
+ }
}
}
diff --git a/channels_digests.go b/channels_digests.go
index 8a1fe8084..f37d26297 100644
--- a/channels_digests.go
+++ b/channels_digests.go
@@ -134,7 +134,8 @@ const (
textNoAppHeader = "Apps with no entry on this console, based on the boxes' last reports:"
textNoAppNone = " %s/%s: no box reports running it (%d box reports read)"
textNoAppRunning = " %s/%s: box %s last reported it running on %s (report %s old)"
- textNoAppSilent = " %s/%s: box %s reported an older CARLOS version that cannot say which apps it runs (report %s old)"
+ textNoAppSilent = " %s/%s: box %s's report cannot say which apps it runs (report %s old)"
+ textNoAppNoReports = " %s/%s: there are no box reports to read"
textNoAppIncomplete = " %s/%s: not every box report could be read"
textNoAppSnapshot = "Box reports are snapshots, written every few minutes; a box with no report for a day is no longer listed."
)
@@ -158,7 +159,11 @@ func printNoAppEvidence(rep apiPointerDigests, now time.Time) {
for _, r := range e.Silent {
fmt.Fprintf(stdout, textNoAppSilent+"\n", e.Account, e.App, r.Box, reportAge(r.At, now))
}
- if e.Complete && len(e.Running) == 0 && len(e.Silent) == 0 {
+ switch {
+ case !e.Complete || len(e.Running) > 0 || len(e.Silent) > 0:
+ case e.Boxes == 0:
+ fmt.Fprintf(stdout, textNoAppNoReports+"\n", e.Account, e.App)
+ default:
fmt.Fprintf(stdout, textNoAppNone+"\n", e.Account, e.App, e.Boxes)
}
}
diff --git a/internal/console/apidigests.go b/internal/console/apidigests.go
index aa76c9b40..fd1356ad4 100644
--- a/internal/console/apidigests.go
+++ b/internal/console/apidigests.go
@@ -245,6 +245,9 @@ func (s *Server) handleAPISystemPointerDigests(w http.ResponseWriter, r *http.Re
// Accounts are walked digestWalkers at a time, each into its own slot,
// so the report keeps the sequential walk's order under the deadline
// (Fable R3 P2-1).
+ // The box reports are folded once, and only if some account lists an
+ // app with no row (#1634).
+ facts := sync.OnceValue(func() func(acct, app string) appFacts { return s.remoteFactsFold(ctx) })
walks := make([]digestAccountWalk, len(sqids))
sem := make(chan struct{}, digestWalkers)
var wg sync.WaitGroup
@@ -252,7 +255,7 @@ func (s *Server) handleAPISystemPointerDigests(w http.ResponseWriter, r *http.Re
sem <- struct{}{}
wg.Go(func() {
defer func() { <-sem }()
- walks[i] = s.walkDigestAccount(ctx, sqid, !known[sqid])
+ walks[i] = s.walkDigestAccount(ctx, sqid, !known[sqid], facts)
})
}
wg.Wait()
@@ -355,9 +358,10 @@ type digestBoxReport struct {
}
// digestNoAppEvidence is digestNoAppRow for acct/app from the box reports
-// (remoteFacts, the pages' cached read: this is a report, not a decision).
-func (s *Server) digestNoAppEvidence(ctx context.Context, acct, app string) digestNoAppRow {
- r := s.remoteFacts(ctx, acct, app).running()
+// (one fold per request of the pages' cached read: this is a report, not a
+// decision).
+func digestNoAppEvidence(facts func(acct, app string) appFacts, acct, app string) digestNoAppRow {
+ r := facts(acct, app).running()
row := digestNoAppRow{Account: acct, App: app, Complete: r.complete, Boxes: r.boxes}
for _, br := range r.running {
row.Running = append(row.Running, digestBoxReport{Box: br.box, Channel: br.rc.Channel, At: br.at.UTC().Format(time.RFC3339)})
@@ -371,7 +375,7 @@ func (s *Server) digestNoAppEvidence(ctx context.Context, acct, app string) dige
// walkDigestAccount reads one account's marker and every app's channels
// for handleAPISystemPointerDigests. A read that fails is the row's error,
// never a shorter listing.
-func (s *Server) walkDigestAccount(ctx context.Context, sqid string, bucketOnly bool) digestAccountWalk {
+func (s *Server) walkDigestAccount(ctx context.Context, sqid string, bucketOnly bool, facts func() func(acct, app string) appFacts) digestAccountWalk {
wk := digestAccountWalk{row: digestAcctRow{Account: sqid, BucketOnly: bucketOnly}}
row := &wk.row
m, err := release.ReadDigestMarker(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid)
@@ -421,6 +425,10 @@ func (s *Server) walkDigestAccount(ctx context.Context, sqid string, bucketOnly
recs, err := release.RecordReport(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid, app)
if err != nil {
row.Error = err.Error()
+ // The heads already listed keep their evidence line.
+ if orphan && len(wk.repairs) > listed {
+ wk.noApp = append(wk.noApp, digestNoAppEvidence(facts(), sqid, app))
+ }
break
}
for _, rec := range recs {
@@ -431,7 +439,7 @@ func (s *Server) walkDigestAccount(ctx context.Context, sqid string, bucketOnly
Unread: rec.Unread, NoBuild: rec.NoBuild, Grant: rec.Grant, GrantMintedAt: grantMinted(rec.Grant, rec.GrantMintedAt), NoApp: orphan})
}
if orphan && len(wk.repairs) > listed {
- wk.noApp = append(wk.noApp, s.digestNoAppEvidence(ctx, sqid, app))
+ wk.noApp = append(wk.noApp, digestNoAppEvidence(facts(), sqid, app))
}
}
return wk
diff --git a/internal/console/remoteinstances.go b/internal/console/remoteinstances.go
index 7edddb171..194d84e90 100644
--- a/internal/console/remoteinstances.go
+++ b/internal/console/remoteinstances.go
@@ -283,8 +283,10 @@ type boxRoute struct {
}
// foldFleetReports folds box reports into per-host reports. Stale boxes are
-// left out under the fleet's one staleness rule (status.BoxStale), as every
-// other box join does. Only remoteFacts calls it.
+// left out of the per-host reports under the fleet's one staleness rule
+// (status.BoxStale), as every other box join does; the route-channel
+// evidence (#1634) keeps every listed box's last report, stale or not.
+// Only remoteFacts and remoteFactsFold call it.
func foldFleetReports(boxes []status.Box, complete bool, now time.Time) fleetReports {
f := fleetReports{byHost: map[string][]hostReport{}, complete: complete, boxes: len(boxes)}
for _, b := range boxes {
@@ -364,6 +366,16 @@ func (s *Server) remoteFacts(ctx context.Context, acct, app string) appFacts {
return appFacts{acct: acct, app: app, reports: foldFleetReports(boxes, complete, time.Now())}
}
+// remoteFactsFold is remoteFacts for many apps from one read and one fold:
+// the pointer digests report asks it for every app it lists "no app on
+// this console" (#1634), so the fleet is folded once per request, not once
+// per app.
+func (s *Server) remoteFactsFold(ctx context.Context) func(acct, app string) appFacts {
+ boxes, complete := s.pageBoxReports(ctx)
+ reports := foldFleetReports(boxes, complete, time.Now())
+ return func(acct, app string) appFacts { return appFacts{acct: acct, app: app, reports: reports} }
+}
+
// host is the one box report about rec's host that may be joined to it, or
// nil. Identity is the record plus a report entry naming the same account
// and app, generated after the record was created: a report naming another
diff --git a/internal/console/remoteinstances_round5_test.go b/internal/console/remoteinstances_round5_test.go
index 974f061ce..9f6081a72 100644
--- a/internal/console/remoteinstances_round5_test.go
+++ b/internal/console/remoteinstances_round5_test.go
@@ -27,8 +27,10 @@ import (
// joins reports for a remote host itself fails here.
func TestRemoteFactsOneAccessor(t *testing.T) {
allowed := map[string]map[string]bool{
- "foldFleetReports": {"remoteFacts": true},
- "pageBoxReports": {"remoteFacts": true, "handleApp": true},
+ // remoteFactsFold is remoteFacts for many apps from one fold, for
+ // the pointer digests report's no-app evidence (#1634).
+ "foldFleetReports": {"remoteFacts": true, "remoteFactsFold": true},
+ "pageBoxReports": {"remoteFacts": true, "handleApp": true, "remoteFactsFold": true},
"byHost": {"foldFleetReports": true, "host": true, "seen": true, "unrecorded": true},
}
files, err := filepath.Glob("*.go")
diff --git a/internal/release/adopt.go b/internal/release/adopt.go
index c0631a52f..b197f3c93 100644
--- a/internal/release/adopt.go
+++ b/internal/release/adopt.go
@@ -1403,11 +1403,11 @@ func CapabilityRoute(rt registry.Route) bool {
return Adoptable(rt) && rt.Backing == registry.BackingUnit
}
-// routeChannel is the channel a route follows; "" means stable.
// RouteChannel is the channel a route follows, as the adopt pass reads it:
// its own, else stable. The status report names it per route (#1634).
func RouteChannel(rt registry.Route) string { return routeChannel(rt) }
+// routeChannel is the channel a route follows; "" means stable.
func routeChannel(rt registry.Route) string {
if rt.Channel == "" {
return "stable"
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go
index 53a627421..0573092da 100644
--- a/internal/status/snapshot.go
+++ b/internal/status/snapshot.go
@@ -830,7 +830,8 @@ type BoxMetrics struct {
// RouteChannelsReported is true from the first binary that builds
// RouteChannels, so an absent map on a box that says so means "no
// routes", and on one that does not means "this binary cannot say". The
- // console's channel retire refuses while any fresh box cannot say.
+ // console's pointer digests report lists a box that cannot say as such,
+ // never as one running nothing.
RouteChannelsReported bool `json:"route_channels_reported,omitempty"`
// RouteVersions is host -> registry.Route.Version for every non-platform
// route this box carries with a Version the adopt pass has stamped