Skip to content

Commit 0467e30

Browse files
committed
feat(bazel): full AADL → WIT → wit-bindgen → .wasm component chain builds
Real end-to-end Bazel build using rules_wasm_component pinned to a specific main-branch SHA (the v1.0.0 tag predates the Bazel-9 CcInfo migration). The chain: arch/kvs.wit │ ▼ wit_library + rust_wasm_component_bindgen │ (in BUILD.bazel) │ src/lib.rs implements the wit-bindgen-generated `Guest` trait │ ▼ rust + WASI sysroot toolchain (pulled by rules_wasm_component) │ bazel-bin/.../kvs_component_*_wasm_base.wasm ← real .wasm Local + CI: bazel build //... ✓ Build completed successfully bazel test //:kvs_component_test ✓ PASSED If src/lib.rs's `impl Guest for Component` doesn't match the WIT signatures (renamed method, wrong arity, drifted error variant), the Rust compile fails. The binary contract is enforced at build time — the operational difference from eclipse-score's interface-as-documentation model is now demonstrably real, not narrative. ## Files - MODULE.bazel — rules_wasm_component via git_override (SHA-pinned to main; v1.0.0 tag has a Bazel-9 incompat issue); rules_rust, bazel_skylib, platforms; crate_universe (`@crates`) wired to Cargo.toml for the bitflags + wit-bindgen runtime deps the bindgen rule needs (known wart in rules_wasm_component — its docstring explicitly tells external consumers to wire this). - BUILD.bazel — wit_library + rust_wasm_component_bindgen + rust_wasm_component_test. - Cargo.toml + Cargo.lock — bitflags + wit-bindgen 0.46 (matched to the CLI version rules_wasm_component embeds). - src/lib.rs — in-memory KVS impl. ~80 LOC; implements the WIT `Guest` trait with store / load / delete / snapshot_create / snapshot_restore. Key validation gates per COMP-REQ-KVS-KEY-NAMING. - .github/workflows/validate.yml — bazel-wasm-component job installs bazelisk and runs `bazel build //...` + `bazel test` on every push/PR. - .gitignore — bazel-* outputs, MODULE.bazel.lock, target/ README updated to reflect that the chain actually builds (status table at the top now uses ✅ / 📄 instead of "real infrastructure / skeleton" prose). This closes the user's "but then you need the full stack with bazel as well or?" question: yes, and it does now.
1 parent aecaf86 commit 0467e30

9 files changed

Lines changed: 709 additions & 19 deletions

File tree

.github/workflows/validate.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,23 @@ jobs:
3939

4040
- name: artifact-driven verification gate
4141
run: make verify
42+
43+
bazel-wasm-component:
44+
name: bazel build (AADL → WIT → wasm component)
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Install bazelisk
50+
run: |
51+
curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64 \
52+
-o /usr/local/bin/bazelisk
53+
chmod +x /usr/local/bin/bazelisk
54+
ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel
55+
bazel --version
56+
57+
- name: bazel build //... (WIT → wit-bindgen → rust_component → .wasm)
58+
run: bazel build //...
59+
60+
- name: bazel test //... (rust_wasm_component_test)
61+
run: bazel test //... --test_output=errors

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
*.swp
33
.DS_Store
44
/tmp-*/
5+
6+
# Bazel outputs
7+
bazel-*
8+
MODULE.bazel.lock
9+
/target/
10+

BUILD.bazel

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""Bazel build for the persistency::kvs WASM component.
2+
3+
The chain:
4+
1. wit_library declares the KVS interface contract (arch/kvs.wit)
5+
2. rust_wasm_component_bindgen generates Rust bindings from the WIT,
6+
compiles src/lib.rs against those bindings, and produces a WASM
7+
component artifact.
8+
3. rust_wasm_component_test smoke-tests that the produced .wasm is
9+
a well-formed component.
10+
11+
If src/lib.rs's `impl Guest for Component` doesn't match the WIT
12+
signatures, the Rust compile fails — the binary contract is
13+
enforced at build time, which is the central operational difference
14+
from eclipse-score's interface-as-documentation approach.
15+
"""
16+
17+
load("@rules_wasm_component//rust:defs.bzl",
18+
"rust_wasm_component_bindgen",
19+
"rust_wasm_component_test")
20+
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
21+
22+
package(default_visibility = ["//visibility:public"])
23+
24+
# ── 1. Declare the WIT interface ──────────────────────────────────────
25+
# arch/kvs.wit declares `package pulseengine:kvs@0.1.0;` with the
26+
# `kvs` interface and `kvs-component` world. This target makes the
27+
# WIT available as a Bazel dependency.
28+
wit_library(
29+
name = "kvs_interface",
30+
package_name = "pulseengine:kvs",
31+
srcs = ["arch/kvs.wit"],
32+
world = "kvs-component",
33+
)
34+
35+
# ── 2. Generate bindings + compile the Rust impl ──────────────────────
36+
# rust_wasm_component_bindgen runs wit-bindgen on :kvs_interface to
37+
# generate the Rust trait `Guest`, then compiles src/lib.rs (which
38+
# implements `Guest`) against those bindings, producing a WASM
39+
# component at bazel-bin/kvs_component.wasm.
40+
rust_wasm_component_bindgen(
41+
name = "kvs_component",
42+
srcs = ["src/lib.rs"],
43+
profiles = ["release"],
44+
validate_wit = False, # consistent with rules_wasm_component basic example
45+
wit = ":kvs_interface",
46+
)
47+
48+
# ── 3. Smoke-test the produced component ──────────────────────────────
49+
rust_wasm_component_test(
50+
name = "kvs_component_test",
51+
component = ":kvs_component",
52+
)

0 commit comments

Comments
 (0)