Repository navigation
v0.4.0
Compiled policies on the generic ABI. Additive — evaluate, evaluate_target and evaluate_addressed are unchanged and every existing caller keeps working.
policy_compile(ast) -> handle
evaluate_compiled(handle, input) -> 1 | 0 | -1
evaluate_compiled_addressed(handle, input, package, rule) -> 1 | 0 | -1
policy_release(handle) -> 1 | 0
Driving the same policy through evaluate costs a JSON parse and an AST build on every decision: the export is handed the policy bytes each call and cannot know they are the ones it parsed last time. Build it once instead and the benchmark's RBAC fixture goes from 5.76 µs to 1.32 µs — ahead of OPA-in-wasm's 2.24 µs, where the one-shot path was behind it. This is the arrangement the proxy-wasm filter has always used internally.
Handles are validated, and carry the generation of the slot they were issued for as well as its index, so a stale handle denies even after its slot has been reused. The host owns the handle and must release it.
A cross-engine benchmark. zig build bench now runs zopa in both shapes, OPA compiled to WASM, and an OPA HTTP sidecar over the same fixtures, and refuses to time anything until all of them return the same decision.
| Per decision (µs) | zopa (evaluate) | zopa (compiled) | OPA (wasm) | OPA (sidecar) |
|---|---|---|---|---|
01_static |
0.36 | 0.08 | 0.82 | 138 |
02_header_eq |
0.97 | 0.19 | 0.96 | 132 |
03_rbac |
5.76 | 1.32 | 2.24 | 149 |
Two corrections the benchmark forced. Both are the kind of thing that only surfaces once you measure instead of assert:
- The README said OPA's WASM build was "~30 MB" and two orders of magnitude larger than zopa. Measured,
opa build -t wasmemits 134 KB for a one-line policy and 149 KB for a sixty-rule one. The ~30 MB figure was the OPA binary (40 MB). The real ratio is about 2x, not 500x — zopa's size advantage is real but different in kind: one module serves every policy, where OPA emits one per policy. - The first cut of the compiled-policy handles could resolve to the wrong policy after a released slot was reused, while the docs claimed a stale handle always denies. Fixed with a generation counter before this release; no shipped version ever carried the bug.
Also: zig build bench used to measure the ~940 KB debug build when run without --release=small, both CI opa downloads now verify a pinned checksum before executing the binary, and the code of conduct no longer implies zopa is a CNCF project.
Full detail in CHANGELOG.md.
What's Changed
- docs(proposals): say which designs actually shipped by @kanywst in #43
- docs: stop hard-wrapping prose across the docs by @kanywst in #44
- feat(bench): compare zopa against OPA in wasm and as a sidecar by @kanywst in #45
- feat(abi): let generic hosts compile a policy once and hold it by @kanywst in #46
- docs: stop implying zopa is a CNCF project by @kanywst in #47
- fix(policy): stop a reused slot from resolving a stale handle by @kanywst in #48
- chore(release): 0.4.0 by @kanywst in #49
Full Changelog: v0.3.1...v0.4.0