# Contributing

> Development workflow, test discipline, and the pre-commit gates for codeweb.

---

LLMS index: [llms.txt](/codeweb/llms.txt)

---

## Repository layout {#repository-layout}

codeweb is a single Rust crate with feature-gated surfaces (`cli`, `tui`, `serve`, `mcp`, `jsp`, `java`, `analyze`, `search-sql-v2`; `full` combines them). There is no workspace: check which module and feature your change touches first. SQL parsing lives in the separate [ogsql-parser](https://github.com/c2j/ogsql-parser) crate.

## Test discipline {#test-discipline}

The repository follows test-driven development, one behavior per loop:

1. **Red** — write a failing behavior test first. A compile error from a not-yet-existing API counts as red.
2. **Green** — write the minimal implementation that passes; do not widen assertions to get there.
3. **Refactor** — only with the tests green, scoped to the change path.

Rules that reviewers enforce:

- Never delete, skip, or weaken existing tests to make changes pass.
- Test names describe behavior (`should_reject_negative_amount`).
- Characterization tests lock current behavior of legacy paths before changing them.
- Fix the implementation when your change breaks an existing test, unless the human who wrote it says otherwise.

## Pre-commit gates {#pre-commit-gates}

Match CI exactly:

```bash
cargo fmt --all -- --check
cargo clippy --features full -- -D warnings
cargo test --features full -- --skip test_path_mapping_applied --skip test_serve_
```

- `cargo build --features full` must compile whenever a change can affect feature-gated code (new enum variants matched in other features, for example).
- The skipped tests are environment-dependent in CI by design; a bare `cargo test --features full` failing on `test_serve_*` locally is a known limitation, so confirm your change did not make it worse.

## Submitting changes {#submitting-changes}

1. Create a feature branch from `main`.
2. Commit with the gates green.
3. Push and open a pull request.
4. A maintainer reviews and merges; contributors do not merge their own pull requests.
