From e755c0b9b5b5a7416e401861ce47b21ace011ce4 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sat, 31 Oct 2026 13:36:51 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix(trackerrow):=20pin=20the?= =?UTF-8?q?=20STAGE=5FTRACKER=5F*=20contract=20and=20list=20tracker-human-?= =?UTF-8?q?attention=20in=20the=20layout=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-trackerrow-drift-guard.md | 1 + src/docs/dashboard-source-layout.md | 3 +- .../tracker_row_shared_asset_test.go | 10 +++++++ src/pkg/webassets/trackerrow/trackerrow.go | 19 +++++++++++++ .../webassets/trackerrow/trackerrow_test.go | 28 +++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixed-trackerrow-drift-guard.md diff --git a/changelog.d/fixed-trackerrow-drift-guard.md b/changelog.d/fixed-trackerrow-drift-guard.md new file mode 100644 index 0000000000..670ebdbb66 --- /dev/null +++ b/changelog.d/fixed-trackerrow-drift-guard.md @@ -0,0 +1 @@ +- The shared tracker row asset now exports `trackerrow.RequiredGlobals`, the `STAGE_TRACKER_*` constants it reads from its host page, and tests fail if that list drifts from the asset or if the spoke stops defining one, so the hub cannot silently light different columns than the spoke. `dashboard-source-layout.md` also lists `tracker-human-attention` in manifest order (#16067, #16068). diff --git a/src/docs/dashboard-source-layout.md b/src/docs/dashboard-source-layout.md index 66c04266ed..0546e8186a 100644 --- a/src/docs/dashboard-source-layout.md +++ b/src/docs/dashboard-source-layout.md @@ -77,7 +77,8 @@ JS (`js/`): `boot`, `core`, `feedback`, `sections`, `layout`, `agent-detail`, `sidebar`, `history-sparklines`, `cost-trend`, `stats`, `agent-now`, `tracker-words-core`, `tracker-words-stage`, `tracker-words-gate`, `tracker-words`, `tracker-row-anchor`, `tracker-row`, `tracker-row-strip`, -`tracker-row-acted`, `tracker-row-layout`, `tracker-row-title`, +`tracker-row-acted`, `tracker-human-attention`, `tracker-row-layout`, +`tracker-row-title`, `tracker-row-render`, `tracker-motion`, `tracker-filter`, `tracker-filter-state`, `nav-count-delta`, `tracker-preparation`, `tracker-native-queue`, `tracker-filter-render`, diff --git a/src/pkg/dashboard/tracker_row_shared_asset_test.go b/src/pkg/dashboard/tracker_row_shared_asset_test.go index 423549fae5..47c0432660 100644 --- a/src/pkg/dashboard/tracker_row_shared_asset_test.go +++ b/src/pkg/dashboard/tracker_row_shared_asset_test.go @@ -46,6 +46,16 @@ func TestTrackerRowSharedAssetCompat(t *testing.T) { } } +// TestTrackerRowRequiredGlobalsDefinedBySpoke pins that the spoke page defines +// every STAGE_TRACKER_* constant the shared row asset reads, so the list the +// hub asserts against stays tied to the values the spoke serves. +func TestTrackerRowRequiredGlobalsDefinedBySpoke(t *testing.T) { + html := indexHTML(t) + for _, name := range trackerrow.RequiredGlobals { + jsConstLine(t, html, name) + } +} + // TestTrackerRowSharedAssetRendersSpokeFixtures renders the same fixtures // through the functions the spoke page defines and through the shared asset // files, and pins both to the spoke's existing columns and title markup. diff --git a/src/pkg/webassets/trackerrow/trackerrow.go b/src/pkg/webassets/trackerrow/trackerrow.go index a80d5863d8..df7c5a7241 100644 --- a/src/pkg/webassets/trackerrow/trackerrow.go +++ b/src/pkg/webassets/trackerrow/trackerrow.go @@ -30,3 +30,22 @@ var Files = []string{ // stageTrackerSplitTitleTag / stageTrackerTitleHtml: the escaped, text-only title. "tracker-row-title.js", } + +// RequiredGlobals lists the STAGE_TRACKER_* constants the assets read as free +// globals. A host must define each with the spoke's value: TestRequiredGlobals +// keeps this list equal to what the assets reference, and +// TestTrackerRowRequiredGlobalsDefinedBySpoke in pkg/dashboard fails when the +// spoke stops defining one, so the hub can assert against it when it embeds +// the assets. +var RequiredGlobals = []string{ + "STAGE_TRACKER_ISSUE_DECISION_COLUMN", + "STAGE_TRACKER_ISSUE_NEEDS_DECISION", + "STAGE_TRACKER_MERGE_COLUMN", + "STAGE_TRACKER_NEEDS_DECISION", + "STAGE_TRACKER_PATH", + "STAGE_TRACKER_POSSIBLY_EXISTS", + "STAGE_TRACKER_PRE_MERGE_SOAK", + "STAGE_TRACKER_PR_COLUMN", + "STAGE_TRACKER_TERMINAL", + "STAGE_TRACKER_TRIAGE_NEEDED", +} diff --git a/src/pkg/webassets/trackerrow/trackerrow_test.go b/src/pkg/webassets/trackerrow/trackerrow_test.go index 02291bd8a3..5439defff8 100644 --- a/src/pkg/webassets/trackerrow/trackerrow_test.go +++ b/src/pkg/webassets/trackerrow/trackerrow_test.go @@ -2,6 +2,8 @@ package trackerrow import ( "io/fs" + "regexp" + "sort" "strings" "testing" ) @@ -62,3 +64,29 @@ func TestAssetsDefineRowFunctions(t *testing.T) { } } } + +// TestRequiredGlobals pins RequiredGlobals to the STAGE_TRACKER_* names the +// embedded assets reference, so a new input cannot be added without listing it. +func TestRequiredGlobals(t *testing.T) { + re := regexp.MustCompile(`\bSTAGE_TRACKER_[A-Z_]+\b`) + seen := map[string]bool{} + for _, name := range Files { + b, err := fs.ReadFile(FS, name) + if err != nil { + t.Fatal(err) + } + for _, m := range re.FindAllString(string(b), -1) { + seen[m] = true + } + } + var got []string + for m := range seen { + got = append(got, m) + } + sort.Strings(got) + want := append([]string(nil), RequiredGlobals...) + sort.Strings(want) + if strings.Join(got, ",") != strings.Join(want, ",") { + t.Errorf("assets reference %v, RequiredGlobals is %v", got, want) + } +} From b6e3fe6b21f59e4313ad6ddd73aba4adcc907a4b Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sat, 31 Oct 2026 13:48:10 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix(trackerrow):=20pin=20Req?= =?UTF-8?q?uiredGlobals=20to=20the=20spoke's=20values=20and=20accept=20dig?= =?UTF-8?q?its=20in=20the=20drift-guard=20regex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RequiredGlobals now carries each STAGE_TRACKER_* constant's spoke JS literal (Global{Name, JS} with Decl()), and TestTrackerRowRequiredGlobalsDefinedBySpoke compares the spoke's declaration against it, so a hub copy with a different value fails the test as #16068 asked. TestRequiredGlobals matches [A-Z0-9_]+ so a future constant with a digit is still forced into the list. Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-trackerrow-drift-guard.md | 2 +- .../tracker_row_shared_asset_test.go | 11 +++-- src/pkg/webassets/trackerrow/trackerrow.go | 45 ++++++++++++------- .../webassets/trackerrow/trackerrow_test.go | 16 +++++-- 4 files changed, 51 insertions(+), 23 deletions(-) diff --git a/changelog.d/fixed-trackerrow-drift-guard.md b/changelog.d/fixed-trackerrow-drift-guard.md index 670ebdbb66..3254210088 100644 --- a/changelog.d/fixed-trackerrow-drift-guard.md +++ b/changelog.d/fixed-trackerrow-drift-guard.md @@ -1 +1 @@ -- The shared tracker row asset now exports `trackerrow.RequiredGlobals`, the `STAGE_TRACKER_*` constants it reads from its host page, and tests fail if that list drifts from the asset or if the spoke stops defining one, so the hub cannot silently light different columns than the spoke. `dashboard-source-layout.md` also lists `tracker-human-attention` in manifest order (#16067, #16068). +- The shared tracker row asset now exports `trackerrow.RequiredGlobals`, the `STAGE_TRACKER_*` constants it reads from its host page pinned to the spoke's values, and tests fail if that list drifts from the asset or if the spoke declares a different value, so the hub cannot silently light different columns than the spoke. `dashboard-source-layout.md` also lists `tracker-human-attention` in manifest order (#16067, #16068). diff --git a/src/pkg/dashboard/tracker_row_shared_asset_test.go b/src/pkg/dashboard/tracker_row_shared_asset_test.go index 47c0432660..d92166908c 100644 --- a/src/pkg/dashboard/tracker_row_shared_asset_test.go +++ b/src/pkg/dashboard/tracker_row_shared_asset_test.go @@ -47,12 +47,15 @@ func TestTrackerRowSharedAssetCompat(t *testing.T) { } // TestTrackerRowRequiredGlobalsDefinedBySpoke pins that the spoke page defines -// every STAGE_TRACKER_* constant the shared row asset reads, so the list the -// hub asserts against stays tied to the values the spoke serves. +// every STAGE_TRACKER_* constant the shared row asset reads with exactly the +// value trackerrow.RequiredGlobals carries (hivecommons/hive#16068), so the +// list the hub asserts against is the one the spoke serves. func TestTrackerRowRequiredGlobalsDefinedBySpoke(t *testing.T) { html := indexHTML(t) - for _, name := range trackerrow.RequiredGlobals { - jsConstLine(t, html, name) + for _, g := range trackerrow.RequiredGlobals { + if got := strings.TrimSpace(jsConstLine(t, html, g.Name)); got != g.Decl() { + t.Errorf("spoke declares %q, trackerrow.RequiredGlobals pins %q; edit both together", got, g.Decl()) + } } } diff --git a/src/pkg/webassets/trackerrow/trackerrow.go b/src/pkg/webassets/trackerrow/trackerrow.go index df7c5a7241..9a0a5af04d 100644 --- a/src/pkg/webassets/trackerrow/trackerrow.go +++ b/src/pkg/webassets/trackerrow/trackerrow.go @@ -31,21 +31,36 @@ var Files = []string{ "tracker-row-title.js", } +// Global is one STAGE_TRACKER_* constant the assets read as a free global, +// with the spoke's JavaScript literal for it. +type Global struct { + Name string + // JS is the spoke's literal for the constant, verbatim as it appears in + // pkg/dashboard/static-src/js (agent-now.js, tracker-words-core.js). + JS string +} + +// Decl returns the `const NAME = JS;` declaration a host page must carry. +func (g Global) Decl() string { + return "const " + g.Name + " = " + g.JS + ";" +} + // RequiredGlobals lists the STAGE_TRACKER_* constants the assets read as free -// globals. A host must define each with the spoke's value: TestRequiredGlobals -// keeps this list equal to what the assets reference, and +// globals, each pinned to the spoke's value (hivecommons/hive#16068). A host +// must define every one with exactly that value: TestRequiredGlobals keeps +// the names equal to what the assets reference, and // TestTrackerRowRequiredGlobalsDefinedBySpoke in pkg/dashboard fails when the -// spoke stops defining one, so the hub can assert against it when it embeds -// the assets. -var RequiredGlobals = []string{ - "STAGE_TRACKER_ISSUE_DECISION_COLUMN", - "STAGE_TRACKER_ISSUE_NEEDS_DECISION", - "STAGE_TRACKER_MERGE_COLUMN", - "STAGE_TRACKER_NEEDS_DECISION", - "STAGE_TRACKER_PATH", - "STAGE_TRACKER_POSSIBLY_EXISTS", - "STAGE_TRACKER_PRE_MERGE_SOAK", - "STAGE_TRACKER_PR_COLUMN", - "STAGE_TRACKER_TERMINAL", - "STAGE_TRACKER_TRIAGE_NEEDED", +// spoke's declaration differs from Decl(), so the hub can assert its own +// definitions against this list when it embeds the assets. +var RequiredGlobals = []Global{ + {Name: "STAGE_TRACKER_ISSUE_DECISION_COLUMN", JS: "10"}, + {Name: "STAGE_TRACKER_ISSUE_NEEDS_DECISION", JS: "45"}, + {Name: "STAGE_TRACKER_MERGE_COLUMN", JS: "80"}, + {Name: "STAGE_TRACKER_NEEDS_DECISION", JS: "85"}, + {Name: "STAGE_TRACKER_PATH", JS: "[0, 10, 20, 30, 50, 80]"}, + {Name: "STAGE_TRACKER_POSSIBLY_EXISTS", JS: "17"}, + {Name: "STAGE_TRACKER_PRE_MERGE_SOAK", JS: "95"}, + {Name: "STAGE_TRACKER_PR_COLUMN", JS: "30"}, + {Name: "STAGE_TRACKER_TERMINAL", JS: "110"}, + {Name: "STAGE_TRACKER_TRIAGE_NEEDED", JS: "15"}, } diff --git a/src/pkg/webassets/trackerrow/trackerrow_test.go b/src/pkg/webassets/trackerrow/trackerrow_test.go index 5439defff8..18acfb4566 100644 --- a/src/pkg/webassets/trackerrow/trackerrow_test.go +++ b/src/pkg/webassets/trackerrow/trackerrow_test.go @@ -66,9 +66,10 @@ func TestAssetsDefineRowFunctions(t *testing.T) { } // TestRequiredGlobals pins RequiredGlobals to the STAGE_TRACKER_* names the -// embedded assets reference, so a new input cannot be added without listing it. +// embedded assets reference, so a new input cannot be added without listing +// it, and that every entry carries a value and a well-formed declaration. func TestRequiredGlobals(t *testing.T) { - re := regexp.MustCompile(`\bSTAGE_TRACKER_[A-Z_]+\b`) + re := regexp.MustCompile(`\bSTAGE_TRACKER_[A-Z0-9_]+\b`) seen := map[string]bool{} for _, name := range Files { b, err := fs.ReadFile(FS, name) @@ -84,7 +85,16 @@ func TestRequiredGlobals(t *testing.T) { got = append(got, m) } sort.Strings(got) - want := append([]string(nil), RequiredGlobals...) + var want []string + for _, g := range RequiredGlobals { + want = append(want, g.Name) + if g.JS == "" { + t.Errorf("%s has no JS value; RequiredGlobals must pin the spoke's literal", g.Name) + } + if d := g.Decl(); d != "const "+g.Name+" = "+g.JS+";" || !re.MatchString(d) { + t.Errorf("%s Decl() = %q", g.Name, d) + } + } sort.Strings(want) if strings.Join(got, ",") != strings.Join(want, ",") { t.Errorf("assets reference %v, RequiredGlobals is %v", got, want)