Skip to main content

Editor

Struct Editor 

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

Authoring session over a Store. Holds the in-memory draft of an open transaction; nothing reaches the store until commit_edit.

Implementations§

Source§

impl Editor

Source

pub fn new(store: Store) -> Self

Source

pub fn store(&self) -> &Store

The underlying store, for read-only inspection (render, etc.).

Source

pub fn begin_edit(&mut self) -> Result<(), EditError>

Source

pub fn abort_edit(&mut self)

Source

pub fn create_function(&mut self, name: &str) -> Result<(), EditError>

Source

pub fn add_param( &mut self, name: &str, ty: Type, min_confidence: Confidence, ) -> Result<(), EditError>

Source

pub fn set_type_params( &mut self, type_params: Vec<String>, ) -> Result<(), EditError>

Source

pub fn set_produces( &mut self, ty: Type, confidence: Confidence, ) -> Result<(), EditError>

Source

pub fn set_effects( &mut self, effects: BTreeSet<Effect>, ) -> Result<(), EditError>

Source

pub fn set_on_failure(&mut self, failures: Vec<String>) -> Result<(), EditError>

Source

pub fn add_step( &mut self, binding: &str, value: ExprSpec, ) -> Result<(), EditError>

Source

pub fn set_yield(&mut self, value: ExprSpec) -> Result<(), EditError>

Source

pub fn describe_hole(&mut self) -> Result<HoleInfo, EditError>

What the body position expects and what is in scope there: the declared produced type, the parameter and prior-step bindings, and the effects the function is allowed to perform.

Source

pub fn commit_edit(&mut self) -> Result<(NodeHash, Report), EditError>

Materialize the draft into the store, run the single checker once, and return the new function’s hash with its Report. All-or-nothing: on any store error nothing is left dangling because content-addressed writes are idempotent and unreferenced. Closes the transaction.

Source

pub fn apply_function( &mut self, spec: &FunctionSpec, ) -> Result<(NodeHash, Report), EditError>

Apply a whole FunctionSpec as one transaction and commit it. This is the declarative equivalent of the fine-grained tool sequence; both go through the same ops, so they produce the same content hash. Expects no transaction already open.

Source

pub fn define_type(&self, spec: &TypeDefSpec) -> Result<NodeHash, EditError>

Materialize one type definition into the store, returning its hash. Type defs are leaf nodes — no draft/transaction is involved.

Source

pub fn apply_module( &self, spec: &ModuleSpec, ) -> Result<(NodeHash, Report), EditError>

Author a whole module — type definitions plus functions — and run the single Core checker on it once, as a unit. Calls resolve across every function in the module (forward, mutual, recursive), so a framework function and an app function that calls it compose in one assembled module with zero language change: the content-addressed store is the linker, and reusing a function is referencing its hash.

Source

pub fn run_module( &self, module: &NodeHash, name: &str, args: &[i64], ) -> Result<i64, EditError>

Lower an authored module and run one of its functions under wasmtime, returning its i64 result. The module-level counterpart of run.

Source

pub fn run_handler( &self, module: &NodeHash, handler: &str, db_path: &str, method: &str, path: &str, body: &str, headers: &str, ) -> Result<HttpResponse, EditError>

Drive a web handler handler(req: Request) -> Response once, against a real SQLite file at db_path (state persists across calls — the load/persist round-trip an i64 run_module cannot exercise). The module-level counterpart of run_module for the framework’s primary artifact: same lowering, but the canonical serve_request path the CLI/HTTP servers use instead of an i64 entry — so an MCP-only agent can execute and verify the Tier-3 app it authored, not only type-check it.

Source

pub fn query_type( &self, module: &NodeHash, name: &str, ) -> Result<Option<SignatureInfo>, EditError>

The signature of name within an applied module — the structural answer to “what does this function expect?”, which an agent needs to call the stdlib/framework correctly. None if absent.

Source

pub fn find_references( &self, root: &NodeHash, target: &NodeHash, ) -> Result<Vec<String>, EditError>

Every node within root’s subtree that has target as a direct child — the structural reference set (design.md §6). Because the store is content-addressed and immutable, a “reference” is a parent whose child-hash list contains target; this is the basis for a rename being a label change, not a structural edit. The returned hashes are unique and sorted (the DAG is walked once per distinct node — shared subtrees are not double-counted). root itself is never reported (it is not a reference to a child).

Source

pub fn replace_node( &self, root: &NodeHash, target: &NodeHash, replacement: &NodeHash, ) -> Result<(NodeHash, Report), EditError>

Structurally replace every occurrence of target within root with replacement, returning the new root hash and its verification Report (design.md §6: every mutating call returns a report). The store is content-addressed and immutable, so this rebuilds each ancestor on the path with the new child hash and rehashes up the spine; subtrees with no target keep their hash and are shared (structural sharing — a no-op replace returns root unchanged). The DAG is rewritten once per distinct node (memoized), so shared subtrees do not blow up.

Source

pub fn fill_hole( &self, root: &NodeHash, hole: &NodeHash, replacement: &NodeHash, ) -> Result<(NodeHash, Report), EditError>

Fill a typed hole with a node (design.md §6). hole must resolve to a Node::Hole; otherwise this is a NotAHole error (use replace_node for a general replace). The candidate tree (hole → replacement) is checked: if it satisfies the principles (report.ok()) the fill is accepted(new_root, report). If not, the fill is rejected: the hole remains, so the returned root is the original root, and the returned report is the candidate’s — it names the violating principle, the §6 “rejected with a structural reason” contract. incomplete (other holes elsewhere) is not a violation and does not reject the fill.

Source

pub fn put_expr(&self, spec: &ExprSpec) -> Result<NodeHash, Error>

Materialize an ExprSpec into the content-addressed store and return its node hash — the editor’s construction primitive, the missing half of structural editing (replace_node/ fill_hole consume a replacement hash; this mints one). Pure surface over the same materialization add_step/set_yield already use, exposed as a one-shot for a projectional editor.

Source

pub fn run( &self, func: &NodeHash, name: &str, args: &[i64], ) -> Result<i64, EditError>

Build a one-function module around func, lower it, and run it under wasmtime, returning its i64 result. The lifecycle build+run tools, composed.

Auto Trait Implementations§

§

impl !Freeze for Editor

§

impl !RefUnwindSafe for Editor

§

impl Send for Editor

§

impl !Sync for Editor

§

impl Unpin for Editor

§

impl UnsafeUnpin for Editor

§

impl !UnwindSafe for Editor

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.