GeezerVison is showing github.com — fix(pm-stack): health snapshot, incremental reconcile streams, single-flight, cached attention (#9850) by dezren39 · Pull Request #10466 · developing-today/code
Conversation
dezren39
commented
Nov 15, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Refs #9850 — round 2. The round-1 fix (PR #10084) isolated the /health client and batched the writes, but the stalls came back: the projector was marked down twice more on the new build (2026-11-15 01:49Z and 02:55Z, ~3 min each), and /api/attention.json timed out four times in a row at the 03:00 CT reconcile fire on 2026-11-15 (35 s client timeouts, load 14→26) after flapping three times on 2026-11-14. This PR removes the mechanisms instead of widening the margins. The sentinel is unchanged — it was correctly reporting real stalls.
Root cause
- The reconcile
reviews stream ignored its cursor. Every pass re-read the full PR list and made one GitHub call per PR — for developing-today/code that is 4,758 PRs — then upserted every review found: the journal shows reviews: written=5433 ms=1692265 (28 minutes of sustained writes) and whole passes of ~11.5k rows taking 22–35 minutes, recurring roughly hourly. The prs stream likewise re-upserted all ~4,757 PRs every pass.
- /health still did live DB work on the request path (a COUNT over three tables, 5 s timeout → 503). Any contention past 5 s — the mega-pass write flood above, on a loaded box — became a sentinel "down" even though the process never died.
- POST /reconcile had no single-flight: the timer fires every ~15 min regardless, so passes overlapped and multiplied the load.
- The aggregator's /api/attention.json re-assembled the whole view on every request (no caching), so under CPU load each request cost seconds — measured live 2026-11-15: avg 0.98 s, worst completed 24.8 s, four consecutive 35 s timeouts at the 03:00 CT reconcile fire. It was the one assembly not behind the codebase's TodayCache.
Fix
- Projector /health serves a background-refreshed snapshot (15 s refresh): zero DB work on the request path. A snapshot older than 120 s answers 503
health_snapshot_stale — a genuinely wedged event loop cannot refresh, so real death still reads as down; a dead process cannot answer at all. Without a snapshot provider (tests, embedders) the previous bounded live probe runs unchanged.
- Reviews stream is incremental: candidates are PRs updated inside the cursor window (cursor − 5 min overlap), the PR list walk is newest-first and stops at the window edge, and a fetched PR still returns its full review list, so nothing is skipped permanently. Cursor semantics unchanged (max submitted_at; advances even when a PR errors — the projector(reconcile): reviews stream is not actually guarded per-PR — one PR's failing reviews endpoint aborts the whole stream, later PRs never reconcile, and the run reports written: 0 despite successful upserts #2745 contract). Measured on the live projection: 4,758 seated PRs vs 15 updated in the last 20 minutes — a pass now fetches tens of PRs instead of thousands.
- prs stream: same newest-first early stop; rows at or below the cursor are not re-upserted (safe: the cursor only covers PRs an earlier unfiltered pass already upserted from pulls data); the cursor still advances over the full walk.
- POST /reconcile is single-flight in serve(): a trigger during a running pass returns 200
{ok: true, skipped: "reconcile_in_progress"}.
- Aggregator: attentionContext is wrapped in the existing TodayCache idiom (pm-stack(aggregator): /board, /api/board.json, /api/overview.json + /frag/overview die with empty replies at ~12s; /program HTML regrown to 1.16MB #5082) — 10 s TTL, coalesced loads, stale-while-revalidate — one cache per census variant, invalidated on the same freshness notices as the today/overview caches.
Evidence
- New regression tests: reviews-stream incremental sweep (seeded cursor → only the updated PR is fetched), prs no-re-upsert below cursor, /health serves the snapshot with a wedged DB, stale snapshot → 503, reconcile gate no-op.
- Projector suite: 142 pass, 0 fail. Aggregator attention suites pass. Note: aggregator
test/today-cache-1179.test.ts currently fails its 5 s hook timeout on pristine main as well under this box's load (verified both trees back to back) — pre-existing, unrelated to this change; the cache primitive itself is untouched.
- Live A/B on a copy of the production DB (old code vs this branch): unloaded /health 4.3 ms (old, live query) vs 0.9 ms (new, snapshot,
snapshotAgeMs present). A local write flood does not reproduce the production stall physics (production writes queue on a remote libSQL service; a local WAL file answers readers instantly), so the request-path invariant is proven by the wedged-DB test instead: /health answers 200 from the snapshot while its DB client throws on every call.
- Production sampler (1 Hz, 502 samples, 2026-11-15 02:50–03:18 CT): /health max 299 ms, zero non-200; /api/attention.json avg 982 ms, worst completed 24.8 s, 4 timeouts of 35 s at 03:00–03:02 CT while load rose 13.9 → 26.1 — the flap this PR's cache removes.
Deploy note: takes effect at the next switch after merge (server code is read at start). The soak gate on #9850 (gate-code-9850-soak) should restart from this deploy.
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…-flight, cached attention (#9850)
Codex Review Summary: ❌ Failed
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
❌ Failed 2026-11-15T09:04:42.031678Z We couldn’t complete this review. Comment @codex review to try again. |
59119b4 |
PR opened |
ℹ️ 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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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 5 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:
21013b4a-8720-4db5-820d-896daa059f8b
Commits
-
Reviewing files that changed from the base of the PR and between 9ce1dbf and 59119b4.
Files selected for processing: 6
-
pm-stack/aggregator/src/server.ts
pm-stack/projector/src/github.ts
pm-stack/projector/src/reconcile.ts
pm-stack/projector/src/server.ts
pm-stack/projector/test/health-isolation.test.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
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
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, add credits to your account and enable them for code reviews in your settings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 15, 2026
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 15, 2026
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|