Skip to content

Conversation

@vcarl
Copy link
Member

@vcarl vcarl commented Dec 10, 2025

No description provided.

@vcarl vcarl marked this pull request as ready for review December 10, 2025 22:18
@github-actions
Copy link

@vcarl vcarl marked this pull request as draft December 16, 2025 06:57
@vcarl vcarl marked this pull request as ready for review January 19, 2026 00:35
@vcarl vcarl requested a review from Copilot January 19, 2026 00:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive Effect-TS documentation and begins migrating the codebase to use Effect-TS for better error handling, async composition, and observability. The changes include extensive documentation, dependency updates for Effect/OpenTelemetry integration, and initial Effect-based implementations of database models.

Changes:

  • Added Effect-TS ecosystem packages and upgraded Sentry to v10 with OpenTelemetry support
  • Created comprehensive Effect-TS documentation and migration guides
  • Migrated userThreads and reportedMessages models to Effect-based implementations with legacy wrappers
  • Added Effect runtime, logging, tracing, and observability infrastructure
  • Removed .ts extensions from import paths across multiple files
  • Deleted outdated documentation files

Reviewed changes

Copilot reviewed 83 out of 85 changed files in this pull request and generated no comments.

Show a summary per file
File Description
package.json Added Effect, OpenTelemetry, and Sentry v10 dependencies
package-lock.json Dependency resolution with new Effect ecosystem packages
vitest.config.ts Removed .ts extension from setupFiles path
vite.config.ts Removed .ts extension from server input path
notes/EFFECT_REFERENCE.md Comprehensive Effect-TS construct decision guide
notes/EFFECT.md Effect service implementation checklist
notes/2026-01-13_1_effect-opentelemetry-integration.md OpenTelemetry integration documentation
notes/2026-01-12_1_observability-overhaul.md Observability migration summary
notes/2025-12-08_1_effect-migration-plan.md Detailed 6-phase migration strategy
app/models/userThreads.ts New Effect-based implementation with legacy wrappers
app/models/reportedMessages.ts New Effect-based implementation with legacy wrappers
app/effects/runtime.ts Effect runtime with tracing and logging layers
app/effects/observability.ts Effect-native logging utilities
app/effects/metrics.ts Effect metrics definitions
app/effects/logger.ts JSON logger for Effect
app/effects/errors.ts Tagged error type definitions
app/effects/tracing.ts OpenTelemetry/Sentry integration layer
app/helpers/*.ts Import path cleanups
app/discord/*.ts Function rename migrations to use legacy wrappers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vcarl vcarl changed the title Add Effect notes and migration plan notes Migrate Escalate and Track features to Effect-TS Jan 19, 2026
vcarl and others added 17 commits January 18, 2026 20:35
Implements the foundation for gradual Effect-TS migration:
- Install effect package
- Create tagged error types for typed error handling
- Create runtime helpers to bridge Effect with Promise-based code
- Create observability bridge for Sentry span integration
- Create Database Service wrapping Kysely with typed errors
- Convert userThreads model as first Effect-based model example

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>

Add Effect/OpenTelemetry tracing with Sentry integration

- Upgrade @sentry/node to v8 with skipOpenTelemetrySetup
- Add @effect/opentelemetry and OpenTelemetry SDK packages
- Add @sentry/opentelemetry for span export
- Add posthog-node for future server-side analytics
- Create tracing.ts with SentrySpanProcessor, SentrySampler, SentryPropagator
- Update runtime.ts to provide TracingLive layer to all effects

Effects using Effect.withSpan will now have their spans exported to Sentry
for visualization in the Performance dashboard.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>

Integrate Effect-based userThreads model into modLog

Updates modLog.ts to use the Effect-based userThreads implementation
via the legacy wrapper functions. This validates the Effect migration
approach while maintaining backward compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>

don't reexport db service from Database
- Create app/effects/models/reportedMessages.ts with Effect-based functions
- Update all imports to use Effect-based version with legacy wrappers
- Delete dead app/models/reportedMessages.server.ts

Functions migrated:
- recordReport (with DatabaseConstraintError handling)
- getReportsForUser
- getReportsForMessage
- getUserReportStats
- deleteReport
- markMessageAsDeleted
- getUniqueNonDeletedMessages
- deleteAllReportedForUser (partial - still uses Discord client directly)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace patchwork logging bridge with Effect's native Logger service.
Add Effect.Metric definitions for APM-style observability (counters,
gauges, histograms). Instrument Database service with query metrics.
Convert deleteAllReportedForUser to Effect-based implementation.

New files:
- app/effects/logger.ts - JSON logger using Effect's Logger service
- app/effects/metrics.ts - Effect.Metric definitions

Changes:
- runtime.ts now provides LoggerLive layer
- observability.ts uses Effect.log* internally (API unchanged)
- Database service tracks query latency/count/errors automatically

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Split the monolithic handlers.ts into focused modules:
- directActions.ts: delete, kick, ban, restrict, timeout handlers
- simpleVote.ts: level 0 escalation, vote, and expedite handlers
- majorityVote.ts: level 1+ escalation upgrade handler
- handlers.ts: thin dispatch layer that re-exports EscalationHandlers

Also fixes missing metrics import in Effect services.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add runner helpers to escalation/index.ts:
- runEscalationEffect: runs Effect with EscalationService provided
- runDirectEffect: runs Effect without service requirements
- getFailure: extracts error from Cause for type-safe matching

Update handlers.ts to use getFailure() pattern instead of directly
accessing exit.cause._tag, which is a Cause discriminator not an
error discriminator.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Create Effect-based resolver at app/effects/resolver/escalationResolver.ts:
- processEscalationEffect: processes single due escalation
- checkPendingEscalationsEffect: gets all due and processes sequentially

Update app/discord/escalationResolver.ts to delegate to Effect resolver:
- Keep executeResolution for use by EscalationService
- Scheduler remains Promise-based but delegates to Effect

Remove dead code:
- Delete simpleVote.ts and majorityVote.ts (replaced by Effect handlers)
- Delete old escalationVotes.server.ts model (replaced by EscalationService)
- Remove unused vote handler from voting.ts (keep pure functions only)

Consolidate types and imports:
- Export Escalation/EscalationRecord types from EscalationService
- Move calculateScheduledFor to helpers/escalationVotes.ts
- Update all imports to use new locations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Relocate model files from app/effects/models/ to app/models/ where they
belong with other data models. Updates all imports accordingly.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Also ensure that all escalate command local files import each other by relative path

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Relocate the Effect-TS Database service from app/effects/services/ to
app/ as a top-level module, reflecting its role as core infrastructure.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Convert getOrCreateUserThread, reportAutomod, reportModAction,
  reportUser, and constructLog to Effect
- Add proper spans for tracing and structured logging via logEffect
- Remove legacy database function imports in favor of Effect versions
- Export Legacy wrappers for callers that haven't migrated yet
- Remove unused retry helper import

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Update to use Effect version with proper runtime and DB layer.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Convert to standard Discord.js patterns with ActionRowBuilder and
ButtonBuilder. Add getReportById to support the delete button handler.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@github-actions
Copy link

Preview deployed

It may take a few minutes before the service becomes available.

Environment URL
Preview https://215.euno-staging.reactiflux.com

Deployed commit: 7dce24d

This preview will be updated on each push and deleted when the PR is closed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 63 out of 65 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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