Repository navigation
perf(server): scope refreshIdeas status queries - #109
Conversation
jerelvelarde
left a comment
There was a problem hiding this comment.
The three status-scoped reads preserve existing filters and side effects while avoiding unrelated rows; all three persistence tests pass. No new security blocker found. Please resolve tests/persistence.test.ts against current main, keeping this status/isolation regression and the section-snapshot regression, then rerun CI, including the currently failing browser-container check. Production patches merge cleanly. Add actual verification results and integration limits to the description.
Keeps current persistence coverage plus the CopilotKit#109 regression; credit @jerelvelarde for the reconciliation request.
|
@jerelvelarde thanks — reconciled this onto current |
|
Thanks — reconciled against current |
jerelvelarde
left a comment
There was a problem hiding this comment.
Value: scopes refreshIdeas database reads to the statuses actually consumed, avoiding unnecessary application-side scans. Template fit: preserves final ideas results, task filtering, active-goal behavior, deduplication, and compare-and-swap acceptance protection. Integrated current main by retaining both independent Store methods and persistence test additions from #108; no behavior rewrite. Security: owner/kind/status remain parameterized and isolated; no introduced security blocker found. Verification on this integrated head: 37 persistence/workflow/agent API tests, changed-file Biome, and diff checks pass. Merge remains gated on fresh required CI for this head and combined verification.
jerelvelarde
left a comment
There was a problem hiding this comment.
Combined verification on the exact integrated tree passes: 483 tests (zero failures/skips), two real Chromium tests, root/mobile/worker typechecks, server build, and full Biome. Fresh CI passed six jobs; browser-container failed on the initial PDF download listing with WORKER_FAILURE. Independently reproduced a pre-existing race in unchanged worker code: readDownloadFailures enumerates a pending journal which successful capture deletes before readFile, producing ENOENT and the same HTTP 500 mapping. The precise CI cause remains an inference because the worker masks that exception. One bounded failed-job retry is justified by this reproduction; merge remains held until required checks pass. A durable worker follow-up would tolerate only ENOENT for an enumerated journal that disappears, while preserving other errors.
Problem
refreshIdeas()performs three full-table reads and then filters by status in JavaScript:status === "succeeded"status === "new"status === "active"Terminal task history is retained, so the task scan grows without bound and runs on both maintenance refreshes and on-demand idea refreshes.
A downstream PGlite benchmark measured the largest hotspot (2,000 ~2KB tasks) at roughly:
Change
Add
Store.listByStatus()with the sameupdated_at DESC,idordering aslist(), then use it for those three status predicates only.All remaining filters and side effects stay unchanged:
messageIdchecks;Regression
Persistence coverage compares the scoped query directly with the previous
list().filter(item.status === value)semantics and verifies owner/kind isolation.No idea ranking, task lifecycle, or goal behavior changes.
Verification
Reconciled against current
mainwhile retaining the existing section-snapshot persistence regression and this PR's status-query regression, as requested by @jerelvelarde.Fresh CI: all seven jobs passed.
Integration limits
Only the three existing status predicates are pushed into SQL. Idea ranking, dedupe, CAS side effects, goal behavior, and the final ideas response are unchanged.