Skip to main content

xian-compiler-core

This crate is the Rust/WASM compiler core described in ../../docs/RUST_COMPILER_CORE.md.

The crate owns the artifact model, hashing rules, diagnostics, source units, parser adapter, Xian-owned syntax tree, semantic linting, source normalization, structural xian_ir_v1 lowering, bounded compile admission, and compiler fixture loader. The checked-in accepted and rejected fixtures are the shared parity oracle for Rust, Python, WASM/JavaScript, linter, and node admission surfaces.

Rust, Python and WASM default to the fresh-chain profile xian_vm_v2. V2 reads decimal literals from their UTF-8 source digits and emits canonical decimal strings. Use decimal for exported fixed-point values. To reproduce a historical artifact, pass vm_profile="xian_vm_v1" in Python or {"vm_profile":"xian_vm_v1"} in WASM options JSON. Both profiles use the xian_ir_v1 envelope.

Current Surface

  • SourceUnit: validated source/module/profile input wrapper
  • ContractArtifact: typed xian_contract_artifact_v1 deployment artifact
  • build_contract_artifact(...): construct artifact metadata from canonical source and canonical IR bytes
  • validate_contract_artifact(...): verify artifact format, profile (and the expected execution profile when given), hashes, JSON IR, embedded IR identity fields, and that re-lowering the source reproduces the IR exactly (which also rejects non-canonical source)
  • CompilerDiagnostic: stable structured diagnostic payload
  • CompilerLimits: consensus defaults for source bytes, syntax nodes/depth, total tokens, and logical-line tokens
  • parse_source(...): RustPython-backed parser adapter for the current Python-like contract syntax, returning an opaque parsed module
  • parse_diagnostics(...): deterministic parser diagnostic adapter with source ranges
  • parse_to_syntax(...): parse source and convert it into a compact Xian-owned syntax tree
  • build_syntax_tree(...): convert an existing parsed module into Xian syntax
  • SyntaxModule, SyntaxStatement, SyntaxExpression: Rust-owned syntax data model used by later lint/normalize/lower stages
  • lint_syntax(...): semantic lint rules over SyntaxModule
  • normalize_syntax(...): deterministic formatter over the Xian syntax tree
  • normalize_source(...): parse, lint, and return canonical source
  • lower_syntax_to_ir(...): lower a validated syntax tree into structural xian_ir_v1
  • lower_source_to_ir(...): normalize, parse, lint, and lower source into structural xian_ir_v1
  • lower_source_to_ir_json(...): return canonical JSON for the lowered IR
  • compile_contract_artifact(...): normalize, lower, and build a hash-checked xian_contract_artifact_v1
  • compile_contract_source(...): the pair a node deploys for submitted source, CompiledSource { source, vm_ir_json } (normalized source plus the canonical IR lowered from it); vm-core's deploy path and contracting.artifacts use it
  • SUPPORTED_VM_PROFILES, DEFAULT_VM_PROFILE, XIAN_VM_V1_PROFILE, XIAN_VM_V2_PROFILE, CONTRACT_ARTIFACT_FORMAT_V1: the profile and format names, defined here once
  • describe_vm_host_surface(): expose the xian_vm_v1_host_v1 host catalog
  • diagnose_contract(...): authoritative high-level compiler entrypoint; validates the complete source-to-IR path and returns stable diagnostics
  • compiler_version(): machine-readable version and schema metadata
  • CompilerFixture: typed representation of xian.compiler_fixture.v1
  • parse_compiler_fixture_json(...): load a fixture JSON document
  • CompilerFixture::validate_basic(): deterministic structural checks for accepted and rejected fixture records

One Implementation For Every Caller

Artifact assembly (normalization, hashes, IR identity, canonical re-lowering, the expected-profile check), the deploy compile pair and the profile constants live only in this crate. The bindings expose the same operations:

Operation Python (xian_compiler_core) WASM (@xian-tech/compiler)
diagnostics diagnose_contract diagnoseContractJson
artifact compile_contract_artifact compileContractArtifactJson
deploy pair compile_contract_source compileContractSourceJson
validation validate_contract_artifact(..., vm_profile=) validateContractArtifactJson(name, json, inputSource?, vmProfile?)
profiles SUPPORTED_VM_PROFILES, DEFAULT_VM_PROFILE, ... compilerVersionJson()

Both return the same artifact JSON (the Python binding parses the same serde_json string the WASM binding returns), and compiler errors use one message format (<code>: <message> followed by the diagnostics JSON). xian-linter and xian contract build-artifacts call the Python binding directly; contracting.artifacts is a thin delegation that also checks the native host catalog against the contract runtime's host bindings; xian-ide-web, xian-playground-web and xian-js use the WASM package. Structural IR validation stays in vm-core (xian_vm_core.validate_module_ir_json), the VM's own admission rules; the linter calls it on the compiled IR.

