3 Commits

Author SHA1 Message Date
4cae73faf6 Update .cursorrules with type-driven design principles
Document design preferences observed in this project:

Principles:
- Parse, Don't Validate (newtype wrappers with validation)
- Correctness by Construction (illegal states unrepresentable)
- Functional Core, Imperative Shell (pure domain + DI)
- Ghost of Departed Proofs (proof tokens like ValidConfigToken)

Guidelines:
- Module organization (single responsibility, < 300 lines)
- Error handling (Result types, structured logging)
- Code quality (no dead code, comprehensive tests)
- Testing strategy (pure functions, mocks, isolation)

These rules capture the architectural decisions made throughout
the sqlite-serve implementation.
2025-11-15 17:30:12 -08:00
0c0a44a533 Integrate domain.rs functional core into handler (DI architecture)
Now Actually Using:
- ValidatedConfig: Parse config into validated types at request time
- ParameterBinding: Type-safe parameter representation
- RequestProcessor: Pure business logic with injected dependencies
- resolve_template_path(): Pure function for path resolution
- resolve_parameters(): Pure parameter resolution

New Adapters (adapters.rs):
- NginxVariableResolver: Implements VariableResolver trait
- SqliteQueryExecutor: Implements QueryExecutor trait
- HandlebarsAdapter: Implements TemplateLoader + TemplateRenderer

Handler Flow (Functional Core, Imperative Shell):
1. Parse strings into validated types (types.rs)
2. Create validated config (domain.rs)
3. Resolve template path (pure function)
4. Create adapters (adapters.rs - imperative shell)
5. Call RequestProcessor.process() (pure core)
6. Return HTML (imperative shell)

Benefits:
✓ Type validation happens at request time
✓ Invalid queries caught early (SELECT-only enforced)
✓ Core business logic is pure and testable
✓ Real DI: can swap implementations via traits
✓ Clear separation of concerns

Test Coverage: 47 tests (added 2 adapter tests)
Production: Verified working with all features

The architecture documented in ARCHITECTURE.md is now actually implemented!
2025-11-15 16:48:54 -08:00
63fbee6694 Fix ngx 0.5.0 API compatibility
- Update HttpModule trait implementation to match ngx 0.5.0 API
- Implement HttpModuleLocationConf as separate unsafe trait
- Fix configuration access using Module::location_conf()
- Replace ngx_null_command macro with explicit null command
- Update imports to use correct constant names
- Suppress C FFI naming convention warnings
2025-11-15 14:26:39 -08:00