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) + } + }) +}