File size: 17,444 Bytes
a10b189 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | # Contributing to Assertica
Thank you for your interest in contributing to Assertica, a deterministic proof language compiler. This document provides guidelines for participating in the project.
---
## Table of Contents
1. [Code of Conduct](#code-of-conduct)
2. [Getting Started](#getting-started)
3. [Development Setup](#development-setup)
4. [Contribution Types](#contribution-types)
5. [Coding Standards](#coding-standards)
6. [Testing Requirements](#testing-requirements)
7. [Submission Process](#submission-process)
8. [Review Process](#review-process)
9. [DCO: Developer Certificate of Origin](#dco-developer-certificate-of-origin)
10. [Architecture Constraints](#architecture-constraints)
---
## Code of Conduct
Assertica is committed to providing a welcoming and inclusive environment. All contributors are expected to:
- Be respectful and professional
- Provide constructive feedback
- Focus on the technical merit of ideas
- Respect intellectual property
- Acknowledge contributions appropriately
Violations can be reported to project maintainers privately.
---
## Getting Started
### Prerequisites
- **Haskell GHC:** 9.2 or later
- **Cabal:** 3.6 or later
- **Git:** For version control
- **familiarity with:**
- Haskell programming language
- Formal verification concepts
- Type systems and proof theory
### Initial Setup
```bash
# Fork repository on GitHub
# Clone your fork
git clone https://github.com/YOUR_USERNAME/Assertica.git
cd Assertica
# Add upstream remote for syncing
git remote add upstream https://github.com/SNAPKITTYAGENT9NOVA/Assertica.git
# Create development branch
git checkout -b feature/your-feature-name
# Build and test
cabal build
cabal test
```
---
## Development Setup
### Environment Configuration
```bash
# Recommended cabal configuration for development
mkdir -p ~/.cabal
cat >> ~/.cabal/cabal.config << 'EOF'
ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fhide-source-paths
tests: True
benchmarks: True
EOF
# Build with coverage
cabal build --enable-coverage
# Install tools for linting (optional but recommended)
cabal install hlint stylish-haskell
```
### Daily Workflow
```bash
# After pulling changes
git fetch upstream
git rebase upstream/main
# Before committing
cabal format # Format .cabal file
cabal build
cabal test --verbose
# Submit
git push origin feature/your-feature-name
# Create pull request on GitHub
```
---
## Contribution Types
### 1. Bug Fixes
**Criteria:**
- Clear reproduction steps
- Affects functionality or correctness
- Not a known limitation
- Minimal risk to other components
**Process:**
1. Create issue describing bug with reproduction
2. Reference issue in PR (`Fixes #123`)
3. Include test case demonstrating fix
4. Update documentation if needed
**Example:**
```haskell
-- Before: incorrect behavior
buggyFunction x = x + 1
-- After: corrected
buggyFunction x = x + 2
-- Test
test_buggy = assertEqual 3 (buggyFunction 2)
```
### 2. Feature Enhancements (Non-Kernel)
**Eligible Components:**
- Standard library (Standard Library module)
- Backend code generation (Code Generator module)
- Verification reporting (Verification Pipeline module)
- CLI tools (Verification Pipeline module)
- Test infrastructure
**Ineligible Components (Kernel):**
- Core AST (Core AST module)
- Equality checker (Equality Checker module)
- Proof checker (Proof Checker module)
- Type checker (Type Checker module)
**Process:**
1. Open discussion issue first
2. Wait for maintainer feedback (24-72 hours)
3. If approved, proceed with implementation
4. Follow coding standards
5. Add comprehensive tests (min. 30 tests for new modules)
6. Submit PR with detailed description
### 3. Documentation Improvements
**Eligible:**
- README clarifications
- Architecture explanations
- Usage examples
- Inline code comments
- API documentation
- Tutorial content
**Process:**
1. Submit PR directly (no issue required)
2. Clear, technical writing
3. Example code must be tested
4. Build documentation locally to verify:
```bash
cabal haddock --haddock-html --open
```
### 4. Test Coverage Expansion
**Requirements:**
- Tests for uncovered code paths
- Determinism verification tests
- Property tests for invariants
- Negative tests (what should fail)
- Integration tests
**Process:**
1. Identify untested code
2. Write comprehensive tests
3. Verify code coverage:
```bash
cabal test --enable-coverage
cat dist/hpc/html/index.html
```
4. Submit PR with test module
### 5. Refactoring (Non-Kernel Only)
**Constraints:**
- No behavior change
- No API change (externally)
- Improves readability or performance
- All tests pass unchanged
**Process:**
1. Open RFC (Request for Comments) issue
2. Wait for approval
3. Refactor with all tests passing
4. Include before/after performance metrics
5. Document rationale in PR
---
## Coding Standards
### Haskell Style Guide
**Module Structure:**
```haskell
{-|
Module : Assertica.Component.SubComponent
Description : One-line description
Copyright : (c) 2026 Ahmad Ali Parr
License : BSL 1.0
Detailed description of module purpose and responsibilities.
Important invariants and guarantees.
-}
{-# LANGUAGE pragmas #-}
module Assertica.Component.SubComponent
( -- * Public API
publicFunction
, PublicType(..)
-- * Internal helpers (for testing only)
, internalHelper
) where
import qualified Data.Set as Set
import qualified Data.Map.Strict as Map
```
**Documentation:**
- Every public function has a Haddock comment
- Document type signatures with examples
- Explain non-obvious invariants
- Note side effects clearly
**Example:**
```haskell
-- | Check deterministic equality of two terms
--
-- Two terms are equal if they normalize to the same canonical form
-- (modulo alpha equivalence).
--
-- Examples:
-- isEqual (TApp (TAbs x (TVar x)) (TConst "5")) (TConst "5") == True
-- isEqual (TVar (Var "x")) (TVar (Var "y")) == False
--
-- Properties:
-- - Deterministic: always returns same result for same input
-- - Idempotent: isEqual t1 t2 == isEqual t1 t2
isEqual :: Term -> Term -> Bool
isEqual t1 t2 = alphaEquivalent (normalize t1) (normalize t2)
```
**Naming Conventions:**
- Types: CamelCase (`Term`, `Assertion`)
- Functions: camelCase (`isDefinitionallyEqual`)
- Constants: SCREAMING_SNAKE_CASE (rarely used)
- Type variables: single lowercase letter or descriptive (`a`, `term`)
- Predicates: prefix with `is` or `has` (`isValid`, `hasProperty`)
**Formatting:**
```bash
# Use cabal's built-in formatter
cabal format
# For Haskell code, use consistent indentation
# 2 spaces for indentation (project standard)
# Line length: prefer <100 characters (max 120)
# Example:
foo :: Term -> Term -> Bool
foo t1 t2 =
let normalized1 = normalize t1
normalized2 = normalize t2
in alphaEquivalent normalized1 normalized2
```
**Error Handling:**
- Use `Either String a` for recoverable errors
- Use `Maybe a` for optional values
- Never use `error` or `undefined` in production code
- Provide meaningful error messages
```haskell
-- Good: clear error message
checkTerm :: Term -> Either String ()
checkTerm t
| isWellFormed t = Right ()
| otherwise = Left $ "Malformed term: " ++ show t
-- Bad: unhelpful message
checkTerm _ = Left "Error"
```
---
## Testing Requirements
### Minimum Coverage
- **New modules:** 95% code coverage minimum
- **Existing modules:** No decrease in coverage
- **Critical path (Equality Checker module, 2B):** 100% coverage required
### Test Structure
```haskell
module Test.YourModule where
import Test.HUnit
import Test.QuickCheck
import Assertica.YourModule
-- Unit tests
test_basic :: Test
test_basic = TestCase $ assertEqual "basic case"
expected
(yourFunction input)
-- Property tests
prop_deterministic :: Term -> Bool
prop_deterministic t =
normalize t === normalize t
-- Negative tests (what should fail)
test_rejectInvalid :: Test
test_rejectInvalid = TestCase $
assertEqual "reject invalid"
(Left "error")
(validate invalidInput)
-- Comprehensive test suite
main :: IO ()
main = do
runTestTT $ TestList
[ test_basic
, test_another
]
quickCheckResult prop_deterministic
```
### Test Organization
```
test/Test/Component/
βββ SubComponentA.hs # Tests for Agent/Component
βββ SubComponentB.hs # One file per component
βββ Integration.hs # Cross-component tests
```
### Running Tests
```bash
# All tests with verbose output
cabal test --test-show-details=direct
# Specific test
cabal test --test-show-details=direct test:assertica-tests -- --match="Equality"
# With coverage
cabal test --enable-coverage
cabal open dist/hpc/html/index.html
```
---
## Submission Process
### Before Submitting
**Checklist:**
- [ ] Code follows style guide
- [ ] New functions documented with examples
- [ ] All tests pass (`cabal test`)
- [ ] Test coverage >95% for new code
- [ ] No compiler warnings (`-Wall`)
- [ ] Determinism verified (property tests)
- [ ] Negative tests included
- [ ] CONTRIBUTING.md DCO clause signed
- [ ] Commit message clear and descriptive
**Commit Message Format:**
```
[Component] Brief description (50 chars max)
Detailed explanation of changes. Wrap at 72 characters.
Mention related issues: Fixes #123, Related to #456
Architectural decisions and trade-offs if relevant.
Co-Authored-By: Your Name <email@example.com> (if applicable)
```
**Examples:**
```
[Standard Library module] Add Lattice.absorbptionProof function
Implements the absorption theorem proof for lattice structures:
a β (a β b) β a
Adds 24 unit tests covering all absorption cases and
proof composition. Verifies proof terms are checked by
Proof Checker module proof checker.
Fixes #145
```
### Submitting a Pull Request
```bash
# Ensure you're up to date
git fetch upstream
git rebase upstream/main
# Push to your fork
git push origin feature/your-feature-name
# Create PR on GitHub with detailed description
```
**PR Template:**
```markdown
## Description
Brief summary of changes
## Motivation
Why is this change needed?
## Changes
- List of modifications
- Affected components
- New files (if any)
## Testing
- Tests added: X unit tests, Y property tests
- Coverage: Z%
- Manual testing: describe what was tested
## Checklist
- [ ] Tests pass locally
- [ ] Coverage maintained/improved
- [ ] Documentation updated
- [ ] DCO signed
- [ ] No breaking changes (if applicable)
## Related Issues
Fixes #123
```
---
## Review Process
### Code Review Policy
**Kernel Changes (Equality Checker module, 2B):**
- Requires 2+ architectural reviews
- 48-hour review period minimum
- All feedback must be addressed
- No force-merge allowed
- Maintainer approval required
**Non-Kernel Changes:**
- Requires 1 maintainer review
- 24-hour review period (unless urgent)
- Feedback incorporated or explained
- One approval to merge
### Review Criteria
Reviewers will evaluate:
1. **Correctness**
- Does it solve the stated problem?
- Are edge cases handled?
- Are there any logical errors?
2. **Quality**
- Code clarity and maintainability
- Adherence to style guide
- Test coverage and quality
3. **Performance**
- No unnecessary allocations
- Complexity appropriate to task
- No regressions in benchmarks
4. **Architecture**
- Fits within role pair boundaries
- Clean interfaces
- No hidden dependencies
5. **Documentation**
- Clear explanations
- Examples where helpful
- Updated README if needed
### Addressing Feedback
- Respond to every comment
- Acknowledge valid points
- Explain disagreements respectfully
- Use "Resolve conversation" only after feedback addressed
- Push updates to same branch (don't force-push)
---
## DCO: Developer Certificate of Origin
By submitting a pull request, you certify that:
```
Developer Certificate of Origin
Version 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
```
**Sign-off:** Include in commit message:
```
Signed-off-by: Your Name <your.email@example.com>
```
**Git configuration:**
```bash
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git commit -s # Automatically sign-off
```
---
## Architecture Constraints
### Module Boundaries
Contributions must respect module architecture boundaries:
| Layer | Modules | Contribution Allowed | Contribution Forbidden |
|-------|---------|----------------------|------------------------|
| **Kernel** | Core AST, Equality Checker | Tests, documentation | Core AST, equality logic |
| **Verification** | Assertion System, Proof Checker | Proof primitives, tests | Proof checker core logic |
| **Syntax** | Parser/Elaborator, Type Checker | Surface syntax, type inference tests | Type system fundamentals |
| **Safety** | Pattern Compiler, Termination/Positivity | New safety checks | Pattern/termination algorithms |
| **Organization** | Module System, Standard Library | Algebraic structures, standard library | Module system core |
| **Emission** | Code Generator, Verification Pipeline | Code generation backends, CLI | Pipeline orchestration |
### Invariants That Cannot Change
These are inviolable (violations rejected in review):
1. **Determinism:** Same input must produce identical output
2. **Fail-Closed:** Unknown inputs must be rejected, never silently accepted
3. **No Algebraic Axioms:** Commutativity, associativity, distributivity forbidden in kernel
4. **Proof Requirements:** Propositional equality requires explicit proof
5. **No SMT Solvers:** Zero external theorem prover calls
6. **No Unsafe Code:** No `unsafeCoerce`, `unsafePerformIO`, etc.
### Integration Points
When adding features, ensure clean integration:
- Use existing equality checker (Equality Checker module) - don't reimplement
- All proof verification goes through Proof Checker module
- Type environment via Type Checker module's API
- Module resolution via Module System module
- Code generation through Code Generator module's interfaces
---
## Common Contribution Patterns
### Adding a New Algebraic Structure (Standard Library module)
1. Create new module: `src/Assertica/StdLib/YourStructure.hs`
2. Define structure (analogous to `Setoid`, `Lattice`)
3. Prove algebraic laws with explicit proof terms
4. Create test module: `test/Test/StdLib/YourStructure.hs`
5. Add 30+ comprehensive tests
6. Update `assertica.cabal` with new modules
7. Submit PR with architecture discussion
### Extending Parser/Elaborator (Parser/Elaborator module)
1. Extend token types in `Lexer.hs` if needed
2. Add parser rule in `Parser.hs`
3. Add elaborator case in `Elaborator.hs`
4. Update surface AST (`Surface/AST.hs`)
5. Add 20+ parser tests
6. Add 15+ elaborator tests
7. Document syntax in examples
8. Submit PR with grammar specification
### Adding Backend Code Generation (Code Generator module)
1. Extend target language support in `CodeGen.hs`
2. Implement term compilation in appropriate compiler
3. Ensure generated code is type-safe
4. Add 15+ end-to-end tests
5. Verify output compiles with target compiler
6. Benchmark code generation performance
7. Submit PR with performance analysis
---
## Frequently Asked Questions
**Q: Can I modify the kernel (Equality Checker module)?**
A: Only for critical bug fixes. Changes require 2+ architectural reviews. Bug fix must have failing test demonstrating issue, and passing test after fix.
**Q: What if I disagree with reviewer feedback?**
A: Respectfully explain your position. If disagreement persists, maintainers make final decision. Disagreement is not grounds for force-merge.
**Q: How long does review typically take?**
A: 24-72 hours for non-kernel, 48+ hours for kernel. Depends on complexity and reviewer availability.
**Q: Can I work on multiple features in parallel?**
A: Yes, use separate branches and PRs. Avoid large PRs (500+ lines) - break into logical units.
**Q: What if my contribution introduces a performance regression?**
A: Regressions must be justified and fixed before merge. Include benchmarks showing impact.
---
## Getting Help
- **Architecture questions:** Open discussion issue
- **Technical questions:** GitHub Discussions
- **Bug reports:** GitHub Issues
- **Security issues:** See SECURITY.md
- **Email:** Contact project maintainers
---
**Last Updated:** 2026-10-03
**Version:** 1.0.0
|