Skip to content

fix(projector): source prs stream from pulls endpoint so draft/merged heal (#4528) - #4597

Merged
dezren39 merged 2 commits into
mainfrom
queue/6483-4528-reconcile-prs-pulls
Nov 3, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/6483-4528-reconcile-prs-pulls

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Queue task 6483 · fixes #4528 (triaged as task 6438).

Reconcile's only item source for PRs was the issues endpoint, whose PR objects carry no draft/merged/merged_at. First-sight PR rows materialized draft=0/merged=0 and the #4158 preservation logic pinned those false defaults forever — re-polling never healed them.

This change sources the prs stream from repos/{repo}/pulls (pulls-shaped, carries the merge fields) instead. Pulls truth lands on first sight and heals legacy false-default rows on a later pass via the existing upsert path. The issues stream is unchanged (still reads the issues endpoint, still skips pull_request-link objects). The reviews stream already enumerated pulls; no change there.

Tests (pm-stack/projector, bun test — 79 pass, 0 fail across 10 files):

Out of scope per packet: issues stream behavior, webhook issue-shaped reset (#4158, fixed by #4516), item deletion (#4210), application-contract design/audit (#4302/#4303).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 21:48
@coderabbitai

coderabbitai Bot commented Nov 2, 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 57 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: 2cc7a360-792c-4821-ac0a-051f44910318
Commits

Reviewing files that changed from the base of the PR and between 5bf164b and a09c6cd.

Files selected for processing: 3
  • pm-stack/projector/src/projector.ts
  • pm-stack/projector/src/reconcile.ts
  • pm-stack/projector/test/reconcile.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 commented Nov 2, 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 ✅ Completed 2026-11-03T01:43:54.625767Z a09c6cd 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.

@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: c0c9c9157b

ℹ️ 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 on lines +65 to +66
const row = fromIssueOrPr(repo, pr, "pr");
await store.upsertItem(db, row);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Derive merged status from the pulls-list payload

For merged PRs, the GitHub pulls-list response contains merged_at but no merged boolean. Passing it directly to fromIssueOrPr makes that mapper emit merged=0, because it checks only obj.merged. Consequently, this poll not only fails to heal legacy merged flags but also overwrites correct merged=1 values previously stored by webhooks: upsertItem accepts equal updated_at timestamps. The aggregator then displays those PRs as closed rather than merged. Derive the flag from merged_at or fetch the detail payload, and remove the artificial merged field from the list-response test fixtures so they exercise the real API shape.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a09c6cd — thank you, this was a real bug. fromIssueOrPr now derives merged from merged_at when the boolean is absent (the pulls LIST shape), keeping the explicit boolean when present and null for issue-shaped payloads (#4158 preservation unchanged). The reconcile tests were also made realistic: the pulls fixtures no longer carry a merged key, so merged-first-sight (merged=1 + merged_at) is proven against the actual list-endpoint shape. Full projector suite: 79 pass / 0 fail. The derivation was salvaged from duplicate PR #4687, which had it right; #4687 is being closed as the duplicate with a salvage note here.

@dezren39

dezren39 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

🤖 Agent note · salvage + canonical resolution (task 6483, lane code-d)

Canonical PR: this one (#4597) — the PR bound to queue task 6483, opened by its first claimant lane at c0c9c91. PR #4687 was a later duplicate from a re-claim (branch queue/6483-4528-reconcile-prs); it is being closed as superseded by this PR.

Salvage from #4687 (diffed in full, per protocol): its one unique correctness item — deriving merged from merged_at for pulls-LIST payloads in projector.ts, plus its realistic no-merged-key test fixtures — is salvaged here in a09c6cd. Its since= query param was NOT salvaged: the pulls list endpoint does not support since (GitHub ignores it), so it changed nothing.

Codex dispositions:

Tests: bun test in pm-stack/projector on the laptop worktree: 79 pass / 0 fail, including draft-first-sight, merged-first-sight, and heal-after-gap.

@dezren39
dezren39 merged commit bb08a7a into main Nov 3, 2026
1 check passed
@dezren39
dezren39 deleted the queue/6483-4528-reconcile-prs-pulls branch November 3, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant