# pyscn Analysis Report

Generated: 2025-11-23 21:42:24

Health Score: 63/100 (Grade: C)

## Analysis Summary

### Quality Scores

Complexity 40/100
Avg: 9.5, High-risk: 28
Dead Code 70/100
27 issues, 2 critical
Duplication 30/100
6.0% duplication, 18 groups
Coupling (CBO) 100/100
Avg: 1.5, High-coupling: 0/145
Dependencies 85/100
No cycles, Depth: 7
Architecture 75/100
76% compliant

### File Statistics

252
Total Files
252
Analyzed Files
9.52
Avg Complexity
27
Dead Code Issues
2360
Unique Fragments
6.0%
Code Duplication
145
Total Classes
0
High Coupling (CBO)
1.50
Avg CBO

### Dependencies

252
Total Modules
237
Total Dependencies
7
Max Depth
✅ 0
Circular Dependencies

### Architecture

58
Violations
75.5%
Compliance
4
Layers Analyzed
237
Total Rules

## Complexity Analysis

40/100
567
Total Functions
9.52
Average
62
Maximum

### Top Complex Functions

Function | File | Complexity | Nesting Depth | Risk
--- | --- | --- | --- | ---
main | install.py | 62 | 6 | high
__main__ | src/mcp_memory_service/config.py | 42 | 0 | high
SqliteVecMemoryStorage.initialize | src/mcp_memory_service/storage/sqlite_vec.py | 38 | 10 | high
token | src/mcp_memory_service/web/oauth/authorization.py | 35 | 4 | high
install_package | scripts/installation/install.py | 33 | 4 | high
SqliteVecMemoryStorage._initialize_embedding_model | src/mcp_memory_service/storage/sqlite_vec.py | 33 | 6 | high
detect_gpu | scripts/installation/install.py | 30 | 8 | high
detect_gpu | install.py | 30 | 8 | high
verify_installation | install.py | 30 | 5 | high
test_memory_crud | scripts/testing/test_memory_api.py | 30 | 6 | high

Showing top 10 of 567 functions

## Dead Code Detection

70/100
27
Total Issues
2
Critical
25
Warnings

### Top Dead Code Issues

File | Function | Lines | Severity | Reason
--- | --- | --- | --- | ---
scripts/installation/install.py | configure_paths | 1361-1365 | critical | unreachable_after_return
scripts/installation/install.py | configure_paths | 1367-1436 | warning | unreachable_branch
scripts/installation/install.py | configure_paths | 1368-1436 | warning | unreachable_branch
scripts/installation/install.py | configure_paths | 1369-1369 | warning | unreachable_branch
scripts/installation/install.py | configure_paths | 1371-1371 | warning | unreachable_branch
scripts/installation/install.py | configure_paths | 1372-1373 | warning | unreachable_branch
scripts/installation/install.py | configure_paths | 1373-1373 | warning | unreachable_branch
scripts/installation/install.py | configure_paths | 1376-1377 | warning | unreachable_branch
scripts/installation/install.py | configure_paths | 1377-1377 | warning | unreachable_branch
scripts/installation/install.py | configure_paths | 1380-1388 | warning | unreachable_branch

Showing top 10 of 27 dead code issues

## Clone Detection

30/100
2360
Unique Fragments
18
Clone Groups
1.00
Avg Similarity

### Clone Groups

Code fragments grouped by similarity

#### Group 17 - 5 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
tests/unit/test_csv_loader.py | 135-146 | 12 lines
tests/unit/test_csv_loader.py | 155-168 | 14 lines
tests/unit/test_csv_loader.py | 177-189 | 13 lines
tests/unit/test_csv_loader.py | 269-282 | 14 lines
tests/unit/test_json_loader.py | 125-147 | 23 lines

#### Group 5 - 4 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
install.py | 1509-1522 | 14 lines
scripts/database/db_health_check.py | 233-249 | 17 lines
scripts/installation/install.py | 1314-1327 | 14 lines
scripts/installation/install.py | 1334-1347 | 14 lines

#### Group 7 - 4 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
install.py | 2862-2873 | 12 lines
install.py | 2892-2903 | 12 lines
scripts/installation/install.py | 1785-1796 | 12 lines
scripts/installation/install.py | 1817-1828 | 12 lines

#### Group 16 - 4 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
tests/unit/test_csv_loader.py | 88-103 | 16 lines
tests/unit/test_csv_loader.py | 112-126 | 15 lines
tests/unit/test_csv_loader.py | 244-260 | 17 lines
tests/unit/test_json_loader.py | 215-234 | 20 lines

#### Group 0 - 3 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
claude-hooks/install_hooks.py | 180-203 | 24 lines
scripts/testing/test_memory_simple.py | 91-102 | 12 lines
scripts/testing/test_search_api.py | 79-96 | 18 lines

#### Group 1 - 3 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
install.py | 327-358 | 32 lines
scripts/installation/install.py | 274-305 | 32 lines
scripts/validation/verify_environment.py | 126-159 | 34 lines

#### Group 2 - 3 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
install.py | 344-358 | 15 lines
scripts/installation/install.py | 291-305 | 15 lines
scripts/validation/verify_environment.py | 144-159 | 16 lines

#### Group 3 - 3 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
install.py | 363-383 | 21 lines
scripts/installation/install.py | 310-330 | 21 lines
scripts/validation/verify_environment.py | 162-183 | 22 lines

#### Group 6 - 3 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
install.py | 2313-2356 | 44 lines
install.py | 2383-2421 | 39 lines
install.py | 2425-2463 | 39 lines

#### Group 8 - 3 clones (Type Type-1, similarity: 1.00)

File | Lines | Size
--- | --- | ---
install.py | 3124-3151 | 28 lines
install.py | 3127-3145 | 19 lines
scripts/installation/install.py | 1927-1945 | 19 lines

Showing top 10 of 18 clone groups

## Class Coupling

100/100

Coupling Between Objects (CBO) metrics

145
Total Classes
0
High Risk Classes
1.50
Average CBO
4
Max CBO

### Most Dependent Classes

Class | File | CBO | Risk Level | Dependent Classes
--- | --- | --- | --- | ---
ConsolidationHealthMonitor | src/mcp_memory_service/consolidation/health.py | 4 | low | HealthMetric, HealthAlert, Any, HealthStatus
ControlledForgettingEngine | src/mcp_memory_service/consolidation/forgetting.py | 3 | low | ConsolidationBase, ForgettingCandidate, ForgettingResult
StorageStats | src/mcp_memory_service/web/api/analytics.py | 3 | low | BaseModel, LargestMemory, GrowthTrendPoint
HybridMemoryStorage | src/mcp_memory_service/storage/hybrid.py | 3 | low | MemoryStorage, BackgroundSyncService, SyncOperation
HTTPClientStorage | src/mcp_memory_service/storage/http_client.py | 3 | low | MemoryStorage, Any, Memory
CloudflareStorage | src/mcp_memory_service/storage/cloudflare.py | 3 | low | Any, Memory, MemoryStorage
ServiceDiscovery | src/mcp_memory_service/discovery/mdns_service.py | 3 | low | AsyncZeroconf, AsyncServiceBrowser, DiscoveryListener
CacheManager | src/mcp_memory_service/utils/cache_manager.py | 2 | low | Any, CacheStats
MemoryResult | src/mcp_memory_service/services/memory_service.py | 2 | low | TypedDict, Any
SSEManager | src/mcp_memory_service/web/sse.py | 2 | low | Any, SSEEvent

Showing top 10 of 145 classes

## Module Dependencies

85/100

Project-wide module dependency graph metrics

252
Total Modules
237
Total Dependencies
7
Max Depth
✅ 0
Circular Dependencies

### Circular Dependencies

✅ No circular dependencies detected

All modules have acyclic dependency relationships.

### Longest Dependency Chains

# | Depth | Path
--- | --- | ---
1 | 6 | src.mcp_memory_service.web.app → src.mcp_memory_service.web.api.mcp → src.mcp_memory_service.web.dependencies → src.mcp_memory_service.services.memory_service → src.mcp_memory_service.storage.base → src.mcp_memory_service.models.memory
2 | 6 | src.mcp_memory_service.discovery → src.mcp_memory_service.api.client → src.mcp_memory_service.storage.factory → src.mcp_memory_service.storage.sqlite_vec → src.mcp_memory_service.consolidation.base → src.mcp_memory_service.models.memory
3 | 6 | src.mcp_memory_service.web.api.events → src.mcp_memory_service.web.dependencies → src.mcp_memory_service.storage.factory → src.mcp_memory_service.storage.sqlite_vec → src.mcp_memory_service.consolidation.base → src.mcp_memory_service.models.memory
4 | 5 | src.mcp_memory_service.api.operations → src.mcp_memory_service.api.client → src.mcp_memory_service.storage.factory → src.mcp_memory_service.storage.sqlite_vec → src.mcp_memory_service.config
5 | 5 | src.mcp_memory_service.discovery → src.mcp_memory_service.api.client → src.mcp_memory_service.storage.factory → src.mcp_memory_service.consolidation.base → src.mcp_memory_service.models.memory
6 | 5 | src.mcp_memory_service.web.app → src.mcp_memory_service.web.api.mcp → src.mcp_memory_service.web.dependencies → src.mcp_memory_service.services.memory_service → src.mcp_memory_service.storage.base
7 | 5 | src.mcp_memory_service.web.app → src.mcp_memory_service.web.api.mcp → src.mcp_memory_service.web.dependencies → src.mcp_memory_service.services.memory_service → src.mcp_memory_service.utils.hashing
8 | 5 | src.mcp_memory_service.web.app → src.mcp_memory_service.web.api.mcp → src.mcp_memory_service.web.dependencies → src.mcp_memory_service.services.memory_service → src.mcp_memory_service.models.memory
9 | 5 | src.mcp_memory_service.web.app → src.mcp_memory_service.web.api.mcp → src.mcp_memory_service.web.dependencies → src.mcp_memory_service.services.memory_service → src.mcp_memory_service.utils.content_splitter
10 | 5 | src.mcp_memory_service.web.api.mcp → src.mcp_memory_service.web.dependencies → src.mcp_memory_service.services.memory_service → src.mcp_memory_service.storage.base → src.mcp_memory_service.models.memory

## Architecture Validation

75/100
4
Layers Analyzed
237
Total Rules
58
Violations
75.5%
Compliance

### Top Rule Violations

Severity | Rule | From | To
--- | --- | --- | ---
error | application -> {application,domain,infrastructure} | scripts.backup.backup_memories | src.mcp_memory_service.config
error | infrastructure -> {infrastructure,domain,application} | scripts.backup.restore_memories | src.mcp_memory_service.config
error | domain !> presentation | scripts.maintenance.cleanup_memories | src.mcp_memory_service.config
error | application -> {application,domain,infrastructure} | scripts.maintenance.regenerate_embeddings | src.mcp_memory_service.config
error | infrastructure -> {infrastructure,domain,application} | scripts.maintenance.repair_malformed_tags | src.mcp_memory_service.config
error | domain !> presentation | src.mcp_memory_service.api.client | src.mcp_memory_service.config
error | domain !> presentation | src.mcp_memory_service.api.operations | src.mcp_memory_service.api.sync_wrapper
error | domain !> presentation | src.mcp_memory_service.backup.scheduler | src.mcp_memory_service.config
error | domain !> presentation | src.mcp_memory_service.cli.main | src.mcp_memory_service.server
error | domain !> presentation | src.mcp_memory_service.cli.utils | src.mcp_memory_service.config
error | domain !> application | src.mcp_memory_service.consolidation.associations | src.mcp_memory_service.consolidation.base
error | domain !> application | src.mcp_memory_service.consolidation.clustering | src.mcp_memory_service.consolidation.base
error | domain !> application | src.mcp_memory_service.consolidation.compression | src.mcp_memory_service.consolidation.base
error | domain !> application | src.mcp_memory_service.consolidation.consolidator | src.mcp_memory_service.consolidation.base
error | domain !> presentation | src.mcp_memory_service.consolidation.consolidator | src.mcp_memory_service.consolidation.decay
error | domain !> application | src.mcp_memory_service.consolidation.consolidator | src.mcp_memory_service.consolidation.forgetting
error | domain !> presentation | src.mcp_memory_service.consolidation.consolidator | src.mcp_memory_service.consolidation.health
error | application -> {application,domain,infrastructure} | src.mcp_memory_service.consolidation.forgetting | src.mcp_memory_service.consolidation.decay
error | domain !> application | src.mcp_memory_service.consolidation.scheduler | src.mcp_memory_service.consolidation.base
error | domain !> presentation | src.mcp_memory_service.discovery.client | src.mcp_memory_service.config