hub v0.181.0 (not deployed): root files are 'behind' only when the files differ (R-1392, decision 304); Go 1.27.4 (R-1391)
gates / gates (push) Successful in 1m55s

This commit is contained in:
admin committed 2026-11-14 10:11:31 +01:00
1 parent 561a4d98e9
commit 83316fc986
15 files changed
+442 -11

No files matched your search

+6
View File
@@ -77,6 +77,7 @@ type Server struct {
offsiteWindowGrant func(customerID string) error
offsiteWindowGrantMax func(customerID string, maxRemove int) error
osUpdates OSUpdateAdmin
sameBundleFiles func(boxVersion, boxSHA, vouchedVersion, vouchedSHA string) bool // R-1392; nil = never the same
offsiteWindowSwitch func(on bool) error
// operator key-file clean-up (decision 72) and abandonment cancel (decision 74). nil → 503.
offsiteRemoveUnpinned func(ctx context.Context, customerID string) (int, error)
@@ -254,6 +255,11 @@ type OSUpdateAdmin interface {
// SetOSUpdateAdmin wires the OS-update operator routes.
func (s *Server) SetOSUpdateAdmin(a OSUpdateAdmin) { s.osUpdates = a }
// SetSameBundleFiles wires the "same files under another label" answer for the System page's Root files cell (R-1392).
func (s *Server) SetSameBundleFiles(f func(boxVersion, boxSHA, vouchedVersion, vouchedSHA string) bool) {
s.sameBundleFiles = f
}
// SetOffsiteWindowLargeGrant wires the operator's one-window raised cap (R-833).
func (s *Server) SetOffsiteWindowLargeGrant(fn func(string, int) error) { s.offsiteWindowGrantMax = fn }
+14 -3
View File
@@ -270,9 +270,10 @@ func guestTrimText(g sysfacts.GuestTrim, now time.Time) (text string, warn bool,
return text, warn, why
}
// bundleCell is the "Root files" cell (R-840): the box's config bundle against the vouched agent's. Amber while behind,
// bundleCell is the "Root files" cell (R-840): the box's config bundle against the vouched agent's. Amber while behind
// (never when the files are the same under another label — sameFiles, R-1392, pinned by TestBundleCell_R1392),
// red from the alarm's wait on, amber when a file was changed by hand (drift); "unknown" is never coloured as a fact.
func bundleCell(f sysfacts.System, vouchedAgent, vouchedSHA string, since time.Time, after time.Duration, now time.Time) cell {
func bundleCell(f sysfacts.System, vouchedAgent, vouchedSHA string, sameFiles bool, since time.Time, after time.Duration, now time.Time) cell {
b := f.Bundle
if !f.Present || b.Version == "" || b.Version == sysfacts.Unknown {
return unknownCell("")
@@ -281,6 +282,9 @@ func bundleCell(f sysfacts.System, vouchedAgent, vouchedSHA string, since time.T
switch {
case vouchedSHA == "":
c.Title = "no vouched bundle to compare with (the vouched agent carries none)"
case b.BundleSHA256 != vouchedSHA && sameFiles:
// R-1392: an agent release that changed no root file gives the bundle a new label and a new sha256.
c.Title = "the same files as the vouched agent " + vouchedAgent + "'s bundle (only the label differs)"
case b.BundleSHA256 != vouchedSHA:
c.Class, c.Title = "warn", "behind the vouched agent "+vouchedAgent+"'s bundle — send it with a signed agent_config_update"
if !since.IsZero() {
@@ -453,7 +457,7 @@ func (s *Server) handleSystem(w http.ResponseWriter, r *http.Request) {
hosts, _ := s.store.ListHosts()
now := time.Now()
in := systemInput{Lines: lines, Facts: map[string]sysfacts.System{}, Names: map[string]string{}, Controllers: map[string]string{},
Agents: map[string]string{}, KernelLines: map[string]osupdates.KernelLine{}, BundleSince: map[string]time.Time{},
Agents: map[string]string{}, KernelLines: map[string]osupdates.KernelLine{}, BundleSince: map[string]time.Time{}, BundleSame: map[string]bool{},
AgentSince: map[string]time.Time{}, BundleAfter: view.BundleThreshold(), AgentAfter: view.AgentThreshold(),
GlobalFloor: s.store.GetGlobalMinControllerVersion(), Releases: view.Releases(), Cancelled: view.CancelledReleases(),
Candidates: view.Candidates(), Now: now}
@@ -479,6 +483,13 @@ func (s *Server) handleSystem(w http.ResponseWriter, r *http.Request) {
}
man := s.store.GetArtifactManifest()
in.VouchedAgent, in.VouchedBundle = man.AgentVersion, man.BundleSHA256
if s.sameBundleFiles != nil && man.BundleSHA256 != "" {
for id, f := range in.Facts {
if b := f.Bundle; f.Present && b.BundleSHA256 != "" && b.BundleSHA256 != man.BundleSHA256 {
in.BundleSame[id] = s.sameBundleFiles(b.Version, b.BundleSHA256, man.AgentVersion, man.BundleSHA256)
}
}
}
ovs, oerr := s.store.CustomerFloorOverrides()
if oerr != nil {
s.logger.Printf("[ERROR] system page: floor overrides: %v", oerr)
+22 -5
View File
@@ -14,19 +14,36 @@ func TestBundleCell(t *testing.T) {
cur := sys(`{"system":{"config_bundle":{"version":"0.143.0","bundle_sha256":"new"}}}`)
old := sys(`{"system":{"config_bundle":{"version":"none"}}}`)
drift := sys(`{"system":{"config_bundle":{"version":"0.143.0","bundle_sha256":"new"},"facts":{"host":{"config_bundle":{"version":"0.143.0","drift":["/usr/local/sbin/felhom-pbs-apply"]}}}}}`)
if c := bundleCell(cur, "0.143.0", "new", time.Time{}, 7*24*time.Hour, now); c.Class != "" || c.Text != "0.143.0" {
if c := bundleCell(cur, "0.143.0", "new", false, time.Time{}, 7*24*time.Hour, now); c.Class != "" || c.Text != "0.143.0" {
t.Fatalf("current: %+v", c)
}
if c := bundleCell(old, "0.143.0", "new", now.Add(-time.Hour), 7*24*time.Hour, now); c.Class != "warn" || c.Text != "none" {
if c := bundleCell(old, "0.143.0", "new", false, now.Add(-time.Hour), 7*24*time.Hour, now); c.Class != "warn" || c.Text != "none" {
t.Fatalf("behind 1 h: %+v", c)
}
if c := bundleCell(old, "0.143.0", "new", now.Add(-8*24*time.Hour), 7*24*time.Hour, now); c.Class != "bad" {
if c := bundleCell(old, "0.143.0", "new", false, now.Add(-8*24*time.Hour), 7*24*time.Hour, now); c.Class != "bad" {
t.Fatalf("behind 8 days: %+v", c)
}
if c := bundleCell(drift, "0.143.0", "new", time.Time{}, 7*24*time.Hour, now); c.Class != "warn" || c.Title == "" {
if c := bundleCell(drift, "0.143.0", "new", false, time.Time{}, 7*24*time.Hour, now); c.Class != "warn" || c.Title == "" {
t.Fatalf("drift: %+v", c)
}
if c := bundleCell(sys(`{}`), "0.143.0", "new", time.Time{}, 7*24*time.Hour, now); c.Text != "unknown" {
if c := bundleCell(sys(`{}`), "0.143.0", "new", false, time.Time{}, 7*24*time.Hour, now); c.Text != "unknown" {
t.Fatalf("no stanza: %+v", c)
}
}
// R-1392 (`09` §3 decision 304): the same files under an older label are not "behind" — no colour, also after the
// alarm's wait; a bundle whose files differ stays amber; drift is still amber.
func TestBundleCell_R1392(t *testing.T) {
now := time.Date(2026, 11, 14, 10, 0, 0, 0, time.UTC)
box := sysfacts.Parse(`{"system":{"config_bundle":{"version":"0.172.1","bundle_sha256":"old"}}}`)
if c := bundleCell(box, "0.173.0", "new", true, now.Add(-8*24*time.Hour), 7*24*time.Hour, now); c.Class != "" || c.Text != "0.172.1" || c.Title == "" {
t.Fatalf("same files, new label: %+v", c)
}
if c := bundleCell(box, "0.173.0", "new", false, now.Add(-time.Hour), 7*24*time.Hour, now); c.Class != "warn" {
t.Fatalf("different files: %+v", c)
}
drift := sysfacts.Parse(`{"system":{"config_bundle":{"version":"0.172.1","bundle_sha256":"old"},"facts":{"host":{"config_bundle":{"version":"0.172.1","drift":["/etc/sudoers.d/felhom-agent"]}}}}}`)
if c := bundleCell(drift, "0.173.0", "new", true, time.Time{}, 7*24*time.Hour, now); c.Class != "warn" {
t.Fatalf("drift under the same files: %+v", c)
}
}
+2 -1
View File
@@ -29,6 +29,7 @@ type systemInput struct {
Names, Controllers, Agents map[string]string // by host id
KernelLines map[string]osupdates.KernelLine
BundleSince, AgentSince map[string]time.Time
BundleSame map[string]bool // R-1392: the box's bundle = the vouched files under another label
Stale, Reboot, NotCov time.Duration
BundleAfter, AgentAfter time.Duration
VouchedAgent, VouchedBundle string
@@ -51,7 +52,7 @@ func buildSystemPage(in systemInput) map[string]interface{} {
for i := range rows {
id := rows[i].HostID
rows[i].KernelDefault, rows[i].KernelStep = kernelCells(in.Facts[id], in.KernelLines[id], in.Now)
rows[i].Bundle = bundleCell(in.Facts[id], in.VouchedAgent, in.VouchedBundle, in.BundleSince[id], in.BundleAfter, in.Now)
rows[i].Bundle = bundleCell(in.Facts[id], in.VouchedAgent, in.VouchedBundle, in.BundleSame[id], in.BundleSince[id], in.BundleAfter, in.Now)
rows[i].Agent = agentCell(in.Agents[id], in.VouchedAgent, in.AgentSince[id], in.AgentAfter, in.Now)
rows[i].Controller = unknownCell(in.Controllers[id])
summariseRow(&rows[i], latest)