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
impl WasmPolicyStore
Sourcepub fn new(
asg: &WasmAgentStateGraph,
prefix: &str,
agent_id: &str,
) -> WasmPolicyStore
pub fn new( asg: &WasmAgentStateGraph, prefix: &str, agent_id: &str, ) -> WasmPolicyStore
Create a PolicyStore bound to an AgentStateGraph instance.
Sourcepub fn propose(
&self,
ref_name: &str,
policy_json: &str,
) -> Result<String, JsValue>
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.
Sourcepub fn ratify(
&self,
ref_name: &str,
path: &str,
ratifier: &str,
reasoning: &str,
) -> Result<(), JsValue>
pub fn ratify( &self, ref_name: &str, path: &str, ratifier: &str, reasoning: &str, ) -> Result<(), JsValue>
Ratify an unratified proposal at path.
Sourcepub fn supersede(
&self,
ref_name: &str,
path: &str,
new_policy_json: &str,
) -> Result<String, JsValue>
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.
Sourcepub fn list(
&self,
ref_name: &str,
prefix_filter: Option<String>,
tenant_filter: Option<String>,
) -> Result<String, JsValue>
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.
Sourcepub fn active(
&self,
ref_name: &str,
prefix_filter: Option<String>,
tenant_filter: Option<String>,
) -> Result<String, JsValue>
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.
Sourcepub fn get(
&self,
ref_name: &str,
path: &str,
version: Option<u64>,
) -> Result<String, JsValue>
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.
Sourcepub fn history(&self, ref_name: &str, path: &str) -> Result<String, JsValue>
pub fn history(&self, ref_name: &str, path: &str) -> Result<String, JsValue>
Walk the supersedes chain (oldest first → current).
Sourcepub fn evaluate(
&self,
ref_name: &str,
situation_json: &str,
action: &str,
agent_id: &str,
tenant_filter: Option<String>,
) -> Result<String, JsValue>
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".
Sourcepub fn evaluate_change(
&self,
ref_name: &str,
proposal_json: &str,
tenant_filter: Option<String>,
) -> Result<String, JsValue>
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.
Sourcepub fn sign(
&self,
ref_name: &str,
path: &str,
signer_key_id: &str,
private_key_hex: &str,
) -> Result<String, JsValue>
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}.
Sourcepub fn verify(
&self,
ref_name: &str,
path: &str,
public_key_hex: &str,
) -> Result<String, JsValue>
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.
Sourcepub fn set_external_evaluator(
&self,
ref_name: &str,
path: &str,
config_json: Option<String>,
) -> Result<String, JsValue>
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.
Trait Implementations§
Source§impl From<WasmPolicyStore> for JsValue
impl From<WasmPolicyStore> for JsValue
Source§fn from(value: WasmPolicyStore) -> Self
fn from(value: WasmPolicyStore) -> Self
Source§impl FromWasmAbi for WasmPolicyStore
impl FromWasmAbi for WasmPolicyStore
Source§impl IntoWasmAbi for WasmPolicyStore
impl IntoWasmAbi for WasmPolicyStore
Source§impl LongRefFromWasmAbi for WasmPolicyStore
impl LongRefFromWasmAbi for WasmPolicyStore
Source§type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>
type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmPolicyStore>
type Anchor = RcRef<WasmPolicyStore>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for WasmPolicyStore
impl OptionFromWasmAbi for WasmPolicyStore
Source§impl OptionIntoWasmAbi for WasmPolicyStore
impl OptionIntoWasmAbi for WasmPolicyStore
Source§impl RefFromWasmAbi for WasmPolicyStore
impl RefFromWasmAbi for WasmPolicyStore
Source§type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>
type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>
Self are recovered from.Source§type Anchor = RcRef<WasmPolicyStore>
type Anchor = RcRef<WasmPolicyStore>
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§impl RefMutFromWasmAbi for WasmPolicyStore
impl RefMutFromWasmAbi for WasmPolicyStore
Source§type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>
type Abi = WasmPtr<WasmRefCell<WasmPolicyStore>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmPolicyStore>
type Anchor = RcRefMut<WasmPolicyStore>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for WasmPolicyStore
impl SupportsInstanceProperty for WasmPolicyStore
impl SupportsStaticProperty for WasmPolicyStore
Source§impl TryFromJsValue for WasmPolicyStore
impl TryFromJsValue for WasmPolicyStore
Source§impl VectorFromWasmAbi for WasmPolicyStore
impl VectorFromWasmAbi for WasmPolicyStore
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmPolicyStore]>
Source§impl VectorIntoWasmAbi for WasmPolicyStore
impl VectorIntoWasmAbi for WasmPolicyStore
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmPolicyStore]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmPolicyStore
impl WasmDescribeVector for WasmPolicyStore
Auto Trait Implementations§
impl !RefUnwindSafe for WasmPolicyStore
impl !UnwindSafe for WasmPolicyStore
impl Freeze for WasmPolicyStore
impl Send for WasmPolicyStore
impl Sync for WasmPolicyStore
impl Unpin for WasmPolicyStore
impl UnsafeUnpin for WasmPolicyStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.