Skip to main content

WasmAgentStateGraph

Struct WasmAgentStateGraph 

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

AgentStateGraph for WASM — uses IndexedDB for persistent browser storage.

Architecture: in-memory cache with write-through to IndexedDB.

  • All reads are instant (from memory)
  • All writes queue changes for IndexedDB flush
  • Call drain_pending() from JS to get queued writes, then persist to IndexedDB
  • Call load_data() on startup to hydrate from IndexedDB

Implementations§

Source§

impl WasmAgentStateGraph

Source

pub fn new(db_name: Option<String>) -> Result<WasmAgentStateGraph, JsValue>

Create a new AgentStateGraph with IndexedDB-backed storage. After construction, call load_data() with data from IndexedDB to restore state.

Source

pub fn load_objects(&self, json_pairs: &str) -> Result<(), JsValue>

Load objects from IndexedDB dump. Call on startup. Pass a JSON string: [[“hex_id”, “json”], …]

Source

pub fn load_commits(&self, json_pairs: &str) -> Result<(), JsValue>

Load commits from IndexedDB dump.

Source

pub fn load_refs(&self, json_pairs: &str) -> Result<(), JsValue>

Load refs from IndexedDB dump.

Source

pub fn drain_pending_objects(&self) -> String

Get pending object writes for flushing to IndexedDB. Returns JSON.

Source

pub fn drain_pending_commits(&self) -> String

Get pending commit writes.

Source

pub fn drain_pending_refs(&self) -> String

Get pending ref writes.

Source

pub fn drain_deleted_refs(&self) -> String

Get pending ref deletions (keys to delete from the refs store), so a deleted branch does not come back on the next load.

Source

pub fn db_name(&self) -> String

Get the IndexedDB database name.

Source

