Every component MUST be written with clean, maintainable code. Functions should be short and have single responsibilities. Code structure must be self-documenting and follow established Lua conventions for Neovim plugins. Dependencies MUST be minimal and well-justified.
Core data processing logic MUST favor functional programming patterns. Pure functions SHOULD be used for schema inference, document parsing, and query execution. State management MUST be explicit and isolated to specific modules. Functional approaches SHOULD be preferred over object-oriented patterns for data transformation operations.
All functions, modules, and variables MUST have descriptive names that clearly communicate their purpose. File and directory structure MUST be intuitive and self-explanatory. Code MUST be written primarily for human readability, with execution as a secondary concern.
### IV. Test-First Development (NON-NEGOTIABLE)
TDD is mandatory: Tests MUST be written before implementation. Red-Green-Refactor cycle MUST be strictly enforced. All tests MUST fail initially, then implementation MUST be added to make them pass. Integration tests MUST validate complete user workflows.
### V. Performance by Design
Query execution MUST be non-blocking and feel instantaneous. Database operations MUST be optimized for typical workloads of several thousand documents. Memory usage MUST be controlled and predictable. Performance decisions MUST be justified with measurements.
## Development Workflow
### Code Review Requirements
All changes MUST pass automated tests before integration. Code reviews MUST verify compliance with constitutional principles. Performance impacts MUST be assessed for database and query operations.
### Quality Standards
All public functions MUST have comprehensive documentation. Error handling MUST be explicit and user-friendly. Logging MUST be structured but minimal to avoid noise.
## Technology Constraints
### Language and Platform
Implementation MUST be in Lua compatible with Neovim. Plugin MUST integrate seamlessly with Neovim's native APIs. Cross-platform compatibility MUST be maintained.
### Dependencies
External dependencies MUST be minimal and essential. SQLite usage MUST be justified and optimized. All dependencies MUST be compatible with Neovim's runtime environment.
This constitution supersedes all other development practices. Amendments require documentation, approval, and migration planning. All development activities MUST verify constitutional compliance. Complex deviations MUST be explicitly justified in implementation plans.