pub struct NudgeState {
pub edits_since_annotation: usize,
pub baseline: Option<Baseline>,
pub window_intent_ids: Option<BTreeSet<String>>,
pub reviewed: BTreeMap<String, ReviewRecord>,
pub proof_reviewed: BTreeMap<String, bool>,
pub throttle: BTreeMap<String, ThrottleRecord>,
}Expand description
The whole engine state file. Every field defaults, so older / partial files deserialize cleanly.
Fields§
§edits_since_annotation: usizeSource edits since the last annotation was added (authoring-debt).
baseline: Option<Baseline>The edit-window baseline, if captured.
window_intent_ids: Option<BTreeSet<String>>The set of authored-intent ids present when the current edit window
began (captured at SessionStart). Powers #7’s new-vs-backlog split: an
unreviewed intent is “new this session” when its id is absent from this
set, else “backlog”. None means no window was captured (no hooks /
fresh checkout) — the split is then suppressed rather than guessed.
reviewed: BTreeMap<String, ReviewRecord>annotation id → review record.
proof_reviewed: BTreeMap<String, bool>proof id → reviewed.
throttle: BTreeMap<String, ThrottleRecord>signal id → throttle record.
Implementations§
Source§impl NudgeState
impl NudgeState
Sourcepub fn load(path: &Path) -> Self
pub fn load(path: &Path) -> Self
Read the state file, tolerating absence and corruption (either yields default state). A nudge hook must never fail on bad state.
Sourcepub fn save(&self, path: &Path) -> Result<()>
pub fn save(&self, path: &Path) -> Result<()>
Atomically write the state file (tempfile in the same dir + rename).
Sourcepub fn unreviewed_count<'a>(
&self,
current: impl IntoIterator<Item = (&'a str, &'a str, &'a str)>,
) -> usize
pub fn unreviewed_count<'a>( &self, current: impl IntoIterator<Item = (&'a str, &'a str, &'a str)>, ) -> usize
Count intents the user has not (currently) reviewed. An intent is
unreviewed when it has no record, its record is reviewed = false, or
its live hashes have drifted from the reviewed snapshot (a post-review
edit re-opens it). current is (id, text_hash, body_hash) for every
authored intent in the index.
Sourcepub fn is_reviewed(&self, id: &str, text_hash: &str, body_hash: &str) -> bool
pub fn is_reviewed(&self, id: &str, text_hash: &str, body_hash: &str) -> bool
True iff this annotation is currently reviewed (record present,
reviewed = true, and both hashes still match — no drift).
Sourcepub fn mark_reviewed(&mut self, id: &str, text_hash: &str, body_hash: &str)
pub fn mark_reviewed(&mut self, id: &str, text_hash: &str, body_hash: &str)
Mark an annotation reviewed against its current hashes (clears any prior drift).
Trait Implementations§
Source§impl Clone for NudgeState
impl Clone for NudgeState
Source§fn clone(&self) -> NudgeState
fn clone(&self) -> NudgeState
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 NudgeState
impl Debug for NudgeState
Source§impl Default for NudgeState
impl Default for NudgeState
Source§fn default() -> NudgeState
fn default() -> NudgeState
Source§impl<'de> Deserialize<'de> for NudgeStatewhere
NudgeState: Default,
impl<'de> Deserialize<'de> for NudgeStatewhere
NudgeState: Default,
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>,
Source§impl PartialEq for NudgeState
impl PartialEq for NudgeState
Source§fn eq(&self, other: &NudgeState) -> bool
fn eq(&self, other: &NudgeState) -> bool
self and other values to be equal, and is used by ==.