Commit Graph

2036 Commits

Author SHA1 Message Date
gpt-engineer-app[bot]
8a73dd0166 Migrate approval to relational inserts
Refactor process_approval_transaction to remove JSONB usage
- Delete JSONB-based building and resolution logic
- Replace with pure relational INSERT/UPDATE paths for parks, rides, companies, ride_models, and photos
- Implement direct temporary reference resolution via SQL queries
- Copy related data (technical specs, coaster stats) after main entity changes
- Remove calls to non-existent functions and simplify flow
2025-11-11 15:11:56 +00:00
gpt-engineer-app[bot]
46ed097a81 Connect to Lovable Cloud
Enable use of Lovable Cloud tool as approved context, preparing for integration and connectivity setup.
2025-11-11 15:11:13 +00:00
gpt-engineer-app[bot]
82b85e3284 Add system phase 4 audits
- Add audit logging for system maintenance operations (cache/orphaned images/manual cleanup)
- Log account deletion request handling (requests/confirm/cancel)
- Log security actions (admin password resets, MFA enforcement changes, account lockouts)
2025-11-11 14:49:11 +00:00
gpt-engineer-app[bot]
466c549e4a Add blog and content approvals logging
Implement Phase 3 audit logging:
- Blog management: create, update, delete, publish
- Manual content deletions (force deletions)
- Direct entity approvals bypassing moderation queue (loggable events where applicable)

Includes integration with central logAdminAction helper and updates to relevant components/hooks:
AdminBlog.tsx (create/update/delete/publish paths)
Moderation queue deletion path (force delete)
Moderation actions paths with direct approvals where possible
New logs for blog_post_created, blog_post_updated, blog_post_deleted, blog_post_published, submission_force_deleted, etc.
2025-11-11 14:47:00 +00:00
gpt-engineer-app[bot]
a5fed1e26a Implement Phase 2 audit logging
Add audit logging for admin settings changes, rate limit config updates, anomaly detection config changes (skipped due to no UI), and version cleanup settings updates. Implement logging via central logAdminAction helper and integrate into AdminSettings, VersionCleanupSettings, and RateLimitAlerts mutations (create, update, delete).
2025-11-11 14:36:10 +00:00
gpt-engineer-app[bot]
8581950a6e Implement Phase 1 audit logging
Add centralized admin action logger and integrate logging for:
- Alert resolutions (system, rate limit, grouped)
- Role grants/revokes in UserRoleManager
- Incident creation/acknowledgement/resolution
- Moderation lock overrides

Includes file updates and usage across relevant components to ensure consistent audit trails.
2025-11-11 14:22:30 +00:00
gpt-engineer-app[bot]
53b576ecc1 Invalidate all system-alerts queries on resolve
Update PipelineHealthAlerts resolve flow to invalidate all severity-specific system_alerts queries (not just the base key), ensuring resolved alerts disappear from UI. Adds broad invalidation pattern and preserves loading state handling.
2025-11-11 14:14:32 +00:00
gpt-engineer-app[bot]
eac8c7a77f Add robust loading cleanup
Ensure Resolve button clears loading state with proper try-catch-finally around async resolution, preventing stuck loading indicator and improving error handling.
2025-11-11 14:12:57 +00:00
gpt-engineer-app[bot]
21cd547c27 Add loading state to Resolve button
- Introduce per-button loading state in PipelineHealthAlerts
- Disable button and show spinner with "Resolving..." while resolving
- Re-enable after operation completes
- Keeps user feedback inline with alert resolution flow
2025-11-11 14:11:46 +00:00
gpt-engineer-app[bot]
da32935d63 Add debugging for Resolve on monitoring page
Enhance PipelineHealthAlerts flow to log and refresh
- Add console logs when resolving alerts on PipelineHealthAlerts
- Invalidate related queries to refresh UI after resolution
- Improve error handling and user feedback paths for resolve action
2025-11-11 14:10:10 +00:00
gpt-engineer-app[bot]
9cabd20e43 Fix Resolve button flow
Investigate and address why the Resolve action isn’t triggering despite superuser role. Add diagnostic logging and ensure the resolve mutation is invoked with correct data, plus prep for validating frontend event wiring and mutation calls.
2025-11-11 13:43:21 +00:00
gpt-engineer-app[bot]
2093560f64 Connect to Lovable Cloud
Implement monitoring and alert-resolve UI improvements:
- Enhance useAlertGroupActions with robust error handling and breadcrumb logging
- Add loading state visuals to GroupedAlertsPanel and Resolve All button
- Integrate loading indicator (Loader2) for better user feedback during resolves
2025-11-11 13:21:58 +00:00
gpt-engineer-app[bot]
0dfc5ff724 Persist spans to DB via logger
Implement fire-and-forget span persistence:
- Add logSpanToDatabase and persistSpanToDatabase to logger
- Persist spans, attributes, events, and event attributes to new tables
- Wire edgeFunctionWrapper to call DB persistence after each span
- Create required tables, views, and security policies
- Ensure non-blocking and guard for missing Supabase creds
2025-11-11 04:28:17 +00:00
gpt-engineer-app[bot]
177eb540a8 Fix security warnings in migration
- Change security settings for views to SECURITY INVOKER
- Add explicit search_path in cleanup_old_spans function
- Ensure safe, non-deferring access to trace views and cleanup routine
2025-11-11 04:24:38 +00:00
gpt-engineer-app[bot]
ca6e95f4f8 Capture backend response metadata
Update edge function wrapper to emit backend metadata headers (X-Request-Id, X-Span-Id, X-Trace-Id, X-Duration-Ms) on responses; adjust logging to include duration and headers. Enhance edgeFunctionTracking to extract and propagate backend metadata from responses and errors; extend errorHandler to capture and log backend metadata for improved observability.
2025-11-11 04:18:20 +00:00
gpt-engineer-app[bot]
08926610b9 Migrate check-transaction-status to wrapper
Migrate the remaining administrative function check-transaction-status to use the wrapEdgeFunction wrapper, aligning with admin-delete-user. Updated to remove manual Deno.serve handling, integrate edge wrapper, standardized logging with edgeLogger, and utilize context for auth and tracing. admin-delete-user already migrated.
2025-11-11 03:56:44 +00:00
gpt-engineer-app[bot]
a1280ddd05 Migrate Novu functions to wrapEdgeFunction
Refactor Phase 3 Batch 2–4 Novu-related functions to use the createEdgeFunction wrapper, replacing explicit HTTP servers with edge wrapper, adding standardized logging, tracing, and error handling across subscriber management, topic/notification, and migration/sync functions.
2025-11-11 03:55:02 +00:00
gpt-engineer-app[bot]
19804ea9bd Migrate Admin Admin Functions to wrapEdgeFunction
Migrate Phase 3 administrative functions to use the wrapEdgeFunction wrapper:
- cancel-account-deletion
- cancel-email-change
- create-novu-subscriber
- update-novu-subscriber
- trigger-notification
- remove-novu-subscriber
- manage-moderator-topic
- migrate-novu-users
- sync-all-moderators-to-topic
- update-novu-preferences
- notify-system-announcement

This update standardizes error handling, tracing, auth, and logging across admin endpoints, removes manual serve/CORS boilerplate, and prepares for consistent monitoring and testing.
2025-11-11 03:49:54 +00:00
gpt-engineer-app[bot]
16a1fa756d Continue Phase 2 Batch 2 and Batch 3
Migrate 6 background jobs to use wrapEdgeFunction: cleanup-old-versions, process-scheduled-deletions, data-retention-cleanup, run-cleanup-jobs, scheduled-maintenance, process-expired-bans. Replace old server routines with edgeFunction wrapper, add centralized logging, tracing, and standardized error handling, and adjust for batch-wise deployment.
2025-11-11 03:36:40 +00:00
gpt-engineer-app[bot]
12d2518eb9 Migrate Phase 2 Batch 1
Migrate 3 Phase 2 monitoring functions (collect-metrics, detect-anomalies, monitor-rate-limits) to use wrapEdgeFunction with smaller batch updates, replacing manual handlers, adding shared logging/tracing, and standardizing error handling.
2025-11-11 03:30:00 +00:00
gpt-engineer-app[bot]
e28dc97d71 Migrate Phase 1 Functions
Migrate 8 high-priority functions (admin-delete-user, mfa-unenroll, confirm-account-deletion, request-account-deletion, send-contact-message, upload-image, validate-email-backend, process-oauth-profile) to wrapEdgeFunction pattern. Replace manual CORS/auth, add shared validations, integrate standardized error handling, and preserve existing rate limiting where applicable. Update implementations to leverage context span, requestId, and improved logging for consistent error reporting and tracing.
2025-11-11 03:03:26 +00:00
gpt-engineer-app[bot]
7181fdbcac Add comprehensive edge-function error handling
Enhance error handling and logging across all edge functions:
- Introduce a shared edgeFunctionWrapper with standardized error handling, request/response logging, tracing, and validation hooks.
- Add runtime type validation utilities (ValidationError, validators, and parse/validate helpers) and integrate into edge flow.
- Implement robust validation for incoming requests and known type mismatches, with detailed logs and structured responses.
- Add post-RPC and post-database error logging to surface type/mismatch issues early.
- Update approval/rejection entry points to leverage new validators and centralized error handling.
2025-11-11 02:54:50 +00:00
gpt-engineer-app[bot]
1a101b4109 Connect to Lovable Cloud
Applied migration to fix process_approval_transaction to support all company types: company, manufacturer, operator, property_owner, designer. This resolves unknown item type errors and enables moderation approvals across all entity types. Migration was executed successfully.
2025-11-11 02:50:04 +00:00
gpt-engineer-app[bot]
60c749c715 Update idempotency key handling in edge functions
Read idempotency key from headers in process-selective-approval and process-selective-rejection, remove it from request bodies, add header validation, and redeploy edge functions to fix idempotency flow.
2025-11-11 02:43:51 +00:00
gpt-engineer-app[bot]
7642ac435b Connect to Lovable Cloud
Improve CORS handling and error logging to fix moderation edge cases:
- Add x-idempotency-key to allowed CORS headers and expose explicit POST methods
- Extend CORS headers to include Access-Control-Allow-Methods
- Update edge function tracing and client error handling to better detect and log CORS/network issues
- Enhance error handling utilities to surface CORS-related failures and provide clearer user messages
2025-11-11 02:39:15 +00:00
gpt-engineer-app[bot]
c632e559d0 Add advanced ML anomaly detection 2025-11-11 02:30:12 +00:00
gpt-engineer-app[bot]
12a6bfdfab Add Advanced ML Anomaly Detection
Enhance detect-anomalies with advanced ML algorithms (Isolation Forest, seasonal decomposition, predictive modeling) and schedule frequent runs via pg_cron. Updates include implementing new detectors, ensemble logic, and plumbing to run and expose results through the anomaly detection UI and data hooks.
2025-11-11 02:28:19 +00:00
gpt-engineer-app[bot]
915a9fe2df Add automated data retention cleanup
Implements edge function, Django tasks, and UI hooks/panels for automatic retention of old metrics, anomalies, alerts, and incidents, plus updates to query keys and monitoring dashboard to reflect data-retention workflows.
2025-11-11 02:21:27 +00:00
gpt-engineer-app[bot]
07fdfe34f3 Fix function search paths
Adjust migrations to set search_path = public for functions to resolve security warnings and ensure proper function execution context.
2025-11-11 02:13:51 +00:00
gpt-engineer-app[bot]
e2b0368a62 Set up auto metric collection
Add Django Celery tasks and utilities to periodically collect system metrics (error rates, response times, queue sizes) and record them into metric_time_series. Include monitoring app scaffolding, metrics collector, Celery beat schedule, middleware for live metrics, and a Supabase edge function for cross-source metrics.
2025-11-11 02:09:55 +00:00
gpt-engineer-app[bot]
be94b4252c Implement ML Anomaly Detection
Introduce statistical anomaly detection for metrics via edge function, hooks, and UI components. Adds detection algorithms (z-score, moving average, rate of change), anomaly storage, auto-alerts, and dashboard rendering of detected anomalies with run-once trigger and scheduling guidance.
2025-11-11 02:07:49 +00:00
gpt-engineer-app[bot]
7fba819fc7 Implement alert correlation UI
- Add hooks and components for correlated alerts and incidents
- Integrate panels into MonitoringOverview
- Extend query keys for correlation and incidents
- Implement incident actions (create, acknowledge, resolve) and wiring
2025-11-11 02:03:20 +00:00
gpt-engineer-app[bot]
5a8caa51b6 Fix search_path on functions
The migration succeeded but security warnings require updating functions to set search_path. Add SET search_path to the three created functions to ensure proper schema resolution and security context.
2025-11-11 01:58:56 +00:00
gpt-engineer-app[bot]
01aba7df90 Connect to Lovable Cloud
Fix security definer view issue by enabling security_invoker on grouped_alerts_view and implement grouped alerts system with new keys, hooks, components, and monitoring overview integration. Added migration to adjust view, updated query keys, created useGroupedAlerts, useAlertGroupActions, GroupedAlertsPanel, and updated MonitoringOverview to include grouped alerts.
2025-11-11 01:51:42 +00:00
gpt-engineer-app[bot]
97f586232f Enable grouped alert view with security considerations
Update: implement grouped_alerts_view migration and address security definer concerns by noting default SECURITY INVOKER behavior for views and ensuring RLS policies on underlying tables apply. This commit covers the view creation and related security clarifications for alert grouping feature.
2025-11-11 01:49:27 +00:00
gpt-engineer-app[bot]
99c917deaf Implement monitoring overview features
Add comprehensive monitoring dashboard scaffolding:
- Extend queryKeys with monitoring keys
- Create hooks: useCombinedAlerts, useRecentActivity, useDatabaseHealth, useModerationHealth
- Build UI components: SystemHealthStatus, CriticalAlertsPanel, MonitoringQuickStats, RecentActivityTimeline, MonitoringNavCards
- Create MonitoringOverview page and integrate routing (MonitoringOverview route)
- Wire AdminSidebar to include Monitoring navigation
- Introduce supporting routing and admin layout hooks/utilities
- Align with TanStack Query patterns and plan for auto-refresh and optimistic updates
2025-11-11 01:33:53 +00:00
gpt-engineer-app[bot]
d94062a937 Connect to Lovable Cloud
The migration completed successfully to enable moderation actions:
- Added SELECT, INSERT, and UPDATE RLS policies for system_alerts
- Grants issued to authenticated users
- Enables viewing, creating, and resolving Pipeline Health alerts via UI
- Resolves the previous issue where Resolve did nothing by lacking permissions
2025-11-11 01:26:06 +00:00
gpt-engineer-app[bot]
5d35fdc326 Enable alert resolution policy
Allow moderators to resolve rate limit alerts by adding UPDATE policy on rate_limit_alerts and granting UPDATE to authenticated users. This completes enabling the Resolve action for alerts.
2025-11-11 01:12:56 +00:00
gpt-engineer-app[bot]
e2692471bb Enhance alert resolution UX
Implement loading state, confirmation dialog, and related UI changes for resolving rate limit alerts:
- Add resolvingAlertId state
- Use ConfirmationDialog for safe resolution
- Update Resolve button to ghost variant with CheckCircle icon and loading behavior
- Wire up loading and disable states during mutation
2025-11-11 00:23:21 +00:00
gpt-engineer-app[bot]
28fa2fd0d4 Monitor rate limits progress
Implement monitor-rate-limits edge function to compare metrics against alert configurations, trigger notifications, and record alerts; update config and groundwork for admin UI integration.
2025-11-11 00:19:13 +00:00
gpt-engineer-app[bot]
677d0980dd Connect to Lovable Cloud
Approved Lovable tool use and migration updates to fix security warning and add monitoring edge function. Prepare and apply migrations to ensure search_path is set to public and implement monitoring endpoint for rate limit metrics.
2025-11-11 00:14:48 +00:00
gpt-engineer-app[bot]
1628753361 Create Rate Limit Admin Dashboard
Add a React admin dashboard component to visualize rate limit metrics and statistics, including data fetching from the rate-limit-metrics edge function, charts and statistics, and admin routes/integration. Includes setup for routing and UI scaffolding to display total requests, block rate, top blocked IPs/users, and recent activity with interactive charts.
2025-11-11 00:06:49 +00:00
gpt-engineer-app[bot]
f15190351d Create rate-limit-metrics edge function
Add an edge function rate-limit-metrics to expose metrics via API, including authentication guards, CORS headers, and multiple query endpoints for recent metrics, stats, and function/user/IP-specific data. Integrates with new metrics and auth helpers and uses existing rate limiter.
2025-11-11 00:02:55 +00:00
gpt-engineer-app[bot]
fa444091db Integrate metrics and auth
Add Phase 2 updates to rateLimiter.ts:
- Import and hook in rateLimitMetrics and authHelpers
- Track per-request metrics on allowed/blocked outcomes
- Extract userId and clientIP for metrics
- Extend RateLimiter to pass functionName for metrics context
- Update withRateLimit to utilize new metadata and return values
2025-11-11 00:01:13 +00:00
gpt-engineer-app[bot]
bea3031767 Create rateLimitMetrics and authHelpers
Implement Phase 1 by adding:

