This project implements a preference injection system that allows dynamic modification of user preferences or settings in applications. The system is designed to inject, override, or manage user preferences at runtime.
Built with ReScript and Deno following the Hyperpolymath Language Standard.
| Language/Tool | Use Case |
|---|---|
| ReScript | Primary application code |
| Deno | Runtime & package management |
| Rust | Performance-critical extensions |
| Bash/POSIX Shell | Scripts, automation |
| Nickel | Configuration language |
| JavaScript | Only compiled output from ReScript |
| Banned | Replacement |
|---|---|
| TypeScript | ReScript |
| Node.js | Deno |
| npm/yarn/pnpm | Deno imports |
| Bun | Deno |
| Go | Rust |
| Makefile | Justfile |
preference-injector/
├── src/rescript/ # ReScript source code
│ ├── core/ # Core injection logic
│ ├── providers/ # Preference providers
│ ├── utils/ # Utility functions
│ ├── types/ # Type definitions
│ ├── errors/ # Error handling
│ ├── crdt/ # CRDT implementations
│ └── crypto/ # Cryptographic utilities
├── tests/rescript/ # ReScript tests
├── examples/ # Usage examples
├── docs/ # Documentation
├── deno.json # Deno configuration
├── bsconfig.json # ReScript configuration
├── Justfile # Task runner (NOT Makefile)
├── Mustfile.epx # Deployment state contract
└── config.ncl # Nickel configuration
- Deno >= 1.40.0
- ReScript >= 11.0.0
- Just (task runner)
# No npm install - Deno handles dependencies
just install # Verifies ReScript is installedjust build # Build ReScript codejust test # Run all testsjust dev # Watch mode with auto-rebuild- Injector: Main module responsible for injecting preferences into target applications
- Providers: Sources of preference data (file-based, API-based, environment variables)
- ConflictResolver: Logic for resolving preference conflicts and priorities
- Validator: Ensure preference values are valid and safe
- CRDT: Distributed synchronization with conflict-free data types
- Crypto: Secure encryption and hashing (no MD5/SHA1)
- Preference Sources: Where preferences originate (config files, databases, APIs)
- Injection Points: Where preferences are applied in the application
- Priority Levels: Mechanism for handling conflicting preferences
- Validation Rules: Constraints and validation for preference values
- Use pattern matching over if/else chains
- Leverage the type system - avoid
Obj.magic - Use labeled arguments for clarity
- Prefer pipe operators (
->) for data transformation - Use Result types for error handling
- Files:
PascalCase.res(ReScript convention) - Modules:
PascalCase - Functions/Values:
camelCase - Constants:
camelCaseorUPPER_SNAKE_CASE - Types:
camelCase(ReScript convention)
- Use 2 spaces for indentation
- Add SPDX license headers to all files
- Use async/await for async operations
- Prefer immutable data structures
- Use Result types (
Ok/Error) for recoverable errors - Use custom error records with
errorCodeandmessage - Log errors appropriately
- Unit tests: Test individual modules in isolation
- Integration tests: Test module interactions
- All tests written in ReScript and run via Deno
- Coverage target: >80%
- Tests:
*_test.res
- Input Validation: Always validate preference values before injection
- Sanitization: Sanitize user-provided preferences
- Encryption: AES-256-GCM for sensitive preferences
- Hashing: SHA-256+ only (NO MD5/SHA1)
- Audit Logging: Track all preference changes
- Cache frequently accessed preferences
- Use lazy loading for large preference sets
- Use LWW-Map for distributed state
- Avoid synchronous blocking operations
- Batch preference updates when possible
- Create new provider module in
src/rescript/providers/ - Follow the existing provider pattern
- Add validation logic
- Write tests in
tests/rescript/ - Update documentation
- Add rule to
Validator.CommonRulesmodule - Add test cases
- Update documentation
Dependencies are managed via deno.json imports:
- No
package.jsonornode_modules - All npm packages accessed via
npm:specifier
Preference not being injected
- Check provider configuration
- Verify injection point is registered
- Check priority settings
- Review validation rules
Build failures
- Run
rescript cleanthenrescript build - Check for syntax errors in .res files
- Verify bsconfig.json is correct
Type errors
- ReScript provides excellent error messages
- Check pattern matching exhaustiveness
- Verify function signatures
Detailed API documentation is available in docs/API.md.
When adding new features:
- Create feature branch from main
- Write tests first (TDD approach preferred)
- Implement feature in ReScript
- Ensure all tests pass (
just test) - Run
just cifor full pipeline - Update documentation
- Create pull request
IMPORTANT: TypeScript, Node.js, npm, and Makefile contributions will be rejected.
PREF_SOURCE=file|api|env
PREF_CACHE_TTL=3600
PREF_VALIDATION_STRICT=true
LOG_LEVEL=info|debug|error- Main branch:
main(protected) - Feature branches:
feature/<description> - Bug fixes:
fix/<description> - Claude AI branches:
claude/*
Use just for all development tasks:
just # List all commands
just build # Build ReScript
just test # Run tests
just ci # Full CI pipeline
just rsr-verify # RSR compliance checkDo NOT use make/Makefile - use Justfile instead.
- All source code is ReScript (compiles to JavaScript)
- Runtime is Deno (not Node.js)
- Configuration uses Nickel for type safety
- Deployment managed via Mustfile.epx
- Document all breaking changes in CHANGELOG.md