Skip to content

refactor: overengineering-audit cleanup (dead code + honest GA apply + telemetry) - #1263

Merged
LucasSantana-Dev merged 3 commits into
mainfrom
chore/overengineering-cleanup
Jun 7, 2026
Merged

LucasSantana-Dev merged 3 commits into
mainfrom
chore/overengineering-cleanup

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Jun 6, 2026 •

Copy link
Copy Markdown
Owner

Consolidated overengineering-audit cleanup (one PR per the chosen delivery). Net −~3,700 LOC, fully verified locally before push.

What's in here

#1257 scope reduced — by design

Only the validate.ts dedup was kept. wrapHandler→asyncHandler and the developerAccess inline were rejected: verification showed both have real consumers (in-handler error→response mapping that artists.test depends on; a test-mock seam used by admin/toggles tests) — i.e. not single-use overengineering. The evidence test, vindicated.

Verification (local, pre-push)

Closes #1256, #1258, #1259, #1260, #1261. (#1257 partially — see above; #1262 tracks the pre-existing env-test bug found during verification.)


Summary by cubic

Cleaned up overengineering: removed dead code and the unused backend executor, made Guild Automation web “Apply” record a plan only (status pending), and added attempt-based usage telemetry across web and bot without PII. Result: ~3,700 LOC deleted and honest audit trails.

  • Refactors

    • Deleted backend GuildAutomationExecutionService and its unit tests.
    • Removed Vercel Flags from FeatureToggleService; fully dropped 'vercel' from provider types, the frontend label map, and tests.
    • Removed dead frontend hooks: useCountUp, useLogsQueries, useAutoModQueries.
    • Added shared stripUnknownFields helper in backend validate.ts.
    • Added lucky_guild_automation_usage_total and a recordAutomationUsage helper; counts plan/apply/reconcile attempts on the web API and the bot /guildconfig command, labels by operation only, and logs operation+guild (no user ID).
  • Migration

    • Web “Apply” now records a plan only and creates a pending run. Use /guildconfig apply in Discord to execute changes (UI now says “Record Plan”).

Written for commit ce86fea. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added usage metrics tracking for Guild Automation plan/apply/reconcile actions.
  • Bug Fixes

    • Corrected Guild Automation UX messaging: "Apply" button now labeled "Record Plan" to clarify that plans are recorded rather than immediately applied; users must apply changes via the /guildconfig apply Discord command.
    • Updated success/failure toast messages to accurately reflect plan recording behavior.
  • Documentation

    • Added architectural decision records documenting Guild Automation module freeze, decommissioning decisions, and plan-only apply behavior.

