pub struct EntryProvenance {
pub path: String,
pub directory: String,
pub source_class: String,
pub section: Option<String>,
pub bytes: u64,
}Expand description
Where the selected thing lives, as the index knows it. Nothing here is authored: every
field is the index’s own crate::model::Provenance, carried rather than restated.
It is a copy of the index’s provenance and not a re-derivation of it, which is the property worth relying on: no path here was constructed by this module, so a path in an answer is a path the index discovered, and the two cannot disagree about where something lives.
bytes is the measured half of an entry’s cost — the estimate on top of it is
tokens_for — so this is also where the budget’s arithmetic starts.
use majordomus_cli::devcontext::{tokens_for, EntryProvenance};
use serde_json::json;
let p: EntryProvenance = serde_json::from_value(json!({
"path": ".ai/repo/adrs/0052-the-episode-is-the-boundary.md",
"directory": ".ai/repo/adrs",
"source_class": "adr",
"section": "adrs",
"bytes": 8_192,
})).unwrap();
// the size is what the cost is computed from, and the estimate says so of itself
assert_eq!(tokens_for(p.bytes), 2_048);
// a file under no manifest section — a root README, say — carries none rather than ""
let rootish: EntryProvenance = serde_json::from_value(json!({
"path": "README.md",
"directory": ".",
"source_class": "readme",
"bytes": 4_000,
})).unwrap();
assert!(rootish.section.is_none());
assert_eq!(rootish.directory, ".", "the root is `.`, not the empty string");Fields§
§path: StringRepository-relative path, forward slashes.
directory: StringThe directory it sits in.
source_class: StringThe sources.yaml class that discovered it.
section: Option<String>The manifest section it falls under, when it falls under one.
bytes: u64Size of the file in bytes.
Trait Implementations§
Source§impl Clone for EntryProvenance
impl Clone for EntryProvenance
Source§fn clone(&self) -> EntryProvenance
fn clone(&self) -> EntryProvenance
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 EntryProvenance
impl Debug for EntryProvenance
Source§impl<'de> Deserialize<'de> for EntryProvenance
impl<'de> Deserialize<'de> for EntryProvenance
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for EntryProvenance
Source§impl JsonSchema for EntryProvenance
impl JsonSchema for EntryProvenance
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for EntryProvenance
impl PartialEq for EntryProvenance
Source§fn eq(&self, other: &EntryProvenance) -> bool
fn eq(&self, other: &EntryProvenance) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for EntryProvenance
impl Serialize for EntryProvenance
impl StructuralPartialEq for EntryProvenance
Auto Trait Implementations§
impl Freeze for EntryProvenance
impl RefUnwindSafe for EntryProvenance
impl Send for EntryProvenance
impl Sync for EntryProvenance
impl Unpin for EntryProvenance
impl UnsafeUnpin for EntryProvenance
impl UnwindSafe for EntryProvenance
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.