Open Manual

Contributing to Nytrix

Start from the source and a reduced reproducer with a known result. Use spec/ for language contracts, learn/ for user workflows, and the architecture map to locate compiler subsystems.

Contributor reference

NeedReference
Dependent types and GADTsFeature contract
UI, engine, and editor workUI guide
Compiler performance gaps and targetBenchmark dashboard and how to read the results
NYC C compilerCompiler and verification evidence
Source ownershipCompiler architecture
Commands, traces, pass isolation, and runtime failuresCompiler debugging
Benchmarking, profiles, sample validation, and editor compilationPerformance
Visible drawing, input, resize, and frame costUI verification
Detailed historical implementation changesExpand a version's Details in the changelog
Dated measurements and rejected experimentsRecorded measurements

The changelog and measurement archive contain dated evidence. Their task labels and timings do not describe current acceptance; see the linked topic pages for current acceptance criteria.

Build

./make doctor
./make all
./make env

Use the compiler in the checkout, not an unrelated installation on PATH. build/release/ny is the launcher; build/release/ny-full is the compiler process. For a direct compiler rebuild:

cmake --build build/release --target ny-full -j 8

Build only the standalone C compiler and its backend dependencies with ./make nyc. The executable is build/release/nyc; ./make debug nyc selects build/debug/nyc. Both commands accept -j N for build parallelism. ./make nyc -h, ./make help nyc, and build/release/nyc --help show the complete compiler flag reference, including compatibility-only switches, target restrictions, and compiler-swap examples. Bootstrap help does not require a built compiler. The compiler and native build tool share Ny's flag-help renderer, automatic terminal colors, glyph policy, and adaptive columns; NYTRIX_COLOR, NYTRIX_GLYPHS, and COLUMNS control presentation.

NYC is currently a compile-only driver: compile with build/release/nyc -c main.c -o main.o, then link with cc main.o -o app. Set CC to NYC only for compile-only build steps; retain a separate link driver when the build system also uses CC to link executables or libraries.

Use separate build directories for different toolchains, targets, and instrumentation. Build configuration, dependencies, and CTest registration belong in CMakeLists.txt. Generated standard-library bundles and binaries under build/ are not source files.

Generated files

Keep build products and retained reports under the build root, which may be deleted at any time. Permanent regression fixtures belong in etc/labs/tests/ or their owning source test directory. A clean checkout must not require local scratch files or unpublished assets.

PathPurpose
build/cache/Repository-managed caches
build/cache/nytrix/Compiler, package, and test-runner caches when the source checkout is writable
build/diagnostics/tests/Default fixture failure bundles
build/check-reports/Source and quality-gate reports
build/examples/Files generated by examples
build/cache/assets/models/Local model cache; configure other roots through the documented asset environment variables

./make test places diagnostics under its selected build root. NYTRIX_TEST_DIAG_DIR overrides the diagnostic directory for both the wrapper and standalone runner. NYTRIX_CACHE_DIR overrides the compiler/package cache root. Source-checkout tools use build/cache/nytrix/; installed tools, or tools without a writable source checkout, use the platform user-cache directory ($XDG_CACHE_HOME/nytrix/ or ~/.cache/nytrix/ on Linux). Compiler artifact directories (std-src, jit, and modules) retain at most 256 MiB and 4096 published files each. Set NYTRIX_CACHE_MAX_MB to a positive integer to change the per-directory byte budget. Publication evicts older artifacts; oversized artifacts remain usable for the current compilation but are not persisted. This limit excludes active temporaries, package downloads, profiles, and diagnostic reports. Test and benchmark wrappers remove their frozen core inputs after use. A later wrapper invocation also reclaims frozen inputs from dead suites on POSIX, without deleting their profiles or diagnostics. System temporary files still follow the platform and TMPDIR; Linux perf maps retain their required /tmp/perf-<pid>.map location.

