-
Notifications
You must be signed in to change notification settings - Fork 0
Enforce orchestrator architecture with ESLint rules #19
Copy link
Copy link
Open
Description
Goal
Enforce the orchestrator architecture patterns using ESLint rules to prevent common violations.
Architectural Rules to Enforce
For Orchestrators
- No
newkeyword - All dependencies must be injected via constructor - No template literals - Prevent report generation (orchestrators return raw data only)
- No audience-based decisions - No if statements or conditionals based on audience parameter
- Must implement proper interface - All orchestrators must have an
execute()method returningLLMInfo - Constructor must accept dependencies - Enforce at least one parameter (dependency injection)
For Services
- Must implement interfaces - All services should implement a defined interface
- No LLMInfo in services - Services return typed data, not LLMInfo
- Async methods only - All public methods should return promises
For DTOs and Data Keys (NEW)
- No magic strings - All data keys must be defined as constants
- DTOs must implement ILLMDataDTO - Enforce interface implementation
- Prefer addDataFromDTO - Warn when using
addDatadirectly instead ofaddDataFromDTO - DTO keys must be const - DTO classes must define their keys as
private static readonly Keys - Explicit return types - All methods must have explicit return types
Implementation Ideas
Option 1: Custom ESLint Plugin
Create eslint-plugin-orchestrator with rules:
orchestrator/no-new-in-bodyorchestrator/no-template-literalsorchestrator/no-audience-decisionsorchestrator/require-di-constructorservice/implement-interfaceservice/no-llminfo-returndto/implement-interface(NEW)dto/no-magic-strings(NEW)dto/require-const-keys(NEW)general/prefer-addDataFromDTO(NEW)general/explicit-return-types(NEW)
Option 2: Use Existing Rules + Custom Config
- Use
no-restricted-syntaxfor AST-based checks - Use
@typescript-eslintrules for type checking - Create custom rule set for orchestrator files
- Use
@typescript-eslint/explicit-function-return-typefor return types
Option 3: Build-time TypeScript Checks
- Use TypeScript compiler API
- Create custom transformer
- Enforce at compile time rather than lint time
Acceptance Criteria
- ESLint catches when orchestrator creates new service instance
- ESLint catches when orchestrator generates formatted text
- ESLint catches audience-based conditionals
- ESLint catches magic strings in data keys
- ESLint enforces DTO interface implementation
- ESLint prefers addDataFromDTO over direct addData
- ESLint enforces explicit return types
- Rules are integrated into CI pipeline
- Clear error messages guide developers to correct patterns
References
- Architecture docs: cc-commands-ts/docs/Architecture.md
- DTO Architecture: cc-commands-ts/docs/DTOArchitecture.md
- Orchestrator patterns: cc-commands-ts/docs/archive/OrchestratorArchitecture.md
- Service patterns: cc-commands-ts/docs/ServicePatterns.md
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels