Skip to content

fix(pr-management-stats): refine is_untriaged predicate + surface draft/non-draft split - #219

Merged
potiuk merged 4 commits into
apache:mainfrom
potiuk:fix-stats-untriaged-scope
May 18, 2026
Merged

potiuk merged 4 commits into
apache:mainfrom
potiuk:fix-stats-untriaged-scope

Conversation

@potiuk

@potiuk potiuk commented May 18, 2026

Copy link
Copy Markdown
Member

Summary

The pr-management-stats dashboard's "Untriaged non-drafts" hero card was over-counting against apache/airflow (~475 open PRs):

  • Reported: 266 untriaged non-drafts / 73 >4w old
  • Actual actionable: ~38 contributor PRs

Breaking down the 73-figure showed two structural issues with the classifier:

  • 26 PRs (35%) were committer-authored — F1-skipped by pr-management-triage, never going to be acted on by the triage skill, but counted toward the hero card.
  • 44 PRs (60%) were already labelled ready for maintainer review — they had cleared the triage bar by an alternate path (direct reviewer promotion, pre-skill-era triage, etc.) but lacked the literal Pull Request quality criteria marker the classifier searches for, so they double-counted as "untriaged" while also appearing in the "Ready for review" hero card.

The recommendation rules and health rating fired on the inflated count, producing advice that didn't match the real state.

Changes

This is a pure classification + documentation refinement. No fetch shape, no GraphQL changes, no breaking changes for adopters.

classify.md

  • Introduces an explicit is_untriaged predicate that combines the existing triage-marker scan with two missing exclusions: (a) author is not OWNER/MEMBER/COLLABORATOR, (b) PR does not carry ready for maintainer review.
  • Documents the rationale for each exclusion.

aggregate.md

  • Adds untriaged_nondraft / untriaged_old / untriaged_med per-area counters that consume the refined predicate.
  • Adds whole-repo total_drafts / total_non_drafts counters powering the dashboard's new draft/non-draft split.
  • Updates the health rating thresholds to read from the refined counters (so a queue full of ready-labelled PRs without the literal marker doesn't false-positive into "Action needed").
  • Adds two new invariants covering the new counter relationships.

render.md

  • Enhances the "Open PRs" hero card with a two-line sub-label:

    • Line 1: <non-draft> non-draft · <draft> draft
    • Line 2: <contributor> contributor · <collaborator> collaborator-authored

    This addresses a recurring maintainer question — "how much of the backlog is in-review vs. still being worked on" — at a glance.

  • Updates the "Untriaged non-drafts" hero card spec to reference the refined is_untriaged predicate and explains why both exclusions matter.

Note on pressure_weight

classify.md#pressure-weight was already correct — collaborator-authored PRs already scored 0, and ready-labelled PRs already got a fixed weight of 1 (regardless of triage state). So the area-pressure ranking didn't need fixing — only the global "untriaged" counters that feed the hero card, health rating, and recommendation rules needed the predicate refinement.

Validation

Ran on apache/airflow (476 open PRs at fetch). Pre-fix dashboard reported 266 / 73; post-fix reads 38 / actual count after exclusions, matching the real backlog the maintainer is actually able to act on.

prek run --all-files passes on the changed files.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.7)

Generated-by: Claude Code (Opus 4.7)

potiuk added 4 commits May 18, 2026 16:32
…raft/non-draft split

When running the stats dashboard against `apache/airflow` (~475 open PRs) the
"Untriaged non-drafts" hero card surfaced 266 PRs / 73 >4w, which read as a
much larger gap than reality. Breaking the figure down by author association
and label showed:

- 26 (35%) were committer-authored — F1-skipped by `pr-management-triage`, not
  actionable, but counted toward the hero card.
- 44 (60%) were already labelled `ready for maintainer review` — they had
  cleared the triage bar by an alternate path (direct reviewer promotion,
  pre-skill-era triage, etc.) but lacked the literal `Pull Request quality
  criteria` marker the classifier searches for, so they double-counted as
  "untriaged" while also appearing in the "Ready for review" hero card.

The true actionable backlog was ~38 contributor PRs, not 73. The dashboard's
recommendation rules and health rating fired on the inflated count and produced
advice that didn't match the real state.

This change refines the predicate the three downstream uses depend on:

- `classify.md`: introduces the explicit `is_untriaged` predicate combining the
  existing triage-marker scan with the two missing exclusions (collaborator-
  authored and ready-labelled).
- `aggregate.md`: adds `untriaged_nondraft` / `untriaged_old` / `untriaged_med`
  per-area counters that consume the refined predicate, plus `total_drafts` /
  `total_non_drafts` whole-repo counters for the dashboard's new draft/non-draft
  split. Updates the health-rating thresholds to read from the refined counters.
- `render.md`: enhances the "Open PRs" hero card with a two-line sub-label —
  `<non-draft> non-draft · <draft> draft` on line 1, contributor/collaborator
  split on line 2 — so the maintainer can see at a glance how much of the queue
  is in-review vs. still being worked on. Updates the "Untriaged non-drafts"
  hero card spec to reference the refined predicate and explains why both
  exclusions matter.

