Skip to content

πŸ› Activity Monitor: persist the merged count in a server ledger, pin the Merged chip, banner and bee flight on merge - #15150

Merged
hivecommons-hive[bot] merged 5 commits into
v5from
fix/merged-ledger
Oct 29, 2026
Merged

hivecommons-hive[bot] merged 5 commits into
v5from
fix/merged-ledger

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #15147

Problem

The Activity Monitor's Merged today chip was accumulated only in the tab (rows vanishing as merged, seeded from the in-memory audit ring): a reload took it from 4 to 0 (and 33 to 4). The celebration also fired where nobody looked β€” the chip sits in a non-sticky toolbar far above a scrolled viewport and the row effect is a one-shot 2.5 s glow (#15096, CDP comment 6481579497).

Change

Server

  • pkg/dashboard/merged_ledger.go β€” a persistent ledger at /data/merged-ledger.json (memory-only without /data): one entry per merged PR {repo, number, title, url, merged_at, merged_by (hive|login), lane, issue}, deduplicated with blank-filling upsert, 90-day retention, 5000-entry cap, an all-time total that only grows, atomic writes. Seeded once on first boot from the audit log's pr_merged history (files + ring) with the PR throughput counter as the floor, so the count does not restart at zero.
  • Fed by the audit log's pr_merged hook (hive's own merges and the poller's observed human / bot merges) and by webhook / closed-sweep snapshots of merged PRs (title + merger login within seconds). pkg/github snapshots now carry merged_at, merged_by, merged_by_hive.
  • GET /api/stage-tracker adds merged{today, total_7d, total_30d, all_time, recent[≀20], tz, day_start}; "today" rolls at midnight in the spoke's zone (UTC when none).

SPA

  • Chip renamed Merged: primary = all-time, "N today Β· N this week" beneath, tooltip with the last five; click opens a popover of recent merges (number, title, by whom, lane, when). Hydrates from the API on first render (no flourish), never goes backwards within a tab, a merge the tab just watched is added on top until the server lists it, in-flight merges the server already counts are held back until the glyph lands.
  • The chip sits in a new sticky bar at the top of the tracker; the stage column header strip is sticky under it.
  • Flight per the operator's spec: a 🐝 (or +1, βš™ β†’ Merges β†’ Glyph, hive.tracker.celebrate_glyph) rises from the row's βœ“ cell (~900 ms, slight arc) to the chip when the chip's box is in the viewport (count bumps, zap on landing) or exits through the top edge otherwise; position: fixed, pointer-events: none, works at any scroll; reduced motion fades in place.
  • Persistent bottom-right banner per merge β€” "βœ“ πŸ› fix: enable bulk delegation for multi-PR parent selectionsΒ #15067 merged β€” title (lane, by hive, 17:42)" β€” until dismissed or 30 s, stacked (max 5), with Show row / Open on GitHub / All merges.
  • Test celebration closes the settings dialog first and plays on a row currently in the viewport with a "(test)" banner.

Tests β€” merged_ledger_test.go (persistence across reload, upsert fill-blanks / earliest time, retention + cap, today per zone incl. midnight rollover, seed floor + once, audit projection, server audit + snapshot recording, API shape); node fixture tests in stage_tracker_cues_test.go (TestStageTrackerMergedChipHydrates, TestStageTrackerFlightTargetNode, updated celebrate tests for flight, banners, sticky chip target).

Docs β€” docs/dashboard-sections.md (Activity Monitor), docs/api-reference.md, changelog.d/fixed-merged-ledger.md.

Not in this PR

