Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/runvil-internal/engine/src/execute/config-limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ impl RunLimits {

/// Returns the default maximum number of tool iterations per section.
#[must_use]
pub fn tool_iterations(&self) -> NonZeroU32 {
pub(crate) fn tool_iterations(&self) -> NonZeroU32 {
self.max_tool_iterations
}

/// Returns the run's concurrency ceiling: the most tasks the
/// scheduler admits at once across the whole run.
#[must_use]
pub fn concurrency(&self) -> NonZeroUsize {
pub(crate) fn concurrency(&self) -> NonZeroUsize {
self.concurrency
}

Expand All @@ -137,14 +137,14 @@ impl RunLimits {

/// Returns the memory ceiling for each Lua virtual machine, in bytes.
#[must_use]
pub fn lua_memory(&self) -> NonZeroUsize {
pub(crate) fn lua_memory(&self) -> NonZeroUsize {
self.lua_memory_bytes
}

/// Returns the maximum number of `log` events that a prompt's Lua code
/// can record in each Lua virtual machine.
#[must_use]
pub fn lua_logs(&self) -> NonZeroU32 {
pub(crate) fn lua_logs(&self) -> NonZeroU32 {
self.lua_log_events
}

Expand Down
43 changes: 3 additions & 40 deletions crates/runvil-internal/engine/src/execute/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ use super::requirements::{Requirements, UnavailablePack};
/// CSPRNG and read the start time from its own clock. The caller records both
/// values, and a replay passes back the recorded ones. Given the same
/// inputs and the same answers, a run reproduces its run id, nonces,
/// `sys.when`, effects, and events. The `Debug` form shows the run id
/// ([`uid`](RunContext::uid)) and never the seed.
/// `sys.when`, effects, and events. The `Debug` form shows the run id and
/// never the seed.
#[non_exhaustive]
pub struct RunContext {
/// Run identity, stamped on every report and event.
Expand All @@ -65,9 +65,6 @@ pub struct RunContext {
/// count, so the run's root task continues the sequence and
/// `(task, seq)` is unique across the parse/run boundary.
pub(super) provenance_start: u32,
/// Model-orchestrated prompt-tool nesting depth: 0 for a root run.
/// Nothing increments it, so it is always 0.
depth: u32,
/// Whether the run reports each model round's raw request and response
/// bodies as `Request` and `Response` events. Off by default: the
/// bodies already travel in the `Chat` effect and its answer, and the
Expand Down Expand Up @@ -134,7 +131,6 @@ impl RunContext {
flags: Flags::EMPTY,
started_at,
provenance_start: 0,
depth: 0,
report_debug: DebugMode::Off,
cancel: CancelHandle::new(),
limits: RunLimits::new(),
Expand Down Expand Up @@ -345,22 +341,6 @@ impl RunContext {
&self.vfs
}

/// Returns the run's current model, or `None` by default.
#[must_use]
pub fn current_model(&self) -> Option<&ModelInfo> {
self.model.as_ref()
}

/// Returns the run's cancel flag.
///
/// The caller watches this flag, so one cancel reaches the run and the
/// effects the caller has in flight. Replace the flag with
/// [`cancel`](RunContext::cancel).
#[must_use]
pub fn cancel_handle(&self) -> CancelHandle {
self.cancel.clone()
}

/// Returns the run's model bindings, which map each declared role to a
/// concrete model.
///
Expand All @@ -387,13 +367,6 @@ impl RunContext {
&self.tools
}

/// Returns the run's name, which identifies the run on every report and
/// event.
#[must_use]
pub fn name(&self) -> &str {
&self.name
}

/// Returns the run's seed, as the caller supplied it.
#[must_use]
pub fn seed(&self) -> RunSeed {
Expand All @@ -406,7 +379,7 @@ impl RunContext {
/// without revealing the seed or the nonce. A replay under the recorded
/// seed has the same id.
#[must_use]
pub fn uid(&self) -> RunUid {
pub(crate) fn uid(&self) -> RunUid {
RunUid::from_seed(&self.seed)
}

Expand All @@ -422,15 +395,6 @@ impl RunContext {
pub fn started_at(&self) -> Timestamp {
self.started_at
}

/// Returns how many model-orchestrated prompt tools this run is nested
/// inside.
///
/// The depth is 0 for a root run.
#[must_use]
pub fn depth(&self) -> u32 {
self.depth
}
}

impl fmt::Debug for RunContext {
Expand All @@ -442,7 +406,6 @@ impl fmt::Debug for RunContext {
.field("flags", &self.flags)
.field("started_at", &self.started_at)
.field("provenance_start", &self.provenance_start)
.field("depth", &self.depth)
.field("report_debug", &self.report_debug)
.field("cancel", &self.cancel)
.field("limits", &self.limits)
Expand Down
11 changes: 5 additions & 6 deletions crates/runvil-internal/engine/src/execute/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ pub enum RunErrorKind {
/// The error's [`RunErrorKind`] says which of the two it is, and the
/// extension of `path` says so too. Use the kind to branch in code, the
/// error message to show a reader, and the location to navigate to the
/// fault. Build one with [`new`](SourceLocation::new) and the `with_`
/// methods.
/// fault. Only the Engine builds one.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct SourceLocation {
Expand Down Expand Up @@ -93,7 +92,7 @@ pub struct SourceLocation {
impl SourceLocation {
/// Builds a location in `path` with no line, column, or span.
#[must_use]
pub fn new(path: impl Into<String>) -> SourceLocation {
pub(crate) fn new(path: impl Into<String>) -> SourceLocation {
SourceLocation {
path: path.into(),
line: None,
Expand All @@ -104,21 +103,21 @@ impl SourceLocation {

/// Sets the 1-based line.
#[must_use]
pub fn with_line(mut self, line: Option<u32>) -> SourceLocation {
pub(crate) fn with_line(mut self, line: Option<u32>) -> SourceLocation {
self.line = line;
self
}

/// Sets the 1-based column.
#[must_use]
pub fn with_column(mut self, column: Option<u32>) -> SourceLocation {
pub(crate) fn with_column(mut self, column: Option<u32>) -> SourceLocation {
self.column = column;
self
}

/// Sets the byte span of the offending region in the document body.
#[must_use]
pub fn with_span(mut self, span: Option<Range<usize>>) -> SourceLocation {
pub(crate) fn with_span(mut self, span: Option<Range<usize>>) -> SourceLocation {
self.span = span;
self
}
Expand Down
4 changes: 2 additions & 2 deletions crates/runvil-internal/engine/src/execute/run/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl FailureRecord {
/// Builds the record of a failure of kind `kind` with `message` as its
/// display text.
#[must_use]
pub fn new(kind: impl Into<String>, message: impl Into<String>) -> FailureRecord {
pub(crate) fn new(kind: impl Into<String>, message: impl Into<String>) -> FailureRecord {
FailureRecord {
kind: kind.into(),
message: message.into(),
Expand Down Expand Up @@ -485,7 +485,7 @@ pub struct ToolAnswerRecord {
impl ToolAnswerRecord {
/// Builds the record of an output of `text` at `trust`.
#[must_use]
pub fn new(text: impl Into<String>, trust: OutputTrust) -> ToolAnswerRecord {
pub(crate) fn new(text: impl Into<String>, trust: OutputTrust) -> ToolAnswerRecord {
ToolAnswerRecord {
text: text.into(),
trust,
Expand Down
8 changes: 4 additions & 4 deletions crates/runvil-internal/lua/src/compactors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl OverflowReason {
/// The invocation tag the compactor callback receives, also the
/// `reason` field of a `context_exhausted` error table.
#[must_use]
pub fn tag(self) -> &'static str {
pub(crate) fn tag(self) -> &'static str {
match self {
OverflowReason::Precheck => "precheck",
OverflowReason::Provider => "provider",
Expand All @@ -85,7 +85,7 @@ impl std::fmt::Display for OverflowReason {
/// An overflow tag's description, or any other reason as given.
///
/// This is the detail a context exhaustion's message shows: an exact
/// [`OverflowReason::tag`] reads as that overflow's [`Display`](std::fmt::Display),
/// `OverflowReason::tag` reads as that overflow's [`Display`](std::fmt::Display),
/// and a caller's own reason reads as itself.
#[must_use]
pub fn exhaustion_detail(reason: &str) -> Cow<'_, str> {
Expand All @@ -102,7 +102,7 @@ pub fn exhaustion_detail(reason: &str) -> Cow<'_, str> {
/// so a section can start its conversation over without leaving, and
/// refuses unless a compactor is running over the list.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Compactor {
pub(crate) enum Compactor {
/// `compactors.fail`: always raises [`Error::ContextExhausted`].
#[default]
Fail,
Expand All @@ -120,7 +120,7 @@ impl Compactor {
/// `Fail` always returns [`Error::ContextExhausted`] holding `reason`;
/// `Clear` returns [`Error::Lua`] when no compactor is running over
/// `list`, and leaves it unchanged.
pub fn invoke(self, list: &MessageList, reason: &str) -> Result<()> {
pub(crate) fn invoke(self, list: &MessageList, reason: &str) -> Result<()> {
match self {
Compactor::Fail => Err(Error::ContextExhausted {
reason: reason.to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion crates/runvil-internal/lua/src/coro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use std::sync::{Arc, LazyLock};

use mlua::{Function, Lua, StdLib, Table, Value};

use crate::SharedSource;
use crate::engine_globals::route_store_to_shims;
use crate::error::SharedSource;
use crate::error::{Error, Result};
use crate::error_value::{install_error_value, install_normalize_failure};
use crate::hardening::InstructionBudget;
Expand Down
2 changes: 1 addition & 1 deletion crates/runvil-internal/lua/src/detail.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The constructor the compiled-program statics wrap their failure with.

use crate::SharedSource;
use crate::error::SharedSource;

/// Wraps a concrete error as a shareable cause.
#[must_use]
Expand Down
6 changes: 4 additions & 2 deletions crates/runvil-internal/lua/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,18 @@ pub struct ToolDispatch {
impl ToolDispatch {
/// The final content: trusted output verbatim, anything else
/// nonce-wrapped.
#[cfg(test)]
#[must_use]
pub fn content(&self) -> &str {
pub(crate) fn content(&self) -> &str {
&self.content
}

/// The content's trust marking: [`OutputTrust::Trusted`]
/// for verbatim output, [`OutputTrust::Untrusted`] for the
/// nonce-wrapped envelope.
#[cfg(test)]
#[must_use]
pub fn trust(&self) -> OutputTrust {
pub(crate) fn trust(&self) -> OutputTrust {
self.trust
}

Expand Down
2 changes: 1 addition & 1 deletion crates/runvil-internal/lua/src/engine_globals-store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use runvil_types::event::lifecycle::{self, Lifecycle};
use runvil_vfs::{Access, VfsError};

use super::{read_store, read_store_numbered};
use crate::SharedSource;
use crate::error::SharedSource;
use crate::error::{Error, Result};
use crate::program::LuaProgram;
use crate::protocol::VfsOp;
Expand Down
15 changes: 8 additions & 7 deletions crates/runvil-internal/lua/src/error-value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub enum ErrorKind {

impl ErrorKind {
/// Every kind, in declaration order.
pub const ALL: &'static [ErrorKind] = &[
pub(crate) const ALL: &'static [ErrorKind] = &[
ErrorKind::ToolLoopExhausted,
ErrorKind::ContextExhausted,
ErrorKind::EmptyModelReply,
Expand All @@ -99,7 +99,7 @@ impl ErrorKind {

/// Returns the `kind` string the Lua table holds.
#[must_use]
pub fn tag(self) -> &'static str {
pub(crate) fn tag(self) -> &'static str {
match self {
ErrorKind::ToolLoopExhausted => "tool_loop_exhausted",
ErrorKind::ContextExhausted => "context_exhausted",
Expand All @@ -119,7 +119,7 @@ impl ErrorKind {

/// Parses a `kind` string; `None` for a tag outside the vocabulary.
#[must_use]
pub fn from_tag(tag: &str) -> Option<ErrorKind> {
pub(crate) fn from_tag(tag: &str) -> Option<ErrorKind> {
match tag {
"tool_loop_exhausted" => Some(ErrorKind::ToolLoopExhausted),
"context_exhausted" => Some(ErrorKind::ContextExhausted),
Expand Down Expand Up @@ -148,7 +148,7 @@ impl std::fmt::Display for ErrorKind {
impl FromStr for ErrorKind {
type Err = ParseErrorKindError;

/// Parses a kind from its exact tag, as [`ErrorKind::from_tag`] does.
/// Parses a kind from its exact tag, as `ErrorKind::from_tag` does.
fn from_str(tag: &str) -> Result<ErrorKind, ParseErrorKindError> {
ErrorKind::from_tag(tag).ok_or_else(|| ParseErrorKindError {
input: tag.to_owned(),
Expand All @@ -169,8 +169,9 @@ pub struct ParseErrorKindError {

impl ParseErrorKindError {
/// Returns the rejected text.
#[cfg(test)]
#[must_use]
pub fn input(&self) -> &str {
pub(crate) fn input(&self) -> &str {
&self.input
}
}
Expand Down Expand Up @@ -266,7 +267,7 @@ impl ErrorValue for Error {
///
/// This is the shape a block coroutine's failure takes when the raised
/// value was an error table (built by the shim's `raise` or by
/// [`error_table`]) and no retained typed error was substituted for it -
/// `error_table`) and no retained typed error was substituted for it -
/// the case for a Lua-side raise. The executor maps it back onto its own
/// internal type by kind.
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -334,7 +335,7 @@ fn finish_table(lua: &Lua, kind: ErrorKind, fields: Table) -> mlua::Result<Table
///
/// # Errors
/// Returns an `mlua` error if the table cannot be created on `lua`.
pub fn error_table(lua: &Lua, error: &impl ErrorValue) -> mlua::Result<Table> {
pub(crate) fn error_table(lua: &Lua, error: &impl ErrorValue) -> mlua::Result<Table> {
let table = lua.create_table()?;
table.raw_set("message", error.to_string())?;
for (name, value) in error.fields() {
Expand Down
2 changes: 1 addition & 1 deletion crates/runvil-internal/lua/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type BoxedSource = Box<dyn std::error::Error + Send + Sync>;
/// globals chunk, and the store shims) are the callers, through
/// `detail::shared_source_new`.
#[derive(Debug, Clone)]
pub struct SharedSource(pub(crate) std::sync::Arc<dyn std::error::Error + Send + Sync>);
pub(crate) struct SharedSource(pub(crate) std::sync::Arc<dyn std::error::Error + Send + Sync>);

impl std::fmt::Display for SharedSource {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion crates/runvil-internal/lua/src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use std::sync::LazyLock;

use mlua::{AnyUserData, Function, Lua, Table, Value};

use crate::SharedSource;
use crate::error::SharedSource;
use crate::error::{Error, Result};
use crate::program::LuaProgram;

Expand Down
2 changes: 1 addition & 1 deletion crates/runvil-internal/lua/src/handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl ToolSet {
/// Returns every installed Pack the caller reports, with the reason,
/// written for the model, when it cannot serve the run.
#[must_use]
pub fn roster(&self) -> &BTreeMap<PackId, Option<String>> {
pub(crate) fn roster(&self) -> &BTreeMap<PackId, Option<String>> {
&self.roster
}

Expand Down
Loading
Loading