# Weir crate inventory
Discovery note for `libs/dataflow/weir` (package `weir@0.1.0`, Vyre `0.4.2` train). Counts are from the tree at audit time: ~205 `src/**/*.rs` modules, ~82 `tests/*.rs` integration targets, 3 criterion benches, release evidence under `release/evidence/weir/`.
## What it does
Weir is the GPU-first dataflow layer above Vyre. Frontends (notably surge-frontend and surgec rule lowering) lower programs into CSR graph buffers and fact bitsets; Weir validates those layouts, builds `vyre::Program` steps, and drives fixed-point / IFDS / witness extraction through Vyre backends (CUDA via `vyre-driver-cuda`, WGPU via `vyre-driver-wgpu`). CPU routines under `weir::oracle` and `*_cpu_oracle` modules exist only for parity, fuzzing, and release evidence: not for production dispatch.
The critical release path is IFDS reachability, resident batching (graph upload once, sequence-window iteration), and `reachability_witness` source-to-sink proof extraction. Secondary primitives cover reaching definitions, points-to, slicing, dominators, range checks, callgraph, liveness, SCC, escape, and SSA phi-placement reference machinery.
## Dependencies (`Cargo.toml`)
| `vyre` | IR `Program` builders and backend traits |
| `vyre-foundation` | Soundness tags (`Soundness`, `PrecisionContract`, …) |
| `vyre-harness` | `inventory::submit!` op entries and convergence contracts |
| `vyre-primitives` | CSR traversals, bitset ops, exploded-graph encoding |
| `bytemuck` | Zero-copy LE packing/unpacking on host |
| `smallvec` | Small inline buffers in hot closures |
| `inventory` | Registered op metadata for harness |
| `serde` (optional) | Witness / evidence serialization |
Dev-dependencies: `criterion`, `proptest`, `surge-frontend`, `vyre-driver*`, `vyre-primitives/cpu-parity` for GPU parity tests.
Features: `default = []`, `cpu-parity` (enables oracle modules + many `[[test]]` targets), `serde` (evidence types).
## Public surface (modules and primary entry points)
| `ssa` | `SsaForm`, `Cfg`, `Block`, `compute_dominators`, `try_compute_dominators`, `compute_dominance_frontiers`, `place_phi_nodes`, `rename_variables`, `ssa_phi_placement_step` |
| `def_use` | `try_def_use_chain` |
| `reaching` / `reaching_def` | `reaching_defs_step`, `ReachingDefs`, `reaching_def`, closure/resident/plan APIs |
| `reaching_def_summary` | `reaching_def_summary`, `fold_summary_partials`, `DEFAULT_PARTIAL_BINS` |
| `ifds` / `ifds_gpu` | `ifds_reach_step`, `Ifds`, resident batch/solve, `IfdsShape`, CSR prepare |
| `reachability_witness` | `prepare_witness_graph`, `extract_path_prepared`, `PathSeed`, `ExtractedPath`, `exploded_reachability_to_statement_mask` |
| `points_to` / `may_alias` | Andersen programs, alias query |
| `slice` | `backward_slice`, resident slice closure |
| `live` / `live_at` | Liveness step and point queries |
| `dominators` / `post_dominates` | Dominator programs |
| `range` / `range_check` | Range propagation and bound check |
| `callgraph` | Callgraph build and reachability |
| `control_dependence` | CD bitset construction |
| `cross_language` | Multi-language edge fusion |
| `escape` / `escapes` | Escape analysis |
| `must_init` / `scc_query` / `value_set` | Specialized queries |
| `summary` / `loop_sum` | Function/loop summarization |
| `soundness` | `Soundness`, `PrimitiveSoundness`, `validate_pipeline`, `DataflowEvidence` |
| `fixed_point_graph` | `FixedPointForwardGraph`, `FixedPointAnalysisPlan`, layout hash |
| `fixed_point_resident` | `FixedPointResidentGraph`, `FixedPointResidentBatch`, caches, scratch |
| `fixed_point_execution_plan` / `_cache` | Plan reuse keyed by layout + backend |
| `graph_layout` | `CsrGraph`, `NormalizedCsrGraph`, `stable_csr_layout_hash` |
| `oracle` (`cpu-parity`) | CPU reference oracles for parity tests |
Private but load-bearing: `dispatch_decode` (pack/unpack ABI), `staging_reserve`, `dense_domain`, `error_format`, IFDS resident solve/prepare internals.
## How downstream crates consume Weir
| **surgec** | Scan pipeline: dominator bitmap sizing via `weir::oracle::graph`, points-to / may-alias predicates, callgraph in diff scans. Does not own parsing; lowers rules then dispatches Weir programs. |
| **surge-frontend** | Walker references `weir::ssa` for Cytron-style SSA while migrating to resident graph programs (`compound_stmt` / walker). |
| **writ** / **scry** | Symbolic paths over Weir-produced reachability witnesses (workspace dependency). |
| **vyre-bench** | Optional `external-baselines` feature for cross-crate vyre vs weir benches. |
Weir is listed in the root workspace `Cargo.toml` and exposed as `weir = { path = "libs/dataflow/weir" }`.
## Tests and benches
**Unit / module tests:** Embedded under `src/**/tests.rs`, `*_tests.rs`, and `#[cfg(test)]` modules (IFDS resident contracts, graph layout, dispatch decode, SSA, scratch retention).
**Integration tests (`tests/`):** Large `df_*` construction/property suites (require `cpu-parity`), GPU parity tests (`*_gpu_parity`, `ifds_resident_*`), release contracts (`release_surface_contract`, `oracle_boundary`, `source_boundary`), scratch/benchmark contracts (`fixed_point_scratch_contract`, `resident_benchmark_contract`).
**Benches (`benches/`):**
| `primitive_micro` | Host micro-LO regression gates (layout hash, summary fold, SSA dominators) |
| `resident_fixed_point_hot_path` | Resident batch warm vs cold graph upload |
| `ifds_direct_resident_hot_path` | IFDS direct resident prepare (`cpu-parity`) |
**Honest gaps:** Many GPU parity and `df_*` tests are feature-gated; default `cargo test -p weir` runs a smaller subset. Full parity requires `cpu-parity` plus working GPU drivers in dev-deps. No single binary “main” for flamegraph: use criterion benches above.