Consolidated overengineering-audit cleanup:
- remove 3 dead frontend hooks (useCountUp, useLogsQueries, useAutoModQueries) (#1261)
- remove never-configured Vercel Flags layer from FeatureToggleService (#1256)
- delete dead backend GuildAutomationExecutionService (1,333 LOC) + its test (#1258)
- guild-automation web apply is now honest: plan-only run record (status pending,
  no false autoAppliedOperations), UI no longer claims "Changes applied" (#1259)
- instrument guild-automation usage (web plan/apply + bot /guildconfig) (#1260)
- dedup unknown-field stripping in validate.ts via one stripUnknownFields helper

Slice #1257 reduced to the validate dedup only: wrapHandler and developerAccess
removal were rejected — both have real consumers (error-response mapping;
test-mock seam), so they are not single-use overengineering.

Includes ADRs 2026-06-06 (decommission, web-apply-plan-only, freeze-and-instrument).

Closes #1256, closes #1258, closes #1259, closes #1260, closes #1261
@vercel

vercel Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Jun 7, 2026 10:58pm

Request Review

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements the guild automation migration freeze strategy with a plan-only web apply interim behavior, adds per-guild usage instrumentation, removes the decommissioned backend execution service, strips never-configured Vercel Flags integration, and refactors validation middleware for code consolidation.

Changes

Guild Automation Freeze & Plan-Only Implementation

Layer / File(s) Summary
Strategic Decisions & ADRs
decisions/*
Three ADRs document the freeze (with telemetry gates for revisit), plan-only web behavior (interim until executor seam), and service decommission (zero production callers).
Backend Data Model: Plan-Only Recording
packages/shared/src/services/guildAutomation/GuildAutomationOrchestrator.ts
createApplyRun now marks runs as pending with empty autoAppliedOperations instead of falsely marking completed, ensuring audit trail reflects no mutations until bot executor runs.
Usage Instrumentation: Metrics & Logging
packages/backend/src/utils/prometheus.ts, packages/backend/src/routes/guildAutomation.ts
New guildAutomationUsageTotal Prometheus counter and structured info logs on plan/apply/reconcile routes capture per-guild, non-PII usage attempts for telemetry-driven revisit gates.
Bot Command Logging Integration
packages/bot/src/functions/management/commands/guildconfig.ts
Guildconfig apply/reconcile subcommands now emit info logs with guild ID, user ID, subcommand, and blockedByProtected flag for usage correlation and audit trails.
Frontend Plan-Only User Experience
packages/frontend/src/pages/GuildAutomation.tsx, packages/frontend/src/pages/GuildAutomation.test.tsx
Button relabeled "Record Plan," success/error toasts now indicate recording (not applying) with Discord command instructions, result sections renamed to reflect plan recording, and test expectations updated to match new UX.

Vercel Flags Removal

Layer / File(s) Summary
Config Module Cleanup
packages/shared/src/config/index.ts
Removes vercelFlags.js re-export and adds new re-exports for youtubeConfig, titlePatterns, and types/config.
FeatureToggleService Implementation
packages/shared/src/services/FeatureToggleService.ts
Removes Vercel flag client integration; getGlobalToggleStatus now returns database overrides when present, otherwise falls through to environment. getGlobalToggleProvider always returns 'database'.
Test Cleanup & Coverage Adjustment
packages/shared/src/services/FeatureToggleService.spec.ts
Removes Vercel SDK mocking and the entire "global Vercel flags" test section; updates DB-override test; adds new coverage for provider resolution and getGlobalToggleProvider behavior.

Supporting Infrastructure & Refactors

Layer / File(s) Summary
Validation Middleware: Unknown Field Stripping
packages/backend/src/middleware/validate.ts
Introduces stripUnknownFields(data, allowedKeys) helper to consolidate repeated key-deletion logic in validateQuery and validateParams, replacing manual loops with a unified allowlist approach.
Frontend Hook Reorganization
packages/frontend/src/hooks/index.ts
Updates barrel export to remove useAutoModQueries and useLogsQueries, and add useServerFilter, usePageMetadata, and useModerationQueries.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • LucasSantana-Dev/Lucky#1258: Main PR directly implements the removal of GuildAutomationExecutionService and includes the same decommission ADR.
  • LucasSantana-Dev/Lucky#1259: Main PR's plan-only web apply and backend data model changes directly address the false-completion issue and implement honest run recording.
  • LucasSantana-Dev/Lucky#1260: Main PR adds the exact per-guild usage instrumentation and plan-only apply behavior requested to support telemetry-driven migration decisions.
  • LucasSantana-Dev/Lucky#1256: Main PR removes the Vercel Flags module and integration, directly addressing the cleanup described in this linked issue.

Possibly related PRs

  • LucasSantana-Dev/Lucky#1068: Retrieved PR modifies GuildAutomationExecutionService; main PR deletes it entirely, creating a direct conflict at the same codebase level.
  • LucasSantana-Dev/Lucky#982: Both PRs modify GuildAutomationOrchestrator's createApplyRun run-status handling and orchestration logic.
  • LucasSantana-Dev/Lucky#969: Both PRs modify the same GuildAutomation frontend component and test suite, updating UI flow and messaging.

Suggested labels

backend, frontend, shared, bot, infra, guild-automation, size/xl

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: removing dead code, making Guild Automation apply honest (plan-only), and adding telemetry.
Linked Issues check ✅ Passed All objectives from #1256 are met: vercelFlags.ts deleted, config/index.ts re-export removed, FeatureToggleService updated to skip Vercel layer, and tests pass.
Out of Scope Changes check ✅ Passed Changes align with stated PR objectives: removed dead code (hooks, Vercel layer, GuildAutomationExecutionService), made web apply honest with plan-only semantics, and added instrumentation; scope reduction noted in objectives.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/overengineering-cleanup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@github-actions

github-actions Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Size Change: -79 B (-0.02%)

Total Size: 433 kB

📦 View Changed
Filename Size Change
packages/frontend/dist/assets/Admin-2hVlWJ6k.js 0 B -2.31 kB (removed) 🏆
packages/frontend/dist/assets/Admin-UZPDA7d-.js 2.29 kB +2.29 kB (new file) 🆕
packages/frontend/dist/assets/AdminSupport-DlgXOmy5.js 1.57 kB +1.57 kB (new file) 🆕
packages/frontend/dist/assets/AdminSupport-Do7GRmvt.js 0 B -1.57 kB (removed) 🏆
packages/frontend/dist/assets/AutoMessages-BA9ISYCh.js 3.21 kB +3.21 kB (new file) 🆕
packages/frontend/dist/assets/AutoMessages-DnCyGi9z.js 0 B -3.21 kB (removed) 🏆
packages/frontend/dist/assets/AutoMod-D6GpOyNm.js 0 B -4.15 kB (removed) 🏆
packages/frontend/dist/assets/AutoMod-DB-pMMw1.js 4.15 kB +4.15 kB (new file) 🆕
packages/frontend/dist/assets/badge-eEY8Zw2c.js 500 B +500 B (new file) 🆕
packages/frontend/dist/assets/badge-SQv9qA0n.js 0 B -502 B (removed) 🏆
packages/frontend/dist/assets/Card-BpBxs2LX.js 0 B -505 B (removed) 🏆
packages/frontend/dist/assets/Card-BTeSORRs.js 505 B +505 B (new file) 🆕
packages/frontend/dist/assets/Changelog-DxFk7GEf.js 31.3 kB +31.3 kB (new file) 🆕
packages/frontend/dist/assets/Changelog-npy8zhA-.js 0 B -31.3 kB (removed) 🏆
packages/frontend/dist/assets/CommandsConfig-Ca4g03_e.js 0 B -1.46 kB (removed) 🏆
packages/frontend/dist/assets/CommandsConfig-Cri-m0_M.js 1.45 kB +1.45 kB (new file) 🆕
packages/frontend/dist/assets/Config-D09F1AbO.js 1.93 kB +1.93 kB (new file) 🆕
packages/frontend/dist/assets/Config-DalrvqvK.js 0 B -1.93 kB (removed) 🏆
packages/frontend/dist/assets/CustomCommands-Cxgt8gLQ.js 2.1 kB +2.1 kB (new file) 🆕
packages/frontend/dist/assets/CustomCommands-DvSdC0bQ.js 0 B -2.11 kB (removed) 🏆
packages/frontend/dist/assets/DashboardOverview-Dw1Xaa1e.js 0 B -3.9 kB (removed) 🏆
packages/frontend/dist/assets/DashboardOverview-SzaJO6oy.js 3.9 kB +3.9 kB (new file) 🆕
packages/frontend/dist/assets/Docs-BNZVAl5D.js 0 B -17.6 kB (removed) 🏆
packages/frontend/dist/assets/Docs-DX38RIia.js 17.6 kB +17.6 kB (new file) 🆕
packages/frontend/dist/assets/DocsShell-BrGmFvci.js 1.42 kB +1.42 kB (new file) 🆕
packages/frontend/dist/assets/DocsShell-D4de4xn_.js 0 B -1.42 kB (removed) 🏆
packages/frontend/dist/assets/EmbedBuilder-BXmXjzp9.js 0 B -3.33 kB (removed) 🏆
packages/frontend/dist/assets/EmbedBuilder-CtS7lTO0.js 3.32 kB +3.32 kB (new file) 🆕
packages/frontend/dist/assets/Features-CcccGTCE.js 0 B -755 B (removed) 🏆
packages/frontend/dist/assets/Features-DzOkl6gN.js 754 B +754 B (new file) 🆕
packages/frontend/dist/assets/GuildAutomation-CuczxUrD.js 3 kB +3 kB (new file) 🆕
packages/frontend/dist/assets/GuildAutomation-DsyLZEwB.js 0 B -2.98 kB (removed) 🏆
packages/frontend/dist/assets/index-BbT-i3ZT.js 59.3 kB +59.3 kB (new file) 🆕
packages/frontend/dist/assets/index-C7ZiA3Rk.js 0 B -59.3 kB (removed) 🏆
packages/frontend/dist/assets/index-ClC8dwNG.css 0 B -18 kB (removed) 🏆
packages/frontend/dist/assets/index-CyVlclma.css 18 kB +18 kB (new file) 🆕
packages/frontend/dist/assets/input-Dqhjv4mz.js 0 B -465 B (removed) 🏆
packages/frontend/dist/assets/input-g3CF9d1s.js 463 B +463 B (new file) 🆕
packages/frontend/dist/assets/label-COm6OtPm.js 0 B -475 B (removed) 🏆
packages/frontend/dist/assets/label-DHnJT59y.js 476 B +476 B (new file) 🆕
packages/frontend/dist/assets/Landing-BZfj2ltj.js 0 B -5.01 kB (removed) 🏆
packages/frontend/dist/assets/Landing-NeesT8tE.js 5.01 kB +5.01 kB (new file) 🆕
packages/frontend/dist/assets/LastFm-C2WnciqG.js 0 B -1.93 kB (removed) 🏆
packages/frontend/dist/assets/LastFm-DbK-hU2Y.js 1.94 kB +1.94 kB (new file) 🆕
packages/frontend/dist/assets/Levels-0i-aHgUb.js 2.19 kB +2.19 kB (new file) 🆕
packages/frontend/dist/assets/Levels-DAeNAQZX.js 0 B -2.19 kB (removed) 🏆
packages/frontend/dist/assets/Login-CFuUGogC.js 0 B -2.49 kB (removed) 🏆
packages/frontend/dist/assets/Login-DIGjzcWQ.js 2.49 kB +2.49 kB (new file) 🆕
packages/frontend/dist/assets/Lyrics-BGl5Mf9r.js 0 B -1.33 kB (removed) 🏆
packages/frontend/dist/assets/Lyrics-DjP4ks3R.js 1.33 kB +1.33 kB (new file) 🆕
packages/frontend/dist/assets/Moderation-DwSB92Ea.js 3.76 kB +3.76 kB (new file) 🆕
packages/frontend/dist/assets/Moderation-xmm8XeO5.js 0 B -3.76 kB (removed) 🏆
packages/frontend/dist/assets/Music-BmQcxZli.js 5.91 kB +5.91 kB (new file) 🆕
packages/frontend/dist/assets/Music-C-LD-0Uj.js 0 B -5.91 kB (removed) 🏆
packages/frontend/dist/assets/MusicConfig-BKjEJuF_.js 0 B -1.6 kB (removed) 🏆
packages/frontend/dist/assets/MusicConfig-D9Ni6gAM.js 1.6 kB +1.6 kB (new file) 🆕
packages/frontend/dist/assets/PreferredArtists-B8RgGZS6.js 0 B -3.79 kB (removed) 🏆
packages/frontend/dist/assets/PreferredArtists-mJ44EQVv.js 3.78 kB +3.78 kB (new file) 🆕
packages/frontend/dist/assets/PrivacyPolicy-C2jeB6am.js 1.77 kB +1.77 kB (new file) 🆕
packages/frontend/dist/assets/PrivacyPolicy-CpMMKe1q.js 0 B -1.77 kB (removed) 🏆
packages/frontend/dist/assets/ReactionRoles-B-NDG0dV.js 1.87 kB +1.87 kB (new file) 🆕
packages/frontend/dist/assets/ReactionRoles-C1LFOqru.js 0 B -1.87 kB (removed) 🏆
packages/frontend/dist/assets/SectionHeader-BumYmyaB.js 892 B +892 B (new file) 🆕
packages/frontend/dist/assets/SectionHeader-CEo2h2K9.js 0 B -895 B (removed) 🏆
packages/frontend/dist/assets/select-9jEr1Lxs.js 0 B -1.22 kB (removed) 🏆
packages/frontend/dist/assets/select-CDl6ZfW_.js 1.22 kB +1.22 kB (new file) 🆕
packages/frontend/dist/assets/ServerLogs-BtMcBVQS.js 3.03 kB +3.03 kB (new file) 🆕
packages/frontend/dist/assets/ServerLogs-COMBOH5H.js 0 B -3.03 kB (removed) 🏆
packages/frontend/dist/assets/ServerSettings-02YR3Pjx.js 0 B -4.13 kB (removed) 🏆
packages/frontend/dist/assets/ServerSettings-CD3cO7k8.js 4.13 kB +4.13 kB (new file) 🆕
packages/frontend/dist/assets/ServersPage-CuOixMEF.js 0 B -2.99 kB (removed) 🏆
packages/frontend/dist/assets/ServersPage-TuvrVC6q.js 2.99 kB +2.99 kB (new file) 🆕
packages/frontend/dist/assets/Skeleton-CYvJMPXg.js 0 B -237 B (removed) 🏆
packages/frontend/dist/assets/Skeleton-x7QqgVaH.js 236 B +236 B (new file) 🆕
packages/frontend/dist/assets/Spotify-Bako-YT7.js 0 B -1.94 kB (removed) 🏆
packages/frontend/dist/assets/Spotify-CaeaGpaW.js 1.94 kB +1.94 kB (new file) 🆕
packages/frontend/dist/assets/Starboard-0FnFyCCt.js 1.7 kB +1.7 kB (new file) 🆕
packages/frontend/dist/assets/Starboard-BZ893IY8.js 0 B -1.71 kB (removed) 🏆
packages/frontend/dist/assets/StatTile-B1-WUayE.js 635 B +635 B (new file) 🆕
packages/frontend/dist/assets/StatTile-nVka1OJ8.js 0 B -638 B (removed) 🏆
packages/frontend/dist/assets/Support-D8efhD6g.js 1.5 kB +1.5 kB (new file) 🆕
packages/frontend/dist/assets/Support-H6feTdyV.js 0 B -1.5 kB (removed) 🏆
packages/frontend/dist/assets/switch-BCt1G0kT.js 540 B +540 B (new file) 🆕
packages/frontend/dist/assets/switch-BMzE1mI8.js 0 B -544 B (removed) 🏆
packages/frontend/dist/assets/TermsOfService-0pm1n6Rx.js 1.59 kB +1.59 kB (new file) 🆕
packages/frontend/dist/assets/TermsOfService-BiT75fj-.js 0 B -1.59 kB (removed) 🏆
packages/frontend/dist/assets/TrackHistory-CF4JLc3u.js 0 B -2.29 kB (removed) 🏆
packages/frontend/dist/assets/TrackHistory-DbVXZcWH.js 2.29 kB +2.29 kB (new file) 🆕
packages/frontend/dist/assets/TwitchNotifications-B_pa7lSc.js 2.43 kB +2.43 kB (new file) 🆕
packages/frontend/dist/assets/TwitchNotifications-CaZy9nou.js 0 B -2.43 kB (removed) 🏆
packages/frontend/dist/assets/useActiveHeading-BoWqwLhv.js 1.35 kB +1.35 kB (new file) 🆕
packages/frontend/dist/assets/useActiveHeading-DantvInO.js 0 B -1.35 kB (removed) 🏆
packages/frontend/dist/assets/useFeatures-4ksHqet6.js 0 B -2.06 kB (removed) 🏆
packages/frontend/dist/assets/useFeatures-CM5aFcMn.js 2.06 kB +2.06 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
packages/frontend/dist/assets/api-DrfvNhiV.js 3.5 kB
packages/frontend/dist/assets/legalNav-B6k3CWsW.js 274 B
packages/frontend/dist/assets/rolldown-runtime-Cyuzqnbw.js 471 B
packages/frontend/dist/assets/routeMeta-BYnvx1U1.js 582 B
packages/frontend/dist/assets/usePageMetadata-DTv-6eVb.js 327 B
packages/frontend/dist/assets/vendor-forms-C-bof8GF.js 25.9 kB
packages/frontend/dist/assets/vendor-radix-DVFBfctr.js 38.9 kB
packages/frontend/dist/assets/vendor-react-2KsUHTcu.js 55.7 kB
packages/frontend/dist/assets/vendor-state-BOzOBCsh.js 24.2 kB
packages/frontend/dist/assets/vendor-ui-CMWzLnlp.js 65.3 kB

compressed-size-action

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/frontend/src/pages/GuildAutomation.test.tsx (2)

82-100: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Update mock to reflect plan-only behavior.

The mockApplyResult still contains applied: 2, failed: 0 with changes marked as status: 'success', but according to the ADRs and stack context, the backend now returns pending runs with empty autoAppliedOperations. The mock should be updated to reflect plan-only behavior with applied: 0, failed: 0 and changes with status: 'pending' (or removed changes array if empty).

This mock is used in tests at lines 273, 302, and 332.

📝 Suggested update to mock
 const mockApplyResult: ApplyResult = {
-    applied: 2,
+    applied: 0,
     failed: 0,
-    summary: 'Applied 2 changes successfully',
-    changes: [
-        {
-            type: 'role',
-            resource: 'moderator',
-            action: 'create',
-            status: 'success',
-        },
-        {
-            type: 'channel',
-            resource: 'announcements',
-            action: 'update',
-            status: 'success',
-        },
-    ],
+    summary: 'Plan recorded (pending execution)',
+    changes: [],
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/frontend/src/pages/GuildAutomation.test.tsx` around lines 82 - 100,
The mockApplyResult should represent plan-only behavior: change applied: 2 ->
applied: 0 and failed: 0, update summary to reflect a plan (e.g., "Plan
generated" or similar), and either set changes to an empty array or mark each
change's status as 'pending' (prefer empty changes to mirror empty
autoAppliedOperations). Update the ApplyResult mock object named mockApplyResult
and ensure the tests that consume it (the ones referencing mockApplyResult in
the GuildAutomation.test.tsx tests) expect applied: 0, failed: 0 and no
successful statuses.

294-322: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Test assertions don't match plan-only behavior.

This test "displays apply result with statistics" expects to see "2 applied" (line 317) and "Applied 2 changes successfully" (lines 318-320) after clicking the "Record Plan" button. However, with the plan-only changes, the backend now returns pending runs with 0 applied operations. The test assertions should be updated to match the new behavior.

📝 Suggested test assertion updates
         await waitFor(() => {
             expect(screen.getByText('Plan Record')).toBeInTheDocument()
-            expect(screen.getByText('2 applied')).toBeInTheDocument()
+            expect(screen.getByText('0 applied')).toBeInTheDocument()
             expect(
-                screen.getByText('Applied 2 changes successfully'),
+                screen.getByText(/Plan recorded/),
             ).toBeInTheDocument()
         })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/frontend/src/pages/GuildAutomation.test.tsx` around lines 294 - 322,
The test 'displays apply result with statistics' in GuildAutomation should be
updated because backend now returns plan-only (pending) runs with 0 applied
operations; update the assertions after clicking the "Record Plan" button (in
this test function and any related expectations that use api.automation.apply /
mockApplyResult) to reflect zero applied results (e.g., assert the UI shows "0
applied" and the corresponding message for no applied changes such as "Applied 0
changes" or "No changes applied") instead of the previous "2 applied" and
"Applied 2 changes successfully".
🧹 Nitpick comments (2)
packages/frontend/src/pages/GuildAutomation.tsx (2)

454-463: ⚖️ Poor tradeoff

Semantic mismatch between heading and result view component.

The heading now says "Plan Record" (line 458) reflecting the plan-only behavior, but the component ApplyResultView (line 462) still displays apply-oriented statistics like "applied" and "failed" counts (lines 160-167). This creates potential UX confusion where users see a "Plan Record" heading with content showing "0 applied" underneath.

Consider either:

  1. Renaming ApplyResultView to a more neutral name like OperationResultView or RunResultView
  2. Updating the component to use plan-oriented language when used in plan-only context ("planned" instead of "applied")
  3. Creating a separate PlanRecordView component specific to plan-only results

The current implementation will work functionally (showing 0 applied), but the mixed terminology may confuse users.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/frontend/src/pages/GuildAutomation.tsx` around lines 454 - 463, The
"Plan Record" heading is semantically mismatched with the apply-focused
ApplyResultView component; update the UI so terminology aligns: either rename
ApplyResultView to a neutral name (e.g., OperationResultView/RunResultView) or
add a mode prop to ApplyResultView (e.g., mode='apply'|'plan') and branch its
labels/stats to show "planned" instead of "applied" when mode === 'plan';
alternatively implement a small PlanRecordView that reuses ApplyResultView logic
but renders plan-oriented labels; update the usage next to the Plan Record
heading to pass the new prop or use the new component so displayed text matches
"Plan Record".

440-440: 💤 Low value

Consider clarifying the comment text.

The comment reads "Plan / Plan Records" which seems redundant. Should this perhaps be "Plan / Apply Results" (if both plan and apply results can appear here) or just "Plan Results" (if only plan records appear)?

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/frontend/src/pages/GuildAutomation.tsx` at line 440, Update the
ambiguous inline comment "// Plan / Plan Records (surface-panel groups)" to a
clearer description that reflects the actual content shown by the UI; for
example change it to "// Plan / Apply Results (surface-panel groups)" if both
plan and apply results can appear, or to "// Plan Results (surface-panel
groups)" if only plan records are present, ensuring the comment near the
surface-panel groups accurately describes the data.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/backend/src/routes/guildAutomation.ts`:
- Around line 110-113: Telemetry logs currently include a userId (e.g., the
infoLog call that sends { guildId, userId } with message 'Guild Automation plan
recorded'), which violates non-PII per-guild telemetry; remove userId from the
payload in that infoLog and the other similar infoLog calls in this file (the
blocks that log guild automation actions/messages around the same patterns),
sending only non-PII fields such as { guildId } (or a guild-level anonymized
identifier if required) and ensure no other references to userId are added to
telemetry payloads.
- Line 109: The usage counter guildAutomationUsageTotal currently increments
only after createPlan/createApplyRun succeed; move or add an increment call to
record attempts by calling guildAutomationUsageTotal.inc({ operation: 'plan' })
(and similarly for 'apply') immediately before invoking
createPlan/createApplyRun in the handlers, and update the post-call logic to
increment a distinct outcome label (e.g. outcome: 'success' or outcome:
'failure') or increment a failure-specific metric on error; ensure you touch the
code paths that currently call guildAutomationUsageTotal.inc (the pre-call
placement around createPlan/createApplyRun and their error handlers) so attempts
and final outcomes are both recorded.

In `@packages/bot/src/functions/management/commands/guildconfig.ts`:
- Around line 260-267: The telemetry call inside infoLog is currently including
interaction.user.id (userId) which exposes PII for this per-guild non-PII
stream; update the object passed to infoLog in the Guild Automation handler to
remove the userId field and only include guildId (guild.id), subcommand, and
blockedByProtected (leave the surrounding message and infoLog invocation
intact), making sure any references to interaction.user.id in that log context
are deleted or commented out so only non-PII fields are emitted.

In `@packages/shared/src/services/FeatureToggleService.ts`:
- Around line 59-62: Update the integration test mocks in
packages/backend/tests/integration/routes/toggles.test.ts so they align with the
new FeatureToggleService behavior: change mocked return value of
FeatureToggleService.getGlobalToggleProvider() from 'vercel' to 'database' (or
adapt the assertion to expect 'database'), and update the mock for
FeatureToggleService.getGlobalToggleStatus() to return the new shape/values
(provider: 'database' or 'environment' and writable: true) so assertions match
FeatureToggleService.getGlobalToggleStatus() and getGlobalToggleProvider()
implementations.

---

Outside diff comments:
In `@packages/frontend/src/pages/GuildAutomation.test.tsx`:
- Around line 82-100: The mockApplyResult should represent plan-only behavior:
change applied: 2 -> applied: 0 and failed: 0, update summary to reflect a plan
(e.g., "Plan generated" or similar), and either set changes to an empty array or
mark each change's status as 'pending' (prefer empty changes to mirror empty
autoAppliedOperations). Update the ApplyResult mock object named mockApplyResult
and ensure the tests that consume it (the ones referencing mockApplyResult in
the GuildAutomation.test.tsx tests) expect applied: 0, failed: 0 and no
successful statuses.
- Around line 294-322: The test 'displays apply result with statistics' in
GuildAutomation should be updated because backend now returns plan-only
(pending) runs with 0 applied operations; update the assertions after clicking
the "Record Plan" button (in this test function and any related expectations
that use api.automation.apply / mockApplyResult) to reflect zero applied results
(e.g., assert the UI shows "0 applied" and the corresponding message for no
applied changes such as "Applied 0 changes" or "No changes applied") instead of
the previous "2 applied" and "Applied 2 changes successfully".

---

Nitpick comments:
In `@packages/frontend/src/pages/GuildAutomation.tsx`:
- Around line 454-463: The "Plan Record" heading is semantically mismatched with
the apply-focused ApplyResultView component; update the UI so terminology
aligns: either rename ApplyResultView to a neutral name (e.g.,
OperationResultView/RunResultView) or add a mode prop to ApplyResultView (e.g.,
mode='apply'|'plan') and branch its labels/stats to show "planned" instead of
"applied" when mode === 'plan'; alternatively implement a small PlanRecordView
that reuses ApplyResultView logic but renders plan-oriented labels; update the
usage next to the Plan Record heading to pass the new prop or use the new
component so displayed text matches "Plan Record".
- Line 440: Update the ambiguous inline comment "// Plan / Plan Records
(surface-panel groups)" to a clearer description that reflects the actual
content shown by the UI; for example change it to "// Plan / Apply Results
(surface-panel groups)" if both plan and apply results can appear, or to "//
Plan Results (surface-panel groups)" if only plan records are present, ensuring
the comment near the surface-panel groups accurately describes the data.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 82f5390c-63f0-40ac-82ab-9ac39b9a60a8

📥 Commits

Reviewing files that changed from the base of the PR and between 7180579 and 40709ec.

📒 Files selected for processing (21)
  • decisions/2026-06-06-decommission-backend-guild-automation-execution-service.md
  • decisions/2026-06-06-guild-automation-migration-freeze-and-instrument.md
  • decisions/2026-06-06-web-guild-automation-apply-plan-only.md
  • packages/backend/src/middleware/validate.ts
  • packages/backend/src/routes/guildAutomation.ts
  • packages/backend/src/services/GuildAutomationExecutionService.ts
  • packages/backend/src/utils/prometheus.ts
  • packages/backend/tests/unit/services/GuildAutomationExecutionService.test.ts
  • packages/bot/src/functions/management/commands/guildconfig.ts
  • packages/frontend/src/hooks/index.ts
  • packages/frontend/src/hooks/useAutoModQueries.ts
  • packages/frontend/src/hooks/useCountUp.test.ts
  • packages/frontend/src/hooks/useCountUp.ts
  • packages/frontend/src/hooks/useLogsQueries.ts
  • packages/frontend/src/pages/GuildAutomation.test.tsx
  • packages/frontend/src/pages/GuildAutomation.tsx
  • packages/shared/src/config/index.ts
  • packages/shared/src/config/vercelFlags.ts
  • packages/shared/src/services/FeatureToggleService.spec.ts
  • packages/shared/src/services/FeatureToggleService.ts
  • packages/shared/src/services/guildAutomation/GuildAutomationOrchestrator.ts
💤 Files with no reviewable changes (9)
  • packages/frontend/src/hooks/useCountUp.ts
  • packages/shared/src/config/vercelFlags.ts
  • packages/frontend/src/hooks/useLogsQueries.ts
  • packages/frontend/src/hooks/useCountUp.test.ts
  • packages/frontend/src/hooks/useAutoModQueries.ts
  • packages/shared/src/config/index.ts
  • packages/frontend/src/hooks/index.ts
  • packages/backend/src/services/GuildAutomationExecutionService.ts
  • packages/backend/tests/unit/services/GuildAutomationExecutionService.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Socket Security: Project Report
  • GitHub Check: Test — frontend
  • GitHub Check: Checks
  • GitHub Check: Test — backend
  • GitHub Check: Test — bot
  • GitHub Check: quality / SAST (CodeQL) (javascript-typescript)
  • GitHub Check: compressed-size
  • GitHub Check: Build — backend
🔇 Additional comments (9)
packages/backend/src/middleware/validate.ts (1)

7-7: LGTM!

Also applies to: 9-15, 44-50, 65-71

packages/shared/src/services/FeatureToggleService.ts (1)

9-9: LGTM!

Also applies to: 59-61

packages/shared/src/services/FeatureToggleService.spec.ts (2)

181-207: LGTM!


162-166: LGTM!

decisions/2026-06-06-decommission-backend-guild-automation-execution-service.md (1)

1-84: LGTM!

decisions/2026-06-06-guild-automation-migration-freeze-and-instrument.md (1)

1-82: LGTM!

decisions/2026-06-06-web-guild-automation-apply-plan-only.md (1)

1-83: LGTM!

packages/shared/src/services/guildAutomation/GuildAutomationOrchestrator.ts (1)

178-190: LGTM!

packages/backend/src/utils/prometheus.ts (1)

53-62: LGTM!

Comment thread packages/backend/src/routes/guildAutomation.ts Outdated
Comment thread packages/backend/src/routes/guildAutomation.ts Outdated
Comment thread packages/bot/src/functions/management/commands/guildconfig.ts
Comment thread packages/shared/src/services/FeatureToggleService.ts
Address PR review (CodeRabbit + SonarCloud) on the usage instrumentation:
- extract recordAutomationUsage() helper, called on entry → counts attempts
  not just successes (failed attempts no longer dropped from the freeze-gate
  signal), and dedups the inc+log block (fixes sonarcloud new-code duplication)
- log operation + guildId only; drop user-id from web and bot telemetry
  (restores the per-guild, non-pii scope)
- remove the now-unreachable 'vercel' value from GlobalFeatureToggleProvider
  (FeatureToggleService always returns 'database' after the vercel-flags
  removal) and update the toggles integration test accordingly
@github-actions github-actions Bot removed the infra label Jun 6, 2026

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 6, 2026
Addresses code-review findings on the overengineering-cleanup PR:

- bot: increment a matching lucky_guild_automation_usage_total counter from
  the /guildconfig plan/apply/reconcile command so the migration-freeze demand
  signal spans both surfaces (web/API + Discord), not just the web — the gate
  sums the two. The bot counter lives in its own registry (service=lucky-bot).
- shared: add GuildAutomationOrchestrator.createApplyRun tests asserting the
  honest web-apply contract — status 'pending' (not 'completed'), empty
  autoAppliedOperations, planRecorded; plus the blocked-by-protected path.
- frontend: complete the vercel provider removal (closes the frontend half of
  the dead-code cleanup) — drop 'vercel' from GlobalFeatureToggleProvider, the
  provider label map, and the three tests that referenced it.
- backend: correct the recordAutomationUsage doc comment (runs after auth, so
  401s aren't counted) and note the bot-side counterpart.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@sonarqubecloud

sonarqubecloud Bot commented Jun 7, 2026

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 48567f0 into main Jun 7, 2026
40 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the chore/overengineering-cleanup branch June 7, 2026 23:01
LucasSantana-Dev added a commit that referenced this pull request Jun 12, 2026
Closes #1260.

State-check first: the instrumentation this issue asks for already
shipped in #1263 (48567f0) — `lucky_guild_automation_usage_total`
Prometheus counter (label: operation, bounded cardinality; guildId in
structured logs only) incremented via `recordAutomationUsage()` on
backend `POST /automation/plan|apply|reconcile` and on bot `/guildconfig
plan|apply|reconcile`, surfaced at the existing `/metrics` endpoints
(readable in Grafana for the 2026-07-06 freeze-gate review per
`decisions/2026-06-06-guild-automation-migration-freeze-and-instrument.md`).

This PR adds the missing verification coverage: 6 tests asserting the
counter increments on all three operations on both surfaces and that
counter failure never breaks the request path.

Verification: backend 67 suites / 1015 tests; bot 2471 tests pass.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Add tests to verify the `lucky_guild_automation_usage_total` counter
increments on plan, apply, and reconcile for both backend POST
`/automation` routes and the bot `/guildconfig` command. Aligns with
Linear #1260 by confirming telemetry is emitted with the correct
`operation` label without affecting request handling.

<sup>Written for commit f8cef2e.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/LucasSantana-Dev/Lucky/pull/1349?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

This branch was successfully deployed

1 active deployment
Preview — ce86fea2 Deployed Jun 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(shared): remove never-configured Vercel Flags layer

1 participant