Every entrypoint always runs the lint rules; they are part of admission. The only compile option is vm_profile, and unknown options (such as lint) are rejected.

Fixtures are refreshed through the authoritative Python binding with:

uv run python scripts/generate_compiler_fixtures.py \
  --profile xian_vm_v1 packages/xian-compiler-core/tests/sources

To regenerate the default V2 fixtures, use the sources in packages/xian-compiler-core/tests/sources_v2.

Run the Rust fixture checks with:

cargo test --manifest-path packages/xian-compiler-core/Cargo.toml

Check the optional binding layers with:

cargo check --manifest-path packages/xian-compiler-core/Cargo.toml \
  --features python-extension
cargo check --manifest-path packages/xian-compiler-core/Cargo.toml \
  --features wasm

Build the Python package locally with:

uv run python -c "import xian_compiler_core"

Build the WASM package from packages/xian-compiler-core/npm with:

npm run build

The WASM build requires wasm-pack and a Rust toolchain with the wasm32-unknown-unknown standard library installed. The generated npm package is consumed by browser apps such as xian-ide-web and by JS callers that want to compile source locally.

Metadata

Release files for xian-tech-compiler-core 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xian-tech-compiler-core 0.2.1
File Size Uploaded Provenance Actions
xian_tech_compiler_core-0.2.1.tar.gz 114.4 kB With provenance Details for xian_tech_compiler_core-0.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for xian-tech-compiler-core 0.2.1
File Actions
xian_tech_compiler_core-0.2.1-cp314-abi3-win_amd64.whl CPython 3.14 abi3 Windows x86-64 Details for xian_tech_compiler_core-0.2.1-cp314-abi3-win_amd64.whl
xian_tech_compiler_core-0.2.1-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.14 abi3 Linux glibc 2.17+ x86-64 Details for xian_tech_compiler_core-0.2.1-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
xian_tech_compiler_core-0.2.1-cp314-abi3-macosx_11_0_arm64.whl CPython 3.14 abi3 macOS 11.0+ ARM64 Details for xian_tech_compiler_core-0.2.1-cp314-abi3-macosx_11_0_arm64.whl
xian_tech_compiler_core-0.2.1-cp314-abi3-macosx_10_12_x86_64.whl CPython 3.14 abi3 macOS 10.12+ x86-64 Details for xian_tech_compiler_core-0.2.1-cp314-abi3-macosx_10_12_x86_64.whl

Total release size: 6.4 MB

Release files / xian_tech_compiler_core-0.2.1.tar.gz

Download URL xian_tech_compiler_core-0.2.1.tar.gz
Size 114.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5ed5247b6c701893c3f476738975b6bbb73e98d622319b2462b6627d155b10f0
BLAKE2b-256 checksum
How to use checksums
5047817c009226e999d183173d8bff76ff893c72744306ea863e4d46c6743770
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / xian_tech_compiler_core-0.2.1-cp314-abi3-win_amd64.whl

Download URL xian_tech_compiler_core-0.2.1-cp314-abi3-win_amd64.whl
Size 1.5 MB
Tags CPython 3.14 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
92e1c6a2b391fb544278760c163f4f0874b5c6ee81189f47a7b5b6b9c328e782
BLAKE2b-256 checksum
How to use checksums
68d6ba3f82498fa5a528e7c70867467729d6df1589bcc01337d6e33ca08bd682
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / xian_tech_compiler_core-0.2.1-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL xian_tech_compiler_core-0.2.1-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.6 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
26de1ee420ea48eeb54a6263acd4223bd42f7b20cd0f7f11df07baecadbefa01
BLAKE2b-256 checksum
How to use checksums
93840ca6f757c604113575831e0edb8f4c5846795866509e62a4f0db157afe57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / xian_tech_compiler_core-0.2.1-cp314-abi3-macosx_11_0_arm64.whl

Download URL xian_tech_compiler_core-0.2.1-cp314-abi3-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.14 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d82ea0e24924cdf932c924a8b269f45faecd40c525078fed217f60060940bfae
BLAKE2b-256 checksum
How to use checksums
acf38f01253c19706abe16d54d094894d189121957d9d235e64097ecd581672b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / xian_tech_compiler_core-0.2.1-cp314-abi3-macosx_10_12_x86_64.whl

Download URL xian_tech_compiler_core-0.2.1-cp314-abi3-macosx_10_12_x86_64.whl
Size 1.6 MB
Tags CPython 3.14 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
885cba9eba590befe57efaad8651bf3f21c17774ad833051d8f85a3463c3fd45
BLAKE2b-256 checksum
How to use checksums
fbe426076f978396eda89e97f728d7a592055f713476ad941c6a68ca9b211828
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for xian-tech-compiler-core 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for xian_tech_compiler_core-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page