Skip to content

fix(admin): address Greptile moderation follow-ups from #941 - #986

Open
Ferryx349 wants to merge 3 commits into
mainfrom
fix/admin-moderation-greptile
Open

Ferryx349 wants to merge 3 commits into
mainfrom
fix/admin-moderation-greptile

Conversation

@Ferryx349

Copy link
Copy Markdown
Collaborator

Description

Follow-up to merged #941 (Greptile review):

  • Lock moderation settings read–update–save across workers
  • Activity stats window uses first_seen (relay receipt time)
  • Normalize IPv6 rate-limit bypass addresses (SocketAddress)
  • Reject reversed kind ranges in PATCH schema
  • Return normalized saved limits from PATCH/actions responses

Related Issue

Closes :- #985

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

Serialize settings updates across workers, count stats by first_seen,
normalize IPv6 bypass addresses, reject reverd kind ranges, and return saved limits from PATCH/actions.
@changeset-bot

changeset-bot Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 527b1af

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 2/5

[Medium impact] The changes affect admin moderation settings and activity reporting.

Do not merge yet: abandoned locks can block moderation, stale-lock cleanup can still allow overlapping saves, and a test still fails TypeScript checking.

Findings

  1. P1 Empty locks block moderation ▶

Summary

This PR tightens moderation writes and activity stats.

  • Admin moderation edits now save one at a time and reply with saved limits.
  • Activity stats count events from when the relay first sees them.
  • Rate-limit bypass lists treat alternate IPv6 spellings as the same address.
  • PATCH rejects kind ranges that run backward.

A new recovery gap leaves empty lock files blocking moderation indefinitely.

Reviews (2) · Last reviewed commit: "fix(admin): address Greptile review on m..." · Reviewed by Greptile

Comment thread test/unit/utils/admin-moderation-persist.spec.ts Outdated
Comment thread src/utils/settings-config.ts Outdated
Comment thread src/utils/settings-config.ts Outdated
Comment thread src/utils/admin-moderation.ts
Comment thread src/utils/admin-moderation-stats.ts
@coveralls

coveralls commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 40154443487

Warning

No base build found for commit 3b35377 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 76.184%

Details

  • Patch coverage: 36 uncovered changes across 5 files (57 of 93 lines covered, 61.29%).

Uncovered Changes

File Changed Covered %
src/utils/settings-config.ts 54 22 40.74%
src/controllers/admin/patch-moderation-limits-controller.ts 2 1 50.0%
src/controllers/admin/post-moderation-actions-controller.ts 4 3 75.0%
src/schemas/admin-moderation-schema.ts 3 2 66.67%
src/utils/admin-moderation.ts 27 26 96.3%
Total (7 files) 93 57 61.29%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 11655
Covered Lines: 9290
Line Coverage: 79.71%
Relevant Branches: 6001
Covered Branches: 4161
Branch Coverage: 69.34%
Branches in Coverage %: Yes
Coverage Strength: 780.75 hits per line

💛 - Coveralls

Comment thread src/utils/admin-moderation.ts
Comment thread src/utils/settings-config.ts Outdated
Comment thread test/unit/utils/admin-moderation-persist.spec.ts Outdated
Comment thread test/unit/utils/admin-moderation-persist.spec.ts
Comment thread src/utils/admin-moderation-stats.ts
Yield while waiting on the settings write lock, reclaim stale locks safely,
normalize IPv6 bypass removal, index first_seen for stats queries, and fix
persist unit test loading under ts-node.
Comment on lines +109 to +111
const metadata = readSettingsWriteLockMetadata(lockPath)
if (metadata && isSettingsWriteLockStale(metadata)) {
attemptStealStaleSettingsWriteLock(lockPath, metadata)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Empty locks block moderation

If a worker dies after openSync creates the lock but before writeFileSync writes its contents, the empty file blocks every later moderation write. readSettingsWriteLockMetadata returns undefined, so this guard never attempts recovery, even after the stale timeout. Each request waits 30 seconds and fails until someone deletes the file. Add safe recovery for abandoned locks with missing or invalid contents.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants