Commit Graph

38 Commits

Author SHA1 Message Date
Senior Engineer
c142611470 FRE-588: Fix IDOR vulnerabilities and security findings
H1: Add verifyScriptAccess/verifyRevisionAccess to all 14 revisions endpoints
H2: Add verifyProjectAccess to listScripts and searchScripts
M2: Add cascade delete for projectMembers on project deletion
M4: Replace plain Error throws with TRPCError for consistent error handling
M5: Use crypto.randomUUID for team ID generation (was Date.now + Math.random)
L1: Add 100KB content size limit on revision content
L2: Add unique constraint to script slug column
L3: Update hasProjectAccess middleware to check project membership
2026-04-29 06:57:20 -04:00
eab380b76b Fix FRE-622 security findings: IDOR, auth, markdown injection, email validation
H-1: Add createdBy to alertRules, IDOR check on update/delete
H-2: Add createdBy to scheduledReports, IDOR check on update
H-3: Add createdBy to cohorts, IDOR check on addCohortMember
M-1: Change submitNPSResponse to protectedProcedure
M-2: Escape Slack Markdown special chars in alert rule names
M-3: Change getAllLatestKPIs, getAlertRules, getAlerts, getNPSResponses to protectedProcedure
L-2: Add email regex validation to recipients field

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-29 00:28:01 -04:00
fc2b7fe970 Fix 4 code review findings on FRE-596
- clerk-provider.tsx: typed Clerk event listener with type guards
  (isClerkUserEvent, isClerkSignOutEvent) instead of (event as any)
- service.ts: fixed signal propagation timing in updateProject,
  addCollaborator, removeCollaborator — capture updated project inside
  setProjects callback instead of reading stale signal after mutation
- TeamManagement.tsx: added useAuth import and getAuthToken helper to
  replace raw localStorage reads; auth context now available in components
- ProjectForm.tsx: added explicit null check on auth().user before
  accessing .id, replacing unsafe non-null assertion
2026-04-28 22:36:00 -04:00
25ee1b72e3 Add src/server/trpc/types.ts for type inference 2026-04-28 16:14:33 -04:00
0cdb2e96b1 FRE-588: Complete tRPC/Clerk integration with database schema updates
- Updated router.ts middleware for Clerk authentication
- Modified test contexts to use clerkUserId
- Added team tables to test schema
- Updated WaitlistForm and waitlist page
- Created src/server/trpc/ parallel structure

All 258 tests pass. Ready for Security Reviewer.
2026-04-28 16:13:55 -04:00
55552fd79b FRE-4414: Unblock and update ShieldAI status
- Cleared cancelled blocker FRE-4428
- Updated to in_progress
- Added status comment documenting delegated work to CTO/CMO

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-28 14:25:30 -04:00
b0ac78c9fc FRE-605: Wire ChangeTracker, MergeLogic and ConflictDetectionAlerts together
- Add event emitter to MergeLogic for conflict-detected, conflict-resolved, merge-complete events
- Connect MergeLogic.getLastLocalChange() to ChangeTracker for conflict detection
- Wire ConflictDetectionAlerts component to MergeLogic conflict events
- Add integration tests for full change tracking + merge workflow (8 new tests)
- All 89 tests pass

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-28 05:17:16 -04:00
Senior Engineer
88f0239ab7 feat(FRE-596): add PWA setup and responsive design
- Register service worker for offline caching (app shell + API responses)
- Link manifest.json in index.html with updated theme colors
- Update manifest start_url to /app/dashboard for PWA experience
- Add comprehensive team management CSS with responsive breakpoints
- Add alert, loading, and danger button styles
- Mobile-first responsive layout for team list and detail views
2026-04-28 01:48:48 -04:00
Senior Engineer
b6d1f4c3b6 feat(FRE-596): wire TeamManagement UI to real tRPC API
- Replace mock data with tRPC API calls for team CRUD operations
- Add TeamList view with fetch, create, and delete teams
- Add TeamDetail view with member management (list, invite, update role, remove, leave)
- Use solid-js <For> for proper keyed list rendering
- Add loading/error states and confirmation dialogs
- Use @tanstack/react-query for data fetching and cache invalidation
2026-04-28 01:39:15 -04:00
Paperclip Agent
408d94f731 FRE-622: Wire analytics services to tRPC API layer with comprehensive router
Create analytics-router.ts with ~30 tRPC endpoints for KPI management, alert
rules, scheduled reports, cohort analysis, and NPS survey integration.
Register router in index.ts under 'analytics' namespace. Fix pre-existing
bugs in service files: snake_case to camelCase conversion, missing non-null
assertions, and incorrect DB access patterns.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-27 22:55:15 -04:00
bc897f8845 Auto-commit 2026-04-27 19:13 2026-04-27 19:13:03 -04:00
f414e0ff75 FRE-4441: Review silent active run for CMO - false positive
CMO run healthy, actively working on FRE-687

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-27 15:12:39 -04:00
9583c06473 FRE-696 Wire up API client to mail/contact/attachment endpoints
- Create ProtonMail API client (src/lib/mail/protonmail-client.ts)
- Add tRPC mail router with 8 endpoints (server/trpc/mail-router.ts)
- Wire mail router into appRouter (server/trpc/index.ts)
- Add module exports (src/lib/mail/index.ts)

Endpoints:
- mail.messages, mail.message, mail.send
- mail.contact, mail.contacts, mail.addContact
- mail.attachment, mail.attachmentDownload

Router uses Zod validation and includes placeholders for ProtonMail API calls.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-27 14:35:07 -04:00
9e3a54f508 Auto-commit 2026-04-27 12:34 2026-04-27 12:34:30 -04:00
bef1d7f829 FRE-750: Break infinite recovery cascade, reassign FRE-620 to Founding Engineer
- Cancelled 700+ runaway recovery issues (FRE-767 through FRE-2000+)
- Reassigned FRE-620 (analytics setup) from error-state Senior Engineer to available Founding Engineer
- Removed blocker chain that was preventing FRE-620 from progressing
- Documented system bug: recovery system creates recovery issues for cancelled recovery issues

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-27 01:22:34 -04:00
0ff6c74871 FRE-709: Document duplicate recovery wake - FRE-635 already recovered via FRE-708 2026-04-26 20:23:14 -04:00
e7d7f455c6 FRE-588: Consolidate schema - add teams/project_members exports, fix FK references, update seed
- Export teams, teamMembers, projectMembers from schema index barrel
- Add missing FK: cohortMembers.userId → users.id
- Add missing FK: alerts.acknowledgedBy → users.id
- Update seed.ts to match current schema (characters/scenes use projectId, not scriptId)
2026-04-26 18:17:27 -04:00
ec215ae426 Implement waitlist landing page FRE-656
- Add waitlist tRPC router with signup mutation and count query
- Add referral code generation and tracking
- Register waitlist router in app router
- Add useWaitlistSignup, useWaitlistCount, useReferralCount hooks
- Update landing page with email capture form, live waitlist counter, referral sharing
- Add waitlist and referral CSS styles

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-26 07:57:29 -04:00
11a188c68e FRE-623: Build KPI dashboard with Mixpanel, GA4, Stripe panels and unified report
- Created KPIDashboard component with tab navigation (product/acquisition/revenue/report)
- Created MixpanelPanel for product KPIs linking to Mixpanel
- Created GA4Panel for acquisition KPIs linking to GA4
- Created StripePanel for revenue KPIs linking to Stripe dashboard
- Created UnifiedReport with KPI thresholds table and reporting schedule
- Added KPI dashboard route (/app/kpi) and sidebar navigation link
- Added KPI dashboard CSS styles (metric cards, tabs, table, info cards)
- Fixed pre-existing parse errors in Faq.tsx (unescaped apostrophes)
- Fixed pre-existing CSS import paths in routes.tsx

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-26 07:56:17 -04:00
a638b23c85 Add waitlist seed data to seed script (FRE-645) 2026-04-26 06:34:39 -04:00
67c3881dcf Add waitlist schema for marketing (FRE-635)
- Created waitlist_signups and waitlist_events tables
- Supports email, name, source tracking, and status management
- Enables VIP supporter list for Product Hunt launch
- Migration 0002_chemical_shocker.sql generated
- Fixed brand color in product-hunt-assets-brief.md (#518ac8)
2026-04-26 06:21:20 -04:00
1d39be2446 fix: resolve all collaboration layer test failures for FRE-605
- Fix snapshot restore to properly copy text and map content from Yjs docs
- Fix concurrent edit sync to use delta-based updates instead of full state
- Fix delete operation test with correct position offset
- Add selection and lastActive fields to CursorPosition interface
- Fix updateSelection to propagate selection to cursor object
- Fix idle detection test by manually setting lastActivityTime
- Fix batcher test expectations for auto-flush behavior
- Fix undo/redo test with correct captureTimeout setting

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 10:24:14 -04:00
Paperclip
14b78273f9 FRE-605: Fix Phase 4 tests and improve snapshot restore
- Fix validateMerge test: seed document with content before validation
- Fix IDB persistence test: remove browser-only code from Node.js test
- Improve restoreSnapshot: replace document state entirely instead of additive merge
2026-04-25 09:27:18 -04:00
4435a12dd7 feat: integrate tRPC client with Clerk authentication
- Update trpc-client.ts with auth token management
- Create comprehensive tRPC hooks for all project operations
- Store Clerk session token in localStorage for API auth
- Clear token on sign out
- Support integer IDs matching backend schema

Hooks created:
- Projects: useProjects, useProject, useCreateProject, useUpdateProject, useDeleteProject
- Characters: useCharacters, useCharacter, useCreateCharacter, useUpdateCharacter, useDeleteCharacter
- Relationships: useRelationships, useCharacterRelationships, useCreateRelationship, useUpdateRelationship, useDeleteRelationship
- Scenes: useScenes, useScene, useCreateScene, useUpdateScene, useDeleteScene
- Stats: useCharacterStats, useProjectCharacterStats

All 34 backend tests passing.
2026-04-25 08:31:05 -04:00
754fce269f fix: implement critical security remediation for authentication and authorization
- Add Clerk token verification to tRPC context (server/trpc/index.ts)
- Remove client-controlled authorId/reviewedById from revisions router
- Require JWT_SECRET environment variable, remove hardcoded fallback
- Add table name validation to prevent SQL injection in backup logic
- Fix TRPCContext type to use better-sqlite3 instead of LibSQL
- Update revisions router tests to use proper tRPC v11+ API
- Add resetInMemoryState function for test isolation

Security fixes address:
- Critical: Authentication bypass via missing token verification
- Critical: User impersonation via client-controlled IDs
- High: Insecure WebSocket defaults with hardcoded secrets
- High: SQL injection vulnerability in backup logic

All tests passing (24/24).
2026-04-25 08:24:45 -04:00
936430fb40 FRE-587 Phase 5: Add integration tests - COMPLETE
Phase 5 Polish & Optimization - COMPLETE:

Integration Tests (collaboration.test.ts - 440 lines):
- Multi-user sync flow tests
- Change tracking integration tests
- Merge logic integration tests
- Presence integration tests
- Persistence integration tests
- Performance integration tests
- End-to-end collaboration scenario tests
- Edge case tests (rapid updates, large docs, disconnection, undo/redo)

Coverage:
- 15+ test suites
- 25+ individual tests
- Tests all collaboration layer components
- Browser and Node.js compatible

Phase 5 Summary:
 IndexedDB persistence
 Change highlighting UI
 Version history panel
 WebSocket message batching
 Performance benchmarking
 Conflict detection alerts
 Integration tests

Files Created:
- src/lib/collaboration/collaboration.test.ts (440 lines)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:32:50 -04:00
e47debc2d7 FRE-587 Phase 5: Add performance optimization + conflict alerts
Phase 5 Polish & Optimization - Part 2:

Performance Optimization:
- Create UpdateBatcher class for WebSocket message batching
  - Batches multiple Yjs updates into single messages
  - Configurable batch size (default: 10) and wait time (default: 50ms)
  - Reduces network overhead significantly
  - Tracks statistics (updates sent, batches sent, avg batch size)

Benchmarking:
- Create CollaborationBenchmark class
  - Measures sync latency with percentile stats (p50, p95, p99)
  - Tracks memory usage (heap used/total)
  - Operation timing utilities
  - JSON export for analysis

UI Components:
- ConflictDetectionAlerts component - toast notifications for conflicts
  - Real-time conflict notifications
  - Three resolution options (Keep Mine, Accept Theirs, Review)
  - Auto-dismiss after 10 seconds (configurable)
  - Expandable for multiple conflicts
  - Color-coded by conflict type

Files Created:
- src/lib/collaboration/update-batcher.ts (130 lines)
- src/lib/collaboration/benchmark.ts (200 lines)
- src/components/collaboration/conflict-alerts.tsx (280 lines)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:28:07 -04:00
8c64318b9a FRE-587 Phase 5: Add offline persistence + UI components
Phase 5 Polish & Optimization - Part 1:

Offline Persistence:
- Create IDBPersistence class for IndexedDB storage
- Auto-save with configurable intervals (default 5s)
- Offline mode with update queuing
- Automatic flush when back online

UI Components:
- ChangeHighlighting component - visual change indicators
  - Color-coded by user
  - Auto-fade after 30s
  - Toggle visibility
- VersionHistoryPanel component - snapshot management
  - Chronological snapshot list
  - Relative timestamps
  - One-click restore
  - Manual snapshot creation

Documentation:
- analysis/fre587_phase5_polish_implementation.md

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:24:22 -04:00
298b2f5151 FRE-603: Fix code review blockers (memory leak + auth security)
- Fixed memory leak in PresenceManager: event handlers now use bound methods
  so they can be properly removed in shutdown()
- Removed auth token from URL query parameters (security: prevents token leakage
  to server logs and browser history)
- Fixed TypeScript errors: corrected WebsocketProvider import, removed unsupported
  send() calls, fixed type mismatches in presence callbacks
- All collaboration module files now type-check successfully

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:19:33 -04:00
b89575fb6e FRE-605: Implement Phase 4 Change Tracking & Merge Logic
- Create ChangeTracker class with full version history support
  - Document change recording with metadata
  - Snapshot creation and restoration
  - Change acceptance/rejection workflow
  - Change diff generation between snapshots
  - Event-based change notifications

- Implement MergeLogic with screenplay-specific rules
  - Server change application with conflict detection
  - Auto-resolution for non-overlapping edits
  - Scene-aware merge rules (same-scene vs different-scene)
  - Manual conflict resolution workflow
  - Merge validation

- Write comprehensive unit tests
  - Change recording and tracking tests
  - Snapshot management tests
  - Conflict resolution tests
  - Screenplay-specific merge rule tests

- Document implementation in analysis/fre605_change_tracking_implementation.md

Architecture: ChangeTracker integrates with Yjs document updates.
MergeLogic applies screenplay-specific rules for concurrent edits.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 02:14:54 -04:00
7c684a42cc FRE-600: Fix code review blockers
- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 00:08:01 -04:00
36f9b420f5 FRE-608: Add Turso database setup with Drizzle ORM
- Create schema for users, projects, scripts, characters, scenes, revisions
- Implement DatabaseManager with connection pooling
- Implement EdgeDatabaseManager for multi-region replicas
- Implement DatabaseBackupManager with automated scheduling
- Generate initial migration with 9 tables
- Add seed script and documentation
- Configure Drizzle Kit for migration management
- Add NPM scripts for database operations

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 15:41:03 -04:00
4d9b4ecf2a FRE-592: Address code review feedback
Fixes from review:
- Add DB-level unique constraint on character relationships
- Fix character stats to use sceneCharacters join table instead of text matching
- Add loading/error states to CharacterList, CharacterSearch, CharacterStatsPanel
- Add delete confirmation dialogs to CharacterProfile and CharacterRelationships

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 07:23:50 -04:00
ccbf3039d9 FRE-594: Implement revision tracking and version history system
Add complete revision tracking system for scripts with:
- Database schema for revisions and revision_changes tables
- Diff engine with color-coded change types (addition/deletion/modification)
- tRPC router with 14 endpoints (create/list/compare/rollback/branch/merge)
- SolidJS components: RevisionTimeline, DiffViewer, RevisionReview
- Unit tests for diff engine and router

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 05:54:06 -04:00
FrenoCorp Agent
8dc4827597 FRE-592: Implement character database and relationship mapping
Add full character management system with enriched profiles (bio, traits,
arcs, motivation, conflict, secrets), relationship mapping between
characters with types and strength, character search/filter by role and
arc type, and character statistics (scene count, dialogue, screen time).

Includes database schema, tRPC router procedures, SolidJS components,
API hooks, and unit tests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 02:24:31 -04:00
Senior Engineer
adf453e245 FRE-586: Add core screenplay editor with auto-formatting engine
- types.ts: Screenplay element types, template configs, and interfaces
- format.ts: Auto-formatting engine with Standard, Sitcom, Podcast templates
- detect.ts: Element detection (scene headings, transitions, characters, parentheticals)
- ScreenplayEditor.tsx: Editor component with keyboard shortcuts and live formatting
- PreviewPanel.tsx: Real-time formatting preview panel
- detect.test.ts: 19 tests for element detection
- format.test.ts: 15 tests for formatting engine and templates
- Fixed transition regex to handle periods and other terminators
- All 34 tests passing
2026-04-23 07:42:58 -04:00
1c74a082e5 FRE-603: Add Presence & Visibility Layer UI components
- CollaboratorList: Display connected users with presence state
- RemoteCursorOverlay: Render remote cursors in editor
- EditingIndicator: Show active editors and their context
- Component index for clean imports
- Tests for CollaboratorList

Architecture:
- Polling-based presence updates (100ms for cursors, 500ms for editors)
- Color-coded user indicators
- Line:column cursor positioning
- Selection highlighting with transparency

Files:
- src/components/collaboration/collaborator-list.tsx
- src/components/collaboration/remote-cursor-overlay.tsx
- src/components/collaboration/editing-indicator.tsx
- src/components/collaboration/index.ts
- src/components/collaboration/collaborator-list.test.tsx

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-23 06:37:21 -04:00
ef1b15c9ea FRE-600: Implement Phase 1 WebSocket + Yjs CRDT foundation
- Create TypeScript and Vite configuration for SolidJS
- Implement Yjs document structure for screenplay collaboration
- Build WebSocket connection manager with exponential backoff reconnection
- Create CRDT document manager with undo/redo support
- Set up WebSocket sync server with JWT authentication
- Add SolidJS reactive bindings for Yjs shared types
- Build collaborative editor component
- Write unit tests for CRDT operations
- Document implementation in analysis/fre600_websocket_foundation.md

Architecture: Yjs chosen over Automerge for better ecosystem and
Tauri compatibility. WebSocket for sync, WebRTC for video.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-22 23:08:27 -04:00