feat(xp): add suspicious XP flag audit#136
Conversation
|
@saurabhhhcodes is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
Siddhartha-singh01
left a comment
There was a problem hiding this comment.
Really solid PR @saurabhhhcodes the detection logic is clean and well-structured,
and I like that the dedupe_key + upsert(ignoreDuplicates) makes the cron idempotent
without reopening flags a maintainer already resolved. The RLS-enabled/no-policy
setup on flagged_accounts is the right call too service-role-only access for an
audit table. Good work.
One thing to fix before merge: in suspicious-xp-audit.ts, both queries (xp_events
and pull_request_reviews over the 8-day window) have no .limit() or pagination.
Supabase caps results at 1000 rows by default, so once there are more than 1000 XP
events or reviews in that window, the audit will silently scan only the first 1000
and miss the rest. For an anti-abuse audit that's a real gap please paginate with
a .range() loop (or an explicit ordered window) so the full window is always
scanned.
Minor (optional): the tests cover the three detection paths and a boundary nicely
worth also adding a case for the severity:'high' escalation.
Also heads-up CI hasn't run yet (the workflow is awaiting maintainer approval) and
the PR notes typecheck/tests weren't run locally, so let's get CI green before
merging.
Thanks for the careful work on this one
|
Thanks for the detailed review @Siddhartha-singh01. Addressed in 0a88095:
Validation:
I could not run the full Vitest suite locally because this clone has no |
There was a problem hiding this comment.
Hi @saurabhhhcodes heads up, CI is currently failing on this PR. The CI / check
job went red, which means one of these steps didn't pass: typecheck, lint,
format:check, or tests.
The good news: our CI bot already posted a comment above titled
"❌ CI failed on step: " that tells you exactly which step broke and how
to fix it. Please start there.
To fix and re-run CI, you'll need a working local environment so you can reproduce
what CI does before pushing:
npm install
npm run typecheck
npm run lint
npm run format:check
npm run test:coverageRun those in order whichever one fails locally is the same one failing in CI. Fix
it, get all of them passing locally, then push the fix to this branch. CI will
re-run automatically on the new commit.
I know you mentioned earlier that your environment had no node_modules and you
couldn't run the suite that's exactly why this slipped through, so it's worth
getting a local setup working now so you can verify before pushing. If npm install
gives you trouble, let us know and we'll help.
The pagination fix itself looked good in review this is just about getting the
checks green. Once CI / check passes, this is ready to merge.
|
Pushed a CI-focused follow-up in Root cause was Supabase type inference on the paginated Validation run locally:
Note: the focused Vitest run could not start in my local Codex macOS sandbox because Rollup's native optional package failed |
|
One more status note: after the |
Siddhartha-singh01
left a comment
There was a problem hiding this comment.
I ran CI's exact steps locally against the latest commit (2f85081) to pin this down:
- typecheck ✅ (your typing fix worked)
- lint ✅
- format:check ❌ ← this is the only failure
- tests ✅ (37 files, 305 tests all pass)
CI runs the steps in order and stops at the first failure, so it's failing on
format:check. Three files aren't Prettier-formatted:
- src/lib/xp/suspicious-flags.ts
- src/lib/db/schema.ts
- src/app/(app)/maintainer/page.tsx
You checked suspicious-xp-audit.ts earlier, but not these three. Just run:
npm run format
then commit and push. That fixes all three. Tests already pass, so once format is
clean, CI will be fully green and this is ready to merge. Almost there
|
Addressed the remaining I formatted the three files called out in review:
Validation run locally with the bundled Node/npm CLI:
Note: the local Husky pre-commit hook calls |
|
Quick latest-head status after rebasing onto current Validation on the current branch:
GitHub Actions is currently |
|
Latest-head status for final review: The current head Current validation on this branch:
Could you please do the final re-review/merge pass when you get a chance, and add the scoring labels if it qualifies: |
|
I rechecked the exact failing area locally. The branch is already formatted now, and the validation commands pass on my side:
|
571fa4c to
3acdb05
Compare
|
Rebased this PR onto the latest Current validation on the rebased head:
The focused Vitest command is still blocked only by the local macOS Rollup optional-native-package code-signature issue in this Codex environment, but the branch is now mergeable again according to GitHub. Could you please rerun/review when convenient? |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Closing this older version as requested in #185 so the suspicious-XP audit work is tracked in one canonical PR.\n\n#185 now carries the cleaner implementation plus the restored pagination fix, and I pushed the follow-up there after review. Thanks for the earlier reviews on this branch; keeping this closed should avoid duplicate #90 tracking. |
Summary
flagged_accountsaudit table and migration for reviewable suspicious-XP evidenceFixes #90
Testing
git diff --cached --check✅Note
I could not run Vitest/typecheck locally in this Codex shell because this checkout has no
node_modulesand no package manager binary (npm,pnpm,yarn,npx, orcorepack) available on PATH. The implementation includes focused Vitest coverage insrc/lib/xp/suspicious-flags.test.tsfor the pure detection logic.GSSoC / NSoC Labels Requested
Please add
gssoc:approved,level:advanced,quality:exceptional,type:security,type:devops,nsoc26, andlevel3if this PR meets the program criteria.