Re-land #76 safely: resilient /skills count + globalStats fallbacks#375
Re-land #76 safely: resilient /skills count + globalStats fallbacks#375
Conversation
Co-authored-by: rknoche <richard.knoche@holidaycheck.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Centralizes public-skill visibility rules in Updates the Written by Cursor Bugbot for commit 89129a5. This will update automatically on new commits. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| key: v.string(), | ||
| activeSkillsCount: v.number(), | ||
| updatedAt: v.number(), | ||
| }).index('by_key', ['key']) |
There was a problem hiding this comment.
Global stats key allows duplicate rows
Medium Severity
globalStats uses a plain by_key index, but writes and reads assume a single row via .unique(). Concurrent initialization paths can insert multiple key: 'default' rows, after which .unique() can throw and break countPublicSkills and mutations that call adjustGlobalPublicSkillsCount.
Additional Locations (2)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89129a5d97
ℹ️ 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".
| const statsCount = await readGlobalPublicSkillsCount(ctx) | ||
| if (typeof statsCount === 'number') return statsCount |
There was a problem hiding this comment.
Avoid serving stale global count from partially maintained cache
countPublicSkills returns globalStats.activeSkillsCount whenever that row exists, but the new delta-maintenance wiring in this commit only covers mutations in convex/skills.ts. I checked other visibility-changing writers (evictSquatterSkillForRestoreInternal in convex/githubRestoreMutations.ts:34-40 and applyEmptySkillCleanupInternal in convex/maintenance.ts:1012-1027), and they still soft-delete/hide skills without updating globalStats, so /skills can report an inflated count until the hourly cron corrects it. Please update those paths (or force a recount here when cache freshness is uncertain) so this query stays consistent.
Useful? React with 👍 / 👎.


Re-lands the #76 skills-count feature that was reverted in #359, with migration-safe behavior.
What changed
/skillstotal count UI +globalStatstable/cron./skillsnever errors ifglobalStatstable/index/row is missing:skills.countPublicSkillsreturns precomputed count when available.globalStatswrite paths so missing storage does not fail unrelated skill mutations.countPublicSkillsfallback paths.Verification
bun run lintbun run buildbun run testFixes #357
Greptile Summary
Re-lands the #76 skills-count feature (reverted in #359) with migration-safe fallbacks. Adds a
globalStatstable with an hourly cron for full reconciliation, incremental count adjustments on every skill mutation path, and acountPublicSkillsquery that prefers precomputed counts but falls back to a live scan if the table isn't ready. Centralizes public-visibility checks fromtoPublicSkillinto a reusableisPublicSkillDocfunction, removes a redundant client-side default-sortuseEffect, and shares Convex React test mocks across the skills test suite.globalStatserror-detection heuristic (isGlobalStatsStorageNotReadyError) is string-based, which is pragmatic for migration safety but may need updating if Convex changes its error message format.{...skill, ...patch}pattern to compute before/after visibility deltas — no double-counting was found in theinsertVersionflow.countPublicSkillsquery paginates through all skills, which could be expensive on large datasets, but this only triggers whenglobalStatshasn't been initialized yet and is quickly resolved by the hourly cron.countPublicSkillsand updated rate-limit tests to handle the newglobalStatsqueries.Confidence Score: 5/5
Last reviewed commit: 89129a5
Context used:
dashboard- AGENTS.md (source)