Skip to main content

WasmPolicyStore

Struct WasmPolicyStore 

Source
pub struct WasmPolicyStore { /* private fields */ }
Expand description

PolicyStore — situation-matching authorization + change-cost policies. Wraps agentstategraph_policy::PolicyStore.

Construct from a WasmAgentStateGraph, a path prefix (e.g. /policies), and an agent id.

Implementations§

Source§

impl WasmPolicyStore

Source

pub fn new( asg: &WasmAgentStateGraph, prefix: &str, agent_id: &str, ) -> WasmPolicyStore

Create a PolicyStore bound to an AgentStateGraph instance.

Source

pub fn propose( &self, ref_name: &str, policy_json: &str, ) -> Result<String, JsValue>

Write a proposed (unratified) policy. Returns "path@version". policy_json is the serialized Policy struct.

Source

pub fn ratify( &self, ref_name: &str, path: &str, ratifier: &str, reasoning: &str, ) -> Result<(), JsValue>

Ratify an unratified proposal at path.

Source

pub fn supersede( &self, ref_name: &str, path: &str, new_policy_json: &str, ) -> Result<String, JsValue>

Replace the active policy at path with new_policy_json. Returns the new "path@version" handle.

Source

pub fn list( &self, ref_name: &str, prefix_filter: Option<String>, tenant_filter: Option<String>, ) -> Result<String, JsValue>

List every policy (active versions, ratified or not). Returns a JSON array.

tenantFilter (0.7.5 §3b / §5d): None/undefined keeps back-compat (all policies considered). When provided, routes through the Rust list_scoped variant so only policies whose tenant_id is unset (global) or equal to the filter are returned.

Source

pub fn active( &self, ref_name: &str, prefix_filter: Option<String>, tenant_filter: Option<String>, ) -> Result<String, JsValue>

List currently-active policies (ratified AND active_from <= now).

tenantFilter (0.7.5 §3b / §5d) matches Self::list semantics.

Source

pub fn get( &self, ref_name: &str, path: &str, version: Option<u64>, ) -> Result<String, JsValue>

Fetch a policy at path. If version is provided, returns the pinned historical version; otherwise the current active version.

Source

pub fn history(&self, ref_name: &str, path: &str) -> Result<String, JsValue>

Walk the supersedes chain (oldest first → current).

Source

pub fn evaluate( &self, ref_name: &str, situation_json: &str, action: &str, agent_id: &str, tenant_filter: Option<String>, ) -> Result<String, JsValue>

Authorization evaluation (POLICY_V1.md §5). Returns a Decision JSON object.

tenantFilter (0.7.5 §3b / §5d) routes through the Rust evaluate_scoped variant: None/undefined considers every policy (back-compat); Some("acme") restricts matching to policies whose tenant_id is unset (global) or equal to "acme".

Source

pub fn evaluate_change( &self, ref_name: &str, proposal_json: &str, tenant_filter: Option<String>, ) -> Result<String, JsValue>

Change-proposal evaluation (POLICY_V1.md §22.2). Returns a Decision JSON object.

tenantFilter (0.7.5 §3b / §5d) matches Self::evaluate semantics.

Source

pub fn sign( &self, ref_name: &str, path: &str, signer_key_id: &str, private_key_hex: &str, ) -> Result<String, JsValue>

Sign the active policy at path with an Ed25519 private key. private_key_hex is a 32-byte seed encoded as 64 hex chars. Returns a JSON string {algorithm, signer_key_id, signature_hex}.

Source

pub fn verify( &self, ref_name: &str, path: &str, public_key_hex: &str, ) -> Result<String, JsValue>

Verify the Ed25519 signature on the policy at path using public_key_hex (64-char hex / 32-byte key). Returns {valid: true, algorithm, signer_key_id} on success, {valid: false, reason} otherwise.

Source

pub fn set_external_evaluator( &self, ref_name: &str, path: &str, config_json: Option<String>, ) -> Result<String, JsValue>

Attach or update the external evaluator reference on the policy at path (stub). Returns the same envelope as sign / verify. Until the runtime-side mutator lands, callers can set external_evaluator on the policy JSON before propose / supersede — the field is preserved by serde round-trip.

Source

pub fn check_tokens( &self, ref_name: &str, tokens_json: &str, ) -> Result<String, JsValue>

List ratified policies whose triggers intersect tokens_json (a JSON array of strings). Convenience wrapper exposing the filter evaluate_change uses internally.

Trait Implementations§

Source§

impl From<WasmPolicyStore> for JsValue

Source§

fn from(value: WasmPolicyStore) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for WasmPolicyStore

Source§

type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: Self::Abi) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for WasmPolicyStore

Source§

type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> Self::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for WasmPolicyStore

Source§

type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<WasmPolicyStore>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for WasmPolicyStore

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for WasmPolicyStore

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for WasmPolicyStore

Source§

type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<WasmPolicyStore>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for WasmPolicyStore

Source§

type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<WasmPolicyStore>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl SupportsConstructor for WasmPolicyStore

Source§

impl SupportsInstanceProperty for WasmPolicyStore

Source§

impl SupportsStaticProperty for WasmPolicyStore

Source§

impl TryFromJsValue for WasmPolicyStore

Source§

fn try_from_js_value(value: JsValue) -> Result<Self, JsValue>

Performs the conversion.
Source§

fn try_from_js_value_ref(value: &JsValue) -> Option<Self>

Performs the conversion.
Source§

impl VectorFromWasmAbi for WasmPolicyStore

Source§

impl VectorIntoWasmAbi for WasmPolicyStore

Source§

impl WasmDescribe for WasmPolicyStore

Source§

impl WasmDescribeVector for WasmPolicyStore

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more