The pressure-score function in `classify.md#pressure-weight` already gave
collaborator-authored PRs weight 0 and ready-labelled PRs a fixed weight of 1,
so the area-pressure ranking was already correct — only the global "untriaged"
counters needed the predicate refinement.

No GraphQL or fetch shape changes; this is a pure classification + documentation
refinement.
…kly stats

Builds on the previous commit. Adds the following to the spec:

1. Bot exclusion in `is_untriaged` — `is_bot()` predicate filters
   dependabot/renovate/github-actions and any `*[bot]` login.
2. New `is_engaged` predicate — broader "any maintainer touched this PR"
   that catches review-thread comments / direct discussion / label-adds the
   strict marker test misses. On `apache/airflow`'s ~457-PR human-authored
   open queue: strict marker-triaged covers ~21%; broad is_engaged covers
   ~59%. The 38-pp gap is "de-facto triaged" — engagement happening
   invisibly to the strict counter.
3. New `is_defacto_triaged` and `is_ai_triaged` predicates — surfaced as
   separate hero-row cards (de-facto-triaged for queue-health insight,
   AI-triaged for skill-throughput accounting).
4. Bot PRs as a separate accounting category. Bot-authored PRs follow their
   own lifecycle (Dependabot, Renovate, etc.) and shouldn't merge into the
   `contributors` count. New `bot_authored` counter surfaced on the
   expanded hero row.
5. Two-row hero grid — the 4 original cards plus a new row of 4
   (Strict-triaged, De-facto triaged, AI-triaged, Bot PRs) so the
   maintainer can see the full breakdown at a glance.
6. Per-triager weekly stats panel — top 15 maintainers ranked by distinct
   PRs engaged across the last 6 weeks. Each row shows a per-week
   AI/manual split so the team can see how much triage throughput goes
   through the skill vs. through direct review.

The strict `is_triaged` definition remains the source of truth for the
action-related flows (`pr-management-triage` row 3-4, sweep 1a) — only
the stats categorisation gets the broader engagement model.

No fetch shape changes — every new counter consumes data already populated
by the existing open-PR query (comments(last:25) + review threads).

Validation: applied against `apache/airflow` (457 human-authored open PRs).
Strict-triaged=98, engaged=272, defacto_triaged=174, untriaged=85 (vs the
266 the previous commit had reported because of the missing bot exclusion).
… is_untriaged

Adds a "Triage tiers — definitions" section at the top of `classify.md` that
defines all four tiers (strict / de-facto / AI-triaged / untriaged) side-by-
side with their predicates, implication chains, and dashboard surface area.

Also calls out what the "literal marker" is — the substring `Pull Request
quality criteria` — since the previous version of the spec referenced it
without ever defining it explicitly. The marker is the visible link text in
the canonical triage-comment template, scanned in comment `body` (not
`bodyText`, to catch HTML-comment legacy form too).

The key behavioural change in this commit:

`is_untriaged` now uses `NOT is_engaged` instead of `NOT is_triaged`.
The previous definition over-counted: PRs where a maintainer left detailed
inline review feedback without including the canonical marker link were
flagged as untriaged, even though they had been substantively engaged.
The new predicate correctly counts only PRs with **zero** maintainer
engagement.

Concrete impact on `<upstream>`'s queue at fix time:
- strict-untriaged (old): 72 non-drafts, 3 >4w
- broad-untriaged (new): 47 non-drafts, 0 >4w
- 25 PRs (35% of the strict count) drop out because they're de-facto-engaged

The dashboard's "Untriaged non-drafts" hero card now surfaces the broad
count, which is the number a maintainer can meaningfully act on. The
de-facto-triaged hero card surfaces the 25 PRs separately as the strict-
counter gap, so the underlying signal is still visible.

Also includes a new invariant in `aggregate.md`:

    engaged + untriaged_nondraft + ready_for_review == non_drafts (contributor)

The three sets now partition the contributor non-draft pool exactly.

No fetch shape changes; no breaking changes for adopters.
…ity Criteria triaged"

The user-facing label was "Strict-triaged" which described the algorithm but
not what the count actually means. "Quality Criteria triaged" matches the
literal substring the detector scans for (`Pull Request quality criteria` —
the link text in the canonical triage-comment template) and reads as a
description of what happened to the PR ("a maintainer linked the quality
criteria") rather than a description of how the classifier works
("strict" predicate).

Renames the hero card label in `render.md` from **Strict-triaged** to
**Quality Criteria triaged**. Updates the side-by-side tier table in
`classify.md` and the invariants in `aggregate.md` to use the same name.

The internal predicate name remains `is_triaged` — only the user-facing
display label changes. The algorithm description in prose ("the strict
marker-only test", "the strict-only count") stays the same; "strict" is
still an accurate adjective for the implementation, just not the card name.

No fetch shape changes, no behavioural changes.
@potiuk
potiuk merged commit 0d95e0a into apache:main May 18, 2026
13 checks passed
@potiuk potiuk added capability:stats Read-only dashboards, metrics, governance evidence family:pr-management pr-management-* skills labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capability:stats Read-only dashboards, metrics, governance evidence family:pr-management pr-management-* skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant