# vyre-foundation
The hardware-neutral compiler foundation for vyre: IR (`Expr`, `Node`,
`Program`), type system, memory model, wire format, visitor traits, and
extension resolvers. Every other vyre crate depends on this one; this
crate depends only on `vyre-spec`, `vyre-macros`, and lightweight
third-party data crates. It does not know what `naga`, `wgpu`, a
dialect, or a backend is.
## Usage
```rust
use vyre_foundation::ir::{BufferDecl, DataType, Expr, Node, Program};
let program = Program::wrapped(
vec![BufferDecl::output("out", 0, DataType::U32).with_count(1)],
[1, 1, 1],
vec![
Node::store("out", Expr::u32(0), Expr::u32(42)),
Node::Return,
],
);
let wire = program.to_wire().unwrap();
assert_eq!(Program::from_wire(&wire).unwrap(), program);
```
## Architecture
See [`COMPUTE_2_0.md`](../.internals/planning/COMPUTE_2_0.md) for the
layer DAG. Foundation sits at the bottom; every migration target
listed there: foundation-ir, foundation-visit, foundation-wire: is
contained in this crate until the per-subcrate split lands in a later
phase.
## Crate contract
This section is generated by `python3 scripts/crate_readmes.py --write` from
the crate manifest, release train, ownership registry, and crate-guide metadata.
### Purpose
Own typed IR and ProgramGraph contracts, validation, diagnostics, serialization, semantic operation registration, and backend-neutral optimization.
### Boundaries
The `foundation-ir` owner maintains this `foundation` crate at `vyre-foundation`.
Its allowed internal production dependencies are: `vyre-macros`, `vyre-spec`.
Any other normal or build dependency requires an ownership-registry change.
### Minimal real example
Run the checked-in behavior from `vyre-foundation/examples/vyre_foundation_release_surface.rs`:
```console
CARGO_BUILD_JOBS=1 ./cargo_full run -p vyre-foundation --example vyre_foundation_release_surface
```
### Features
- Manifest features: `default`, `serde`
- Default feature members: None
### Errors and unsupported behavior
Malformed programs, incompatible schemas, and invalid transformations fail closed through validation or parsing errors before execution.
### Testing
Use [`docs/testing/vyre-foundation.md`](../docs/testing/vyre-foundation.md) for exact commands, Cargo targets, hardware
requirements, evidence outputs, expected skips, and failure semantics.
### Release status
`vyre-foundation@0.7.2` is a publishable crate on the current Vyre release train. Publication still requires the release evidence and user-approval gates.
### Ownership
`docs/CRATE_OWNERSHIP.toml` is authoritative for this crate's responsibility
and allowed internal edges. Regenerate `docs/CRATE_GRAPH.md` and
`docs/OWNERSHIP.md` after changing that registry.
### License
Licensed under either of
- Apache License, Version 2.0, or
- MIT license
at your option. See the workspace `LICENSE-APACHE` and `LICENSE-MIT` files.