From d84f1bb8a3c991ef9b1d26e7365ed5c4e282d755 Mon Sep 17 00:00:00 2001 From: hyperpolymath <6759885+hyperpolymath@users.noreply.github.com> Date: Wed, 24 Jun 2026 15:08:23 +0100 Subject: [PATCH] fix: add lib accessors so examples compile basic_usage.rs and mlp_router.rs called methods that didn't exist on the public API (8x E0599). Add thin 1:1 accessor/convenience wrappers: - Orchestrator::current_project() -> delegates to context manager - MLP::input_size() / MLP::output_size() -> getters for private fields - MLP::train_step() -> backward + update, returns the step loss cargo check --examples is now clean (lib was already fine). Co-Authored-By: Claude Opus 4.8 --- src/mlp.rs | 18 ++++++++++++++++++ src/orchestrator.rs | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/src/mlp.rs b/src/mlp.rs index e2c5045..bfeab48 100644 --- a/src/mlp.rs +++ b/src/mlp.rs @@ -146,6 +146,24 @@ impl MLP { // Phase 2 implementation } + /// Number of input features the network expects. + pub fn input_size(&self) -> usize { + self.input_size + } + + /// Number of output classes the network produces. + pub fn output_size(&self) -> usize { + self.output_size + } + + /// Run one training step: compute loss and gradients via `backward`, + /// apply them with `update`, and return the loss for this step. + pub fn train_step(&mut self, input: &[f32], target: &[f32], learning_rate: f32) -> f32 { + let (loss, gradients) = self.backward(input, target); + self.update(&gradients, learning_rate); + loss + } + /// Argmax: Return the index of the maximum value. pub fn argmax(values: &[f32]) -> usize { values diff --git a/src/orchestrator.rs b/src/orchestrator.rs index 0ae248a..e139bf2 100644 --- a/src/orchestrator.rs +++ b/src/orchestrator.rs @@ -88,6 +88,11 @@ impl Orchestrator { self.context.switch_project(project); } + /// Borrow the active project name, if one is set. + pub fn current_project(&self) -> Option<&str> { + self.context.current_project() + } + /// Drop the active project's conversation history. pub fn clear_history(&mut self) { self.context.clear_history();