Skip to main content

ContextRetriever

Struct ContextRetriever 

Source
pub struct ContextRetriever { /* private fields */ }
Expand description

Context retriever for gathering relevant code context

Implementations§

Source§

impl ContextRetriever

Source

pub fn new(working_dir: PathBuf) -> Self

Create a new context retriever

Source

pub fn with_max_file_bytes(self, bytes: usize) -> Self

Set max bytes per file

Source

pub fn with_max_context_bytes(self, bytes: usize) -> Self

Set max total context bytes

Source

pub fn search(&self, pattern: &str, max_results: usize) -> Vec<SearchHit>

Search for a pattern in the workspace using ripgrep Respects .gitignore and common ignore patterns

Source

pub fn read_file_truncated(&self, path: &Path) -> Result<String>

Read a file with truncation if it exceeds max bytes

Source

pub fn get_task_context( &self, context_files: &[PathBuf], output_files: &[PathBuf], ) -> String

Get context for a task based on its context_files and output_files Returns a formatted string suitable for LLM prompts

Source

pub fn search_for_context(&self, query: &str, max_results: usize) -> String

Search for relevant code based on a query (e.g., function name, class name) Returns formatted context for LLM

Source

pub fn build_restriction_map( &self, node: &SRBNNode, manifest: &OwnershipManifest, ) -> RestrictionMap

PSP-5 Phase 3: Build a restriction map for a node

The restriction map defines the context boundary: what files, digests, and summaries a node is allowed to see. Built from the ownership manifest, task graph, and parent scope.

Source

pub fn assemble_context_package( &self, node: &SRBNNode, restriction_map: &RestrictionMap, ) -> ContextPackage

PSP-5 Phase 3: Assemble a reproducible context package for a node

Builds a complete, bounded context package from the restriction map. Prioritizes: owned files (full content) > sealed interfaces (digest or content) > summaries.

Source

pub fn compute_structural_digest( &self, path: &str, artifact_kind: ArtifactKind, source_node_id: &str, ) -> Result<StructuralDigest>

PSP-5 Phase 3: Compute a structural digest for a file

Source

pub fn format_context_package(&self, package: &ContextPackage) -> String

PSP-5 Phase 3: Format a context package as text for LLM prompts

Source

pub fn validate_provenance_record( &self, record: &ContextProvenanceRecord, ) -> Vec<String>

PSP-5 Phase 3: Validate a persisted provenance record against the current workspace.

Parses structural digest references from the provenance record and checks whether the referenced source files still exist on disk. Returns a list of missing file paths — empty means no drift detected.

Source

pub fn get_project_summary(&self) -> String

Gather a structured project summary for injection into sheafification prompts.

Returns a formatted string describing: detected language plugins, dependency manifests, entry points, test locations, and build system. Uses the plugin registry and file-system inspection; zero LLM calls.

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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToAst for T

Source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,