GeezerVison is showing github.com — fix(aggregator): TTL-cache + single-flight the board/overview/program assemblies (#5082) by dezren39 · Pull Request #8338 · developing-today/code
Conversation
dezren39
commented
Nov 10, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
What this fixes
The remaining layer of #5082. The payload-bounding half landed in #7753 and the projector outage underneath is repaired, but the board-family assembly itself was still re-run live on every request: boardContext() / overviewContext() in pm-stack/aggregator/src/server.ts fan out to a Kaneo login + poll (sequential per-project task pagination), one projector /links call per board card, and the items() closure — with no TTL cache and no coalescing. Under ordinary fleet load that assembly outlives the 10 s dashboard deadline (assembly-deadline.ts), so /board, /api/board.json, /api/overview.json, and /program 503 even with every upstream healthy (verified live 2026-11-10: all four 503 at ~10.1–10.5 s while a single projector /links took 0.05 s and /api/quota.json answered in ~1.4 s). Concurrent cold loads each started their own assembly (measured 2026-11-08: 3 concurrent → 3 assemblies, all 503).
Design
The assemblies get the exact contract /today already has (#1179), reusing its class unchanged (src/today-cache.ts):
loadBoardContext() (was boardContext()) now runs through a TodayCache — TTL 10 s (TODAY_CACHE_TTL_MS, inside fix(aggregator): heavy pages + per-request live fan-out - /projects 109KB, /sessions 100KB, / renders in ~0.7s, /today ~1.8s #1179's accepted 5–15 s window and 6× tighter than the 60 s health-probe cache) — and boardContext() is the cached accessor. Every existing caller benefits: /board, /api/board.json, the overview, /today, the queue, provenance priming.
loadOverviewContext() gets the same wrap (overviewContext()), covering /, /frag/overview, /api/overview.json. Its board leg rides the board cache, so a cold overview and a cold board share one board assembly.
- The
/program + /api/program.json handler's live-source fan-out is extracted to loadProgramSources() behind the same cache (programSources()); the local-store reads (commentFormOpts, actionsStore.byObject()) and everything view-dependent stay per-request.
Single-flight: concurrent cold requests share one in-flight load (TodayCache coalescing). A throwing load is never cached — the slot releases and the next request retries, so the error boundary behaves exactly as before. Fail-soft facet fallbacks (e.g. an empty board when Kaneo is down) are cached as-is until expiry: they are the honest degraded state of that read, the same truthfulness rule #1179 documents. Provenance (prov() / provDetail()) is still read live per request at the call sites, never from the cache.
The existing deadline + stale-fallback layer (assembly-deadline.ts: 10 s deadline, last-good up to 5 min, 2 MB cap, keyed by pathname+search) is unchanged — it is now the second line of defense instead of the only one, and warm hits return in milliseconds so it should rarely engage.
One stacking note: /today's board leg can now lag up to ~20 s worst case (its own 10 s cache over the board cache's 10 s). Both bounds were accepted independently for this class of display data; noted here so it's a decision, not an accident.
Variant inventory (why no cache keys are needed)
The caches sit below the variant split — they hold the variant-free assembly, and every variant is derived per request from it — so a variant body can never be served for another variant, by construction:
| Route |
Variants found |
Where the split happens |
/board |
?done=all; saved views (vf.*, view, viewer) |
renderBoard / view filter in the handler, from the shared context |
/api/board.json |
?done=all (#7753); saved views (#8058) |
boardJsonBody / boardJsonViewBody per request |
/api/overview.json |
none |
deriveOverview per request |
/frag/overview |
none |
deriveOverview + render per request |
/program, /api/program.json |
saved views (pool filtering); ?area= (render-only) |
handler derivations from the cached source bundle |
Deliberately left uncached: boardRender's per-request local-store reads (actions/comments counts, comment form options) and /program's briefs/forecasts — cheap local reads where freshness matters more. /api/program.json is not in BOUNDED_DASHBOARD_PATHS today (pre-existing); it shares the now-cached handler assembly but its deadline behavior is unchanged. The /attention page's own attentionContext path is untouched (it is cached only as part of the overview assembly).
Deploy path
Aggregator source + tests only; no pkgs/ or Nix module changes. Deployment is merge → nixos-rebuild switch: the packaged aggregator from the pm-stack packaging change (pkgs/pm-aggregator, fix/8171-pm-stack-nix-apps) picks this up from the store — not a checkout pull.
Test evidence
New tests in test/board-cache-5082.test.ts (9 tests):
- (a) concurrent cold loads coalesce to one underlying assembly (gated loader, 3 waiters, loader called once);
- (b) a second request inside the TTL does not re-run the assembly (fake clock, same object);
- (c) at TTL expiry the assembly reloads;
- (d) a failed assembly is never cached — next request retries and its success caches;
- (e)
?done=all vs the default body: both derived from a single shared assembly (loader called once, identical context object), default done strip = 100 (DONE_STRIP_RENDER_LIMIT), ?done=all = all 150, each body shipping exactly its visible cards' items;
- route wiring through a booted fixture-mode server: warm
/api/board.json byte-identical, ?done=all never cross-serves after the default ran, 5 concurrent requests serve one body, /board + /board?done=all render, /api/overview.json warm byte-identical, /frag/overview renders, /program + /api/program.json serve.
Counts (laptop, worktree, PM_AGG_FRESHNESS_PORT moved off 4871):
- Required set —
board-cache-5082 + board-json-5082 + board-json-view-8058 + boot: 35 pass / 0 fail (196 expect() calls).
- Post-merge re-run including
today-cache-1179 + assembly-deadline: 60 pass / 0 fail (309 expect() calls).
tsc --noEmit: 0 errors in src/ and 0 in the new test file (pre-existing test/ errors on main untouched).
- Full aggregator suite: 2160 pass / 9 fail — and the same 9 fail on pristine
origin/main (verified by stashing this change and re-running those 7 files: 191 pass / 9 fail). Pre-existing, unrelated (live-source registry, epic ETA, collector parsing, dns page, pool assembly).
- Boot smoke (fixture mode, alternate ports):
/board cold 21 ms → warm 2–6 ms; /api/overview.json cold 10 ms → warm 1 ms. Fixture assemblies are cheap, so treat this as directional — the production effect is skipping a multi-second live assembly per request, which is what the unit tests pin.
Fixes #5082
![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.
chatgpt-codex-connector[bot] reacted with thumbs up emoji
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 58 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:
e1dc715e-aee8-4a64-b4fa-16e36ae74c0b
Commits
-
Reviewing files that changed from the base of the PR and between 196c4d2 and bd898a7.
Files selected for processing: 2
-
pm-stack/aggregator/src/server.ts
pm-stack/aggregator/test/board-cache-5082.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.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-11-10T23:09:36.117682Z |
bd898a7 |
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|