Title: projector(reconcile): the prs stream reads the issues endpoint, so reconcile can never learn draft/merged/merged_at — first-sight PRs are stored draft=0/merged=0 forever · Issue #4528 · developing-today/code · GitHub
Open Graph Title: projector(reconcile): the prs stream reads the issues endpoint, so reconcile can never learn draft/merged/merged_at — first-sight PRs are stored draft=0/merged=0 forever · Issue #4528 · developing-today/code
X Title: projector(reconcile): the prs stream reads the issues endpoint, so reconcile can never learn draft/merged/merged_at — first-sight PRs are stored draft=0/merged=0 forever · Issue #4528 · developing-today/code
Description: Summary The projector's reconcile poller can never learn a PR's draft / merged / merged_at — and for a PR it discovers first, it stores the wrong values permanently. Both item streams in pm-stack/projector/src/reconcile.ts read the issue...
Open Graph Description: Summary The projector's reconcile poller can never learn a PR's draft / merged / merged_at — and for a PR it discovers first, it stores the wrong values permanently. Both item streams in pm-stack/p...
X Description: Summary The projector's reconcile poller can never learn a PR's draft / merged / merged_at — and for a PR it discovers first, it stores the wrong values permanently. Both item streams in pm...
Opengraph URL: https://github.com/developing-today/code/issues/4528
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"projector(reconcile): the prs stream reads the issues endpoint, so reconcile can never learn draft/merged/merged_at — first-sight PRs are stored draft=0/merged=0 forever","articleBody":"## Summary\n\nThe projector's reconcile poller can never learn a PR's `draft` / `merged` / `merged_at` — and for a PR it discovers first, it stores the wrong values permanently.\n\nBoth item streams in `pm-stack/projector/src/reconcile.ts` read the **issues** endpoint:\n\n- `reconcile.ts:47-49` — the `issues` and `prs` streams share one path: `` `repos/${repo}/issues?${q}&filter=all` ``; the `prs` stream only filters the same list to objects with a `pull_request` link (`:55-57`).\n\nObjects from that endpoint are issue-shaped for PRs: a `pull_request` link (whose nested object carries `merged_at`) but **no top-level `draft` / `merged` / `merged_at`** — the same shape the repo's own test documents for webhook issue objects (`pm-stack/projector/test/projector.test.ts`, the #4158 describe block: \"it has a pull_request link but NO merged / merged_at / draft\").\n\nSince the #4158 fix (merged today as #4516), `fromIssueOrPr` (`projector.ts:52-58`) emits `null` for those three fields on issue-shaped payloads, and `upsertItem` (`store.ts`) preserves stored values for `null`. That is correct for webhooks. For reconcile it means:\n\n1. **First sight materializes false defaults.** A brand-new row INSERTs with `COALESCE(?,0)` (`store.ts`, upsertItem insert step), so a draft PR reconcile discovers is stored `draft=0` (ready for review) and a merged PR is stored `merged=0, merged_at=null` (closed-unmerged).\n2. **Reconcile can never heal it.** Every later poll re-reads the same issue-shaped objects, emits `null` again, and the store preserves the wrong stored values. Only a later `pull_request` webhook with a newer `updated_at` can correct the row — exactly the delivery reconcile exists to not depend on (\"poll GitHub … so the projection self-heals beyond webhook delivery\", `reconcile.ts:1-4`).\n3. **The truth is already in the same run, and is discarded.** The `reviews` stream fetches `repos/${repo}/pulls?per_page=100&state=all` (`reconcile.ts:128`) — pulls-shaped objects that DO carry `draft` / `merged` / `merged_at` — and uses them only to enumerate PR numbers for review fetching. No item row is upserted from them.\n\n## Evidence (verified this run, laptop probe)\n\nProbe: `~/git/fleet/probe-2026-11-02-laneB-reconcileprs/` on the laptop — verbatim copies of `pm-stack/projector/src/{reconcile,projector,store,github}.ts` + `schema.sql` at main `4c42670d0` (md5-matched against the primary clone), driven through the real `reconcileRepos` with a fake GitHub fetch:\n\n- `/issues?…` returns two issue-shaped PR objects: #7 an open **draft** PR, #8 a **merged** PR (`pull_request.merged_at` nested in the link object only).\n- `/pulls?…` (reviews stream) returns the pulls-shaped truth: #7 `draft:true`, #8 `merged:true, merged_at:\"2026-10-03T00:00:00Z\"`.\n\nStored rows after reconcile run 1 **and** run 2 (identical):\n\n```\nPROBE run1 #7 draft/merged/merged_at: 0 0 null\nPROBE run1 #8 draft/merged/merged_at: 0 0 null\nPROBE run2 #7 draft/merged/merged_at: 0 0 null\nPROBE run2 #8 draft/merged/merged_at: 0 0 null\n```\n\nControl: the repo's own `reconcile.test.ts` + `projector.test.ts` pass in the same probe directory (0 fail).\n\n## Why it matters\n\n`pmp_items.draft/merged/merged_at` is what the aggregator/dashboard reads as fact about PR state. Any PR whose `pull_request` webhook was missed, predates the projector, or lands while webhooks are down is projected by reconcile with merge fields that are silently wrong — a merged PR reads as closed-unmerged and a draft reads as ready — and no amount of re-polling fixes it. This is the reconcile-side counterpart of #4158: that issue fixed issue-shaped payloads *resetting* known values; this one is reconcile *never being able to learn* them, because its item source is an endpoint that does not carry them.\n\nDistinct from: #4158 (webhook reset, fixed), #4302/#4303 (the application contract and its writer-inventory audit — this is a concrete writer defect that inventory should disposition), #4210 (item deletion path).\n\n## Acceptance criteria\n\n- [ ] Reconcile sources PR-shaped data for the `prs` stream (e.g. upsert items from the `/pulls` list response it already fetches, or fetch pulls-shaped objects for the prs stream), so a reconcile-discovered PR is stored with its real `draft` / `merged` / `merged_at`.\n- [ ] A PR first projected by reconcile as a draft reads `draft=1`; a merged PR reads `merged=1` with its `merged_at`; a second reconcile pass over unchanged data changes nothing.\n- [ ] A row previously materialized with the false defaults is healed by a later reconcile pass (the pulls-shaped upsert carries a non-null carrier signal, so the #4158 preservation logic does not pin the wrong values).\n- [ ] Regression tests in `pm-stack/projector/test/reconcile.test.ts` (fake-GitHub style, like the existing streams tests) cover draft-first-sight, merged-first-sight, and heal-after-webhook-gap; the existing projector suite stays green.\n- [ ] Issues stream behavior is unchanged (plain issues still project from `/issues`).\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-11-02T18:33:05Z","url":"https://github.com/developing-today/code/issues/4528"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:38abc462-0d46-aed1-1e13-58eb8840abc6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ECCC:804E:2FA0B1:3E6312:6B061679 |
| html-safe-nonce | 19f24511b5cae3b6a945b10730a1884dfe56e65393bedaed865e3e6a0b966936 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0NDOjgwNEU6MkZBMEIxOjNFNjMxMjo2QjA2MTY3OSIsInZpc2l0b3JfaWQiOiI4ODA1OTM5MTQyMDQwMzYwNTY5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 666cb41e70b4b9a169c123ed3f2c845928699960bcde6e5cb60a9571f968e422 |
| hovercard-subject-tag | issue:6168614938 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/4528/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c0f68896013c6c61da124905056900f829240aee5805b1e64e3b7c59e5bbe2c5/developing-today/code/issues/4528 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c0f68896013c6c61da124905056900f829240aee5805b1e64e3b7c59e5bbe2c5/developing-today/code/issues/4528 |
| og:image:alt | Summary The projector's reconcile poller can never learn a PR's draft / merged / merged_at — and for a PR it discovers first, it stores the wrong values permanently. Both item streams in pm-stack/p... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width