Skip to main content

ContextGraph

Struct ContextGraph 

Source
pub struct ContextGraph<S> { /* private fields */ }
Expand description

The embeddable core API: an agent runtime links this directly and calls commit/checkout inline per turn.

Implementations§

Source§

impl<S: CommitStore + RefStore> ContextGraph<S>

Source

pub fn new(store: S) -> Self

Source

pub fn store(&self) -> &S

Source

pub async fn resolve(&self, target: &CheckoutTarget) -> Result<CommitId>

Resolves a checkout target to a concrete commit id, without materializing.

§Errors
Source

pub async fn commit( &self, parent: Option<CommitId>, author: Author, delta: Delta, metadata: Metadata, ) -> Result<CommitId>

Creates a new commit as a child of parent (None for a root commit). Content-addressed and idempotent: identical content always returns the same id without creating a duplicate node. Does not move any branch pointer — see commit_advancing_branch for the combined op used by normal per-turn agent loops.

§Errors
Source

pub async fn commit_advancing_branch( &self, branch_name: &str, author: Author, delta: Delta, metadata: Metadata, ) -> Result<CommitId>

Commits a new turn and advances branch_name to point at it in one step. The commit is durably written before the branch pointer moves, so no reader can ever observe a branch pointing at a not-yet-persisted commit. Commits a new turn and advances branch_name to point at it in one step. The commit is durably written before the branch pointer moves, so no reader can ever observe a branch pointing at a not-yet-persisted commit.

§Errors

Any error returned by commit (e.g. parent not found) or store.set_branch.

Source

pub async fn branch(&self, name: &str, at_commit_id: CommitId) -> Result<()>

Creates a new branch pointer at an existing commit. Fails if the branch already exists or the commit does not.

§Errors
Source

pub async fn move_branch( &self, name: &str, to_commit_id: CommitId, ) -> Result<()>

Moves an existing branch pointer to a different (existing) commit.

§Errors
Source

pub async fn delete_branch(&self, name: &str) -> Result<()>

Source

pub async fn list_branches(&self) -> Result<Vec<(String, CommitId)>>

Source

pub async fn checkout( &self, target: CheckoutTarget, ) -> Result<MaterializedContext>

Materializes the ordered message list a model would see at target.

Source

pub async fn fork( &self, from_commit_id: CommitId, new_branch_name: &str, ) -> Result<()>

Explicit speculative-branch creation: “try two continuations from the same decision point” in one call. Semantically identical to branch (a fork is a branch at an existing commit) but exposed under its own name since it’s the primary developer-facing verb for A/B’ing a decision point — including forking again from an existing fork.

Source

pub async fn rollback( &self, branch_name: &str, to_commit_id: CommitId, ) -> Result<()>

Moves branch_name backward to to_commit_id. Matches git’s reset semantics: commits “ahead” of the new position are not deleted — they remain reachable by hash, or by any other branch still pointing past them.

Source

pub async fn log( &self, target: CheckoutTarget, filter: &LogFilter, offset: usize, limit: usize, ) -> Result<LogPage>

Walks the ancestry of target (a commit, or a branch’s current head) newest-first, applying filter and then offset/limit pagination.

Source

pub async fn diff( &self, from: CheckoutTarget, to: CheckoutTarget, ) -> Result<ContextDiff>

Structural diff between two materialized contexts. from/to can each independently be a commit or a branch’s current head, so this covers both the commit-pair and branch-pair forms.

Source

pub async fn merge( &self, branch_a: &str, branch_b: &str, strategy: MergeStrategy, ) -> Result<CommitId>

Merges branch_b into branch_a, creating an explicit merge commit and advancing branch_a to it. See crate::merge for why this never silently merges divergent conversation content.

Source

pub async fn bisect<F>( &self, good: CommitId, bad: CommitId, predicate: F, ) -> Result<BisectOutcome>

Binary-searches the ancestry path between good and bad for the exact commit where predicate flips from true to false.

Source

pub async fn gc(&self) -> Result<Vec<CommitId>>

Explicit, opt-in garbage collection: removes every commit not reachable from any branch. Never runs implicitly.

Auto Trait Implementations§

§

impl<S> Forget for ContextGraph<S>

§

impl<S> Freeze for ContextGraph<S>
where S: Freeze,

§

impl<S> Move for ContextGraph<S>

§

impl<S> RefUnwindSafe for ContextGraph<S>
where S: RefUnwindSafe,

§

impl<S> Send for ContextGraph<S>
where S: Send,

§

impl<S> Sync for ContextGraph<S>
where S: Sync,

§

impl<S> Unpin for ContextGraph<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for ContextGraph<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for ContextGraph<S>
where S: UnwindSafe,

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> 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> 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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