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
impl Editor
pub fn new(store: Store) -> Self
pub fn begin_edit(&mut self) -> Result<(), EditError>
pub fn abort_edit(&mut self)
pub fn create_function(&mut self, name: &str) -> Result<(), EditError>
pub fn add_param( &mut self, name: &str, ty: Type, min_confidence: Confidence, ) -> Result<(), EditError>
pub fn set_type_params( &mut self, type_params: Vec<String>, ) -> Result<(), EditError>
pub fn set_produces( &mut self, ty: Type, confidence: Confidence, ) -> Result<(), EditError>
pub fn set_effects( &mut self, effects: BTreeSet<Effect>, ) -> Result<(), EditError>
pub fn set_on_failure(&mut self, failures: Vec<String>) -> Result<(), EditError>
pub fn add_step( &mut self, binding: &str, value: ExprSpec, ) -> Result<(), EditError>
pub fn set_yield(&mut self, value: ExprSpec) -> Result<(), EditError>
Sourcepub fn describe_hole(&mut self) -> Result<HoleInfo, EditError>
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.
Sourcepub fn commit_edit(&mut self) -> Result<(NodeHash, Report), EditError>
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.
Sourcepub fn apply_function(
&mut self,
spec: &FunctionSpec,
) -> Result<(NodeHash, Report), EditError>
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.
Sourcepub fn define_type(&self, spec: &TypeDefSpec) -> Result<NodeHash, EditError>
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.
Sourcepub fn apply_module(
&self,
spec: &ModuleSpec,
) -> Result<(NodeHash, Report), EditError>
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.
Sourcepub fn run_module(
&self,
module: &NodeHash,
name: &str,
args: &[i64],
) -> Result<i64, EditError>
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.
Sourcepub fn run_handler(
&self,
module: &NodeHash,
handler: &str,
db_path: &str,
method: &str,
path: &str,
body: &str,
headers: &str,
) -> Result<HttpResponse, EditError>
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.
Sourcepub fn query_type(
&self,
module: &NodeHash,
name: &str,
) -> Result<Option<SignatureInfo>, EditError>
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.
Sourcepub fn find_references(
&self,
root: &NodeHash,
target: &NodeHash,
) -> Result<Vec<String>, EditError>
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).
Sourcepub fn replace_node(
&self,
root: &NodeHash,
target: &NodeHash,
replacement: &NodeHash,
) -> Result<(NodeHash, Report), EditError>
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.
Sourcepub fn fill_hole(
&self,
root: &NodeHash,
hole: &NodeHash,
replacement: &NodeHash,
) -> Result<(NodeHash, Report), EditError>
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.
Sourcepub fn put_expr(&self, spec: &ExprSpec) -> Result<NodeHash, Error>
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.
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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