Files
ziran/docs/CAPABILITIES.md
T
waoziandClaude Opus 5.5 931fed4c86 Run ZX natively by default and integrate the finished assembly lanes
One commit, because the parts below only build together.

Allocator: an interval needed at the current instruction is never
evicted, and the allocated-program verifier checks that every operand sits
where the allocation says.

AArch64 encoder: compiler_aarch64.zi encodes allocated machine IR with the
shared ARM byte helpers, maps the function-address relocation,
sign-extends signed 8- and 16-bit loads and rejects what it cannot encode
with a named diagnostic. It has no AOT ELF writer yet.

Native default with checked pointers and no fallback: on linux-x86_64,
`ziran run app.zx`, `zi2zx run`, the embedding API's Auto and the Kryon
players run a bundle's verified program as native code in W^X memory.
Stray and freed pointers, double free, bounds and read-only stores trap. A
native gap is a named preflight error, nothing falls back to the engine,
and `--backend engine` picks it explicitly. zx2native uses the same
preflight. Native code exchanges module state for hot reload, checks the
stack, zeroes fresh locals, spends fuel at the engine's checkpoints and
returns records, arrays and strings from host calls. `zi2zx --debug` source
origins name lines in native traps and `zx2native --emit map`. The host
value API drops its VM prefix (HostValue, HOST_*). A call with a record
result loads the hidden result address into rax only after its stack
arguments are stored, and an indirect target stays in r10: rax could hold
a stack argument (Kryon's text-field clip guard arrived as an address) or
the target (indirect calls returning records crashed).

Self-hosting ports: compiler_backend_process, compiler_backend_cache,
compiler_native_names and compiler_runtime_emit replace the zir_c_build,
zir_c_cache and zir_c_process C, with checked bootstrap C and Makefile
rules. zir_c.toolchain again reports "compiling OUT failed:" with the head
of the compiler output and a truncation marker. The parallel scheduler no
longer stalls on a held compiler after reaping a finished job, and poll or
read errors now fail the build. A fresh BUILD_DIR (Kryon's runtime build)
builds: generated files have pattern rules, objects wait for the headers
they include, and engine flags are per object instead of leaking into zi2c.

Legacy removals F1-F10 and N1-N4: the duplicate LirX64 encoder and its
spec test, zir_c_*, zir_runtime and zir_native, nine zero-reference spec
tests, vec_capacity, the zx_metadata and native_cache_names benchmarks,
build-android-host.sh and two shell wrappers are deleted; zx2native is
machine-only; `zi2zx` rejects `--opt` on ZX input; the bootstrap is
regenerated. ASSEMBLY docs, the legacy-removal plan, the milestones and the
remaining-work plan record the current position.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 14:04:48 -03:00

5.8 KiB

Compiler capability output

ziran capabilities --json prints one JSON object describing the currently supported output targets and shared limits. Use --target=c, go, or zx to select one target. The command works without a project or network access, so an editor or coding agent can query the installed compiler before generating code. The numeric_conformance object is a stable-ID registry. Its ids cite the numerical cases proven by numeric semantics for C, Go, and .zx; they are described by numeric_conformance.json. The width matrix adds 592 independently generated boundary conversions across all 64 integer type pairs, from source and saved IR on those three targets. assembly_targets (in the full report) is the direct assembly target's registry: every described CPU/OS row with its abi, pointer_bits, state (implemented, gap, excluded or unknown), the stable diagnostic selecting it produces, its cpu_baseline, and the CPU features and OS services it implements. Only implemented rows pass preflight; no row is implemented yet, so every row reports assembly.gap.target-unimplemented. ziran capabilities --assembly-target=ROW[+FEATURE...] [--os-service=NAME]... [INPUT.zi|INPUT.zir ...] runs that preflight before reading any input: it prints the row with "preflight":"pass", or fails before any output, initializer, host call or entry with assembly.gap.target-unimplemented, assembly.gap.cpu-feature or assembly.gap.os-service (JSON with --diagnostics=json). schema_version starts at 1; consumers should reject schema versions they do not understand and ignore unknown fields within a version.

tier says how complete a target is. primary targets, C and the portable .zx runner, carry every language feature and gate every change. The downstream applications build through them. The secondary target, Go, may lag behind a new feature, but must reject a program it cannot run faithfully during checking or lowering, never emit code with a different meaning. New language work lands on the primary targets first.

source_and_saved_ir reports that the target accepts checked source and saved .zir inputs. parallel_execution is threads for C forward CPU regions and serial for Go and the portable engine. device backend. text_view_mutable_bytes reports the current observable It does not promise a parallel result reduction. gpu_execution is gap for every target: there is no device backend, and CPU execution is never selected. text_view_mutable_bytes reports the current observable divergence when backing bytes are mutated after making a view: native C borrows those bytes, while Go and .zx copy them. Checking rejects mutation of local backing storage while a direct, field-held, aliased, or checked-call-produced view is live. Field-sensitive checks protect the borrowed field or array while allowing sibling record fields to change. Global views track their backing-global origins and alias chains, and views through local *value pointers protect their pointee and pointer aliases. Unknown local pointer views are rejected when their backing lifetime cannot be proved. Local copies of pointer parameters preserve their backing identity. Separate pointer or slice parameters of the same type are possible aliases. Checked calls include transitive parameter/global writes, and earlier text arguments stay live while later arguments and the procedure body execute. Unknown callbacks conservatively write reference arguments. Differently typed pointer aliases and arbitrary host-backed aliases still need further coverage; raw native FFI has no checked memory-effect contract.

automatic_vec_drop is true for every target: direct owned Vec locals and parameters are released at scope exit or return, as are vectors reachable through record fields and fixed arrays. Global storage remains shared and is not automatically released. text_view_local_mutation_check is true for every target: checking rejects mutation of local backing storage while a direct, field-held, aliased, or checked-call-produced TextView is live. Checks are field-sensitive, include global backing origins, local *value pointer aliases, and local copies of pointer parameters. text_view_opaque_pointer_check reports rejection of TextView through opaque local pointers with unproven backing lifetimes. heap_allocation reports zero-initialized New(T) and free(pointer). C, Go, and the portable engine are checked from source and saved IR by tests/heap_new.sh. Native pointers retain their native lifetime rules; this flag does not promise automatic ownership or runtime checking of arbitrary pointer aliases.

target_preflight reports the common foreign identity/import, native callback ABI, and Go/portable scalar-union checks available through ziran check --target=... and builds. Go and .zx reject #c_call procedure types with a procedures.c-call capability diagnostic before native output is emitted. The target's lowerer and verifier still enforce its other limits. aggregate_vec_transfer is true: whole local aggregates, fresh aggregate call results, and vector-bearing record-literal fields can move through assignment, argument passing, and return, with native targets recursively clearing every moved vector field. diagnostics_json is partial: compiler tools, the package launcher, and formatter report ordinary argument, input, output, allocation, and native-tool failures as schema-versioned JSON, but arbitrary external package tools and fatal process signals can still produce unstructured output. These are current boundaries, not feature requests or guarantees about unlisted behavior. See implementation status and the owned-value contract for detail.