Remove task-created scaffolds after verification. Retain only the reports, reproducers, and captures needed for an unresolved result, recording the command and build identity with them. Historical capture names are not distributed artifacts or a substitute for reproducing the result.

Make a change

  1. Reduce a failure to one source file or fixture. Keep its command, flags, expected result, and diagnostic or output.
  2. Locate the first incorrect boundary. Check callers and the existing contract before changing it.
  3. Change the owning layer and preserve rejection behavior for unsupported cases. Do not hide a failure by selecting another backend.
  4. Add a regression for observable behavior, including a rejected or cleanup case when the change defines that boundary.
  5. Run the affected program, then the focused fixture and appropriate broader checks. Update the contract and changelog for public changes.

Parsing owns source forms; shared semantic analysis owns types, effects, ownership, and proofs; language lowering produces NYIR; machine lowering owns target ABI and instruction details. Keep physical registers out of target-independent NYIR transforms. Source facts become optimizer evidence only through explicit derivation and invalidation.

Carry representation, ownership, effects, proofs, and ABI facts explicitly between stages. Backends must not reconstruct source contracts from names or incidental tag bits. Follow the public headers in src/include/ when changing a supported C API.

The compiler, loader, intern table, and parts of the runtime have process-global state. Separate build and test processes can run in parallel; independent concurrent compiler sessions in one process are not supported. See the embedding API for nested-call and lifecycle rules.

Design and review

Identify the invariant, its owner, callers, representation, and failure behavior before changing an interface. Keep ownership, mutation, errors, and conversions explicit. Put policy with its owner; separate I/O and nondeterminism from deterministic work when practical.

An abstraction needs a concrete alternate implementation, caller-owned policy, or verification boundary. Share invariants rather than similar syntax. Account for allocation, copying, repeated work, cache invalidation, and lifecycle changes. If deleting a layer also deletes its complexity, remove it. If that complexity reappears across callers, the layer may be justified.

Use a prototype to answer one unresolved question. Keep it separate from production under the task workspace, exercise the actual uncertainty, transfer the result to its owner, and remove the scaffold. Avoid unrelated persistence, fallbacks, validation, or new layers.

Migrate all affected callers and remove obsolete aliases and paths. A lasting design record is useful for a hard-to-reverse choice: explain the problem, alternatives, chosen boundary, accepted costs, and verification. In review, check failure cases, unsupported inputs, and resource costs as well as the successful path.

Working together

Agree on file ownership, dependencies, and expected checks before parallel work. Assume a shared checkout and index unless separate worktrees are verified; different terminals, branches, or processes do not provide isolation. Serialize overlapping edits, shared builds, generated outputs, caches, and Git operations. Re-read files after another contributor changes them.

Integrate isolated changes one at a time and check the combined result. Individual passing checks do not establish that the integrated change works. Before taking over unfinished work, confirm the ownership transfer and retain its changed paths, last verified result, open checks, evidence, and next command. Keep one work queue rather than competing copies.

Source conventions

Nytrix parameters, fields, and typed bindings use Type name. A semicolon starts a comment. Public modules keep their keyword metadata first:

;; Keywords: example arithmetic
;; A small arithmetic helper.
module example(double)

fn double(int value) int { value * 2 }

Use hyphens in .nshape names (loop-unswitch.nshape) and underscores in C filenames and identifiers (loop_unswitch.c). Extend an existing shared implementation rather than creating a parallel fast path with a different contract.

Language extensions should reuse existing forms where possible: <...> for type and compile-time parameters, where for constraints, proof<P> for explicit evidence, comptime for static work, and quote { ... }, ${...}, and emit for syntax generation. Prefer contextual keywords. Compiler-only facts such as SSA versions and proof invalidation do not belong in source syntax.

Reusing upstream code

Identify the actual source and immutable revision before copying an implementation. Check its license and retain required notices. Distinguish a verbatim copy, an adaptation, and an independent implementation of documented behavior. Record the representation, ABI, ownership, or platform differences that affect the port, then exercise the caller's execution path and relevant upstream tests where available.

