Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ openfeature-provider/go/demo/demo
target/
# Ignore WASM in root wasm/ directory (build artifact)
wasm/confidence_resolver.wasm
wasm/confidence_event_engine.wasm
# But DO track WASM embedded in Go provider (committed for go:embed)
!openfeature-provider/go/wasm/confidence_resolver.wasm

# Ignore e2e test environment files (contain credentials)
.env.test



# Local planning docs — not part of PRs
ai-plans/
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ resolver = "2" # Use the new resolver for edition 2021
members = [
"wasm-msg",
"wasm/rust-guest",
"wasm/event-guest",
"confidence-resolver",
"confidence-event-engine",
"confidence-cloudflare-resolver",
"openfeature-provider/java",
"openfeature-provider/js",
Expand All @@ -18,7 +20,9 @@ members = [
default-members = [
"wasm-msg",
"wasm/rust-guest",
"wasm/event-guest",
"confidence-resolver",
"confidence-event-engine",
"confidence-cloudflare-resolver"
]
[profile.wasm]
Expand Down
110 changes: 108 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ COPY confidence-resolver/Cargo.toml ./confidence-resolver/
COPY confidence-cloudflare-resolver/Cargo.toml ./confidence-cloudflare-resolver/
COPY wasm-msg/Cargo.toml ./wasm-msg/
COPY wasm/rust-guest/Cargo.toml ./wasm/rust-guest/
COPY wasm/event-guest/Cargo.toml ./wasm/event-guest/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also make sure the event engine is included in the Docker stages that actually run from the final all target? I guess copying the crate into the build context is the first step, but since this PR adds a committed confidence_event_engine.wasm, I just want to make sure CI also builds/lints/tests the standalone module rather than only making its sources available.

COPY confidence-event-engine/Cargo.toml ./confidence-event-engine/
COPY openfeature-provider/java/Cargo.toml ./openfeature-provider/java/
COPY openfeature-provider/js/Cargo.toml ./openfeature-provider/js/
COPY openfeature-provider/go/Cargo.toml ./openfeature-provider/go/
Expand All @@ -58,6 +60,7 @@ COPY wasm/proto ./wasm/proto/

# Copy build.rs files
COPY confidence-resolver/build.rs ./confidence-resolver/
COPY confidence-event-engine/build.rs ./confidence-event-engine/
COPY wasm-msg/build.rs ./wasm-msg/
COPY wasm/rust-guest/build.rs ./wasm/rust-guest/
COPY openfeature-provider/rust/build.rs ./openfeature-provider/rust/
Expand All @@ -68,10 +71,14 @@ RUN mkdir -p confidence-resolver/src && \
echo "pub fn dummy() {}" > confidence-resolver/src/lib.rs && \
mkdir -p confidence-cloudflare-resolver/src && \
echo "pub fn dummy() {}" > confidence-cloudflare-resolver/src/lib.rs && \
mkdir -p confidence-event-engine/src && \
echo "pub fn dummy() {}" > confidence-event-engine/src/lib.rs && \
mkdir -p wasm-msg/src && \
echo "pub fn dummy() {}" > wasm-msg/src/lib.rs && \
mkdir -p wasm/rust-guest/src && \
echo "pub fn dummy() {}" > wasm/rust-guest/src/lib.rs && \
mkdir -p wasm/event-guest/src && \
echo "pub fn dummy() {}" > wasm/event-guest/src/lib.rs && \
mkdir -p openfeature-provider/rust/src && \
echo "pub fn dummy() {}" > openfeature-provider/rust/src/lib.rs

Expand Down Expand Up @@ -100,8 +107,10 @@ COPY --from=rust-deps /workspace/target /workspace/target
COPY Cargo.toml Cargo.lock ./
COPY confidence-resolver/ ./confidence-resolver/
COPY confidence-cloudflare-resolver/ ./confidence-cloudflare-resolver/
COPY confidence-event-engine/ ./confidence-event-engine/
COPY wasm-msg/ ./wasm-msg/
COPY wasm/rust-guest/ ./wasm/rust-guest/
COPY wasm/event-guest/ ./wasm/event-guest/
COPY wasm/proto/ ./wasm/proto/
COPY openfeature-provider/java/Cargo.toml ./openfeature-provider/java/
COPY openfeature-provider/js/Cargo.toml ./openfeature-provider/js/
Expand Down Expand Up @@ -129,6 +138,27 @@ FROM confidence-resolver.build AS confidence-resolver.test
WORKDIR /workspace/confidence-resolver
RUN make test

# ==============================================================================
# Build confidence-event-engine
# ==============================================================================
FROM rust-test-base AS confidence-event-engine.build

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also reference these new event-engine stages from the final all target further down in this file? I thing Docker won’t run this stage family in the main build unless something copies from confidence-event-engine.test / .lint there.

WORKDIR /workspace/confidence-event-engine
RUN cargo build --release --lib

# ==============================================================================
# Test confidence-event-engine
# ==============================================================================
FROM confidence-event-engine.build AS confidence-event-engine.test
WORKDIR /workspace/confidence-event-engine
RUN make test

# ==============================================================================
# Lint confidence-event-engine
# ==============================================================================
FROM confidence-event-engine.build AS confidence-event-engine.lint
WORKDIR /workspace/confidence-event-engine
RUN make lint

# ==============================================================================
# Build wasm-msg (test + lint derive from this to reuse artifacts)
# ==============================================================================
Expand Down Expand Up @@ -172,8 +202,10 @@ COPY --from=rust-deps /workspace/target /workspace/target
COPY Cargo.toml Cargo.lock ./
COPY confidence-resolver/ ./confidence-resolver/
COPY confidence-cloudflare-resolver/ ./confidence-cloudflare-resolver/
COPY confidence-event-engine/ ./confidence-event-engine/
COPY wasm-msg/ ./wasm-msg/
COPY wasm/rust-guest/ ./wasm/rust-guest/
COPY wasm/event-guest/ ./wasm/event-guest/
COPY wasm/proto/ ./wasm/proto/
COPY openfeature-provider/java/Cargo.toml ./openfeature-provider/java/
COPY openfeature-provider/js/Cargo.toml ./openfeature-provider/js/
Expand Down Expand Up @@ -219,6 +251,42 @@ FROM scratch AS wasm-rust-guest.artifact

COPY --from=wasm-rust-guest.build /workspace/target/wasm32-unknown-unknown/wasm/rust_guest.wasm /confidence_resolver.wasm

# ==============================================================================
# Build wasm/event-guest WASM
# ==============================================================================
FROM wasm-deps AS wasm-event-guest.build

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also reference this event WASM stage from the final all target further down in this file? Docker won’t force wasm-event-guest.build / .lint / .artifact during the main build unless all copies from them.


WORKDIR /workspace/wasm/event-guest
RUN make build

WORKDIR /workspace

RUN ls -lh target/wasm32-unknown-unknown/wasm/event_guest.wasm && \
echo "Event WASM size: $(du -h target/wasm32-unknown-unknown/wasm/event_guest.wasm | cut -f1)"

# ==============================================================================
# Test wasm/event-guest (host target — covers build_payload mapping rules)
# ==============================================================================
FROM rust-test-base AS wasm-event-guest.test

WORKDIR /workspace/wasm/event-guest
RUN make test

# ==============================================================================
# Lint wasm/event-guest (WASM target)
# ==============================================================================
FROM wasm-deps AS wasm-event-guest.lint

WORKDIR /workspace/wasm/event-guest
RUN make lint

# ==============================================================================
# Extract wasm/event-guest WASM artifact
# ==============================================================================
FROM scratch AS wasm-event-guest.artifact

COPY --from=wasm-event-guest.build /workspace/target/wasm32-unknown-unknown/wasm/event_guest.wasm /confidence_event_engine.wasm

# ==============================================================================
# Build confidence-cloudflare-resolver (WASM target)
# ==============================================================================
Expand Down Expand Up @@ -306,8 +374,10 @@ COPY openfeature-provider/js/src ./src/
COPY openfeature-provider/js/tsconfig.json openfeature-provider/js/tsdown.config.ts openfeature-provider/js/vitest.config.ts ./
COPY openfeature-provider/js/Makefile ./

# Copy WASM module
# Copy WASM modules. The paths mirror the repo layout because the tests load
# them relative to src/ (see WasmResolver.test.ts / EventWasmResolver.test.ts).
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm ../../../wasm/confidence_resolver.wasm
COPY --from=wasm-event-guest.artifact /confidence_event_engine.wasm ../../../wasm/confidence_event_engine.wasm


# ==============================================================================
Expand Down Expand Up @@ -441,6 +511,35 @@ RUN set -e; \
fi; \
echo "✅ WASM files are in sync"

# ==============================================================================
# Validate committed event engine WASM matches a fresh build (Go go:embed)
# ==============================================================================
FROM alpine:3.22 AS openfeature-provider-go.validate-event-wasm

RUN apk add --no-cache diffutils

COPY --from=wasm-event-guest.artifact /confidence_event_engine.wasm /built/confidence_event_engine.wasm

COPY openfeature-provider/go/confidence/internal/event_tracking/assets/confidence_event_engine.wasm /committed/confidence_event_engine.wasm

RUN set -e; \
echo "Validating event engine WASM sync for Go provider..."; \
if ! cmp -s /built/confidence_event_engine.wasm /committed/confidence_event_engine.wasm; then \
echo ""; \
echo "❌ ERROR: Event engine WASM files are out of sync!"; \
echo ""; \
echo "The committed WASM embedded by the Go provider does not match a fresh build."; \
echo "Note: the binary embeds absolute source paths, so it must be built in Docker."; \
echo ""; \
echo "To fix:"; \
echo " make sync-wasm-event-go"; \
echo " git add openfeature-provider/go/confidence/internal/event_tracking/assets/confidence_event_engine.wasm"; \
echo " git commit -m 'chore: sync event engine WASM for Go provider'"; \
echo ""; \
exit 1; \
fi; \
echo "✅ Event engine WASM files are in sync"

# ==============================================================================
# Build OpenFeature Provider (Go) (test + lint derive from this)
# ==============================================================================
Expand Down Expand Up @@ -555,8 +654,9 @@ COPY openfeature-provider/proto ../proto/
COPY openfeature-provider/python/src ./src/
COPY openfeature-provider/python/tests ./tests/

# Copy WASM module into resources
# Copy WASM modules into resources
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm ./resources/wasm/confidence_resolver.wasm
COPY --from=wasm-event-guest.artifact /confidence_event_engine.wasm ./resources/wasm/confidence_event_engine.wasm

# Copy test data fixtures (needed by tests)
# conftest.py expects data at ../../data relative to python dir
Expand Down Expand Up @@ -748,6 +848,7 @@ FROM scratch AS all

# Copy build artifacts (forces build stages to execute)
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm /artifacts/wasm/
COPY --from=wasm-event-guest.artifact /confidence_event_engine.wasm /artifacts/wasm/

# Force test stages to run by copying marker files
COPY --from=confidence-resolver.test /workspace/Cargo.toml /markers/test-resolver
Expand All @@ -765,11 +866,16 @@ COPY --from=openfeature-provider-rust.test_e2e /workspace/Cargo.toml /markers/te

# Force validation stages to run
COPY --from=openfeature-provider-go.validate-wasm /built/confidence_resolver.wasm /markers/validate-wasm-go
COPY --from=openfeature-provider-go.validate-event-wasm /built/confidence_event_engine.wasm /markers/validate-event-wasm-go

# Force lint stages to run by copying marker files
COPY --from=confidence-resolver.lint /workspace/Cargo.toml /markers/lint-resolver
COPY --from=wasm-msg.lint /workspace/Cargo.toml /markers/lint-wasm-msg
COPY --from=wasm-rust-guest.lint /workspace/Cargo.toml /markers/lint-guest
COPY --from=wasm-event-guest.lint /workspace/Cargo.toml /markers/lint-event-guest
COPY --from=wasm-event-guest.test /workspace/Cargo.toml /markers/test-event-guest
COPY --from=confidence-event-engine.test /workspace/Cargo.toml /markers/test-event-engine
COPY --from=confidence-event-engine.lint /workspace/Cargo.toml /markers/lint-event-engine
COPY --from=openfeature-provider-go.lint /app/go.mod /markers/lint-openfeature-go
COPY --from=openfeature-provider-ruby.lint /app/Gemfile /markers/lint-openfeature-ruby
COPY --from=openfeature-provider-python.lint /app/pyproject.toml /markers/lint-openfeature-python
Expand Down
31 changes: 28 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@
# Local development commands - delegates to component Makefiles

TARGET_WASM := target/wasm32-unknown-unknown/wasm/rust_guest.wasm
TARGET_EVENT_WASM := target/wasm32-unknown-unknown/wasm/event_guest.wasm
GO_WASM := openfeature-provider/go/confidence/internal/local_resolver/assets
GO_EVENT_WASM := openfeature-provider/go/confidence/internal/event_tracking/assets

.PHONY: $(TARGET_WASM) test lint build all clean
.PHONY: $(TARGET_WASM) $(TARGET_EVENT_WASM) test lint build all clean

$(TARGET_WASM):
@$(MAKE) -C wasm/rust-guest build

$(TARGET_EVENT_WASM):
@$(MAKE) -C wasm/event-guest build

wasm/confidence_resolver.wasm: $(TARGET_WASM)
@mkdir -p wasm
@cp -p $(TARGET_WASM) $@
@echo "WASM size: $$(ls -lh $@ | awk '{print $$5}')"

wasm/confidence_event_engine.wasm: $(TARGET_EVENT_WASM)
@mkdir -p wasm
@cp -p $(TARGET_EVENT_WASM) $@
@echo "Event WASM size: $$(ls -lh $@ | awk '{print $$5}')"

# Sync WASM to Go provider using Docker to ensure correct toolchain
.PHONY: sync-wasm-go
sync-wasm-go:
Expand All @@ -25,6 +35,17 @@ sync-wasm-go:
@echo " git add $(GO_WASM)/confidence_resolver.wasm"
@echo " git commit -m 'chore: sync WASM module for Go provider'"

# Sync event engine WASM to Go provider using Docker to ensure correct toolchain
.PHONY: sync-wasm-event-go
sync-wasm-event-go:
@echo "Building event engine WASM with Docker to ensure correct dependencies..."
@docker build --platform linux/arm64 --target wasm-event-guest.artifact --output type=local,dest=$(GO_EVENT_WASM) .
@echo "✅ Event WASM synced to $(GO_EVENT_WASM)/"
@echo ""
@echo "Don't forget to commit the change:"
@echo " git add $(GO_EVENT_WASM)/confidence_event_engine.wasm"
@echo " git commit -m 'chore: sync event engine WASM for Go provider'"

# Build Cloudflare deployer image using main Dockerfile
.PHONY: build-deployer
build-deployer:
Expand All @@ -38,6 +59,8 @@ build-deployer:

test:
$(MAKE) -C confidence-resolver test
$(MAKE) -C confidence-event-engine test
$(MAKE) -C wasm/event-guest test
$(MAKE) -C wasm-msg test
$(MAKE) -C openfeature-provider/js test
$(MAKE) -C openfeature-provider/java test
Expand All @@ -48,15 +71,17 @@ test:

lint:
$(MAKE) -C confidence-resolver lint
$(MAKE) -C confidence-event-engine lint
$(MAKE) -C wasm-msg lint
$(MAKE) -C wasm/rust-guest lint
$(MAKE) -C wasm/event-guest lint
$(MAKE) -C confidence-cloudflare-resolver lint
$(MAKE) -C openfeature-provider/go lint
$(MAKE) -C openfeature-provider/ruby lint
$(MAKE) -C openfeature-provider/rust lint
cargo fmt --check -p wasm-msg -p rust-guest -p confidence_resolver -p confidence-cloudflare-resolver -p spotify-confidence-openfeature-provider
cargo fmt --check -p wasm-msg -p rust-guest -p event-guest -p confidence_resolver -p confidence-event-engine -p confidence-cloudflare-resolver -p spotify-confidence-openfeature-provider

build: wasm/confidence_resolver.wasm
build: wasm/confidence_resolver.wasm wasm/confidence_event_engine.wasm
$(MAKE) -C openfeature-provider/js build
$(MAKE) -C openfeature-provider/java build
$(MAKE) -C openfeature-provider/go build
Expand Down
13 changes: 13 additions & 0 deletions confidence-event-engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "confidence-event-engine"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
prost = { version = "0.13", default-features = false }
prost-types = { version = "0.13", default-features = false }
crossbeam-queue = { version = "0.3.12", default-features = false, features = ["alloc"] }

[build-dependencies]
prost-build = "0.13"
12 changes: 12 additions & 0 deletions confidence-event-engine/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# confidence-event-engine Makefile

.PHONY: test lint clean

test:
cargo test -p confidence-event-engine

lint:
cargo clippy -p confidence-event-engine --lib --release -- -D warnings

clean:
cargo clean
Loading
Loading