Skip to content

docs: add decision records for may 23 refactor batch - #1040

Merged
LucasSantana-Dev merged 22 commits into
mainfrom
docs/may-23-refactor-adrs
May 24, 2026
Merged

LucasSantana-Dev merged 22 commits into
mainfrom
docs/may-23-refactor-adrs

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented May 24, 2026 •

Copy link
Copy Markdown
Owner

ADRs for the 5 refactors merged in PRs #979–#983 and the Phase 4 test reduction strategy.

Decision records added

Summary by CodeRabbit

  • Documentation
    • Added architecture decision records documenting planned service refactoring, test optimization strategies, and API consolidation initiatives to improve system maintainability.

Review Change Stack

@vercel

vercel Bot commented May 24, 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 May 24, 2026 9:02pm

Request Review

@coderabbitai

coderabbitai Bot commented May 24, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds six Architecture Decision Records documenting planned backend refactorings: service extraction (ArtistSuggestionService), pipeline and context value object introductions (AutoplayContext, MessagePipeline), API consolidation (Recommendation Engine single entrypoint), domain layer separation (Guild Automation split), and a test reduction strategy with replacement test protocols.

Changes

Architecture Decision Records – May 2026

Layer / File(s) Summary
Service Extraction Pattern – Artist Suggestion
docs/decisions/2026-05-23-artist-suggestion-service.md
ADR documents extracting the three-tier artist suggestion workflow from the /artists route handler into ArtistSuggestionService, including caching ownership and relocation of the popular artists fallback into a typed config constant.
Pipeline & Context Value Object Refactoring
docs/decisions/2026-05-23-autoplay-context-value-object.md, docs/decisions/2026-05-23-message-pipeline-handler-chain.md
Two ADRs documenting refactoring patterns: AutoplayContext for collapsing collector signatures from 15+ positional arguments to a single typed parameter with per-invocation cache relocation; MessagePipeline architecture with MessageContext, MessageHandler contracts, and four ordered handlers (AutoModHandler, SpamHandler, CustomCommandHandler, XpHandler).
API Surface Consolidation – Recommendation Engine
docs/decisions/2026-05-23-recommendation-engine-single-entrypoint.md
ADR consolidates four public entry points into a single recommendTracks(context) API using a strategy discriminator, un-exports internal helpers, and removes runtime config mutation in favor of immutable startup injection.
Domain Architecture Separation – Guild Automation
docs/decisions/2026-05-23-guild-automation-orchestrator-repository-split.md
ADR documents splitting the Guild Automation service into a pure GuildAutomationOrchestrator (executor orchestration and result aggregation) and a GuildAutomationRepository (Prisma reads/writes with optimistic lock protocol), with the existing service becoming a thin coordinator.
Test Reduction Phase 4 Strategy
docs/decisions/2026-05-23-bot-test-reduction-phase4-replacement-strategy.md
Multi-part ADR defining a paired "delete → replace → gate → commit" protocol for test reduction, specifying replacement test criteria (module-level flow tests with real SUT and fake externals only), per-file targets, execution checklist for each file, it.each consolidation allowances for surviving tests, and revisit triggers tied to mutation testing and executor PRs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • LucasSantana-Dev/Lucky#966: Documents the Phase 4 test reduction strategy and replacement test protocol directly addressing the issue's PRD for deletion-based test count reduction with behavioral coverage.

Possibly related PRs

  • LucasSantana-Dev/Lucky#979: Implements the Recommendation Engine API consolidation described in the single-entrypoint ADR, replacing multiple get* methods with recommendTracks(input: RecommendationInput).
  • LucasSantana-Dev/Lucky#980: Implements the ArtistSuggestionService extraction and popular artists constant relocation documented in the artist-suggestion-service ADR.

Suggested labels

documentation, architecture, size/m

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change—adding decision records for a batch of May 23 refactors—and accurately reflects the changeset content.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/may-23-refactor-adrs

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.

@LucasSantana-Dev
LucasSantana-Dev enabled auto-merge (squash) May 24, 2026 15:28

@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.

@github-actions

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@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.

@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.

@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.

@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.

@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.

@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.

@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 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: 7

🤖 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 `@docs/decisions/2026-05-23-artist-suggestion-service.md`:
- Around line 24-28: The fenced code block that lists Tier 1–3 suggestions is
missing a language tag and triggers markdownlint MD040; update that block (the
triple-backtick block containing "Tier 1: User's saved preferences..." through
"Tier 3: Static popular fallback list") to include a language identifier (e.g.,
add "text" after the opening ```), so the block becomes ```text and resolves the
lint error.

In `@docs/decisions/2026-05-23-autoplay-context-value-object.md`:
- Around line 23-44: Update the documented AutoplayContext interface in the ADR
to match the actual implemented contract in
packages/bot/src/utils/music/autoplay/autoplayContext.ts: replace/remove fields
that don’t exist (e.g., remove guildId and seedTracks), add missing fields such
as queue, and correct nullability/types for sessionMood, genreContext,
currentTrack, and recentArtists; also remove any extra maps/sets that aren’t
present and ensure field names (e.g., artistFrequency, likedWeights,
preferredArtistKeys, blockSertanejo, replenishCount) and their types exactly
match the implementation so the ADR reflects the real AutoplayContext definition
used by the codebase.

In `@docs/decisions/2026-05-23-bot-test-reduction-phase4-replacement-strategy.md`:
- Line 81: The ADR contains contradictory statements about Jest's it.each
counting behavior; update the document to consistently state that Jest treats
each row in it.each as a separate test (i.e., it DOES NOT reduce the test
count), and apply this correction where referenced (the earlier paragraph around
the current Line 20–23, the entry mentioning `candidateScorer.spec.ts` at Line
81, and the related sections around Lines 103–107) so all mentions reflect that
each it.each row is counted as an individual test for Phase 4 planning.

In `@docs/decisions/2026-05-23-guild-automation-orchestrator-repository-split.md`:
- Line 29: The ADR currently has a mismatch in the documented signature for
orchestrator.run: Line 29 lists (manifest, liveState, executors[], ctx) while
Line 45 omits ctx; make these consistent by choosing one canonical signature and
applying it to both locations—either add ctx to the signature on Line 45 or
remove ctx from Line 29 (and update any other occurrences in the document), and
ensure you reference the same symbol name "orchestrator.run" and parameter order
(manifest, liveState, executors[]) consistently throughout the ADR.
- Around line 43-47: Update the ADR to mandate that any call sequence starting
with repository.acquireLock(guildId) must guarantee
repository.releaseLock(guildId) in a finally path; explicitly state that
repository.getManifest/getLiveState, orchestrator.run, and
repository.persistRunResult may throw and therefore lock release must be
described as happening inside a try/finally (or equivalent) to avoid leaks,
referencing the sequence entries repository.acquireLock(guildId),
repository.getLiveState(guildId) (formerly getManifest), orchestrator.run(...),
repository.persistRunResult(...), and repository.releaseLock(guildId) so readers
know exactly which operations require the finally semantics.

In `@docs/decisions/2026-05-23-message-pipeline-handler-chain.md`:
- Line 58: Update the phrasing on line 58 to reflect actual file ownership:
don't state that messageHandler.ts "becomes messagePipeline.ts"; instead
indicate that messageHandler.ts (wiring/context) remains separate from
message/pipeline.ts (execution chain) and that adding a new concern introduces a
new file (e.g., message/pipeline.ts) rather than editing messageHandler.ts;
reference the filenames messageHandler.ts, messagePipeline.ts, and
message/pipeline.ts in the reworded sentence to make the split and
responsibilities explicit.

In `@docs/decisions/2026-05-23-recommendation-engine-single-entrypoint.md`:
- Around line 35-40: The doc currently defines strategy: 'history' |
'preference' | 'contextual' | 'auto' as required but also states 'auto' is the
default; make the contract unambiguous by either turning the field into an
optional property (e.g., strategy?: ...) and documenting that missing strategy
defaults to 'auto', or keep it required and explicitly state callers must pass
'auto' when they want default behavior; update the prose around the type
definition and the example usage to reflect the chosen approach so the ADR and
the type signature for the strategy field are consistent.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 09bf1d07-f1bc-4aa7-8565-1895411671a2

📥 Commits

Reviewing files that changed from the base of the PR and between d44a60b and ace62d8.

📒 Files selected for processing (6)
  • docs/decisions/2026-05-23-artist-suggestion-service.md
  • docs/decisions/2026-05-23-autoplay-context-value-object.md
  • docs/decisions/2026-05-23-bot-test-reduction-phase4-replacement-strategy.md
  • docs/decisions/2026-05-23-guild-automation-orchestrator-repository-split.md
  • docs/decisions/2026-05-23-message-pipeline-handler-chain.md
  • docs/decisions/2026-05-23-recommendation-engine-single-entrypoint.md

Comment thread docs/decisions/2026-05-23-artist-suggestion-service.md
Comment thread docs/decisions/2026-05-23-autoplay-context-value-object.md
Comment thread docs/decisions/2026-05-23-message-pipeline-handler-chain.md

@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.

@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.

@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.

@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.

@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.

@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.

@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.

@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.

@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.

@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.

@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.

@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

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit e55e1e3 into main May 24, 2026
31 of 33 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the docs/may-23-refactor-adrs branch May 24, 2026 20:59

This branch was successfully deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant