|
| 1 | +@startuml Symphony Class Diagram |
| 2 | +' Symphony CLI - Core Architecture |
| 3 | +' Design Patterns: Registry, Plugin, Strategy, Dual Schema |
| 4 | + |
| 5 | +skinparam classAttributeIconSize 0 |
| 6 | +skinparam linetype ortho |
| 7 | + |
| 8 | +package "Schema (Dual Schema Pattern)" { |
| 9 | + class UserPolicy <<A Schema>> { |
| 10 | + +Version: string |
| 11 | + +RBAC: UserRBAC |
| 12 | + +Rules: []UserRule |
| 13 | + -- |
| 14 | + Natural language rules |
| 15 | + for human authoring |
| 16 | + } |
| 17 | + |
| 18 | + class CodePolicy <<B Schema>> { |
| 19 | + +Version: string |
| 20 | + +RBAC: PolicyRBAC |
| 21 | + +Rules: []PolicyRule |
| 22 | + +Enforce: EnforceSettings |
| 23 | + -- |
| 24 | + Formal rules for |
| 25 | + machine execution |
| 26 | + } |
| 27 | + |
| 28 | + class PolicyRule { |
| 29 | + +ID: string |
| 30 | + +Selector: Selector |
| 31 | + +Engine: string |
| 32 | + +Check: map |
| 33 | + } |
| 34 | + |
| 35 | + class Selector { |
| 36 | + +Languages: []string |
| 37 | + +Include: []string |
| 38 | + +Exclude: []string |
| 39 | + +Roles: []string |
| 40 | + } |
| 41 | + |
| 42 | + UserPolicy ..> CodePolicy : "LLM converts" |
| 43 | + CodePolicy *-- PolicyRule |
| 44 | + PolicyRule *-- Selector |
| 45 | +} |
| 46 | + |
| 47 | +package "Linter (Plugin Pattern)" { |
| 48 | + interface Linter <<interface>> { |
| 49 | + +Name(): string |
| 50 | + +GetCapabilities(): Capabilities |
| 51 | + +CheckAvailability(ctx): error |
| 52 | + +Execute(ctx, config, files): ToolOutput |
| 53 | + +ParseOutput(output): []Violation |
| 54 | + } |
| 55 | + |
| 56 | + interface Converter <<interface>> { |
| 57 | + +Name(): string |
| 58 | + +GetLLMDescription(): string |
| 59 | + +GetRoutingHints(): []string |
| 60 | + +ConvertSingleRule(ctx, rule): SingleRuleResult |
| 61 | + +BuildConfig(results): LinterConfig |
| 62 | + } |
| 63 | + |
| 64 | + class Registry <<singleton>> { |
| 65 | + -tools: map[string]ToolEntry |
| 66 | + +RegisterTool(linter, converter, configFile) |
| 67 | + +GetAllTools(): []ToolEntry |
| 68 | + +GetByName(name): ToolEntry |
| 69 | + } |
| 70 | + |
| 71 | + class ESLint implements Linter |
| 72 | + class Prettier implements Linter |
| 73 | + class TSC implements Linter |
| 74 | + class PyLint implements Linter |
| 75 | + |
| 76 | + Registry o-- Linter : registers |
| 77 | + Registry o-- Converter : registers |
| 78 | +} |
| 79 | + |
| 80 | +package "LLM Provider (Strategy Pattern)" { |
| 81 | + interface Provider <<interface>> { |
| 82 | + +Name(): string |
| 83 | + +Execute(ctx, prompt, format): string |
| 84 | + } |
| 85 | + |
| 86 | + class ClaudeCode implements Provider |
| 87 | + class GeminiCLI implements Provider |
| 88 | + class OpenAIAPI implements Provider |
| 89 | +} |
| 90 | + |
| 91 | +package "Validator (Execution Unit Pattern)" { |
| 92 | + class Validator { |
| 93 | + +ValidateChanges(changes): ValidationResult |
| 94 | + -createExecutionUnits(): []ExecutionUnit |
| 95 | + -executeInParallel(units): []Violation |
| 96 | + } |
| 97 | + |
| 98 | + interface ExecutionUnit <<interface>> { |
| 99 | + +Execute(ctx): []Violation |
| 100 | + +GetRuleIDs(): []string |
| 101 | + +GetEngineName(): string |
| 102 | + +GetFiles(): []string |
| 103 | + } |
| 104 | + |
| 105 | + class LinterExecutionUnit implements ExecutionUnit { |
| 106 | + Batch: all files, all rules |
| 107 | + Single linter invocation |
| 108 | + } |
| 109 | + |
| 110 | + class LLMExecutionUnit implements ExecutionUnit { |
| 111 | + Granular: one file, one rule |
| 112 | + Parallel LLM calls |
| 113 | + } |
| 114 | + |
| 115 | + Validator --> ExecutionUnit : creates |
| 116 | + LinterExecutionUnit --> Linter : uses |
| 117 | + LLMExecutionUnit --> Provider : uses |
| 118 | +} |
| 119 | + |
| 120 | +package "MCP Server" { |
| 121 | + class MCPServer { |
| 122 | + +query_conventions(category, languages): string |
| 123 | + +validate_code(role): ValidationResult |
| 124 | + } |
| 125 | + |
| 126 | + MCPServer --> Validator : delegates |
| 127 | + MCPServer --> UserPolicy : reads |
| 128 | +} |
| 129 | + |
| 130 | +package "RBAC" { |
| 131 | + class RBACChecker { |
| 132 | + +CheckPermission(role, file): bool |
| 133 | + +GetDeniedFiles(role, files): []string |
| 134 | + } |
| 135 | + |
| 136 | + Validator --> RBACChecker : "first check" |
| 137 | +} |
| 138 | + |
| 139 | +' Key relationships |
| 140 | +Validator --> CodePolicy : validates against |
| 141 | +Converter ..> Provider : "uses for conversion" |
| 142 | + |
| 143 | +note bottom of Registry |
| 144 | + Self-registration via init() |
| 145 | + in each linter package |
| 146 | +end note |
| 147 | + |
| 148 | +note bottom of ExecutionUnit |
| 149 | + Linters: Batched for efficiency |
| 150 | + LLM: Granular for parallelism |
| 151 | +end note |
| 152 | + |
| 153 | +@enduml |
0 commit comments