feat(scan): add new ai capability scan categories#46
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 6 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request updates the portal submodule pointer to a new commit and extends the scan service with five additional allowed scan category slugs—document-editing, meeting-management, task-scheduling, file-management, and team-collaboration—alongside corresponding updates to the LLM system prompt. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
fd535d8 to
1e2bf0d
Compare
Add five new scan categories to the AI capability review system: - document-editing: document editing operations - meeting-management: meeting management functions - task-scheduling: task scheduling capabilities - file-management: file management operations - team-collaboration: team collaboration features Signed-off-by: 林凯90331 <90331@sangfor.com> Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@server/internal/services/scan_service.go`:
- Around line 31-35: The migration seed in
server/migrations/20260407110000_add_scan_category_and_seed_taxonomy.sql is
missing metadata for the five new slugs listed in allowedScanCategories
(document-editing, meeting-management, task-scheduling, file-management,
team-collaboration), so EnsureCategory creates them with only placeholder
English names; update the SQL seed to insert rows for those five slugs including
multilingual fields (name_en, name_zh, description_en, description_zh) and a
sensible sort_order to match the existing taxonomy ordering so runtime-created
categories match seeded ones; locate the seed INSERT statements in that
migration and add one fully populated record per slug consistent with the other
entries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 26c68ceb-f1f8-4398-bf14-b0c07ef419a8
📒 Files selected for processing (2)
portalserver/internal/services/scan_service.go
| "document-editing", | ||
| "meeting-management", | ||
| "task-scheduling", | ||
| "file-management", | ||
| "team-collaboration", |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Confirm new slugs in scan service
echo "== New category slugs in scan_service.go =="
rg -n -C2 'document-editing|meeting-management|task-scheduling|file-management|team-collaboration' server/internal/services/scan_service.go || true
# 2) Check seed migration coverage
echo
echo "== Seeded slugs in taxonomy migration =="
rg -n -C1 "INSERT INTO item_categories|\\('.*', '\\{\"en\"" server/internal/migrations/20260407110000_add_scan_category_and_seed_taxonomy.sql || true
# 3) Compare slugs from Go allowed list vs SQL seeded list
python - <<'PY'
import re, pathlib
go_path = pathlib.Path("server/internal/services/scan_service.go")
sql_path = pathlib.Path("server/internal/migrations/20260407110000_add_scan_category_and_seed_taxonomy.sql")
go = go_path.read_text(encoding="utf-8")
sql = sql_path.read_text(encoding="utf-8")
go_block = re.search(r"var\s+allowedScanCategories\s*=\s*\[\]string\{(.*?)\n\}", go, re.S)
go_slugs = set(re.findall(r'"([^"]+)"', go_block.group(1))) if go_block else set()
sql_slugs = set(re.findall(r"\('([^']+)'\s*,\s*'\{", sql))
missing_in_sql = sorted(go_slugs - sql_slugs)
print("Go allowed slugs:", len(go_slugs))
print("SQL seeded slugs:", len(sql_slugs))
print("Missing in SQL:")
for s in missing_in_sql:
print(" -", s)
PYRepository: XDfield/costrict-web
Length of output: 1299
🏁 Script executed:
#!/bin/bash
# List all migration files to see what exists
echo "== All migration files =="
ls -la server/internal/migrations/ 2>/dev/null | head -20 || echo "migrations dir not found"
# Search for any migration files with scan or category in name
echo
echo "== Migration files with 'scan' or 'category' in name =="
find server/internal/migrations -name "*scan*" -o -name "*category*" -o -name "*taxonomy*" 2>/dev/null || true
# Search for INSERT INTO item_categories across all migrations
echo
echo "== Files containing 'item_categories' inserts =="
rg -l "item_categories" server/internal/migrations/ 2>/dev/null || true
# Search for any reference to the new slugs in migration files
echo
echo "== References to new category slugs in migrations =="
rg "document-editing|meeting-management|task-scheduling|file-management|team-collaboration" server/internal/migrations/ -n 2>/dev/null || echo "No matches found"Repository: XDfield/costrict-web
Length of output: 267
🏁 Script executed:
#!/bin/bash
# Search for database/migration patterns in the project
echo "== Looking for database setup/migration patterns =="
find . -name "*.go" -type f | xargs rg -l "migration|Migration|migrate" | head -10
# Search for database schema or initialization
echo
echo "== Files with database schema or gorm models =="
find . -path ./vendor -prune -o -name "*.go" -type f | xargs rg -l "type.*struct.*\`gorm|CREATE TABLE|schema" | head -10
# Look at the actual scan_service to see how CategorySvc works
echo
echo "== CategorySvc usage in scan_service.go =="
rg -A5 "CategorySvc" server/internal/services/scan_service.go
# Check if there's a models or database directory
echo
echo "== Project structure - look for db/models =="
ls -la server/internal/ 2>/dev/null | grep -E "^d"
</parameter>Repository: XDfield/costrict-web
Length of output: 2818
🏁 Script executed:
#!/bin/bash
# Check the migrations directory (not internal/migrations)
echo "== Files in server/migrations/ =="
ls -la server/migrations/ 2>/dev/null | head -20
# Look for SQL migration files
echo
echo "== SQL migration files =="
find server/migrations -name "*.sql" -type f 2>/dev/null | sort
# Check embed.go to understand migration approach
echo
echo "== server/migrations/embed.go content =="
cat server/migrations/embed.go 2>/dev/null | head -30
# Search for any migration file mentioning category, scan, or taxonomy
echo
echo "== Search for category/scan references in migrations =="
find server/migrations -type f -exec grep -l "category\|taxonomy\|scan" {} \; 2>/dev/null
# Look for the specific date pattern in migrations
echo
echo "== Migrations with date 202604 (April 2026) =="
find server/migrations -name "*202604*" -o -name "*20260407*" 2>/dev/nullRepository: XDfield/costrict-web
Length of output: 4285
🏁 Script executed:
#!/bin/bash
# Read the actual migration file
echo "== Content of 20260407110000_add_scan_category_and_seed_taxonomy.sql =="
cat server/migrations/20260407110000_add_scan_category_and_seed_taxonomy.sql
echo
echo "== Content of 20260407000000_seed_item_categories.sql =="
cat server/migrations/20260407000000_seed_item_categories.sqlRepository: XDfield/costrict-web
Length of output: 3094
🏁 Script executed:
#!/bin/bash
# Find CategoryService implementation
echo "== CategoryService.EnsureCategory implementation =="
find . -name "*.go" -type f | xargs rg -A10 "func.*EnsureCategory"
# Also check what the category model looks like
echo
echo "== Item category model structure =="
rg -A5 "type ItemCategory\|type Category" server/internal/models/models.go 2>/dev/null | head -20Repository: XDfield/costrict-web
Length of output: 960
🏁 Script executed:
#!/bin/bash
# Get full EnsureCategory implementation
echo "== Full CategoryService.EnsureCategory implementation =="
rg -A30 "func.*EnsureCategory" server/internal/services/category_service.go
# Check the ItemCategory model
echo
echo "== ItemCategory model in models.go =="
rg -B2 -A15 "type ItemCategory" server/internal/models/models.goRepository: XDfield/costrict-web
Length of output: 2431
Add seeded metadata for newly accepted category slugs.
The migration file server/migrations/20260407110000_add_scan_category_and_seed_taxonomy.sql currently seeds 12 category slugs with full multilingual metadata (English and Chinese names, descriptions, sort order). However, the five new slugs accepted in allowedScanCategories (document-editing, meeting-management, task-scheduling, file-management, team-collaboration) are not included in this seed data.
When these categories are created at runtime via EnsureCategory, they receive only placeholder metadata: an English name matching the slug, with no Chinese translation, descriptions, or sort order. This creates inconsistency between seeded and runtime-created categories.
Add these five slugs to the migration seed data with proper multilingual metadata to ensure consistency across all supported categories.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@server/internal/services/scan_service.go` around lines 31 - 35, The migration
seed in server/migrations/20260407110000_add_scan_category_and_seed_taxonomy.sql
is missing metadata for the five new slugs listed in allowedScanCategories
(document-editing, meeting-management, task-scheduling, file-management,
team-collaboration), so EnsureCategory creates them with only placeholder
English names; update the SQL seed to insert rows for those five slugs including
multilingual fields (name_en, name_zh, description_en, description_zh) and a
sensible sort_order to match the existing taxonomy ordering so runtime-created
categories match seeded ones; locate the seed INSERT statements in that
migration and add one fully populated record per slug consistent with the other
entries.
1e2bf0d to
bd7d66c
Compare
Add five new scan categories to the AI capability review system:
document-editing: document editing operations
meeting-management: meeting management functions
task-scheduling: task scheduling capabilities
file-management: file management operations
team-collaboration: team collaboration features
Summary by CodeRabbit
New Features
Chores