Thank you for your interest in contributing to Bond Math! This document outlines the standards and conventions for contributing to this project.
- Getting Started
- Commit Message Standards
- Branch Naming
- Pull Request Process
- Code Review Guidelines
- Architecture as Code
- Node.js 18+ (for TypeScript services and Wrangler)
- Python 3.11+ (for valuation and metrics services)
- Java 17+ (for pricing engine)
- Terraform 1.5+ (for infrastructure)
- Wrangler CLI (Cloudflare Workers deployment)
# Clone the repository
git clone https://github.com/chrislyons-dev/bond-math.git
cd bond-math
# Install root dependencies (if any)
npm install
# Set up each service (see service-specific READMEs)
cd services/gateway && npm install
cd ../daycount && npm install
# etc.We follow Conventional Commits with some Bond Math-specific conventions.
<type>(<scope>): <subject>
<body>
<footer>
Must be one of:
- feat: New feature
- fix: Bug fix
- docs: Documentation only changes
- style: Code style changes (formatting, missing semicolons, etc.)
- refactor: Code change that neither fixes a bug nor adds a feature
- perf: Performance improvement
- test: Adding or updating tests
- build: Changes to build system or dependencies
- ci: Changes to CI/CD configuration
- chore: Other changes that don't modify src or test files
- arch: Architecture changes (diagrams, ADRs, metadata)
The scope should identify which part of the system is affected:
Services:
gateway– Gateway Workerdaycount– Day-Count servicevaluation– Bond Valuation servicemetrics– Metrics servicepricing– Pricing Engine
Infrastructure:
iac– Infrastructure as Code (Terraform, Wrangler)deploy– Deployment scripts and configuration
Cross-cutting:
auth– Authentication and authorizationdocs– Documentationtesting– Test infrastructureapi– API contracts and schemas
Examples:
feat(daycount): add ACT/ACT ICMA convention support
fix(gateway): correct internal JWT expiration validation
docs(adr): add ADR for caching strategy
arch(gateway): update component diagram with new routes
refactor(valuation): extract schedule generation to separate module
test(integration): add end-to-end pricing flow tests
ci(deploy): parallelize Worker deployments
- Use imperative mood ("add" not "added" or "adds")
- Don't capitalize first letter
- No period at the end
- Limit to 50 characters
- Wrap at 72 characters
- Explain what and why, not how
- Reference issues and ADRs when relevant
- Reference breaking changes:
BREAKING CHANGE: <description> - Reference issues:
Fixes #123,Closes #456,Ref #789 - Reference ADRs:
ADR: 0010
feat(daycount): add 30/360 ISDA convention
Implements the ISDA variant of 30/360 day count convention
to support certain corporate bond calculations.
ADR: 0007
fix(gateway): prevent token replay attacks
Added nonce validation to internal JWT verification.
Tokens with duplicate nonces within the TTL window
are now rejected with 401 Unauthorized.
The attack vector was discovered during security review
of the zero-trust authorization flow.
Fixes #42
ADR: 0005
feat(api)!: standardize error response format
BREAKING CHANGE: All API errors now return RFC 7807
Problem Details format instead of custom error objects.
Before:
{
"error": "Invalid input",
"code": "VALIDATION_ERROR"
}
After:
{
"type": "https://bondmath.dev/errors/validation",
"title": "Invalid Input",
"status": 400,
"detail": "The 'convention' field is required"
}
Clients must update error handling logic.
Ref #67
arch(gateway): document service binding flow
Added C4 component diagram showing how Gateway Worker
uses service bindings to route requests to internal services.
Updated metadata annotations in gateway/src/index.ts
to reflect current dependencies.
ADR: 0010
Use descriptive branch names with the following format:
<type>/<short-description>
Types:
feature/– New featuresfix/– Bug fixesdocs/– Documentation updatesrefactor/– Code refactoringtest/– Test additions or updateschore/– Maintenance tasks
Examples:
feature/act-act-icma-convention
fix/gateway-token-validation
docs/update-deployment-guide
refactor/extract-jwt-utils
test/add-daycount-integration-tests
chore/upgrade-wrangler-cli
-
Ensure all tests pass locally
make test -
Update Architecture as Code metadata if you changed service behavior
- Add/update
@service,@endpoint,@callsannotations - Regenerate diagrams:
make arch-docs
- Add/update
-
Update relevant documentation
- Service README if public API changed
- ADR if architectural decision was made
- Reference docs in
/docs/reference/
-
Run linting and formatting
make lint make format
Use the same format as commit messages:
feat(daycount): add ACT/ACT ICMA convention
## Summary
Brief description of what this PR does.
## Changes
- Bullet point list of changes
- Keep it concise
## Testing
How was this tested?
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manually tested in local Wrangler dev environment
- [ ] Deployed to preview environment
## Architecture Impact
- [ ] No architecture changes
- [ ] Updated service metadata annotations
- [ ] Added/updated C4 diagrams
- [ ] Created new ADR
## Breaking Changes
- [ ] No breaking changes
- [ ] Breaking changes documented below
## Checklist
- [ ] Code follows project conventions
- [ ] Tests pass locally
- [ ] Documentation updated
- [ ] Commit messages follow standards
- [ ] Architecture metadata updated (if applicable)
## Related Issues
Fixes #123 Ref ADR-0010- PRs require at least one approval before merging
- CI must pass (tests, linting, diagram generation)
- Address all review comments or explain why changes aren't needed
- Keep PRs focused and reasonably sized (< 500 lines ideal)
Focus on:
- ✅ Correctness and edge cases
- ✅ Security implications (especially auth/authz flows)
- ✅ Adherence to zero-trust model
- ✅ Architecture as Code metadata accuracy
- ✅ Test coverage for critical paths
- ✅ Clear error messages and logging
- ✅ Performance implications (especially for edge Workers)
Don't bikeshed:
- ❌ Code style (handled by automated formatters)
- ❌ Minor naming preferences (unless truly confusing)
Be kind:
- Phrase feedback as questions when appropriate
- Acknowledge good solutions
- Explain the "why" behind suggestions
- Respond to all comments (even if just "acknowledged")
- Don't take feedback personally
- Ask for clarification if needed
- Mark conversations as resolved once addressed
Any change that affects architecture must update metadata annotations.
-
Always:
- Adding a new service
- Adding a new API endpoint
- Changing service dependencies
- Modifying authentication/authorization
-
Consider:
- Changing error handling significantly
- Adding caching
- Changing rate limits
- Updating SLA requirements
- Update annotations in the source code (see ADR-0010)
- Regenerate diagrams locally:
make arch-docs
- Review generated diagrams to ensure accuracy
- Commit both code and diagram changes in the same PR
When making a significant architectural decision:
-
Copy the ADR template:
cp docs/adr/TEMPLATE.md docs/adr/XXXX-your-decision.md
-
Fill in all sections:
- Context: What decision needs to be made and why
- Options: At least 2-3 alternatives considered
- Decision: What was chosen
- Trade-offs: Honest assessment of pros/cons
- Outcome: Expected impact
-
Use a conversational but professional tone (see existing ADRs)
-
Get feedback before marking as "Accepted"
- Follow Google TypeScript Style Guide
- Use strict TypeScript (
strict: true) - Prefer
constoverlet - Avoid
any– useunknownif type is truly unknown - Document all public APIs with JSDoc
- Follow PEP 8
- Use type hints (PEP 484)
- Maximum line length: 88 characters (Black default)
- Use
rufffor linting - Document all public functions with docstrings (Google style)
- Follow Google Java Style Guide
- Use Java 17 features
- Prefer immutability
- Document all public APIs with Javadoc
- Unit tests: All business logic functions
- Integration tests: Service-to-service interactions
- Contract tests: API request/response formats
- Security tests: Auth/authz paths
Use descriptive test names that read like specifications:
Good:
test('returns 401 when Auth0 token is expired');
test('mints internal JWT with correct actor claim');
test('calculates ACT/360 year fraction correctly for leap year');Bad:
test('test1');
test('auth fails');
test('calculation');tests/
├── unit/
│ ├── gateway/
│ ├── daycount/
│ └── ...
├── integration/
│ ├── gateway-to-daycount.test.ts
│ └── ...
└── load/
└── ...
(To be defined as project matures)
For now:
- Merges to
mainauto-deploy to production via GitHub Actions - Use feature flags for incomplete features
- Maintain backward compatibility or clearly document breaking changes
- GitHub Discussions: For general questions
- GitHub Issues: For bugs and feature requests
- Slack/Discord: (If/when established)
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to Bond Math! 🎉
Your work helps demonstrate that clean architecture, strong conventions, and Architecture as Code principles can make distributed systems understandable and maintainable.