Skip to content

feat(aggregator): Needs-Drew label census on the attention view (#1226) - #3970

Merged
dezren39 merged 4 commits into
mainfrom
queue/4936-1226-needs-drew-census
Nov 3, 2026
Merged

dezren39 merged 4 commits into
mainfrom
queue/4936-1226-needs-drew-census

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

What

Implements task 4936 for #1226: the GitHub user/review + user/escalated labels become a read-only source for the aggregator's attention view — one reconciled Needs-Drew census across all four repos.

  • src/needs-drew.ts — buildNeedsDrewCensus: paginated GitHub search per repo × label (open only), dedupes items carrying both labels, defensively drops closed items from payloads, kind issue/PR, explicit reason extracted when the body states one (otherwise null — renderers show an honest fallback), per-source status with failures/truncation and fetchedAt freshness; complete is true only when every source answered fully.
  • src/source.ts — optional Source.needsDrew?() facet (same pattern as coverageCensus?), so fixtures/test doubles keep working.
  • src/sources/live.ts — live implementation with a 5-minute cache; uses PM_AGG_GITHUB_TOKEN/GITHUB_TOKEN when present, works unauthenticated.
  • src/render.ts — "Needs Drew — GitHub label census" section on /attention: unavailable renders as unavailable (never a confident zero), source failures render a banner naming repo + label.
  • src/server.ts — census rides attentionContext; new machine form /api/needs-drew.json (503 when the source cannot census). /api/attention.json shape unchanged.

Reconciliation direction, as specified in the packet: labels are the input to the page; the aggregator never writes labels back.

Acceptance discrepancy (preserved, not claimed)

The original #1226 acceptance says "#1007 appears in the queue". Issue #1007 is closed, and this census is open-only by design, so a closed item cannot appear. Literal acceptance is not claimed; #1226 stays open for Drew's reconciliation ruling.

Verification

Queue: task 4936 (repo-health-code-pilot), lane D.

Labels as a read-only source: buildNeedsDrewCensus paginates the GitHub search API for open issues and PRs carrying user/review or user/escalated across the four repos, dedupes items carrying both labels, defensively drops closed items, extracts an explicit reason when the body states one (else null, rendered as an honest fallback), and reports per-source failures/truncation and freshness instead of rendering them as an empty queue.

Wired as an optional Source facet (needsDrew?) so fixtures and test doubles keep working; the live source caches the sweep for 5 minutes and uses PM_AGG_GITHUB_TOKEN/GITHUB_TOKEN when present. Rendered as a section on /attention and served at /api/needs-drew.json (503 when the source cannot census).

Verified: new test/needs-drew.test.ts 10/10 (both labels, overlap dedupe, closed exclusion, pagination, source failure, reason fallback, render states); full aggregator suite 1307 pass with only the pre-existing boot.test.ts full-suite flakiness (11/11 standalone in this worktree and on clean main); tsc error count unchanged vs main (12, all pre-existing). Live spot-check: census counts reconcile exactly with gh for all 8 repo/label sources (105 items; code user/review 26, user/escalated 37).
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 20:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T12:36:07.445754Z
We couldn’t complete this review. Comment @codex review to try again.
b9ec82a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 20 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1eef76f1-6f9e-4cfe-bbb2-c6ada0e45471
Commits

Reviewing files that changed from the base of the PR and between 9d1464c and b9ec82a.

Files selected for processing: 7
  • pm-stack/aggregator/events.json
  • pm-stack/aggregator/src/needs-drew.ts
  • pm-stack/aggregator/src/render.ts
  • pm-stack/aggregator/src/server.ts
  • pm-stack/aggregator/src/source.ts
  • pm-stack/aggregator/src/sources/live.ts
  • pm-stack/aggregator/test/needs-drew.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8e58a2cd4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pm-stack/aggregator/src/sources/live.ts Resolved
Comment thread pm-stack/aggregator/src/needs-drew.ts Resolved
Comment thread pm-stack/aggregator/src/server.ts Resolved
…s, fetch census only where rendered (#3970)

Three unresolved Codex P2 findings on PR #3970:

- live.ts: concurrent attention fragments each started their own census
  on a cold cache (24 GitHub search calls instead of 8). The sweep is
  now a single-flight, TTL-cached sweeper (createNeedsDrewSweeper) and
  only a resolved sweep is cached.
- needs-drew.ts: GitHub's HTTP 200 + incomplete_results:true signal was
  dropped, so a search timeout could present an authoritative empty
  queue. The flag now marks the source and census incomplete, and the
  banner names it distinctly from a page-cap truncation.
- server.ts: attentionContext awaited the eight-query census for every
  caller, so the overview, Today, /api/attention.json and
  /api/coverage.json could wait ~64s on an unreachable GitHub API for a
  result they discard. The census is now opt-in (shouldFetchNeedsDrewCensus)
  and only the attention page render opts in.

Tests: single-flight sharing, TTL reuse, honest failure caching, the
incomplete_results flag end to end with its banner, and the opt-in gate.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dezren39
dezren39 merged commit a6ee280 into main Nov 3, 2026
1 check passed
@dezren39
dezren39 deleted the queue/4936-1226-needs-drew-census branch November 3, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant