[PR #333] feat: moderation v2 core backend engine and pipeline #332

Open
opened 2026-02-15 17:16:58 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openclaw/clawhub/pull/333
Author: @ArthurzKV
Created: 2/15/2026
Status: 🔄 Open

Base: mainHead: codex/skill-verification-v2-clawhub-core


📝 Commits (3)

  • 3f10048 feat: add moderation v2 core engine and backend pipeline
  • ac8fde6 fix: address moderation engine and backfill edge cases
  • beba7a0 chore: rename network reason code to nonstandard_network

📊 Changes

10 files changed (+3282 additions, -2425 deletions)

View changed files

📝 convex/lib/moderation.ts (+27 -27)
convex/lib/moderationEngine.test.ts (+54 -0)
convex/lib/moderationEngine.ts (+358 -0)
convex/lib/moderationReasonCodes.ts (+60 -0)
📝 convex/lib/public.ts (+55 -49)
📝 convex/lib/skillPublish.ts (+174 -158)
📝 convex/lib/skillSafety.ts (+11 -6)
📝 convex/schema.ts (+216 -177)
📝 convex/skills.ts (+1778 -1551)
📝 convex/vt.ts (+549 -457)

📄 Description

Summary

Core backend delivery for moderation v2: normalized moderation fields, canonical reason-code engine, deterministic static scan integration, publish-time derivation, and backfill hooks.

Scope

  • Schema additions for normalized moderation and per-version staticScan.
  • New moderation reason-code contract and moderation engine.
  • Context-aware moderation heuristics updates.
  • Publish pipeline + backend moderation derivation wiring.
  • VT/LLM/static merge handling and backfill internals.
  • Visibility/safety checks switched to normalized verdict fallback.

Notes

  • Compatibility fields remain in place (moderationReason, moderationFlags).
  • API/CLI/UI surface changes are split into separate PRs.

Greptile Summary

This PR introduces a moderation v2 backend engine with normalized moderation fields, a deterministic static scan pipeline, canonical reason codes, and backfill infrastructure. The core architecture is sound — new moderationReasonCodes.ts and moderationEngine.ts provide a clean contract, the publish pipeline integrates static scanning at publish time, and resolveSkillVerdict provides backward-compatible verdict resolution across legacy and v2 fields.

  • Bug in escalateByVtInternal: patch.moderationFlags is computed from multi-scanner merge logic but then unconditionally overwritten by legacyFlagsFromVerdict(nextVerdict), discarding the bypassSuspicious and alreadyBlocked handling. Compare with approveSkillByHashInternal which correctly uses newFlags ?? nextLegacyFlags.
  • Backfill pagination skip: getSkillBatchForModerationBackfillInternal advances the cursor before the batch-full break, causing the next batch's strict gt query to skip the candidate at the break point.
  • False-positive in static scan: scanCodeFile's child_process detection relies on findFirstLine's fallback behavior, which returns the first line of the file when the exec/spawn pattern isn't found — producing misleading findings.
  • Schema additions (moderationVerdict, moderationReasonCodes, moderationEvidence, staticScan) align correctly with TypeScript types.
  • Legacy compatibility fields (moderationReason, moderationFlags) are preserved alongside the new normalized fields.

Confidence Score: 2/5

  • This PR has two bugs in moderation enforcement paths that should be fixed before merging.
  • Two logic bugs affect security-sensitive code paths: (1) escalateByVtInternal overwrites carefully computed moderationFlags, potentially allowing a bypassed suspicious flag to persist when the v2 verdict says otherwise, and (2) the backfill cursor can silently skip skills. The static scan false-positive is lower severity but still affects moderation accuracy. The core engine design and schema additions are solid.
  • Pay close attention to convex/skills.ts (escalateByVtInternal moderationFlags overwrite at line 2791, and backfill cursor logic at lines 2145-2147) and convex/lib/moderationEngine.ts (findFirstLine fallback in scanCodeFile).

Last reviewed commit: 3f10048

Context used:

  • Context from dashboard - AGENTS.md (source)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openclaw/clawhub/pull/333 **Author:** [@ArthurzKV](https://github.com/ArthurzKV) **Created:** 2/15/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/skill-verification-v2-clawhub-core` --- ### 📝 Commits (3) - [`3f10048`](https://github.com/openclaw/clawhub/commit/3f100483f2b2d47f5e9000c435bb1e155653d00b) feat: add moderation v2 core engine and backend pipeline - [`ac8fde6`](https://github.com/openclaw/clawhub/commit/ac8fde672aabadb7e237b39608da04926d5eea08) fix: address moderation engine and backfill edge cases - [`beba7a0`](https://github.com/openclaw/clawhub/commit/beba7a005efe670f46b824592c1328ce37ef5402) chore: rename network reason code to nonstandard_network ### 📊 Changes **10 files changed** (+3282 additions, -2425 deletions) <details> <summary>View changed files</summary> 📝 `convex/lib/moderation.ts` (+27 -27) ➕ `convex/lib/moderationEngine.test.ts` (+54 -0) ➕ `convex/lib/moderationEngine.ts` (+358 -0) ➕ `convex/lib/moderationReasonCodes.ts` (+60 -0) 📝 `convex/lib/public.ts` (+55 -49) 📝 `convex/lib/skillPublish.ts` (+174 -158) 📝 `convex/lib/skillSafety.ts` (+11 -6) 📝 `convex/schema.ts` (+216 -177) 📝 `convex/skills.ts` (+1778 -1551) 📝 `convex/vt.ts` (+549 -457) </details> ### 📄 Description ## Summary Core backend delivery for moderation v2: normalized moderation fields, canonical reason-code engine, deterministic static scan integration, publish-time derivation, and backfill hooks. ## Scope - Schema additions for normalized moderation and per-version `staticScan`. - New moderation reason-code contract and moderation engine. - Context-aware moderation heuristics updates. - Publish pipeline + backend moderation derivation wiring. - VT/LLM/static merge handling and backfill internals. - Visibility/safety checks switched to normalized verdict fallback. ## Notes - Compatibility fields remain in place (`moderationReason`, `moderationFlags`). - API/CLI/UI surface changes are split into separate PRs. <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR introduces a moderation v2 backend engine with normalized moderation fields, a deterministic static scan pipeline, canonical reason codes, and backfill infrastructure. The core architecture is sound — new `moderationReasonCodes.ts` and `moderationEngine.ts` provide a clean contract, the publish pipeline integrates static scanning at publish time, and `resolveSkillVerdict` provides backward-compatible verdict resolution across legacy and v2 fields. - **Bug in `escalateByVtInternal`**: `patch.moderationFlags` is computed from multi-scanner merge logic but then unconditionally overwritten by `legacyFlagsFromVerdict(nextVerdict)`, discarding the `bypassSuspicious` and `alreadyBlocked` handling. Compare with `approveSkillByHashInternal` which correctly uses `newFlags ?? nextLegacyFlags`. - **Backfill pagination skip**: `getSkillBatchForModerationBackfillInternal` advances the cursor before the batch-full break, causing the next batch's strict `gt` query to skip the candidate at the break point. - **False-positive in static scan**: `scanCodeFile`'s `child_process` detection relies on `findFirstLine`'s fallback behavior, which returns the first line of the file when the exec/spawn pattern isn't found — producing misleading findings. - Schema additions (`moderationVerdict`, `moderationReasonCodes`, `moderationEvidence`, `staticScan`) align correctly with TypeScript types. - Legacy compatibility fields (`moderationReason`, `moderationFlags`) are preserved alongside the new normalized fields. <h3>Confidence Score: 2/5</h3> - This PR has two bugs in moderation enforcement paths that should be fixed before merging. - Two logic bugs affect security-sensitive code paths: (1) escalateByVtInternal overwrites carefully computed moderationFlags, potentially allowing a bypassed suspicious flag to persist when the v2 verdict says otherwise, and (2) the backfill cursor can silently skip skills. The static scan false-positive is lower severity but still affects moderation accuracy. The core engine design and schema additions are solid. - Pay close attention to `convex/skills.ts` (escalateByVtInternal moderationFlags overwrite at line 2791, and backfill cursor logic at lines 2145-2147) and `convex/lib/moderationEngine.ts` (findFirstLine fallback in scanCodeFile). <sub>Last reviewed commit: 3f10048</sub> <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=a1d58d20-b4dd-4cbb-973a-9fd7824e1921)) <!-- /greptile_comment --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 17:16:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openclaw/clawhub#332