#14934 still showing PR in progress Β· #14945 an hour after the merge is not a dashboard cache problem: the PR merged into v6 (non-default, so GitHub does not auto-close) and the hive's close-on-merge skipped it as untrusted_author although the hive merged it. Filed as #15148.

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hanthor for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 28, 2026
@hivecommons-hive hivecommons-hive Bot added author/human A person pushed this PR themselves dco All commits are DCO signed-off stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#15184 πŸ“– docs: refresh operator decision API reference CONFLICT src/docs/api-reference.md
#15180 πŸ› Audit contributor tier changes; refresh parked PRs' role tier each sweep same files src/pkg/dashboard/audit.go
src/pkg/dashboard/static/index.html
#15134 πŸ› Delegated decision on a capability gap: model the blocker, stop the un-park/re-park loop, name the missing App permission CONFLICT src/docs/api-reference.md
#14807 ✨ dashboard: stream Job pod logs in the terminal pane for sandbox.runtime: job agents same files src/docs/api-reference.md
src/pkg/dashboard/server.go
src/pkg/dashboard/static/index.html
#15085 ✨ Activity Monitor: Adopt now and Reroute to another clanker for PRs waiting on a contributor's clanker CONFLICT src/docs/api-reference.md
#15104 πŸ› Activity Monitor: Rebase, then merge as maintainer; fixer owns parked conflicting PRs; dismiss self-inflicted changes_requested same files src/docs/dashboard-sections.md
src/pkg/dashboard/server.go
src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/stage_tracker_cues_test.go
src/pkg/dashboard/static/index.html
#15122 πŸ› Write-back containment: per-kind gate for every unsolicited GitHub write, with backfill guard CONFLICT src/docs/api-reference.md
#15157 ✨ Conflict-aware merge train in the automerge lanes same files src/docs/dashboard-sections.md
src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/static/index.html

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed (correctness) β€” no blocking findings; two low advisories.

  1. Low β€” chip can bump before the flight when the server counts a merge one poll ahead of the row leaving. stageTrackerMergedHoldback only subtracts a pending key that is both in _stageTrackerCelebratePending and in server.recent (index.html, stageTrackerMergedHoldback). When the hive's own merge lands in the ledger via the audit hook (merged_ledger_server.go recordMergedAudit) but the row is only dropped by a later poller cycle, poll N already shows all_time+1 with no pending key, so stageTrackerMergedCountDraw raises _stageTrackerMergedShown silently; on poll N+1 the key becomes fresh/pending, the computed count dips by one, and the never-backwards guard hides it β€” the landing pop then fires on an unchanged number. Cosmetic; the body's "held back until the glyph lands" only holds when the count and the row removal arrive in the same payload. Not worth blocking; noting it so the behaviour is expected.

  2. Low β€” first-boot seed qualifies short repo names with Project.Org when no status snapshot is loaded yet. mergedRepoQualifier (merged_ledger_server.go) falls back to org + "/" + repo when s.status is nil, which is the state during RegisterAPI β†’ mergedLedger() β†’ seedMergedLedger. For a hive tracking repos outside its own org, seeded keys (otherorg-repo β†’ org/repo) will not match the keys the closed sweep records a moment later (overviewRepoName, the real owner), so the first 24 h look-back can double-count those merges once. One-time and bounded; a follow-up could defer the seed until the first status publish or qualify from deps.Config repo list.

Process: tide reports a merge conflict with v5; needs a rebase before it can land.

β€” hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security perspective (read at e5c59ae) β€” no blocker; one advisory.

Low Β· merged_by is interpolated into popover innerHTML without esc() β€” src/pkg/dashboard/static/index.html:18517: stageTrackerMergedByText(e.merged_by) (returns 'by @' + by, index.html:18508–18511) is joined into meta and emitted raw at index.html:18519 (<span class="ham-merged-meta">${meta}</span>), while the sibling lane field on the same line is escaped. Not exploitable today β€” the value comes from safeGetLogin(pr.GetMergedBy()) (src/pkg/github/webhook_item_refresh.go) or the audit actor attr (merged_ledger.go mergedByFromAudit), both GitHub logins restricted to [A-Za-z0-9-] β€” but the ledger is persisted and re-read from /data/merged-ledger.json (merged_ledger.go newMergedLedger), so the invariant now rests on the file's provenance rather than on the renderer. The banner path is already safe (who lands in t.text, escaped at index.html:18774+ via esc(t.text)).

        const meta = [esc(stageTrackerMergedByText(e.merged_by)), e.lane ? esc(e.lane) : '', e.at ? fmtAt(e.at) : ''].filter(Boolean).join(' Β· ');

β€” hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intent alignment vs #15147 (read at e5c59ae): all seven expected items are implemented β€” ledger (merged_ledger.go, 90-day retention, monotone all_time, seed floor), merged{…} API block (stage_tracker.go:99), renamed sticky chip + popover, bottom-right banner, glyph flight, dialog-closing Test celebration β€” and each is covered by the listed tests. No unrelated scope; api-reference.md churn is the citation-line renumbering. Two small notes:

  1. Banner "Open on GitHub" can be absent for a live merge (low). stageTrackerMergeBanner (index.html:18784–18787) only emits the link when info.url is set, and that comes solely from server.recent; _stageTrackerPRTitle keeps titles only (stageTrackerPRTitles, index.html:18476–18484). On the poller/audit path the row can vanish before the ledger's enriched entry reaches the tab, so the banner the spec calls for ("Show row / Open on GitHub / All merges") loses its middle link. The PR key already carries owner/name, so a fallback is cheap:

          const info = Object.assign({ title: _stageTrackerPRTitle[b.key] || '', merged_by: '', lane: '', url: '' }, recent || {}, b);
          if (!info.url && info.repo && info.repo.indexOf('/') > 0 && info.number > 0 && !info.preview) info.url = `https://github.com/${info.repo}/pull/${info.number}`;
    
  2. Advisory β€” ledger scope is "every merged PR in a configured repo", not "every PR the hive tracked". sweepClosedRows feeds merged from the whole ListClosedSince result before the frontendRepoLists filter (stage_tracker_closed_sweep.go:149–159), and the comment says this is deliberate. It is a reasonable reading of #15147 Β§1, but it means all_time will drift above the PR-throughput counter it was seeded from (hive-observed merges only). Worth a line in docs/dashboard-sections.md so the two numbers are not expected to agree.

β€” hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style / maintainability review (head e5c59ae) β€” the diff implements every item in #15147 (ledger, merged{} block, chip/popover, sticky bar, banner, flight, glyph setting, test celebration); nothing blocking. Three small coupling / duplication points worth tidying:

  1. "hive" attribution literal is now shared across two packages by coincidence. src/pkg/github/webhook_item_refresh.go:121 compares prTerminalMergeAttribution(...) == "hive" against the bare literal returned at prchurn.go:161, and src/pkg/dashboard/merged_ledger.go:55 separately declares MergedByHive = "hive" (also matched in mergedByFromAudit). The three only agree by convention; a rename in prchurn.go breaks MergedByHive silently. Suggest one exported constant in pkg/github and alias it:

    --- a/src/pkg/github/prchurn.go
    +++ b/src/pkg/github/prchurn.go
    +// PRMergeAttributionHive is prTerminalMergeAttribution's "the hive merged it" value.
    +const PRMergeAttributionHive = "hive"
     ...
    -		return "hive"
    +		return PRMergeAttributionHive
    --- a/src/pkg/github/webhook_item_refresh.go
    +++ b/src/pkg/github/webhook_item_refresh.go
    -			snap.MergedByHive = prTerminalMergeAttribution(snap.MergedBy, c.getHiveIdentity(), c.appBotLogin) == "hive"
    +			snap.MergedByHive = prTerminalMergeAttribution(snap.MergedBy, c.getHiveIdentity(), c.appBotLogin) == PRMergeAttributionHive
    --- a/src/pkg/dashboard/merged_ledger.go
    +++ b/src/pkg/dashboard/merged_ledger.go
    -	MergedByHive = "hive"
    +	MergedByHive = github.PRMergeAttributionHive
  2. Ledger path is a mutable package global that tests overwrite. merged_ledger.go:40 var mergedLedgerPath, read in merged_ledger_server.go:22, and reassigned in merged_ledger_test.go:38-39 with a t.Cleanup restore. The sibling persistence in this package (PRThroughputCounters, pr_throughput_counters.go:442 a.prCountersPath) keeps the path as an instance field instead. A mergedPath string field on Server (defaulting to /data/merged-ledger.json inside mergedLedger()) would follow that convention and let the tests stop mutating globals β€” this package already has t.Parallel() tests, so a global is a race waiting to happen.

  3. Glyph setting read is duplicated inline. index.html:19312 reads localStorage.getItem(STAGE_TRACKER_CELEBRATE_GLYPH_KEY) via an inline IIFE inside the settings-sync call, duplicating the read in stageTrackerCelebrateGlyph() (:18427). Small helper:

     function stageTrackerCelebrateGlyphSetting() {
       try { return stageTrackerCelebrateGlyphId(localStorage.getItem(STAGE_TRACKER_CELEBRATE_GLYPH_KEY)); } catch { return STAGE_TRACKER_CELEBRATE_GLYPH_DEFAULT; }
     }
     function stageTrackerCelebrateGlyph() { return STAGE_TRACKER_CELEBRATE_GLYPHS[stageTrackerCelebrateGlyphSetting()]; }
    

    then celebrateGlyph: stageTrackerCelebrateGlyphSetting() at :19312. Same spirit: the HH:MM padStart formatter is now written three times (:18501, :18515, :18773), and the const bar = … at :18598 is fetched only as a truthy guard before e.target.closest('#activity-monitor-sticky').

