feat(policy): Phase 2 scaffolding - Wasm interpreter + pooled runtime#23
Draft
srdjan wants to merge 1 commit into
Draft
feat(policy): Phase 2 scaffolding - Wasm interpreter + pooled runtime#23srdjan wants to merge 1 commit into
srdjan wants to merge 1 commit into
Conversation
Adds an `init(pool_ptr)` function to `WasmPolicyChecker` that mirrors `LocalPolicyChecker.init`, making the startup-time checker selection point explicit. Uses `*anyopaque` to avoid a circular import with the wasm package; the Phase 2 implementation PR will introduce the proper module boundary once `wasm.WasmPool` is live.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 scaffolding for the Wasm-backed policy capability gating system described in
docs/zigttp_zigts_policy_wasm_spec.md. This PR locks in the Phase 2 contract so the implementation PR has clear, compilable targets. No Wasm interpreter is implemented here.Spec reference:
docs/zigttp_zigts_policy_wasm_spec.md— relevant sections:WasmInterpreter.callPolicyCheckstub inpackages/zigts/src/wasm/interpreter.zigWasmPoolskeleton inpackages/zigts/src/wasm/pool.zigencodes this contract in its doc commentinterpreter.zigand in the Phase 2 checklist belowwasm_policy_hashfield inHandlerContract(packages/zigts/src/contract_types.zig) and round-tripped through the contract JSON writer/parserWhat's in this PR
packages/zigts/src/wasm/(new directory)interpreter.zigWasmInterpreterstruct —init,deinit,callPolicyCheckstubs (spec sections 6, 10)pool.zigWasmPoolskeleton wrapping theLockFreePoolpattern —acquire/releasestubs (spec section 10)loader.zigloadWasmArtifactstub — returns raw bytes; later phases add WIT validationroot.zigpackages/zigts/src/policy.zigWasmPolicyCheckerstruct added alongsideLocalPolicyChecker; both exposecheck(input: PolicyInput) PolicyResultso call sites are unchanged at Phase 2 rolloutWasmPolicyChecker.init(pool_ptr)stub mirrorsLocalPolicyChecker.init— makes the startup-time checker selection point explicit"WasmPolicyChecker matches LocalPolicyChecker for known fixtures"added witherror.SkipZigTest— see note belowpackages/zigts/src/contract_types.zigwasm_policy_hash: [32]u8field added toHandlerContract(all-zeros = no Wasm policy present)"wasmPolicyHash"incontract_json_writer.zigand round-tripped incontract_json_parser.zigusing the existingwriteJsonHex/hexToBytesconventionsFailing test — intentional
The test
"WasmPolicyChecker matches LocalPolicyChecker for known fixtures"returnserror.SkipZigTestand does not break CI. It locks in the equivalence contract: the Wasm-backed checker must produce byte-identical results to the in-process checker for every fixture inpackages/zigts/src/fixtures/policy/. The implementation PR will convert it to a real fixture loop by removing thereturn error.SkipZigTestline.Phase 2 implementation checklist
WasmInterpreter.callPolicyCheckwith strict timeout per spec section 10WasmPool(spec section 10: never instantiate per request)wasm_policy_hashfield throughcurrentPolicyHashRaw(reuserule_registry.policyHashconventions)Generated by Claude Code