|
| 1 | +# Contributing to AffineScript |
| 2 | + |
| 3 | +Thank you for your interest in AffineScript — a practical language for |
| 4 | +resource-safe systems, compiling to typed WebAssembly. This guide covers |
| 5 | +how to set up a working tree, file useful bugs, and submit changes. |
| 6 | + |
| 7 | +For the language itself, start from [`README.adoc`](README.adoc). For |
| 8 | +project state, blockers, and next-actions, see |
| 9 | +[`.machine_readable/descriptiles/STATE.a2ml`](.machine_readable/descriptiles/STATE.a2ml). |
| 10 | + |
| 11 | +’’’’’ |
| 12 | + |
| 13 | +## Quick Start |
| 14 | + |
| 15 | +``` bash |
| 16 | +git clone https://github.com/hyperpolymath/affinescript.git |
| 17 | +cd affinescript |
| 18 | + |
| 19 | +# Provision the OCaml toolchain (one-shot). See README.adoc "Getting Started" |
| 20 | +# for the full list of opam packages and the `eval $(opam env)` note for |
| 21 | +# non-interactive shells. |
| 22 | +opam install -y \ |
| 23 | + sedlex menhir ppx_deriving ppx_sexp_conv sexplib0 fmt cmdliner yojson \ |
| 24 | + alcotest ocamlformat \ |
| 25 | + js_of_ocaml js_of_ocaml-ppx js_of_ocaml-compiler |
| 26 | +eval "$(opam env --switch=default --set-switch)" |
| 27 | + |
| 28 | +# Verify setup |
| 29 | +dune build |
| 30 | +dune runtest |
| 31 | +``` |
| 32 | + |
| 33 | +Tested on OCaml 4.14.2 (the constraint in `dune-project` is `>=` |
| 34 | +`4.14`). |
| 35 | + |
| 36 | +### Repository Structure |
| 37 | + |
| 38 | + affinescript/ |
| 39 | + ├── lib/ # Compiler core (lexer, parser, typechecker, codegen, verifier) |
| 40 | + ├── bin/ # CLI driver — `_build/default/bin/main.exe` |
| 41 | + ├── stdlib/ # Standard library `.affine` modules |
| 42 | + ├── test/ # Alcotest suites (lexer, golden, e2e fixtures) |
| 43 | + ├── tests/ # Topic-grouped tests (borrow, codegen, effects, parser, …) |
| 44 | + ├── examples/ # Self-contained example programs |
| 45 | + ├── conformance/ # Conformance test corpus |
| 46 | + ├── docs/ # Specs, decisions, guides |
| 47 | + ├── packages/ # Aggregate JS/TS/ binding packages |
| 48 | + ├── editors/ # Editor integrations |
| 49 | + ├── js/ # `js_of_ocaml` playground (built into `playground.bc.js`) |
| 50 | + ├── .machine_readable/ # Machine-readable metadata (`.a2ml`) — see 0-AI-MANIFEST.a2ml |
| 51 | + ├── .github/ # CI workflows, issue templates |
| 52 | + ├── CODE_OF_CONDUCT.md |
| 53 | + ├── CONTRIBUTING.md # This file |
| 54 | + ├── LICENSE / LICENSES # MIT OR AGPL-3.0-or-later |
| 55 | + ├── MAINTAINERS.adoc |
| 56 | + ├── README.adoc |
| 57 | + ├── SECURITY.md |
| 58 | + ├── dune-project |
| 59 | + └── justfile |
| 60 | + |
| 61 | +’’’’’ |
| 62 | + |
| 63 | +## How to Contribute |
| 64 | + |
| 65 | +### Reporting Bugs |
| 66 | + |
| 67 | +**Before reporting:** 1. Search [existing |
| 68 | +issues](https://github.com/hyperpolymath/affinescript/issues). 2. Check |
| 69 | +that the bug reproduces against `main` (`git` `pull` `&&` `dune` |
| 70 | +`build`). |
| 71 | + |
| 72 | +**When reporting:** use the [bug report |
| 73 | +template](.github/ISSUE_TEMPLATE/bug_report.md) and include: |
| 74 | + |
| 75 | +- Clear, descriptive title. |
| 76 | + |
| 77 | +- Environment: OCaml version, opam switch, OS. |
| 78 | + |
| 79 | +- Steps to reproduce, ideally as a minimal `.affine` file plus the exact |
| 80 | + `dune` `exec` `affinescript` `--` `<subcommand>` `<file>` invocation. |
| 81 | + |
| 82 | +- Expected vs actual behaviour (compiler output, generated Wasm, runtime |
| 83 | + trap, etc.). |
| 84 | + |
| 85 | +### Suggesting Features |
| 86 | + |
| 87 | +**Before suggesting:** 1. Skim [`docs/ROADMAP.adoc`](docs/ROADMAP.adoc) |
| 88 | +and `.machine_readable/descriptiles/STATE.a2ml`. 2. Search existing |
| 89 | +issues and discussions. |
| 90 | + |
| 91 | +**When suggesting:** use the [feature request |
| 92 | +template](.github/ISSUE_TEMPLATE/feature_request.md) and include: |
| 93 | + |
| 94 | +- Problem statement — what pain point does this solve? |
| 95 | + |
| 96 | +- Proposed solution and any alternatives considered. |
| 97 | + |
| 98 | +- Whether the change touches the core language, a face (frontend |
| 99 | + surface), a backend, or the stdlib. |
| 100 | + |
| 101 | +### Your First Contribution |
| 102 | + |
| 103 | +Look for issues labelled: |
| 104 | + |
| 105 | +- [`good` `first` |
| 106 | + `issue`](https://github.com/hyperpolymath/affinescript/labels/good%20first%20issue) |
| 107 | + |
| 108 | +- [`help` |
| 109 | + `wanted`](https://github.com/hyperpolymath/affinescript/labels/help%20wanted) |
| 110 | + |
| 111 | +- [`documentation`](https://github.com/hyperpolymath/affinescript/labels/documentation) |
| 112 | + |
| 113 | +’’’’’ |
| 114 | + |
| 115 | +## Development Workflow |
| 116 | + |
| 117 | +### Branch Naming |
| 118 | + |
| 119 | + docs/short-description # Documentation |
| 120 | + test/what-added # Test additions |
| 121 | + feat/short-description # New features |
| 122 | + fix/issue-number-description # Bug fixes |
| 123 | + refactor/what-changed # Code improvements |
| 124 | + security/what-fixed # Security fixes |
| 125 | + ci/what-changed # CI / tooling |
| 126 | + |
| 127 | +Branch from `main` and target `main` in your PR. |
| 128 | + |
| 129 | +### Commit Messages |
| 130 | + |
| 131 | +We follow [Conventional Commits](https://www.conventionalcommits.org/): |
| 132 | + |
| 133 | + <type>(<scope>): <description> |
| 134 | + |
| 135 | + [optional body] |
| 136 | + |
| 137 | + [optional footer, e.g. closes #N or Co-Authored-By: ...] |
| 138 | + |
| 139 | +Common types: `feat`, `fix`, `docs`, `test`, `refactor`, `chore`, `ci`. |
| 140 | +Common scopes: `lexer`, `parser`, `typecheck`, `codegen`, `verify`, |
| 141 | +`stdlib`, `cli`, `readme`. |
| 142 | + |
| 143 | +### Required Checks |
| 144 | + |
| 145 | +Before opening a PR, locally: |
| 146 | + |
| 147 | +``` bash |
| 148 | +dune build # must exit 0 |
| 149 | +dune runtest # must be green |
| 150 | +dune fmt # optional — auto-formats with ocamlformat |
| 151 | +``` |
| 152 | + |
| 153 | +The `methodology.a2ml` file lists the canonical gate set. CI will rerun |
| 154 | +`build` + `runtest` plus the security, lint, and policy workflows in |
| 155 | +`.github/workflows/`. |
| 156 | + |
| 157 | +### Pull Requests |
| 158 | + |
| 159 | +1. Push your branch and open a PR against `main`. |
| 160 | + |
| 161 | +2. Use a Conventional-Commit-shaped title. |
| 162 | + |
| 163 | +3. In the body, summarise the change and link the issue it closes. |
| 164 | + |
| 165 | +4. Keep PRs focused — split unrelated changes into separate PRs. |
| 166 | + |
| 167 | +5. CI must be green. Maintainers squash-merge by default; commit |
| 168 | + message lineage is preserved in the PR body. |
| 169 | + |
| 170 | +’’’’’ |
| 171 | + |
| 172 | +## Code of Conduct |
| 173 | + |
| 174 | +This project follows the [Code of Conduct](CODE_OF_CONDUCT.md). By |
| 175 | +participating you agree to abide by it. |
| 176 | + |
| 177 | +## License |
| 178 | + |
| 179 | +By contributing you agree your contribution is licensed under the |
| 180 | +project’s dual licence (MIT OR AGPL-3.0-or-later), as recorded in |
| 181 | +[`LICENSE`](LICENSE) and per-file SPDX headers. |
0 commit comments