9.5 KiB
Contributing to Psycho-Symbolic Reasoner
Thank you for your interest in contributing to the Psycho-Symbolic Reasoner! This document provides guidelines and information for contributors.
🤝 Code of Conduct
We are committed to providing a welcoming and inclusive environment for all contributors. Please read and follow our Code of Conduct.
🚀 Getting Started
Prerequisites
- Node.js: Version 18.0.0 or higher
- Rust: Latest stable version (install via rustup)
- wasm-pack: For building WebAssembly modules
- Git: For version control
Development Setup
-
Fork and clone the repository:
git clone https://github.com/your-username/sublinear-time-solver.git cd sublinear-time-solver/psycho-symbolic-reasoner -
Install dependencies:
npm install -
Build the project:
npm run build -
Run tests:
npm test -
Start development server:
npm run dev:serve
📋 Development Workflow
Branch Strategy
main- Production-ready codedevelop- Integration branch for featuresfeature/*- Feature development branchesbugfix/*- Bug fix brancheshotfix/*- Critical fixes for production
Making Changes
-
Create a feature branch:
git checkout -b feature/your-feature-name -
Make your changes following our coding standards
-
Write or update tests for your changes
-
Run the test suite:
npm test npm run lint npm run typecheck -
Commit your changes using conventional commits:
git commit -m "feat: add new reasoning algorithm" -
Push and create a pull request
🎯 Types of Contributions
🐛 Bug Reports
When reporting bugs, please include:
- Clear description of the issue
- Steps to reproduce the problem
- Expected vs actual behavior
- Environment details (OS, Node.js version, etc.)
- Relevant logs or error messages
Use our bug report template.
✨ Feature Requests
For new features, please provide:
- Clear use case and motivation
- Detailed description of the proposed feature
- Potential implementation approach
- Examples of how it would be used
Use our feature request template.
📚 Documentation
Documentation improvements are always welcome:
- API documentation improvements
- Tutorial and example additions
- README enhancements
- Code comments and inline documentation
🧪 Testing
Help improve our test coverage:
- Unit tests for Rust components
- Integration tests for TypeScript layer
- End-to-end tests for CLI and MCP functionality
- Performance benchmarks
💻 Coding Standards
Rust Code
- Follow Rust API Guidelines
- Use
cargo fmtfor formatting - Use
cargo clippyfor linting - Write comprehensive unit tests
- Document public APIs with rustdoc
/// Extracts sentiment from text input
///
/// # Arguments
/// * `text` - The input text to analyze
///
/// # Returns
/// * `SentimentResult` - Analysis results with score and confidence
///
/// # Examples
/// ```
/// let result = extract_sentiment("I love this!");
/// assert!(result.score > 0.5);
/// ```
pub fn extract_sentiment(text: &str) -> SentimentResult {
// Implementation...
}
TypeScript Code
- Follow TypeScript ESLint rules
- Use Prettier for code formatting
- Write JSDoc comments for public APIs
- Prefer functional programming patterns
- Use strict type checking
/**
* Creates a new planning instance with the given configuration
*
* @param config - Planner configuration options
* @returns Promise resolving to configured planner instance
*
* @example
* ```typescript
* const planner = await createPlanner({
* rulesPath: './rules.json',
* enableLogging: true
* });
* ```
*/
export async function createPlanner(config: PlannerConfig): Promise<Planner> {
// Implementation...
}
Commit Messages
We use Conventional Commits:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changesstyle:- Code style changes (no logic changes)refactor:- Code refactoringtest:- Test additions or modificationschore:- Build process or auxiliary tool changes
Examples:
feat: add sentiment analysis caching
fix: resolve memory leak in graph traversal
docs: update MCP integration examples
test: add integration tests for planner
🧪 Testing Guidelines
Unit Tests
Write unit tests for all new functionality:
Rust tests:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_sentiment_analysis() {
let result = extract_sentiment("I'm happy!");
assert!(result.score > 0.0);
assert_eq!(result.primary_emotion, "joy");
}
}
TypeScript tests:
import { test } from 'node:test';
import { strictEqual } from 'node:assert';
import { PsychoSymbolicReasoner } from '../src/index.js';
test('should initialize reasoner correctly', async () => {
const reasoner = new PsychoSymbolicReasoner();
await reasoner.initialize();
strictEqual(reasoner.isReady(), true);
});
Integration Tests
Test component interactions:
test('MCP integration end-to-end', async () => {
const server = new MCPServer();
await server.start();
const response = await server.callTool('extractSentiment', {
text: 'I love this framework!'
});
strictEqual(response.score > 0.5, true);
});
Performance Tests
Include performance benchmarks for critical paths:
test('graph query performance', async () => {
const start = performance.now();
await reasoner.queryGraph(complexQuery);
const duration = performance.now() - start;
// Should complete within 100ms for 1000 node graph
assert(duration < 100);
});
📦 Build and Release Process
Local Development
# Build everything
npm run build
# Build with watch mode
npm run build:dev
# Test with coverage
npm run test
# Lint and format
npm run lint:fix
npm run format
# Type checking
npm run typecheck
Release Process
- Update version in
package.json - Update CHANGELOG.md with new features and fixes
- Run full test suite:
npm test - Build production version:
npm run build - Create release PR to
mainbranch - Tag release after merge:
git tag v1.0.1 - Publish to NPM:
npm publish
🏗️ Architecture Guidelines
Project Structure
psycho-symbolic-reasoner/
├── src/ # TypeScript source
│ ├── cli/ # CLI interface
│ ├── mcp/ # MCP server and tools
│ ├── api/ # REST API
│ ├── lib/ # Core library
│ └── types/ # TypeScript definitions
├── graph_reasoner/ # Rust graph reasoning
├── extractors/ # Rust affect/preference extraction
├── planner/ # Rust planning algorithms
├── tests/ # Test suites
├── examples/ # Usage examples
├── docs/ # Documentation
└── benchmarks/ # Performance tests
Design Principles
- Separation of Concerns: Keep Rust performance-critical code separate from TypeScript integration
- Type Safety: Use strict TypeScript and Rust type systems
- Performance First: Optimize hot paths, especially in Rust core
- Security: Maintain WASM sandboxing and input validation
- Extensibility: Design for easy addition of new reasoning modules
- Documentation: Code should be self-documenting with comprehensive comments
Adding New Features
- Rust Core: Implement performance-critical algorithms in Rust
- WASM Bindings: Create TypeScript bindings for Rust functionality
- TypeScript API: Provide high-level, easy-to-use TypeScript APIs
- MCP Integration: Expose functionality as MCP tools when applicable
- CLI Support: Add CLI commands for new features
- Documentation: Update docs and examples
🔧 Troubleshooting
Common Issues
WASM build failures:
# Reinstall wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# Clean and rebuild
npm run clean
npm run build:wasm
TypeScript compilation errors:
# Check TypeScript version
npx tsc --version
# Clean TypeScript cache
rm -rf node_modules/.cache
npm run build:ts
Test failures:
# Run specific test
npm test -- --grep "sentiment"
# Run with verbose output
npm test -- --verbose
Getting Help
- 📚 Check our documentation
- 🐛 Search existing issues
- 💬 Join discussions
- 📧 Email maintainers: github@ruv.net
🎖️ Recognition
Contributors are recognized in:
- README.md - Major contributors listed
- CHANGELOG.md - Feature and fix attributions
- GitHub releases - Contributor highlights
- Annual reports - Top contributor recognition
📄 License
By contributing to Psycho-Symbolic Reasoner, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to the future of psycho-symbolic reasoning! 🧠✨