From 4b5d732ec11e82f10bf30ffff51035bdce8c4d89 Mon Sep 17 00:00:00 2001 From: jerryfane Date: Sun, 26 Jul 2026 20:16:21 +0200 Subject: [PATCH] feat(org): add OrgBadges.ActiveJobs schema field (#1127) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Schema-only addition for gitmoot#1127 (a role whose herdr seat goes idle while its dispatched workers are still queued/running currently reads as plain "idle" on the org page). Adds a live queued+running jobs count to OrgBadges, distinct from the existing OrgRoleActivity.JobsToday (a same-UTC-day job-outcome histogram) — the doc comment names the distinction explicitly so the two aren't conflated. No rendering touched (web/ untouched) and no population logic added — this repo has no access to gitmoot's job/workflow store. A follow-up gitmoot/gitmoot PR populates the field and bumps this repo's pin. Per gitmoot-coc's ruling: g2's exclusive-ownership boundary on this repo is a collision guard on web/dist/index.html specifically, not a whole-repo claim — a schema-only Go DTO change doesn't cross it. g2 notified before opening this PR. --- datasource.go | 10 +++++++++- datasource_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/datasource.go b/datasource.go index f38a8d7..f54888f 100644 --- a/datasource.go +++ b/datasource.go @@ -524,11 +524,19 @@ type OrgNode struct { LastSeenAt string `json:"last_seen_at,omitempty"` // labeled "last dispatch" by clients } -// OrgBadges contains the blocked/recycle signals displayed on an org node. +// OrgBadges contains the blocked/recycle/activity signals displayed on an org node. type OrgBadges struct { BlockedSince string `json:"blocked_since,omitempty"` // RFC3339 Overdue string `json:"overdue,omitempty"` // Go duration text MissedWakes int `json:"missed_wakes"` + // ActiveJobs is the LIVE count of jobs currently queued or running, + // attributed to this role via ActingOrgRole (gitmoot#1114). This is a + // different, finer-grained signal than OrgRoleActivity.JobsToday (a + // same-UTC-day outcome histogram) — do not collapse the two. ActiveJobs + // answers "is the lane busy right now"; JobsToday answers "what + // happened today". Lets a role whose seat has gone idle still show as + // active while its dispatched workers are mid-flight (gitmoot#1127). + ActiveJobs int `json:"active_jobs,omitempty"` } // OrgEscalation is one open read-only escalation. diff --git a/datasource_test.go b/datasource_test.go index 6fc4d4a..796b058 100644 --- a/datasource_test.go +++ b/datasource_test.go @@ -141,3 +141,42 @@ func TestWorkflowAdditiveJSONContracts(t *testing.T) { } }) } + +func TestOrgBadgesActiveJobsAdditiveJSONContract(t *testing.T) { + t.Run("legacy payload omits active_jobs", func(t *testing.T) { + const payload = `{"blocked_since":"2026-07-23T01:31:00Z","overdue":"23m","missed_wakes":2}` + var badges OrgBadges + if err := json.Unmarshal([]byte(payload), &badges); err != nil { + t.Fatalf("unmarshal legacy OrgBadges: %v", err) + } + if badges.ActiveJobs != 0 { + t.Fatalf("legacy OrgBadges.ActiveJobs = %d, want 0", badges.ActiveJobs) + } + got, err := json.Marshal(badges) + if err != nil { + t.Fatalf("marshal legacy OrgBadges: %v", err) + } + if string(got) != payload { + t.Fatalf("legacy OrgBadges JSON = %s, want %s", got, payload) + } + }) + + t.Run("active jobs round trip", func(t *testing.T) { + badges := OrgBadges{ActiveJobs: 3} + got, err := json.Marshal(badges) + if err != nil { + t.Fatalf("marshal OrgBadges with ActiveJobs: %v", err) + } + const want = `{"missed_wakes":0,"active_jobs":3}` + if string(got) != want { + t.Fatalf("OrgBadges JSON = %s, want %s", got, want) + } + var roundTrip OrgBadges + if err := json.Unmarshal(got, &roundTrip); err != nil { + t.Fatalf("unmarshal OrgBadges: %v", err) + } + if roundTrip.ActiveJobs != 3 { + t.Fatalf("round-trip OrgBadges.ActiveJobs = %d, want 3", roundTrip.ActiveJobs) + } + }) +}