pub struct GraphContext {
pub items: Vec<ContextItem>,
pub dropped_items: usize,
}Expand description
The graph context handed to one file’s review.
GraphContext::none is the diff-only arm, and build_prompt renders no
context section for it, so the baseline prompt carries no vestigial heading
promising something that is not there.
§What is in it, and why those and not the rest
The menu roteiro review already computes is governing ADRs, callers,
callees, blast radius and authored drift. The arm takes two of those and
records the omission of the others as a decision:
- Governing ADR and blueprint sections (
authored). The one thing a per-file reviewer structurally cannot obtain: a decision written in another file that the code under review contradicts. This iscontract-drift’s defining shape and the authored layer’s whole purpose. - The file’s own doc surface outside the diff (
derived).build_promptinstructs the model to stay silent unless both halves of a conflict are visible, and a-U3diff shows at most three lines either side. A doc comment at the top of a file and the code that betrays it 700 lines down are never both in the hunks. The graph holds each symbol’s doc comment, so this makes the promise-half visible without pasting the file. - Callers, callees and blast radius are deliberately excluded. Measured on this repository a single changed symbol carries dozens of caller keys, and their bodies would dominate the prompt — the failure mode above, bought knowingly. Recorded here so the absence reads as a decision rather than an oversight, and so a later arm that adds them knows it is changing a pre-registered variable.
Fields§
§items: Vec<ContextItem>The items, in the order they are rendered.
dropped_items: usizeItems dropped by GraphContext::fit to stay inside the cap.
Counted rather than silently absorbed, for the same reason
Prompt::dropped_tokens is: a run that quietly shed the context it was
measuring would report the graph arm as having been tested when it was
partly the diff-only arm wearing its name.
Implementations§
Source§impl GraphContext
impl GraphContext
Sourcepub fn tokens(&self) -> usize
pub fn tokens(&self) -> usize
Estimated tokens this context will cost, by estimate_tokens over the
text build_prompt actually renders — label, provenance tag and body.
Sourcepub fn fit(items: Vec<ContextItem>, diff_tokens: usize) -> Self
pub fn fit(items: Vec<ContextItem>, diff_tokens: usize) -> Self
Drop whole items, lowest-priority last-first, until the context fits the
cap for a diff of diff_tokens.
Whole items, never a truncated one. A half-quoted ADR is worse than no
ADR: it reads as a complete statement of a decision and is not one, so a
model can be handed a promise whose exception was cut off and report the
code as contradicting it. build_prompt makes the same choice for the
same reason and truncates only the diff.
Callers pass items in priority order — most valuable first — because this drops from the tail.
Trait Implementations§
Source§impl Clone for GraphContext
impl Clone for GraphContext
Source§fn clone(&self) -> GraphContext
fn clone(&self) -> GraphContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GraphContext
impl Debug for GraphContext
Source§impl Default for GraphContext
impl Default for GraphContext
Source§fn default() -> GraphContext
fn default() -> GraphContext
impl Eq for GraphContext
Source§impl PartialEq for GraphContext
impl PartialEq for GraphContext
impl StructuralPartialEq for GraphContext
Auto Trait Implementations§
impl Freeze for GraphContext
impl RefUnwindSafe for GraphContext
impl Send for GraphContext
impl Sync for GraphContext
impl Unpin for GraphContext
impl UnsafeUnpin for GraphContext
impl UnwindSafe for GraphContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.