|
| 1 | +# Contributing |
| 2 | + |
| 3 | +GitContribute is organized around explicit capability boundaries. Start with |
| 4 | +[the architecture guide](docs/architecture.md) before changing storage, |
| 5 | +network, process-execution, or protocol code. |
| 6 | + |
| 7 | +## Development setup |
| 8 | + |
| 9 | +Requirements: |
| 10 | + |
| 11 | +- Go 1.26 or newer |
| 12 | +- Git |
| 13 | + |
| 14 | +Run the standard validation suite from the repository root: |
| 15 | + |
| 16 | +```sh |
| 17 | +gofmt -w <changed-go-files> |
| 18 | +go test ./... |
| 19 | +go vet ./... |
| 20 | +``` |
| 21 | + |
| 22 | +Use focused race tests for changes involving SQLite transactions, goroutines, |
| 23 | +filesystem locks, job ownership, or cancellation: |
| 24 | + |
| 25 | +```sh |
| 26 | +go test -race ./internal/app ./internal/corpus |
| 27 | +``` |
| 28 | + |
| 29 | +The SQLite driver is pure Go. Keep CGO disabled compatibility when changing |
| 30 | +storage or build dependencies. |
| 31 | + |
| 32 | +## Where changes belong |
| 33 | + |
| 34 | +- Put use-case decisions and capability composition in `internal/app`. |
| 35 | +- Put SQL, transactions, migrations, and local query ordering in |
| 36 | + `internal/corpus`. |
| 37 | +- Keep GitHub SDK mapping and HTTP policy in `internal/github`. |
| 38 | +- Keep CLI, MCP, and TUI code as adapters over application contracts. |
| 39 | +- Keep process execution in the acquisition, workspace, or evidence boundary; |
| 40 | + corpus reads must never execute commands. |
| 41 | + |
| 42 | +Prefer a narrow product-owned interface over exposing a third-party type to |
| 43 | +another package. |
| 44 | + |
| 45 | +## Storage invariants |
| 46 | + |
| 47 | +When changing corpus writes, preserve these rules: |
| 48 | + |
| 49 | +1. Record source observations even when an older observation loses projection |
| 50 | + ordering. |
| 51 | +2. Update projections only when `(source_updated_at, |
| 52 | + observation_sequence)` wins. |
| 53 | +3. Buffer paginated child data and replace it atomically only after retrieval |
| 54 | + completes. |
| 55 | +4. Treat an empty complete child set as a valid replacement. |
| 56 | +5. Give paginated queries a stable final tie-breaker and bind cursors to their |
| 57 | + query scope. |
| 58 | +6. Keep multi-record imports and state transitions transactional. |
| 59 | + |
| 60 | +Add a new numbered Goose migration for schema changes. Test both upgrade and |
| 61 | +rollback behavior when the migration is reversible. |
| 62 | + |
| 63 | +## Side effects and security |
| 64 | + |
| 65 | +- Local inspection commands must remain offline. |
| 66 | +- GitHub reads must be explicit, bounded, rate-limited, and cancellation-aware. |
| 67 | +- Do not add GitHub mutation without a separate reviewed capability. |
| 68 | +- Never execute repository-controlled code during crawl, sync, indexing, |
| 69 | + search, health, or dossier operations. |
| 70 | +- Reject credentials in persisted remote URLs and redact secrets and absolute |
| 71 | + local paths from exported metadata. |
| 72 | +- Require explicit authorization for validation commands and keep their |
| 73 | + environment allowlisted. |
| 74 | + |
| 75 | +## Tests |
| 76 | + |
| 77 | +Tests should prove behavior at the owner boundary. Important regression cases |
| 78 | +include: |
| 79 | + |
| 80 | +- stale and equal-timestamp observations; |
| 81 | +- interrupted pagination and complete empty replacement; |
| 82 | +- stable cursor ordering and scope mismatch; |
| 83 | +- retry cancellation and per-attempt rate limiting; |
| 84 | +- cross-process mirror locking and job reconciliation; |
| 85 | +- read-only operations performing no network or process work; |
| 86 | +- transaction rollback after a late validation or persistence failure. |
| 87 | + |
| 88 | +Use local HTTP servers, temporary repositories, and temporary databases. Do |
| 89 | +not depend on live GitHub state in the test suite. |
| 90 | + |
| 91 | +## Pull requests |
| 92 | + |
| 93 | +Keep changes focused on one outcome. For storage, concurrency, protocol, or |
| 94 | +execution changes, describe the invariant being protected and include the |
| 95 | +focused regression command. For large changes, give reviewers an order that |
| 96 | +starts with the owner boundary and highest-risk state transition. |
0 commit comments