Files
aji/CONTRIBUTING.md
T
dev 4138a52af6 cli: add initialized buffers and safe owning vectors
Introduce linear_buffers through the specification, AIR parser/serializer,
verifier, deterministic interpreter and source lowering. A buffer owns an
initialized prefix with explicit reserve, bounded push, moving pop/views and
recoverable empty-only free. Growth charges old+new capacity; failed growth,
full push and nonempty free preserve or return complete ownership.

Implement compiler-pinned safe std.vec with nine operations for Copy values,
owners, files and channel endpoints. Permit complete Copy moves inside
specialized generic bodies without weakening monomorphic or borrow rules.
Update RFC 0024, Q-036, STD-6a/b, reference grammar, Quick Reference, bundles,
source coverage and CI. Remaining collections stay STD-6c.

Validation: unit tests and AIR round-trip; 757 conformance cases; 56 dedicated
buffer cases with per-instruction collection and 32-seed schedule stress;
extended memory test; hosted smoke; 36 module, 20 generic, 49 linear and
118 buffer CLI checks; 91/91 source constructs; Zig fmt and reference bundles.
Full source bundle: 49,589 -> 52,384 cl100k tokens (+5.6%); AIR 175,736 bytes.
The reference interpreter's push copies its initialized prefix; no native
performance or empirical MCC benefit is claimed.
2026-10-06 23:26:41 +03:00

78 lines
4.5 KiB
Markdown

# Contributing
Read `AGENTS.md` first. It holds the non-negotiable principles and the checklists every change must satisfy. This file covers the mechanics.
## Toolchain
- Zig **0.17.0** (pinned in `mise.toml` and `build.zig.zon`). With mise: `mise install`.
## Commands
```sh
zig build # build ./zig-out/bin/aji
zig build test # unit tests (includes registry ↔ docs sync check)
zig build test-extended # long-running tests; also `zig build conformance -- --collect-every-step`
zig build conformance # conformance suite, see tests/conformance/README.md
zig build run -- check f.air # verify a text AIR module
zig build run -- run f.air # verify and execute @main (deterministic profile)
python3 tests/hosted/smoke.py # hosted profile against the real OS
python3 tests/hosted/source_modules.py # explicit package CLI and file-loading contracts
python3 tests/hosted/source_generics.py # explicit generics, constraints and provenance
python3 tests/hosted/source_linear.py # whole-value owners, canonical AIR and CLI errors
python3 tests/hosted/source_buffers.py # initialized storage, owning vectors and CLI contracts
(cd tools/eval && python3 -m unittest discover tests) # evaluation harness self-tests
zig fmt --check build.zig src tools
```
CI runs `zig fmt --check`, `zig build test`, `zig build conformance` and the hosted smoke tests on every push and pull request. A separate job runs `zig build test-extended` and conformance with collection before every instruction (`--collect-every-step`).
## Repository layout
```text
docs/spec/ normative specification
docs/rfcs/ design RFCs (template: 0000-template.md)
docs/reference/ grammar, error codes, intrinsics, glossary
docs/design/ design decisions log, open questions
docs/plan/ implementation plan, phase task breakdowns
docs/dev/ implementation architecture, testing guide
src/ reference implementation (Zig)
root.zig library root
diag.zig diagnostic envelope + error-code registry
air.zig AIR data model, text parser/serializer
verifier.zig verifier passes
interp.zig deterministic AIR interpreter
check.zig parse → verify pipeline used by CLI and tools
main.zig `aji` CLI
tools/conformance.zig conformance runner
tests/conformance/ .air conformance tests
std/ safe Aji standard modules embedded with the compiler
examples/ illustrative Aji source programs
```
Everything under `src/` except `main.zig` is part of the trusted computing base or feeds it. Keep it small and free of heuristics.
## Workflow for a change
1. **Find the governing text.** Precedence: `docs/spec/` → `docs/reference/` → examples → README. RFCs explain decisions; their accepted rules are already in the spec. If the spec does not answer the question, add a `Q-NNN` entry to `docs/design/open-questions.md` and resolve it in the spec before relying on an answer.
2. **Spec first.** If the behavior is not specified, change the spec (or write an RFC for major changes) before code. Never let the implementation define semantics silently.
3. **Tests first.** Add conformance tests (`accept` and `reject`) for every verifier rule touched.
4. **Implement.**
5. **Features.** A new AIR construct belongs to a feature in `docs/reference/air-features.md`; publishing a feature means specifying it fully, changing its status to `published` in the registry and `src/air/features.zig`, and adding it to `supported`.
6. **Diagnostics.** A new rejection needs a code in `docs/reference/error-codes.md` *and* `src/diag.zig`; the unit test fails if they drift.
7. **Run** `zig fmt`, `zig build test`, `zig build conformance`.
## Definition of done
- [ ] Spec/reference updated or confirmed unchanged.
- [ ] Positive and negative conformance tests.
- [ ] Stable diagnostic code for every new rejection.
- [ ] Interpreter test if observable at runtime.
- [ ] Memory/concurrency/FFI/unsafe changes: the 8-point checklist from `AGENTS.md`.
- [ ] AIR changes: the instruction contract from `AGENTS.md` / spec 07 §4.
- [ ] Concurrency changes: deterministic scheduler tests and randomized schedule stress tests.
- [ ] Semantic features: `.aji` syntax and lowering (spec 15), the Quick Reference updated and its examples checked, `.aji` run and reject tests, `tools/source_coverage.py` passing with the new constructs listed.
## Commits
One logical change per commit. Prefix the subject with the area: `spec:`, `rfc:`, `air:`, `verifier:`, `interp:`, `diag:`, `cli:`, `tests:`, `build:`, `docs:`.