Copy verbatim only when the contracts, representation, dependencies, and target assumptions match. Otherwise adapt the algorithm and invariants to Nytrix's types, APIs, ABI, ownership, and errors. Fetch the files needed for the port; a large repository need not be copied wholesale.

Record the URL, immutable revision, file or symbol, license, reused portions, adaptations, and tests consulted in the change description or required source notice. Keep legally required attribution in its required location. Do not distribute copied code with unresolved license or provenance. Remove unused upstream layers and replace the old path after verification, without adding aliases just to resemble the original.

Run relevant upstream checks and the Nytrix consumer path. If upstream checks cannot run, record the limit and use an independent target-side check. A port, a successful build, and target-only tests do not establish upstream parity.

For LLVM research, follow the owning implementation and tests at one pinned revision: loop vectorization under llvm/lib/Transforms/Vectorize/, scalar transforms under llvm/lib/Transforms/Scalar/, register allocation under llvm/lib/CodeGen/, and target lowering under llvm/lib/Target/. A pass name or assembly excerpt alone does not establish the upstream invariant.

Setup scripts and external services

Read the service's documented API and active configuration before changing external state. Define prerequisites, inputs, effects, success checks, recovery, and irreversible steps. Agree on destructive, public, or credential-changing operations before execution. Document steps that require a person's access or decision, including how to resume after failure.

Keep temporary setup scripts with the task. Make repeats safe where the operation permits it; do not promise idempotence for an irreversible action. Never log secrets, pass them in command arguments, or persist them to an unapproved location. Read interactive secrets without echo and limit their lifetime.

Check shell scripts with bash -n and ShellCheck when available. Exercise harmless paths or a genuine dry run; do not fake provisioning or change an account solely to test a script. Report the invocation, exercised paths, manual steps, and outstanding external checks. Syntax checks alone do not verify a migration.

Documentation

Fence every Nytrix source excerpt as ny, including syntax templates, fragments, host-dependent examples, and expected failures. Do not relabel source as text to suppress highlighting or hide a compiler failure. State whether an excerpt is a complete program, a fragment, or a rejection example, and name required libraries, files, services, targets, or devices before the code. Compile and check complete runnable examples; explain the relevant contract or known limitation for fragments and failures. Shell blocks use bash or sh; output, diagrams, and other formats use their appropriate tags.

Use one callout form consistently:

> **Note:** A factual qualification or constraint.

> **Tip:** A useful optional technique.

> **Warning:** A risk or behavior likely to surprise the reader.

Put callouts beside the claim they qualify; do not add one merely for decoration. Every learn page should state its prerequisites when relevant and offer a short Next route. Spec pages over about 60 lines should include a small contents list. Keep examples and navigation specific to the page; do not add boilerplate sections that repeat the introduction or existing links.

Pages can begin with site metadata:

<!-- nytrix-doc: {"audience":"user","featured":true,"group":"learn","order":10,"summary":"One sentence describing this page."} -->

audience identifies the reader; group and order control navigation; summary supplies card and search text; featured controls curated placement. Keep API documentation with its owning declaration. Library facades can add module-level Markdown:

;; Keywords: text collections
;; One sentence describing the module.
;; References:
;; - core.str
;; Documentation:
;; ## Scope
;; Explain the public API and its limits.
module core.example

Use relative Markdown links and check anchors after renaming headings. In table cells, escape literal pipe characters, including those inside inline code. Separate implemented behavior from proposals; a specification is not an implementation work order.

Write for the reader's task. State behavior, requirements, and failures directly. Remove repeated introductions, slogans, inflated claims, decorative emphasis, and conclusions that repeat an example. Keep technical terms stable; forced synonyms and conversational filler make a reference harder to use.

