Skip to content

Commit 44af62c

Browse files
committed
build(nix): package wasm resolver variant
1 parent 6d55357 commit 44af62c

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

flake.nix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,30 @@
151151
};
152152
};
153153

154+
# Production variant for catalogs that declare wasm resource-profile resolvers. Keep the
155+
# default package lightweight; consumers opt into the wasmtime closure explicitly.
156+
st2WasmResolver = st2.overrideAttrs (old: {
157+
pname = "st2-wasm-resolver";
158+
cargoBuildFeatures = (old.cargoBuildFeatures or [ ]) ++ [ "wasm-resolver" ];
159+
cargoCheckFeatures = (old.cargoCheckFeatures or [ ]) ++ [ "wasm-resolver" ];
160+
# Wasmtime's Cranelift build and the feature-gated resolver tests need the Rust toolchain
161+
# inherited from buildRustPackage plus an LLVM linker on every supported platform.
162+
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.lld ];
163+
});
164+
165+
# Non-vacuous feature gate: both the runner's live resync integration and agent-spec's wasm
166+
# ABI/containment suite compile and execute with the same features as the production variant.
167+
st2WasmResolverCheck = st2WasmResolver.overrideAttrs (_: {
168+
pname = "st2-wasm-resolver-check";
169+
cargoTestFlags = [
170+
"--workspace"
171+
"--test"
172+
"resync"
173+
"--test"
174+
"profile_wasm"
175+
];
176+
});
177+
154178
# Narrow sandbox-safe integration gate for the atomic snapshot boundary. The main package
155179
# deliberately omits the broad doctor suite because some doctor cases exercise facilities
156180
# unavailable in the Nix sandbox. A dedicated target containing exactly one test makes the
@@ -249,6 +273,7 @@
249273
in
250274
{
251275
packages.st2 = st2;
276+
packages.st2-wasm-resolver = st2WasmResolver;
252277
packages.default = st2;
253278

254279
# `nix flake check` is the whole CI: it builds the package — which runs
@@ -266,6 +291,34 @@
266291
checks.message-cli = st2MessageCli;
267292
checks.parked-recovery = st2ParkedRecovery;
268293
checks.otel-export = st2OtelExport;
294+
checks.wasm-resolver-feature = st2WasmResolverCheck;
295+
# Exercise the shipped binary, not a cargo-side surrogate: its version entrypoint runs and
296+
# the same artifact strictly admits a catalog carrying a real wasm profile module.
297+
checks.wasm-resolver-artifact = pkgs.runCommand "st2-wasm-resolver-artifact-${version}" { } ''
298+
${st2WasmResolver}/bin/st2 --version |
299+
${pkgs.gnugrep}/bin/grep -E '^st2 [^[:space:]]+' >/dev/null
300+
301+
catalog="$TMPDIR/catalog"
302+
mkdir -p "$catalog/resolvers" "$catalog/h/worker"
303+
cp ${self}/crates/agent-spec/tests/fixtures/demo_resolver.wasm \
304+
"$catalog/resolvers/goal.wasm"
305+
cat > "$catalog/catalog.kdl" <<'EOF'
306+
profile "dev.schickling.agent-goal" {
307+
wasm "resolvers/goal.wasm"
308+
class "immediate"
309+
}
310+
EOF
311+
cat > "$catalog/h/worker/agent.kdl" <<'EOF'
312+
agent "worker" {
313+
host "h"
314+
command "true"
315+
resource "goal" uri="dev.schickling.agent-goal://h/worker" reason="Mission."
316+
}
317+
EOF
318+
319+
${st2WasmResolver}/bin/st2 validate "$catalog" --host h --strict
320+
touch "$out"
321+
'';
269322

270323
# Real producer-consumer contract: st2 consumes `pty list --json` from the exact pty
271324
# revision that owns fleet observation. Fake CLI fixtures below still cover malformed

0 commit comments

Comments
 (0)