- supabase/functions/_shared/rateLimitMetrics.ts: in-memory rate limit metrics utilities (record, query, stats, clear, and helpers)
- supabase/functions/_shared/authHelpers.ts: auth helpers for extracting userId, client IP, and rate-limit keys (code scaffolding)
2025-11-10 23:57:35 +00:00
gpt-engineer-app[bot]
6da29e95a4 Add rate limiting to high-risk
Introduce centralized rate limiting by applying defined tiers (STRICT, STANDARD, LENIENT, MODERATE) to high-risk edge functions:
- export-user-data (STRICT, 5 req/min)
- send-contact-message (STANDARD, 20 req/min)
- validate-email-backend (LENIENT, 30 req/min)
- admin-delete-user, resend-deletion-code (MODERATE)
- additional standard targets identified (request-account-deletion, cancel-account-deletion) as per guidance

Implements:
- Wrapped handlers with withRateLimit using centralized rateLimiters
- Imported from shared rate limiter module
- Annotated with comments explaining tier rationale
- Updated three initial functions and extended coverage to admin/account management functions
- Added documentation guide for rate limiting usage

This aligns with the Rate Limiting Guide and centralizes rate limit configuration for consistency.
2025-11-10 21:39:37 +00:00
gpt-engineer-app[bot]
ed6ddbd04b Centralize rate limiting config
Create shared rateLimitConfig.ts with tiers (strict, moderate, lenient, generous, per-user variants) and update edge functions to import centralized rate limiters. Replace inline rate limiter usage with new config, preserving backward compatibility. Add documentation guide for rate limiting usage.
2025-11-10 21:33:08 +00:00
gpt-engineer-app[bot]
bf3da6414a Centralize CORS configuration
Consolidate CORS handling by introducing a shared supabase/functions/_shared/cors.ts and migrate edge functions to import from it. Remove inline cors.ts usage across functions, standardize headers (including traceparent and x-request-id), and prepare for environment-aware origins.
2025-11-10 21:28:46 +00:00
gpt-engineer-app[bot]
7cbd09b2ad Add missing CORS headers
Updated edge functions to include traceparent and x-request-id in Access-Control-Allow-Headers for:
- supabase/functions/process-selective-approval/cors.ts
- supabase/functions/process-selective-rejection/cors.ts

This fixes CORS preflight and allows POST requests to reach edge functions.
2025-11-10 21:22:30 +00:00
gpt-engineer-app[bot]
dc12ccbc0d Enable JWT for rejection function
Update supabase/config.toml to set verify_jwt = true for process-selective-rejection, aligning platform authentication with function usage and allowing POST requests to reach the edge function.
2025-11-10 21:09:37 +00:00