Skip to main content

Conversation

Struct Conversation 

Source
pub struct Conversation {
    pub messages: Vec<Message>,
    pub taint: Taint,
    pub rewritten: Vec<Vec<Message>>,
}
Expand description

A conversation, and what has entered it.

The taint lives here, with the messages, because that is what it is a property of. Tracking it per run meant the lethal trifecta was defeated by pressing Enter: fetch a hostile page on one turn, read a secret and send on the next, and the interlock saw a clean slate both times — while the attacker’s text sat in the model’s context the whole while, still able to steer it. A turn boundary is not a security boundary.

Bundling the two makes the right thing the default rather than something each caller has to remember. Keep the history and you keep the taint; start a new conversation — a batch item, a subagent, an eval case — and you get a clean one, because you built a new Conversation to do it.

Fields§

§messages: Vec<Message>§taint: Taint

What has entered this conversation so far. Grows, never shrinks: there is no way to un-read a page.

§rewritten: Vec<Vec<Message>>

Full states of messages that an in-place rewrite replaced during the current run, oldest first — compaction, eviction, thinning. The loop snapshots the list before each rewrite pass and clears at run start; Session::record_run walks these before the final state, so turns a mid-run rewrite dropped still reach the file. Without this, a run long enough to compact itself lost its own head: the front-end records at run end, and the rewrite record carries only what survived.

On the conversation rather than the outcome for the same reason taint is: it is a fact about what the messages went through, and bundling it with them makes the right thing the default — the recording call receives the conversation and cannot skip what it carries.

Implementations§

Source§

impl Conversation

Source

pub fn new() -> Self

Source

pub fn user(text: impl Into<String>) -> Self

Open with one user message.

Source

pub fn resumed(messages: Vec<Message>, taint: Taint) -> Self

Resume a transcript whose taint is known — from a session file that recorded it.

Source

pub fn push(&mut self, message: Message)

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Trait Implementations§

Source§

impl Clone for Conversation

Source§

fn clone(&self) -> Conversation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Conversation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Conversation

Source§

fn default() -> Conversation

Returns the “default value” for a type. Read more
Source§

impl From<Vec<Message>> for Conversation

Source§

fn from(messages: Vec<Message>) -> Self

Messages with no recorded taint are treated as clean. That is right for a conversation being started and wrong for one being resumed — use Conversation::resumed there, or resuming launders the taint the same way a turn boundary used to.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, <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.
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