Version: 1.0
Last Updated: 2025-01-XX
Purpose: Define code, documentation, and testing standards for Sentinel
Files: snake_case.rs, kebab-case.tsx
Functions: camelCase() or snake_case() (language dependent)
Classes: PascalCase
Constants: SCREAMING_SNAKE_CASE
Private: _leadingUnderscore
src/
├── core/ # Core business logic
├── cli/ # CLI interface
├── gui/ # Desktop GUI
├── utils/ # Shared utilities
└── types/ # Type definitions
- What needs comments: Complex algorithms, non-obvious decisions, workarounds
- What doesn't: Self-explanatory code
- Format:
// Single lineor/* Multi-line */
// ✅ Good: Descriptive errors
throw new Error("Failed to start process 'api': Port 3000 already in use");
// ❌ Bad: Generic errors
throw new Error("Error");Every public function must have:
- Description (what it does)
- Parameters (type + description)
- Return value
- Example usage
- Errors thrown
Example:
/// Starts a process with the given configuration.
///
/// # Arguments
/// * `config` - Process configuration including name, command, and options
///
/// # Returns
/// * `Ok(ProcessHandle)` - Handle to the running process
/// * `Err(ProcessError)` - If process fails to start
///
/// # Example
/// ```
/// let handle = start_process(&config)?;
/// ```
pub fn start_process(config: &ProcessConfig) -> Result<ProcessHandle> {
// ...
}- Top of each module: Purpose, responsibilities, usage example
- Auto-generate from inline docs
- Keep docs close to code
- Minimum: 90% line coverage
- Target: 95% line coverage
- Critical paths: 100% coverage (process lifecycle, config parsing)
tests/
├── unit/ # Test individual functions
├── integration/ # Test component interactions
└── e2e/ # Test full workflows
#[test]
fn test_process_starts_successfully() { }
#[test]
fn test_process_fails_when_port_in_use() { }
#[test]
fn test_config_validation_rejects_invalid_yaml() { }✅ Public APIs
✅ Error conditions
✅ Edge cases
✅ Integration points
❌ Private implementation details
❌ External dependencies (mock them)
# Run all tests
make test
# Run with coverage
make test-coverage
# Run specific test
make test-unit NAME=process_managerfeature/process-manager
fix/memory-leak
docs/api-reference
refactor/config-system
feat: Add process auto-restart functionality
fix: Resolve memory leak in log viewer
docs: Update installation instructions
test: Add integration tests for CLI
refactor: Simplify config validation logic
- ✅ All tests pass
- ✅ Code coverage ≥ 90%
- ✅ Documentation updated
- ✅ No linter warnings
- ✅ Changelog entry added
- Validate all user input (config files, CLI args)
- Sanitize process commands (prevent injection)
- Validate file paths (no traversal)
- Request minimum necessary privileges
- Drop privileges when not needed
- Never run processes as root
- Audit dependencies weekly (
cargo audit,npm audit) - Use known-good versions
- Lock dependencies (Cargo.lock, package-lock.json)
- No secrets in logs
- Secure temp file creation
- Clean up resources on exit
- Target: < 1.5 seconds
- Max: 2 seconds
- Test:
time sentinel start
- Idle: < 50MB
- 10 processes: < 100MB
- 100 processes: < 250MB
- Idle: < 2%
- Active monitoring: < 5%
- Follow Semantic Versioning (semver)
- Format:
MAJOR.MINOR.PATCH - Example:
1.0.0,1.1.0,1.1.1
- All tests pass
- Documentation updated
- CHANGELOG updated
- Version bumped
- Binaries built for all platforms
- Release notes written
- GitHub release created
- Packages published (brew, npm, cargo)
- Code follows standards
- Tests are comprehensive
- Documentation is clear
- No security issues
- Performance is acceptable
- Changes are necessary
- Clear PR description
- Link to related issue
- Screenshots (if UI change)
- Performance benchmarks (if applicable)
Remember: These standards ensure Sentinel remains maintainable, secure, and performant. When in doubt, prioritize security and user experience.