β€” hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@clubanderson
clubanderson force-pushed the fix/merged-ledger branch 2 times, most recently from 31b3ae9 to dec2ac9 Compare October 28, 2026 23:50
@kubestellar-prow kubestellar-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2026
@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 28, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply.

@hivecommons-hive hivecommons-hive Bot added role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 28, 2026
… chip

Server side of #15096: every tracked PR that reaches
merged (hive, human or other bot; audit log, webhook or closed sweep) is
recorded in /data/merged-ledger.json, seeded from audit history on first
boot, and summarised on /api/stage-tracker as merged{today, total_7d,
total_30d, all_time, recent}.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…ht, tests and docs

The Activity Monitor's chip is now "Merged" (all-time, with today / this
week beneath), pinned at the top of the tracker with the column header
strip, hydrated from /api/stage-tracker's merged block so a reload shows
the server's number and never goes backwards within a tab, with a popover
of recent merges. A merge raises a bee (or +1, hive.tracker.celebrate_glyph)
from the row's check cell to the chip when it is in view, else off the top
of the screen, and posts a dismissible bottom-right banner with Show row.
Test celebration closes the dialog and plays on a row in the viewport.

Go tests cover ledger persistence, upsert, retention and cap, today's
rollover per zone, seeding, the audit projection, the server hooks and the
API shape; node fixture tests cover hydration, the flight target and the
banners. Docs and changelog updated.

Fixes #15147

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…GitHub backfill on first boot, fixture fixes

The ledger's merged.recent now settles a vanished PR row as merged (a
human's merge celebrates too); a ledger seeded on this boot makes the
first closed sweep look back 30 days over GitHub's closed list so the
count backfills beyond the audit log; the popover's date uses the shared
dashboard timezone helper; node fixtures fixed (duplicate binding,
titles, ledger-settled merges). Refs #15147

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
… banner links without ledger enrichment, one hive attribution constant, docs on ledger scope

Refs #15147

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@hivecommons-hive
hivecommons-hive Bot merged commit 3399efe into v5 Oct 29, 2026
77 of 78 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/merged-ledger branch October 29, 2026 00:13
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#1515022c2f40` sha256:7b4ec8f176dabf54d4798fa4cc11b028a90b90c47cbf3c5acee06d62ee02c789 β€” download from the dashboard or `hivectl review evidence #15150`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 22c2f40.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/human A person pushed this PR themselves conflicts-with-open-pr Open PR has a merge conflict with another open PR dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

πŸ› Activity Monitor "Merged today" chip resets to 0 on reload β€” count lives only in the tab

1 participant