@dynamicu/chromedebug-mcp 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +344 -0
- package/LICENSE +21 -0
- package/README.md +250 -0
- package/chrome-extension/README.md +41 -0
- package/chrome-extension/background.js +3917 -0
- package/chrome-extension/chrome-session-manager.js +706 -0
- package/chrome-extension/content.css +181 -0
- package/chrome-extension/content.js +3022 -0
- package/chrome-extension/data-buffer.js +435 -0
- package/chrome-extension/dom-tracker.js +411 -0
- package/chrome-extension/extension-config.js +78 -0
- package/chrome-extension/firebase-client.js +278 -0
- package/chrome-extension/firebase-config.js +32 -0
- package/chrome-extension/firebase-config.module.js +22 -0
- package/chrome-extension/firebase-config.module.template.js +27 -0
- package/chrome-extension/firebase-config.template.js +36 -0
- package/chrome-extension/frame-capture.js +407 -0
- package/chrome-extension/icon128.png +1 -0
- package/chrome-extension/icon16.png +1 -0
- package/chrome-extension/icon48.png +1 -0
- package/chrome-extension/license-helper.js +181 -0
- package/chrome-extension/logger.js +23 -0
- package/chrome-extension/manifest.json +73 -0
- package/chrome-extension/network-tracker.js +510 -0
- package/chrome-extension/offscreen.html +10 -0
- package/chrome-extension/options.html +203 -0
- package/chrome-extension/options.js +282 -0
- package/chrome-extension/pako.min.js +2 -0
- package/chrome-extension/performance-monitor.js +533 -0
- package/chrome-extension/pii-redactor.js +405 -0
- package/chrome-extension/popup.html +532 -0
- package/chrome-extension/popup.js +2446 -0
- package/chrome-extension/upload-manager.js +323 -0
- package/chrome-extension/web-vitals.iife.js +1 -0
- package/config/api-keys.json +11 -0
- package/config/chrome-pilot-config.json +45 -0
- package/package.json +126 -0
- package/scripts/cleanup-processes.js +109 -0
- package/scripts/config-manager.js +280 -0
- package/scripts/generate-extension-config.js +53 -0
- package/scripts/setup-security.js +64 -0
- package/src/capture/architecture.js +426 -0
- package/src/capture/error-handling-tests.md +38 -0
- package/src/capture/error-handling-types.ts +360 -0
- package/src/capture/index.js +508 -0
- package/src/capture/interfaces.js +625 -0
- package/src/capture/memory-manager.js +713 -0
- package/src/capture/types.js +342 -0
- package/src/chrome-controller.js +2658 -0
- package/src/cli.js +19 -0
- package/src/config-loader.js +303 -0
- package/src/database.js +2178 -0
- package/src/firebase-license-manager.js +462 -0
- package/src/firebase-privacy-guard.js +397 -0
- package/src/http-server.js +1516 -0
- package/src/index-direct.js +157 -0
- package/src/index-modular.js +219 -0
- package/src/index-monolithic-backup.js +2230 -0
- package/src/index.js +305 -0
- package/src/legacy/chrome-controller-old.js +1406 -0
- package/src/legacy/index-express.js +625 -0
- package/src/legacy/index-old.js +977 -0
- package/src/legacy/routes.js +260 -0
- package/src/legacy/shared-storage.js +101 -0
- package/src/logger.js +10 -0
- package/src/mcp/handlers/chrome-tool-handler.js +306 -0
- package/src/mcp/handlers/element-tool-handler.js +51 -0
- package/src/mcp/handlers/frame-tool-handler.js +957 -0
- package/src/mcp/handlers/request-handler.js +104 -0
- package/src/mcp/handlers/workflow-tool-handler.js +636 -0
- package/src/mcp/server.js +68 -0
- package/src/mcp/tools/index.js +701 -0
- package/src/middleware/auth.js +371 -0
- package/src/middleware/security.js +267 -0
- package/src/port-discovery.js +258 -0
- package/src/routes/admin.js +182 -0
- package/src/services/browser-daemon.js +494 -0
- package/src/services/chrome-service.js +375 -0
- package/src/services/failover-manager.js +412 -0
- package/src/services/git-safety-service.js +675 -0
- package/src/services/heartbeat-manager.js +200 -0
- package/src/services/http-client.js +195 -0
- package/src/services/process-manager.js +318 -0
- package/src/services/process-tracker.js +574 -0
- package/src/services/profile-manager.js +449 -0
- package/src/services/project-manager.js +415 -0
- package/src/services/session-manager.js +497 -0
- package/src/services/session-registry.js +491 -0
- package/src/services/unified-session-manager.js +678 -0
- package/src/shared-storage-old.js +267 -0
- package/src/standalone-server.js +53 -0
- package/src/utils/extension-path.js +145 -0
- package/src/utils.js +187 -0
- package/src/validation/log-transformer.js +125 -0
- package/src/validation/schemas.js +391 -0
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Interaction Capture System - Data Flow Architecture
|
|
3
|
+
*
|
|
4
|
+
* This module defines the complete data flow architecture and module boundaries
|
|
5
|
+
* for the unified interaction capture system.
|
|
6
|
+
*
|
|
7
|
+
* SYSTEM OVERVIEW:
|
|
8
|
+
* ================
|
|
9
|
+
* The capture system replaces three separate legacy systems:
|
|
10
|
+
* 1. Frame recording (screenshots + console logs)
|
|
11
|
+
* 2. Workflow recording (user actions + DOM state)
|
|
12
|
+
* 3. Function tracing (execution traces)
|
|
13
|
+
*
|
|
14
|
+
* UNIFIED APPROACH:
|
|
15
|
+
* ================
|
|
16
|
+
* All interactions are captured as CaptureEvents with a unified format.
|
|
17
|
+
* Each event has a type (screen, dom, console, user, function, network, state)
|
|
18
|
+
* and type-specific data payload.
|
|
19
|
+
*
|
|
20
|
+
* DATA FLOW DIAGRAM:
|
|
21
|
+
* ==================
|
|
22
|
+
*
|
|
23
|
+
* ┌─────────────────────────────────────────────────────────────────────┐
|
|
24
|
+
* │ CAPTURE SOURCES │
|
|
25
|
+
* └─────────────────────────────────────────────────────────────────────┘
|
|
26
|
+
* │ │ │
|
|
27
|
+
* ▼ ▼ ▼
|
|
28
|
+
* ┌───────────────┐ ┌─────────────────┐ ┌──────────────────┐
|
|
29
|
+
* │ Chrome │ │ Puppeteer │ │ DevTools │
|
|
30
|
+
* │ Extension │ │ Source │ │ Source │
|
|
31
|
+
* │ │ │ │ │ │
|
|
32
|
+
* │ • Screenshots │ │ • DOM Snapshots │ │ • Console Logs │
|
|
33
|
+
* │ • User Events │ │ • Network Data │ │ • Function Trace │
|
|
34
|
+
* │ • Console │ │ • Performance │ │ • Browser State │
|
|
35
|
+
* └───────────────┘ └─────────────────┘ └──────────────────┘
|
|
36
|
+
* │ │ │
|
|
37
|
+
* └────────────────────┼────────────────────┘
|
|
38
|
+
* ▼
|
|
39
|
+
* ┌─────────────────────────────────────────────────────────────────────┐
|
|
40
|
+
* │ CAPTURE COLLECTOR │
|
|
41
|
+
* │ │
|
|
42
|
+
* │ • Event Routing & Coordination │
|
|
43
|
+
* │ • Source Registration │
|
|
44
|
+
* │ • Event Sequencing │
|
|
45
|
+
* │ • Memory Pressure Management │
|
|
46
|
+
* └─────────────────────────────────────────────────────────────────────┘
|
|
47
|
+
* ▼
|
|
48
|
+
* ┌─────────────────────────────────────────────────────────────────────┐
|
|
49
|
+
* │ CAPTURE PROCESSORS │
|
|
50
|
+
* │ │
|
|
51
|
+
* │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
52
|
+
* │ │ Filter │ │ Transform │ │ Enrichment │ │ Compression │ │
|
|
53
|
+
* │ │ Processor │ │ Processor │ │ Processor │ │ Processor │ │
|
|
54
|
+
* │ │ │ │ │ │ │ │ │ │
|
|
55
|
+
* │ │ • Dedupe │ │ • Normalize │ │ • Add Meta │ │ • Image │ │
|
|
56
|
+
* │ │ • Priority │ │ • Sanitize │ │ • Correlate │ │ • JSON │ │
|
|
57
|
+
* │ │ • Rate Limit│ │ • Format │ │ • Context │ │ • Binary │ │
|
|
58
|
+
* │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
59
|
+
* └─────────────────────────────────────────────────────────────────────┘
|
|
60
|
+
* ▼
|
|
61
|
+
* ┌─────────────────────────────────────────────────────────────────────┐
|
|
62
|
+
* │ CAPTURE STORAGE │
|
|
63
|
+
* │ │
|
|
64
|
+
* │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
65
|
+
* │ │ Database │ │ File System │ │ Memory │ │ Network │ │
|
|
66
|
+
* │ │ Storage │ │ Storage │ │ Storage │ │ Storage │ │
|
|
67
|
+
* │ │ │ │ │ │ │ │ │ │
|
|
68
|
+
* │ │ • SQLite │ │ • Images │ │ • Recent │ │ • Cloud │ │
|
|
69
|
+
* │ │ • Metadata │ │ • Videos │ │ • Cache │ │ • Backup │ │
|
|
70
|
+
* │ │ • Indexes │ │ • Logs │ │ • Temp │ │ • Sync │ │
|
|
71
|
+
* │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
72
|
+
* └─────────────────────────────────────────────────────────────────────┘
|
|
73
|
+
* ▼
|
|
74
|
+
* ┌─────────────────────────────────────────────────────────────────────┐
|
|
75
|
+
* │ CAPTURE QUERY & ANALYSIS │
|
|
76
|
+
* │ │
|
|
77
|
+
* │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
78
|
+
* │ │ Query │ │ Search │ │ Analytics │ │ Export │ │
|
|
79
|
+
* │ │ Engine │ │ Engine │ │ Engine │ │ Engine │ │
|
|
80
|
+
* │ │ │ │ │ │ │ │ │ │
|
|
81
|
+
* │ │ • Filter │ │ • Text │ │ • Patterns │ │ • JSON │ │
|
|
82
|
+
* │ │ • Sort │ │ • Semantic │ │ • Metrics │ │ • CSV │ │
|
|
83
|
+
* │ │ • Paginate │ │ • Fuzzy │ │ • Reports │ │ • Video │ │
|
|
84
|
+
* │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
85
|
+
* └─────────────────────────────────────────────────────────────────────┘
|
|
86
|
+
*
|
|
87
|
+
* MEMORY MANAGEMENT STRATEGY:
|
|
88
|
+
* ===========================
|
|
89
|
+
*
|
|
90
|
+
* 1. TIERED STORAGE:
|
|
91
|
+
* • Hot Data (Recent): Memory cache for instant access
|
|
92
|
+
* • Warm Data (Session): Database for quick queries
|
|
93
|
+
* • Cold Data (Archive): File system for long-term storage
|
|
94
|
+
*
|
|
95
|
+
* 2. SIZE-BASED OPTIMIZATION:
|
|
96
|
+
* • Small Events (<1KB): Keep in memory, batch to database
|
|
97
|
+
* • Medium Events (1KB-100KB): Stream to database immediately
|
|
98
|
+
* • Large Events (100KB-1MB): Stream to file system, reference in database
|
|
99
|
+
* • Huge Events (>1MB): Compress, stream to file system
|
|
100
|
+
*
|
|
101
|
+
* 3. MEMORY PRESSURE HANDLING:
|
|
102
|
+
* • Monitor memory usage continuously
|
|
103
|
+
* • Trigger cleanup when limits approached
|
|
104
|
+
* • Use backpressure to slow capture if needed
|
|
105
|
+
* • Implement circular buffers for high-frequency events
|
|
106
|
+
*
|
|
107
|
+
* 4. PERFORMANCE OPTIMIZATION:
|
|
108
|
+
* • Async processing pipelines
|
|
109
|
+
* • Batch operations for database writes
|
|
110
|
+
* • Streaming for large data
|
|
111
|
+
* • Lazy loading for queries
|
|
112
|
+
*
|
|
113
|
+
* MODULE BOUNDARIES & DEPENDENCIES:
|
|
114
|
+
* =================================
|
|
115
|
+
*
|
|
116
|
+
* 1. CAPTURE SOURCES (Independent):
|
|
117
|
+
* - No dependencies on other capture modules
|
|
118
|
+
* - Only depends on types.js for event format
|
|
119
|
+
* - Can be developed and tested in isolation
|
|
120
|
+
* - Examples: ChromeExtensionSource, PuppeteerSource, DevToolsSource
|
|
121
|
+
*
|
|
122
|
+
* 2. CAPTURE COLLECTOR (Orchestrator):
|
|
123
|
+
* - Depends on ICaptureSource interface
|
|
124
|
+
* - Manages source lifecycle
|
|
125
|
+
* - Routes events to processors
|
|
126
|
+
* - Handles backpressure and flow control
|
|
127
|
+
*
|
|
128
|
+
* 3. CAPTURE PROCESSORS (Transformers):
|
|
129
|
+
* - No dependencies on sources or storage
|
|
130
|
+
* - Only depends on types.js for event format
|
|
131
|
+
* - Can be chained in pipeline
|
|
132
|
+
* - Examples: FilterProcessor, CompressionProcessor, EnrichmentProcessor
|
|
133
|
+
*
|
|
134
|
+
* 4. CAPTURE STORAGE (Persistence):
|
|
135
|
+
* - No dependencies on sources or processors
|
|
136
|
+
* - Only depends on types.js for event format
|
|
137
|
+
* - Multiple storage backends possible
|
|
138
|
+
* - Examples: SQLiteStorage, FileSystemStorage, MemoryStorage
|
|
139
|
+
*
|
|
140
|
+
* 5. CAPTURE QUERY (Read Layer):
|
|
141
|
+
* - Depends only on ICaptureStorage interface
|
|
142
|
+
* - Provides unified query interface
|
|
143
|
+
* - Can work with any storage backend
|
|
144
|
+
*
|
|
145
|
+
* 6. CAPTURE ANALYZER (Intelligence):
|
|
146
|
+
* - Depends only on ICaptureQuery interface
|
|
147
|
+
* - Provides insights and analytics
|
|
148
|
+
* - Can be extended with new analysis types
|
|
149
|
+
*
|
|
150
|
+
* ERROR HANDLING STRATEGY:
|
|
151
|
+
* ========================
|
|
152
|
+
*
|
|
153
|
+
* 1. GRACEFUL DEGRADATION:
|
|
154
|
+
* • If screenshot capture fails, continue with other events
|
|
155
|
+
* • If database unavailable, fallback to file storage
|
|
156
|
+
* • If memory full, switch to streaming mode
|
|
157
|
+
*
|
|
158
|
+
* 2. ERROR ISOLATION:
|
|
159
|
+
* • Errors in one source don't affect others
|
|
160
|
+
* • Processor errors don't stop the pipeline
|
|
161
|
+
* • Storage errors trigger fallback mechanisms
|
|
162
|
+
*
|
|
163
|
+
* 3. RECOVERY MECHANISMS:
|
|
164
|
+
* • Automatic retry with exponential backoff
|
|
165
|
+
* • Circuit breaker pattern for failing components
|
|
166
|
+
* • Health checks for system components
|
|
167
|
+
*
|
|
168
|
+
* 4. ERROR REPORTING:
|
|
169
|
+
* • Structured error events in capture stream
|
|
170
|
+
* • Error metrics and monitoring
|
|
171
|
+
* • Debug logs with context
|
|
172
|
+
*
|
|
173
|
+
* EXTENSIBILITY DESIGN:
|
|
174
|
+
* =====================
|
|
175
|
+
*
|
|
176
|
+
* 1. NEW CAPTURE TYPES:
|
|
177
|
+
* • Add new type to CAPTURE_TYPES enum
|
|
178
|
+
* • Define data format in EVENT_DATA_TYPES
|
|
179
|
+
* • Implement source for new type
|
|
180
|
+
* • System automatically handles storage/query
|
|
181
|
+
*
|
|
182
|
+
* 2. NEW SOURCES:
|
|
183
|
+
* • Implement ICaptureSource interface
|
|
184
|
+
* • Register with collector
|
|
185
|
+
* • No changes needed to other modules
|
|
186
|
+
*
|
|
187
|
+
* 3. NEW PROCESSORS:
|
|
188
|
+
* • Implement ICaptureProcessor interface
|
|
189
|
+
* • Register in processing pipeline
|
|
190
|
+
* • Can transform any event type
|
|
191
|
+
*
|
|
192
|
+
* 4. NEW STORAGE BACKENDS:
|
|
193
|
+
* • Implement ICaptureStorage interface
|
|
194
|
+
* • Register with system
|
|
195
|
+
* • Query layer works automatically
|
|
196
|
+
*
|
|
197
|
+
* CHROME EXTENSION INTEGRATION:
|
|
198
|
+
* ==============================
|
|
199
|
+
*
|
|
200
|
+
* 1. MESSAGE PASSING:
|
|
201
|
+
* • Extension uses chrome.runtime.sendMessage
|
|
202
|
+
* • Background script receives and forwards to collector
|
|
203
|
+
* • Efficient binary data transfer for screenshots
|
|
204
|
+
*
|
|
205
|
+
* 2. CONTENT SCRIPT COORDINATION:
|
|
206
|
+
* • DOM events captured by content script
|
|
207
|
+
* • User interactions tracked with event listeners
|
|
208
|
+
* • Coordinates with background script via messaging
|
|
209
|
+
*
|
|
210
|
+
* 3. PERFORMANCE CONSIDERATIONS:
|
|
211
|
+
* • Batch small events to reduce message overhead
|
|
212
|
+
* • Stream large events (screenshots) efficiently
|
|
213
|
+
* • Use transfer objects for binary data
|
|
214
|
+
*
|
|
215
|
+
* TESTING STRATEGY:
|
|
216
|
+
* =================
|
|
217
|
+
*
|
|
218
|
+
* 1. UNIT TESTING:
|
|
219
|
+
* • Each module can be tested in isolation
|
|
220
|
+
* • Mock interfaces for dependencies
|
|
221
|
+
* • Test data generators for event types
|
|
222
|
+
*
|
|
223
|
+
* 2. INTEGRATION TESTING:
|
|
224
|
+
* • Test module interactions
|
|
225
|
+
* • End-to-end capture scenarios
|
|
226
|
+
* • Performance testing with large datasets
|
|
227
|
+
*
|
|
228
|
+
* 3. INCREMENTAL TESTING WITH TRUSTBUTVERIFY:
|
|
229
|
+
* • Test individual modules as developed
|
|
230
|
+
* • Verify interfaces work correctly
|
|
231
|
+
* • Ensure performance meets requirements
|
|
232
|
+
*
|
|
233
|
+
* MIGRATION FROM LEGACY SYSTEMS:
|
|
234
|
+
* ===============================
|
|
235
|
+
*
|
|
236
|
+
* 1. PARALLEL OPERATION:
|
|
237
|
+
* • New system runs alongside legacy
|
|
238
|
+
* • Compare outputs for compatibility
|
|
239
|
+
* • Gradual migration of features
|
|
240
|
+
*
|
|
241
|
+
* 2. DATA MIGRATION:
|
|
242
|
+
* • Convert legacy frame recordings to new format
|
|
243
|
+
* • Convert workflow recordings to capture events
|
|
244
|
+
* • Preserve existing analysis capabilities
|
|
245
|
+
*
|
|
246
|
+
* 3. API COMPATIBILITY:
|
|
247
|
+
* • Maintain existing MCP tool interfaces
|
|
248
|
+
* • New tools use unified capture format
|
|
249
|
+
* • Legacy tools get compatibility layer
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* System configuration constants
|
|
254
|
+
*/
|
|
255
|
+
export const ARCHITECTURE_CONFIG = {
|
|
256
|
+
// Memory management thresholds
|
|
257
|
+
MEMORY: {
|
|
258
|
+
// Maximum memory usage before triggering cleanup (MB)
|
|
259
|
+
MAX_MEMORY_MB: 100,
|
|
260
|
+
// Memory usage that triggers warnings (MB)
|
|
261
|
+
WARNING_THRESHOLD_MB: 75,
|
|
262
|
+
// Memory usage that triggers aggressive cleanup (MB)
|
|
263
|
+
CRITICAL_THRESHOLD_MB: 90,
|
|
264
|
+
// Cleanup interval in milliseconds
|
|
265
|
+
CLEANUP_INTERVAL_MS: 30000
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
// Event processing limits
|
|
269
|
+
EVENTS: {
|
|
270
|
+
// Maximum events in memory before flushing
|
|
271
|
+
MAX_MEMORY_EVENTS: 1000,
|
|
272
|
+
// Batch size for database writes
|
|
273
|
+
BATCH_SIZE: 100,
|
|
274
|
+
// Maximum event age in memory (ms)
|
|
275
|
+
MAX_AGE_MS: 60000,
|
|
276
|
+
// Circuit breaker failure threshold
|
|
277
|
+
ERROR_THRESHOLD: 5
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
// Storage configuration
|
|
281
|
+
STORAGE: {
|
|
282
|
+
// File size thresholds for storage decisions
|
|
283
|
+
SMALL_EVENT_BYTES: 1024, // < 1KB
|
|
284
|
+
MEDIUM_EVENT_BYTES: 102400, // < 100KB
|
|
285
|
+
LARGE_EVENT_BYTES: 1048576, // < 1MB
|
|
286
|
+
// Database page size optimization
|
|
287
|
+
DB_PAGE_SIZE: 4096,
|
|
288
|
+
// File system chunk size
|
|
289
|
+
FS_CHUNK_SIZE: 65536
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
// Performance tuning
|
|
293
|
+
PERFORMANCE: {
|
|
294
|
+
// Processing pipeline worker count
|
|
295
|
+
PROCESSOR_WORKERS: 2,
|
|
296
|
+
// Storage writer worker count
|
|
297
|
+
STORAGE_WORKERS: 1,
|
|
298
|
+
// Query engine cache size (entries)
|
|
299
|
+
QUERY_CACHE_SIZE: 1000,
|
|
300
|
+
// Network timeout for remote storage
|
|
301
|
+
NETWORK_TIMEOUT_MS: 30000
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Data flow validation rules
|
|
307
|
+
*/
|
|
308
|
+
export const FLOW_VALIDATION = {
|
|
309
|
+
// Required fields for each event type
|
|
310
|
+
REQUIRED_FIELDS: {
|
|
311
|
+
screen: ['imageData', 'format', 'width', 'height'],
|
|
312
|
+
dom: ['html'],
|
|
313
|
+
console: ['level', 'message'],
|
|
314
|
+
user: ['action', 'target'],
|
|
315
|
+
function: ['name', 'status'],
|
|
316
|
+
network: ['url', 'method'],
|
|
317
|
+
state: ['type', 'from', 'to']
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
// Maximum sizes for different data types
|
|
321
|
+
MAX_SIZES: {
|
|
322
|
+
// Maximum image size in bytes (10MB)
|
|
323
|
+
IMAGE_BYTES: 10485760,
|
|
324
|
+
// Maximum HTML size in bytes (1MB)
|
|
325
|
+
HTML_BYTES: 1048576,
|
|
326
|
+
// Maximum log message length
|
|
327
|
+
MESSAGE_LENGTH: 10000,
|
|
328
|
+
// Maximum function trace depth
|
|
329
|
+
TRACE_DEPTH: 100
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
// Event rate limits
|
|
333
|
+
RATE_LIMITS: {
|
|
334
|
+
// Maximum events per second by type
|
|
335
|
+
screen: 10, // 10 screenshots per second max
|
|
336
|
+
dom: 5, // 5 DOM snapshots per second max
|
|
337
|
+
console: 100, // 100 log messages per second max
|
|
338
|
+
user: 50, // 50 user interactions per second max
|
|
339
|
+
function: 1000, // 1000 function calls per second max
|
|
340
|
+
network: 100, // 100 network requests per second max
|
|
341
|
+
state: 20 // 20 state changes per second max
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Error recovery strategies
|
|
347
|
+
*/
|
|
348
|
+
export const ERROR_RECOVERY = {
|
|
349
|
+
// Retry configuration
|
|
350
|
+
RETRY: {
|
|
351
|
+
// Maximum retry attempts
|
|
352
|
+
MAX_ATTEMPTS: 3,
|
|
353
|
+
// Initial delay in milliseconds
|
|
354
|
+
INITIAL_DELAY_MS: 1000,
|
|
355
|
+
// Backoff multiplier
|
|
356
|
+
BACKOFF_MULTIPLIER: 2,
|
|
357
|
+
// Maximum delay in milliseconds
|
|
358
|
+
MAX_DELAY_MS: 30000
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
// Circuit breaker configuration
|
|
362
|
+
CIRCUIT_BREAKER: {
|
|
363
|
+
// Failure count threshold
|
|
364
|
+
FAILURE_THRESHOLD: 5,
|
|
365
|
+
// Time window for failure count (ms)
|
|
366
|
+
FAILURE_WINDOW_MS: 60000,
|
|
367
|
+
// Circuit open duration (ms)
|
|
368
|
+
OPEN_DURATION_MS: 30000,
|
|
369
|
+
// Half-open test interval (ms)
|
|
370
|
+
HALF_OPEN_INTERVAL_MS: 10000
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
// Fallback strategies
|
|
374
|
+
FALLBACK: {
|
|
375
|
+
// Storage fallback chain
|
|
376
|
+
STORAGE_CHAIN: ['database', 'filesystem', 'memory'],
|
|
377
|
+
// Processing fallback (skip on error)
|
|
378
|
+
PROCESSING_SKIP: true,
|
|
379
|
+
// Source failure handling (continue with others)
|
|
380
|
+
SOURCE_ISOLATION: true
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Module dependency graph for initialization order
|
|
386
|
+
*/
|
|
387
|
+
export const DEPENDENCY_GRAPH = {
|
|
388
|
+
// Modules with no dependencies (can start first)
|
|
389
|
+
LEVEL_0: [
|
|
390
|
+
'ICaptureErrorHandler',
|
|
391
|
+
'ICaptureMemoryManager'
|
|
392
|
+
],
|
|
393
|
+
|
|
394
|
+
// Modules depending on level 0
|
|
395
|
+
LEVEL_1: [
|
|
396
|
+
'ICaptureStorage',
|
|
397
|
+
'ICaptureSource'
|
|
398
|
+
],
|
|
399
|
+
|
|
400
|
+
// Modules depending on level 1
|
|
401
|
+
LEVEL_2: [
|
|
402
|
+
'ICaptureProcessor',
|
|
403
|
+
'ICaptureQuery'
|
|
404
|
+
],
|
|
405
|
+
|
|
406
|
+
// Modules depending on level 2
|
|
407
|
+
LEVEL_3: [
|
|
408
|
+
'ICaptureCollector',
|
|
409
|
+
'ICaptureAnalyzer'
|
|
410
|
+
],
|
|
411
|
+
|
|
412
|
+
// Top-level orchestrator
|
|
413
|
+
LEVEL_4: [
|
|
414
|
+
'ICaptureSystem'
|
|
415
|
+
]
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Export architecture configuration
|
|
420
|
+
*/
|
|
421
|
+
export default {
|
|
422
|
+
ARCHITECTURE_CONFIG,
|
|
423
|
+
FLOW_VALIDATION,
|
|
424
|
+
ERROR_RECOVERY,
|
|
425
|
+
DEPENDENCY_GRAPH
|
|
426
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Error Handling System - Testing Strategy
|
|
2
|
+
|
|
3
|
+
## Testing Framework Requirements
|
|
4
|
+
|
|
5
|
+
### Unit Tests
|
|
6
|
+
- **Storage Layer Tests:** Validate chrome.storage.local and IndexedDB operations
|
|
7
|
+
- **State Machine Tests:** Verify all state transitions and actions
|
|
8
|
+
- **Circuit Breaker Tests:** Test failure threshold and recovery behavior
|
|
9
|
+
- **Compression Tests:** Validate data compression/decompression accuracy
|
|
10
|
+
|
|
11
|
+
### Integration Tests
|
|
12
|
+
- **End-to-End Error Scenarios:** Simulate network failures, server errors, storage quota exceeded
|
|
13
|
+
- **Cross-Component Communication:** Test message passing between background script and content scripts
|
|
14
|
+
- **Backup/Recovery Workflows:** Validate complete backup creation and restoration processes
|
|
15
|
+
|
|
16
|
+
### Performance Tests
|
|
17
|
+
- **Memory Usage:** Monitor memory consumption during error scenarios
|
|
18
|
+
- **Storage Efficiency:** Measure compression ratios and storage utilization
|
|
19
|
+
- **Response Times:** Validate error handling doesn't impact normal operation performance
|
|
20
|
+
|
|
21
|
+
### Error Simulation Framework
|
|
22
|
+
```javascript
|
|
23
|
+
const ERROR_SIMULATION = {
|
|
24
|
+
networkFailure: () => { /* Mock network timeout */ },
|
|
25
|
+
serverError: () => { /* Mock HTTP 500 responses */ },
|
|
26
|
+
storageQuotaExceeded: () => { /* Mock storage quota errors */ },
|
|
27
|
+
browserCrash: () => { /* Simulate tab close events */ }
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Validation Checklist
|
|
32
|
+
- [ ] All data protection tiers function correctly
|
|
33
|
+
- [ ] State machine handles all defined transitions
|
|
34
|
+
- [ ] Circuit breaker prevents cascading failures
|
|
35
|
+
- [ ] Backup/recovery processes are reliable
|
|
36
|
+
- [ ] User notifications work across all scenarios
|
|
37
|
+
- [ ] Performance impact is within acceptable limits
|
|
38
|
+
- [ ] Memory leaks are prevented during extended error periods
|