For prose-only edits, preserve code, commands, paths, metadata, link targets, measurements, and caveats. Review whole paragraphs, then compare the rewrite with the original claims. Do not invent anecdotes, certainty, or results. The Humanizer and portable variant offer editing checklists; their patterns are not automatic word bans.

Unpublished changes stay under the latest existing version in the changelog. Use short visible bullets and that version's <details><summary>Details</summary> for longer, non-repetitive records. Do not add an Unreleased section or bump the version; new release headings and version changes require the maintainer's release decision. Record verified changes and qualified measurements, not speculative improvements.

Tests

Fixtures live under these roots:

PathCoverage
etc/labs/tests/lang/Source semantics, types, modules, runtime, and interop
etc/labs/tests/lang/errors/Rejected source and expected diagnostics
etc/labs/tests/code/IR, backend, ABI, target, format, and compiler probes
etc/labs/tests/bench/Benchmark fixtures, including paired C/Ny workloads
core/Module-local #main checks

Test observable results, errors, boundaries, cleanup, and state transitions. Avoid assertions about copied source text, forwarding, mock echoes, or incidental defaults. Remove tests that pin wording or private implementation choices rather than a public contract. Exercise the changed program or tool as well as its regression fixture; a build alone does not verify execution.

Run a focused fixture cold:

NYTRIX_NO_PROGRESS=1 NYTRIX_TEST_COLD=1 \
  ./make test --pattern types/refinements/refinements.nshape --failures-only

A focused pattern skips the automatic full benchmark suite. Run ./make bench when measurements are required. NYTRIX_TEST_NO_BENCH=1 skips benchmarks in an unfiltered test run.

Core bitcode generation defaults to 16 standard-library loader threads. Set NYTRIX_CORE_BC_THREADS to an integer from 1 to 64 when a focused test shares a memory-constrained host; this changes only the core bitcode precompile, not fixture worker parallelism.

The wrapper hashes etc/labs/tests/ and core/ before a test or benchmark gate and checks them again before reporting its verdict. If either tree changes, or an input cannot be read for the recheck, the result is INVALIDATED (exit 2), not a pass or failure. Rerun after source edits stop.

The standalone runner accepts fixture paths:

NYTRIX_TEST_CACHE=0 NYTRIX_NO_PROGRESS=1 \
  build/release/ny-test --bin build/release/ny --timeout 300 \
  etc/labs/tests/lang/types/refinements/refinements.nshape

Put backend flags in a fixture's flags or flags_matrix; .nshape metadata is not Ny source. --no-progress is a compiler flag, not a ny-test flag. Let commands detect diagnostic color normally.

After a standard-library change, rebuild its generated artifacts and exercise both direct calls and composition through imports, callbacks, and ABI boundaries. For a standalone reproducer with library caches disabled:

NYTRIX_STD_CACHE=0 NYTRIX_STD_BC_CACHE_AUTO=0 \
  build/release/ny-full --no-progress path/to/reproducer.ny

Additional in-process compiler checks:

build/release/ny-full --type-row-test
build/release/ny-full --backend-test
build/release/ny-full --backend-test passes/scalar/gvn_pre

Backend regression drivers and shared support live under src/code/test/backend/, grouped by passes, lowering, code generation, cache, portable targets, and runtime. Select a test by its path relative to that root or by its filename stem. C frontend fixtures live directly in src/code/test/lang/c/; Ny frontend and embedding test support lives directly in src/code/test/lang/ny/. The shared language test registrations, fixture discovery, and generated stdlib debug-path fixture are managed by src/code/test/lang/run.cmake.

Quality gate

NYTRIX_NO_PROGRESS=1 ./make check

This fail-closed gate checks source hygiene, tidy, formatting/parser behavior, source audit, tool builds, auxiliary preflight drivers and CTests, cold standard-library tests, failure replay, and benchmarks. Fixture results and benchmark tables stream to the terminal. It stops at the first failing stage. A focused run is useful during development but is not a substitute for the full gate when shared compiler or runtime behavior changes.

Native and runtime debugging

Use the debugging guide for command lookup, pass isolation, and instrumentation.

Follow the value through parsing, semantic analysis, lowering, NYIR, machine form, object/link, and execution. IR or assembly can locate a fault; only an executed result checks the complete path.

For a reduced case.ny, select the native check matching the question:

build/release/ny-full --no-progress --native-only --nyr-verify case.ny
build/release/ny-full --no-progress --native-only --native-oracle-per-pass case.ny
build/release/ny-full --no-progress --nyr-dump=stats case.ny
FailureFirst useful check
Parse or type errorReduced source with --diag-rich or --diag-compact --collect-errors
Wrong native result--native-only --native-result-oracle
Suspected optimizer regression--native-only --native-oracle-per-pass, then a focused pass dump
Invalid IR--nyr-verify, --nyr-dump=cfg, or --nyr-dump=raw
Register pressure or spills--regalloc-heat and machine-form output
Machine/object faultNY_DUMP_OBJ_NYIR=1, NY_DUMP_MACH=1, NY_KEEP_ASM=1
CrashDebug build and debugger backtrace against ny-full
Browser failureBrowser engine, capability, expected marker, and virtual-time budget

For source types and dynamic boundaries, use --explain=types, --explain=signatures, --explain=fallbacks, or --explain=any. The pipeline reference covers artifact and dump options. Focus traces on the failing phase rather than enabling every category.

Typed integer slots contain raw machine values; dynamic NyValue slots carry tagged values. Pointer, handle, callback, and container boundaries must preserve their own representation. Check both sides of a conversion before changing a runtime helper. A regression should read back the payload and any relevant kind, length, ownership, or error state.

The runtime entry point src/code/backend/runtime/init.c includes its component C files into one translation unit. Keep static names and declarations compatible across those files. GMP remains optional; native BigInt layouts must work without it.

Project-local shared libraries referenced by link "...so" with a sibling C source are built under <tmpdir>/nytrix-shlib/. Do not copy generated binaries into source to satisfy a fixture.

Source converters

Extend the existing formatter converters and keep a fixture for each new input shape. Unsupported C or Python input must retain a visible marker and a useful diagnostic instead of disappearing during conversion. Converter declarations and dispatch live under src/cmd/tools/fmt/.

Test processes

Timeouts must stop fixture descendants, not just the runner. Inspect process ownership before terminating an abandoned run; avoid broad pkill -f commands in a shared workspace. Report pass, failure, timeout, skip, and cached reuse separately. An unavailable display, device, or target runner limits coverage; it is not a successful execution.

Performance

Use Performance for measurement methods and Recorded measurements for dated results.

Keep source, input, checksum, target, route, optimization, cache state, warmups, and measured region fixed. Separate compiler time, startup/link time, runtime, and peak memory. Cache hits, skipped engines, failed compilations, and zero-duration rows are not measurements.

./make bench

Benchmark fixtures run serially by default so concurrent workloads do not contaminate per-fixture timing gates. Pass --jobs N or set NYTRIX_BENCH_JOBS=N to trade measurement isolation for throughput.

For the standalone benchmark runner, select --bench-engine and --bench-target explicitly when comparing routes. Use matching source ny and source c workloads when a meaningful C comparison exists; otherwise label the benchmark non-comparative. One run checks correctness, not speed. See Performance for measurement practice.

Browser work

Native window and renderer checks are described in UI verification; browser execution has a different host contract.

./make web-test reads etc/labs/tests/lang/interop/web/tests.json. Each fixture needs an observable browser result and a bounded virtual-time budget. The maintained wasm-bare path and the separate Emscripten adapter have different build/import contracts. Check WebGL2, Asyncify, assets, persisted VFS, and other host capabilities on the actual route; native filesystem, process, and Vulkan APIs are not automatically browser APIs.

Sanitizers and memory tools

Use separate instrumented build directories. For ASan and UBSan:

cmake -S . -B build/asan -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"
cmake --build build/asan -j 8
ASAN_OPTIONS=detect_leaks=1:halt_on_error=1 \
  build/asan/ny-test --bin build/asan/ny_debug --failures-only \
  --pattern types/refinements/refinements.nshape

Exercise native and JIT execution separately. A JIT non-local-exit warning or signal alone is not a sanitizer finding; retain the actual report and reduce the failing case. For TSan use -fsanitize=thread; MemorySanitizer requires Clang and -fsanitize=memory.

Valgrind should run the compiler process rather than its launcher:

valgrind --leak-check=full --show-leak-kinds=definite \
  --errors-for-leak-kinds=definite --error-exitcode=97 \
  build/release/ny-full path/to/reproducer.ny

For coverage, configure a separate tree with --coverage, build it, and run with NYTRIX_BUILD_DIR selecting that tree. Use lcov and genhtml to collect and render results.

CI and commits

Pushes and pull requests run native build and source checks on Ubuntu, macOS, and Windows. They do not install emulators or run cross-target fixture suites.

Use Actions → Native CI → Run workflow for deeper checks:

macOS source checks use Apple silicon. Execution modes use Intel macOS hosts so the x86-64 NYR routes run natively rather than through emulation. No lane executes the LLVM JIT data-section mapping on Apple arm64 yet: in src/code/lang/ny/gen/llvm/jit.c, ny_apple_jit_alloc_section and its finalize counterpart map data as plain RW pages and reserve MAP_JIT for code only, and that path has not been built or run on macOS.

ControlBehavior
Modechecks, tests, benchmarks, or full (tests, then benchmarks)
PlatformOne native host or all three
FilterTest-path substring or benchmark filename; empty runs all
WorkersParallel test workers; benchmarks always run serially
ColdBypass test result and execution caches; enabled by default
ReplayReplay failed tests and retain diagnostics; enabled by default
Samples / optimizationBenchmark samples after one warm-up, and O0–O3

For full mode, use a filename filter such as startup.nshape that matches both a functional fixture and a benchmark. A failed stage stops later execution; the job summary and downloadable logs remain available. Reports are retained for seven days. Hosted-runner timing is comparative evidence, not a stable performance baseline.

Locally, ./make check --no-test-suite runs the fast build-and-source gate. Use plain ./make check for the complete cold test and benchmark gate. Local test and sanitizer commands are listed in ./make --help.

Commit format

Commit subjects use <type>(<scope>): imperative summary, for example fix(native): preserve raw string tags. Keep subjects plain ASCII and under 68 characters; the scope is required. Types are build, chore, ci, docs, feat, fix, perf, refactor, style, and test. Keep commits coherent, explain non-obvious decisions in the body, and omit generated or co-author trailers. Install the repository hooks with:

git config core.hooksPath .githooks

Pre-commit checks staged whitespace, hygiene, print-debugging, and formatting; commit-msg checks the subject. Run ./make check before publishing. Preserve unrelated working changes. Generated files, temporary debugging probes, and unrelated edits do not belong in a contribution.

Shared Git work

Stage exact paths or hunks belonging to the change and preserve unrelated index content. Do not use reset, restore, stash, checkout, clean, or conflict-abort commands to tidy a shared workspace. Agree before switching branches, publishing, or rewriting history; verify the repository, remote URL, source branch, and destination. A remote called origin or a mirror is not necessarily an approved publication target.

A history rewrite needs an agreed destination and recoverable backup. Use --force-with-lease only for the agreed rewrite; inspect a rejected lease instead of forcing over new work.

For conflicts, inspect both changes and their history, combine independent edits, and resolve incompatible behavior at its owning contract. Check the resolved program before staging the relevant hunks and continuing the merge or rebase. Preserve unrelated staged and working changes throughout.