pub fn get( &self, path: &str, reference: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>

Get a JSON value at a path.

Source

pub fn set( &self, path: &str, json_value: &str, category: &str, description: &str, reference: Option<String>, reasoning: Option<String>, confidence: Option<f64>, namespace: Option<String>, ) -> Result<String, JsValue>

Set a JSON value at a path.

Source

pub fn delete( &self, path: &str, category: &str, description: &str, reference: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>

Delete a value at a path.

Source

pub fn branch( &self, name: &str, from: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>

Create a branch.

Source

pub fn merge( &self, source: &str, target: Option<String>, description: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>

Merge source into target.

Source

pub fn diff( &self, ref_a: &str, ref_b: &str, namespace: Option<String>, ) -> Result<String, JsValue>

Structured diff between two refs. Returns JSON.

Source

pub fn log( &self, reference: Option<String>, limit: Option<u32>, namespace: Option<String>, ) -> Result<String, JsValue>

Commit log. Returns JSON.

Source

pub fn blame( &self, path: &str, reference: Option<String>, namespace: Option<String>, ) -> Result<String, JsValue>

Blame — who modified a path and why.

Source

pub fn speculate( &self, from: Option<String>, label: Option<String>, namespace: Option<String>, ) -> Result<u32, JsValue>

Create a speculation. Returns handle ID.

Source

pub fn spec_get(&self, handle_id: u32, path: &str) -> Result<String, JsValue>

Get from a speculation.

Source

pub fn spec_set( &self, handle_id: u32, path: &str, json_value: &str, ) -> Result<(), JsValue>

Set in a speculation.

Source

pub fn commit_speculation( &self, handle_id: u32, category: &str, description: &str, reasoning: Option<String>, confidence: Option<f64>, ) -> Result<String, JsValue>

Commit a speculation.

Source

pub fn discard_speculation(&self, handle_id: u32) -> Result<(), JsValue>

Discard a speculation.

Source

pub fn create_epoch( &self, id: &str, description: &str, ) -> Result<String, JsValue>

Create an epoch.

Source

pub fn seal_epoch(&self, id: &str, summary: &str) -> Result<(), JsValue>

Seal an epoch.

Source

pub fn tasks_create_plan( &self, prefix: &str, agent_id: &str, ref_name: &str, name: &str, description: Option<String>, ) -> Result<String, JsValue>

Create a plan. Returns the Plan as JSON.

Source

pub fn tasks_list_plans( &self, prefix: &str, agent_id: &str, ref_name: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_list_plans_by_status( &self, prefix: &str, agent_id: &str, ref_name: &str, status: Option<String>, ) -> Result<String, JsValue>

Source

pub fn tasks_get_plan( &self, prefix: &str, agent_id: &str, ref_name: &str, name: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_archive_plan( &self, prefix: &str, agent_id: &str, ref_name: &str, name: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_delete_plan( &self, prefix: &str, agent_id: &str, ref_name: &str, name: &str, ) -> Result<(), JsValue>

Source

pub fn tasks_add_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, title: &str, priority: &str, parent_id: Option<String>, blockers_json: Option<String>, assigned_to: Option<String>, ) -> Result<String, JsValue>

Add a task. priority is “low”|“medium”|“high”|“critical”. blockers_json is a JSON array of task id strings (or null).

Source

pub fn tasks_add_task_with_extensions( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, title: &str, priority: &str, parent_id: Option<String>, blockers_json: Option<String>, assigned_to: Option<String>, payload_json: Option<String>, parent_change: Option<String>, on_complete_json: Option<String>, ) -> Result<String, JsValue>

Add a task with the 0.6.0 extension fields (payload, parent_change, on_complete). All three are JSON strings; pass None / null for unset. payload is an arbitrary JSON value, parent_change a "spec-id@version" handle, on_complete a JSON-serialized OnCompleteHook.

Source

pub fn tasks_list_tasks( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_task_ids( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_get_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_start_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_complete_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, proof_kind: &str, proof_value: &str, proof_note: Option<String>, ) -> Result<String, JsValue>

Complete a task. proof_kind is “commit”|“file”|“test”|“text”.

Source

pub fn tasks_abandon_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, reason: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_set_priority( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, priority: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_set_title( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, title: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_set_blockers( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, blockers_json: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_assign_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, agent: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_unassign_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, task_id: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_next_task( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, ) -> Result<String, JsValue>

Source

pub fn tasks_next_task_for( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, agent: Option<String>, include_unassigned: bool, ) -> Result<String, JsValue>

Source

pub fn tasks_derived_status( &self, prefix: &str, agent_id: &str, ref_name: &str, plan: &str, parent_id: &str, ) -> Result<String, JsValue>

Source

pub fn migrate_check( &self, ref_name: &str, target: Option<String>, ) -> Result<String, JsValue>

Check migration status. Returns a JSON report (see CheckResult).

Source

pub fn migrate_run( &self, ref_name: &str, target: Option<String>, mode: &str, ) -> Result<String, JsValue>

Run migrations. mode is "apply" or "dry-run".

Source

pub fn create_session( &self, agent_id: &str, working_branch: Option<String>, parent_session: Option<String>, delegated_intent: Option<String>, report_to: Option<String>, path_scope: Option<String>, ) -> Result<String, JsValue>

Create a durable session record. Returns the Session as JSON.

Source

pub fn get_session(&self, id: &str) -> Result<String, JsValue>

Fetch a session by id. Returns JSON, or “null” if not found.

Source

pub fn list_sessions( &self, agent_filter: Option<String>, ) -> Result<String, JsValue>

List sessions, optionally filtered by agent_id.

Source

pub fn end_session(&self, id: &str, status: &str) -> Result<(), JsValue>

End a session. status is “active” | “completed” | “abandoned”.

Source

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

Apply a taint. params_json shape: {"name","effect","reason","severity","expires","propagate","agent_id","metadata"}. Returns the new taint id.

Source

pub fn untaint( &self, ref_name: &str, path: &str, name: &str, params_json: &str, ) -> Result<(), JsValue>

Resolve a taint by name on path. params_json shape: {"reason","proof","agent_id"}.

Source

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

Apply a quarantine. params_json shape: {"name","reason","severity","authorized_agents","expires","propagate","agent_id"}.

Source

pub fn unquarantine( &self, ref_name: &str, path: &str, name: &str, params_json: &str, ) -> Result<(), JsValue>

Release a quarantine. params_json shape matches untaint.

Source

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

Apply a watch. params_json shape: {"name","reason","metric","threshold","direction","check_interval_secs","expires", "severity","propagate","agent_id"}.

Source

pub fn unwatch( &self, ref_name: &str, path: &str, name: &str, params_json: &str, ) -> Result<(), JsValue>

Remove a watch. params_json shape: {"reason","agent_id"}.

Source

pub fn list_taints( &self, path_prefix: Option<String>, kind: Option<String>, include_resolved: bool, ) -> Result<String, JsValue>

List taints / quarantines / watches. Returns a JSON array of [Taint] records.

Source

pub fn check_taint( &self, path: &str, agent_id: Option<String>, confidence: Option<f64>, ) -> Result<String, JsValue>

Check taint status for path given agent_id + confidence. Returns a [TaintCheck] JSON object.

Source

pub fn list_epochs(&self) -> Result<String, JsValue>

List epochs. Returns JSON.

Source

pub fn list_all_epochs(&self) -> Result<String, JsValue>

List epochs across every workspace. Returns JSON.

list_epochs returns only the active workspace’s epochs. This binding cannot select a workspace, so without this it could not reach epochs outside the default one at all.

Trait Implementations§

Source§

impl From<WasmAgentStateGraph> for JsValue

Source§

fn from(value: WasmAgentStateGraph) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for WasmAgentStateGraph

Source§

type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>

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 WasmAgentStateGraph

Source§

type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>

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 WasmAgentStateGraph

Source§

type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<WasmAgentStateGraph>

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 WasmAgentStateGraph

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 WasmAgentStateGraph

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 WasmAgentStateGraph

Source§

type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>

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

type Anchor = RcRef<WasmAgentStateGraph>

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 WasmAgentStateGraph

Source§

type Abi = WasmPtr<WasmRefCell<WasmAgentStateGraph>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<WasmAgentStateGraph>

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 WasmAgentStateGraph

Source§

impl SupportsInstanceProperty for WasmAgentStateGraph

Source§

impl SupportsStaticProperty for WasmAgentStateGraph

Source§

impl TryFromJsValue for WasmAgentStateGraph

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 WasmAgentStateGraph

Source§

impl VectorIntoWasmAbi for WasmAgentStateGraph

Source§

impl WasmDescribe for WasmAgentStateGraph

Source§

impl WasmDescribeVector for WasmAgentStateGraph

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