7.6 KiB
7.6 KiB
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.tomlandbuild.zig.zon). With mise:mise install.
Commands
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_borrow_returns.py # explicit origins, retained views, packages and profiles
python3 tests/hosted/source_format.py # formatter CLI, comments, idempotence and public-corpus AIR fidelity
python3 tests/hosted/source_diagnostic_reasons.py # stable E7006 categories and CLI/package provenance
python3 tests/hosted/related_locations.py # factual conflict/spawn positions, source mapping and package provenance
python3 tests/hosted/source_lifetimes.py # AIR rejection twins and exact lifetime/join diagnostic positions
python3 tests/hosted/source_array_arguments.py # array argument shape, cleanup, AIR and package parity
python3 tests/hosted/source_type_positions.py # structural type errors at annotations, templates and packages
python3 tests/hosted/source_own_array_content.py # Copy content, nominal/generic types and repeated allocations
python3 tests/hosted/source_array_literals.py # inferred elements, repetitions, explicit moves and packages
python3 tests/hosted/source_inferred_content.py # constructor content, transfers, recovery and package provenance
python3 tests/hosted/source_nonvalue_operands.py # never operands, divergent receivers, traps and package provenance
python3 tests/hosted/source_store_modes.py # exclusive places, source positions, array modes and package provenance
python3 tests/hosted/examples.py --stress 200 # all examples/packages, wire bytes, partial I/O and source/AIR schedules
python3 tests/hosted/source_static_functions.py # explicit operations, effects, nominal policy identity and workers
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
python3 tests/hosted/source_deque.py # ring order, returned owners and CLI contracts
python3 tests/hosted/source_hash.py # pure hashes, chunks and source/package/hosted contracts
python3 tests/hosted/source_errors.py # pure built-in error construction and authority separation
python3 tests/hosted/source_map.py # exact numeric keys, owning values and profile/package parity
python3 tools/map_vectors.py # independent dictionary oracle for public map traces
python3 tests/hosted/source_hashmap.py # explicit general key policies, profiles and returned ownership
python3 tools/hashmap_vectors.py # independent dict and dense-order oracle, Copy/owning values
python3 tests/hosted/source_hashset.py # duplicate key ownership, source/AIR, packages and profiles
python3 tools/hashset_vectors.py # independent set and representative oracle, Copy/owning keys
python3 tests/hosted/source_heap.py # explicit ordering, owning extraction and profile/package parity
python3 tools/heap_vectors.py # independent heapq traces and exhaustive small permutations
python3 tests/hosted/source_io.py # bounded I/O, profiles, partial errors and explicit resources
python3 tools/io_vectors.py # independent byte/count/cursor oracle for read/copy boundaries
python3 tests/hosted/source_buffered_io.py # owning adapters, partial failures and no retry
python3 tools/buffered_io_vectors.py # independent read-prefix and segmented-write bytes
python3 tests/hosted/source_path.py # pure paths, ranges, profiles and independent authority
python3 tools/path_vectors.py # independent forward-stack path/query/capacity oracle
(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
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
- 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 aQ-NNNentry todocs/design/open-questions.mdand resolve it in the spec before relying on an answer. - 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.
- Tests first. Add conformance tests (
acceptandreject) for every verifier rule touched. - Implement.
- 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 topublishedin the registry andsrc/air/features.zig, and adding it tosupported. - Diagnostics. A new rejection needs a code in
docs/reference/error-codes.mdandsrc/diag.zig; the unit test fails if they drift. - 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:
.ajisyntax and lowering (spec 15), the Quick Reference updated and its examples checked,.ajirun and reject tests,tools/source_coverage.pypassing 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:.